2 * Displays the "Summary Page"
4 * Copyright (c) 1996-2012 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, version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
18 extern int calendar_summary_view(void);
21 * Display today's date in a friendly format
23 void output_date(void) {
29 localtime_r(&now, &tm);
31 wc_strftime(buf, 32, "%A, %x", &tm);
35 void tmplput_output_date(StrBuf *Target, WCTemplputParams *TP)
43 localtime_r(&now, &tm);
45 n = wc_strftime(buf, 32, "%A, %x", &tm);
46 StrBufAppendBufPlain(Target, buf, n, 0);
51 * New messages section
53 void new_messages_section(void) {
57 int number_of_rooms_to_check;
58 char *rooms_to_check = "Mail|Lobby";
61 number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
62 if (number_of_rooms_to_check == 0) return;
64 wc_printf("<table border=\"0\" width=\"100%%\">\n");
65 for (i=0; i<number_of_rooms_to_check; ++i) {
66 extract_token(room, rooms_to_check, i, '|', sizeof room);
68 serv_printf("GOTO %s", room);
69 serv_getln(buf, sizeof buf);
71 extract_token(room, &buf[4], 0, '|', sizeof room);
72 wc_printf("<tr><td><a href=\"dotgoto?room=");
76 wc_printf("</a></td><td>%d/%d</td></tr>\n",
77 extract_int(&buf[4], 1),
78 extract_int(&buf[4], 2)
82 wc_printf("</table>\n");
90 void tasks_section(void) {
99 SharedMessageStatus Stat;
101 memset(&Stat, 0, sizeof(SharedMessageStatus));
102 Stat.maxload = 10000;
103 Stat.lowest_found = (-1);
104 Stat.highest_found = (-1);
106 Buf = NewStrBufPlain(HKEY("_TASKS_"));
110 if (WCC->CurRoom.view != VIEW_TASKS) {
114 num_msgs = load_msg_ptrs("MSGS ALL", NULL, &Stat, NULL);
118 at = GetNewHashPos(WCC->summ, 0);
119 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
120 Msg = (message_summary*) vMsg;
121 tasks_LoadMsgFromServer(NULL, NULL, Msg, 0, 0);
126 if (calendar_summary_view() < 1) {
128 wc_printf(_("(None)"));
129 wc_printf("</i><br>\n");
137 void calendar_section(void) {
145 message_summary *Msg;
149 SharedMessageStatus Stat;
151 memset(&Stat, 0, sizeof(SharedMessageStatus));
152 Stat.maxload = 10000;
153 Stat.lowest_found = (-1);
154 Stat.highest_found = (-1);
156 Buf = NewStrBufPlain(HKEY("_CALENDAR_"));
159 if ( (WC->CurRoom.view != VIEW_CALENDAR) && (WC->CurRoom.view != VIEW_CALBRIEF) ) {
163 num_msgs = load_msg_ptrs("MSGS ALL", NULL, &Stat, NULL);
165 calendar_GetParamsGetServerCall(&Stat,
175 at = GetNewHashPos(WCC->summ, 0);
176 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
177 Msg = (message_summary*) vMsg;
178 calendar_LoadMsgFromServer(NULL, &v, Msg, 0, 0);
182 if (calendar_summary_view() < 1) {
184 wc_printf(_("(Nothing)"));
185 wc_printf("</i><br>\n");
187 __calendar_Cleanup(&v);
190 void tmplput_new_messages_section(StrBuf *Target, WCTemplputParams *TP) {
191 new_messages_section();
193 void tmplput_tasks_section(StrBuf *Target, WCTemplputParams *TP) {
196 void tmplput_calendar_section(StrBuf *Target, WCTemplputParams *TP) {
204 void display_summary_page(void)
206 output_headers(1, 1, 1, 0, 0, 0);
207 do_template("summary_page");
216 RegisterNamespace("TIME:NOW", 0, 0, tmplput_output_date, NULL, CTX_NONE);
217 WebcitAddUrlHandler(HKEY("summary"), "", 0, display_summary_page, ANONYMOUS);
218 WebcitAddUrlHandler(HKEY("new_messages_html"), "", 0, new_messages_section, AJAX);
219 WebcitAddUrlHandler(HKEY("tasks_inner_html"), "", 0, tasks_section, AJAX);
220 WebcitAddUrlHandler(HKEY("calendar_inner_html"), "", 0, calendar_section, AJAX);