2 * Displays the "Summary Page"
4 * Copyright (c) 1996-2011 by the citadel.org team
6 * This program is open source software. You can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 extern int calendar_summary_view(void);
27 * Display today's date in a friendly format
29 void output_date(void) {
35 localtime_r(&now, &tm);
37 wc_strftime(buf, 32, "%A, %x", &tm);
41 void tmplput_output_date(StrBuf *Target, WCTemplputParams *TP)
49 localtime_r(&now, &tm);
51 n = wc_strftime(buf, 32, "%A, %x", &tm);
52 StrBufAppendBufPlain(Target, buf, n, 0);
57 * New messages section
59 void new_messages_section(void) {
63 int number_of_rooms_to_check;
64 char *rooms_to_check = "Mail|Lobby";
67 number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
68 if (number_of_rooms_to_check == 0) return;
70 wc_printf("<table border=\"0\" width=\"100%%\">\n");
71 for (i=0; i<number_of_rooms_to_check; ++i) {
72 extract_token(room, rooms_to_check, i, '|', sizeof room);
74 serv_printf("GOTO %s", room);
75 serv_getln(buf, sizeof buf);
77 extract_token(room, &buf[4], 0, '|', sizeof room);
78 wc_printf("<tr><td><a href=\"dotgoto?room=");
82 wc_printf("</a></td><td>%d/%d</td></tr>\n",
83 extract_int(&buf[4], 1),
84 extract_int(&buf[4], 2)
88 wc_printf("</table>\n");
96 void tasks_section(void) {
102 message_summary *Msg;
105 SharedMessageStatus Stat;
107 memset(&Stat, 0, sizeof(SharedMessageStatus));
108 Stat.maxload = 10000;
109 Stat.lowest_found = (-1);
110 Stat.highest_found = (-1);
112 Buf = NewStrBufPlain(HKEY("_TASKS_"));
116 if (WCC->CurRoom.view != VIEW_TASKS) {
120 num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL);
124 at = GetNewHashPos(WCC->summ, 0);
125 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
126 Msg = (message_summary*) vMsg;
127 tasks_LoadMsgFromServer(NULL, NULL, Msg, 0, 0);
132 if (calendar_summary_view() < 1) {
134 wc_printf(_("(None)"));
135 wc_printf("</i><br>\n");
143 void calendar_section(void) {
150 message_summary *Msg;
154 SharedMessageStatus Stat;
156 memset(&Stat, 0, sizeof(SharedMessageStatus));
157 Stat.maxload = 10000;
158 Stat.lowest_found = (-1);
159 Stat.highest_found = (-1);
161 Buf = NewStrBufPlain(HKEY("_CALENDAR_"));
164 if ( (WC->CurRoom.view != VIEW_CALENDAR) && (WC->CurRoom.view != VIEW_CALBRIEF) ) {
168 num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL);
170 calendar_GetParamsGetServerCall(&Stat,
177 at = GetNewHashPos(WCC->summ, 0);
178 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
179 Msg = (message_summary*) vMsg;
180 calendar_LoadMsgFromServer(NULL, &v, Msg, 0, 0);
184 if (calendar_summary_view() < 1) {
186 wc_printf(_("(Nothing)"));
187 wc_printf("</i><br>\n");
189 __calendar_Cleanup(&v);
192 void tmplput_new_messages_section(StrBuf *Target, WCTemplputParams *TP) {
193 new_messages_section();
195 void tmplput_tasks_section(StrBuf *Target, WCTemplputParams *TP) {
198 void tmplput_calendar_section(StrBuf *Target, WCTemplputParams *TP) {
206 RegisterNamespace("TIME:NOW", 0, 0, tmplput_output_date, NULL, CTX_NONE);
207 RegisterNamespace("SUMMARY:NEWMESSAGES_SELECTION", 0, 0, tmplput_new_messages_section, NULL, CTX_NONE);
208 RegisterNamespace("SUMMARY:TASKSSECTION", 0, 0, tmplput_tasks_section, NULL, CTX_NONE);
209 RegisterNamespace("SUMMARY:CALENDAR_SECTION", 0, 0, tmplput_calendar_section, NULL, CTX_NONE);
211 WebcitAddUrlHandler(HKEY("new_messages_html"), "", 0, new_messages_section, AJAX);
212 WebcitAddUrlHandler(HKEY("tasks_inner_html"), "", 0, tasks_section, AJAX);
213 WebcitAddUrlHandler(HKEY("calendar_inner_html"), "", 0, calendar_section, AJAX);