3 * Displays the "Summary Page"
5 * Copyright (c) 1996-2021 by the citadel.org team
7 * This program is open source software. You can redistribute it and/or
8 * modify it under the terms of the GNU General Public License, version 3.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
19 extern int calendar_summary_view(void);
22 * Display today's date in a friendly format
24 void output_date(void) {
30 localtime_r(&now, &tm);
32 wc_strftime(buf, 32, "%A, %x", &tm);
36 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)
65 wc_printf("<table border=\"0\" width=\"100%%\">\n");
66 for (i = 0; i < number_of_rooms_to_check; ++i) {
67 extract_token(room, rooms_to_check, i, '|', sizeof room);
69 serv_printf("GOTO %s", room);
70 serv_getln(buf, sizeof buf);
72 extract_token(room, &buf[4], 0, '|', sizeof room);
73 wc_printf("<tr><td><a href=\"dotgoto?room=");
77 wc_printf("</a></td><td>%d/%d</td></tr>\n", extract_int(&buf[4], 1), extract_int(&buf[4], 2)
81 wc_printf("</table>\n");
89 void tasks_section(void) {
97 SharedMessageStatus Stat;
99 memset(&Stat, 0, sizeof(SharedMessageStatus));
100 Stat.maxload = 10000;
101 Stat.lowest_found = (-1);
102 Stat.highest_found = (-1);
104 Buf = NewStrBufPlain(HKEY("_TASKS_"));
108 if (WC->CurRoom.view != VIEW_TASKS) {
112 num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
116 at = GetNewHashPos(WC->summ, 0);
117 while (GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
118 Msg = (message_summary *) vMsg;
119 tasks_LoadMsgFromServer(NULL, NULL, Msg, 0, 0);
124 if (calendar_summary_view() < 1) {
126 wc_printf(_("(None)"));
127 wc_printf("</i><br>\n");
135 void calendar_section(void) {
143 message_summary *Msg;
146 SharedMessageStatus Stat;
148 memset(&Stat, 0, sizeof(SharedMessageStatus));
149 Stat.maxload = 10000;
150 Stat.lowest_found = (-1);
151 Stat.highest_found = (-1);
153 Buf = NewStrBufPlain(HKEY("_CALENDAR_"));
156 if ((WC->CurRoom.view != VIEW_CALENDAR) && (WC->CurRoom.view != VIEW_CALBRIEF)) {
160 num_msgs = load_msg_ptrs("MSGS ALL", NULL, NULL, &Stat, NULL, NULL, NULL, NULL, 0);
162 calendar_GetParamsGetServerCall(&Stat, &v, readnew, cmd, sizeof(cmd), filter, sizeof(filter));
166 at = GetNewHashPos(WC->summ, 0);
167 while (GetNextHashPos(WC->summ, at, &HKLen, &HashKey, &vMsg)) {
168 Msg = (message_summary *) vMsg;
169 calendar_LoadMsgFromServer(NULL, &v, Msg, 0, 0);
173 if (calendar_summary_view() < 1) {
175 wc_printf(_("(Nothing)"));
176 wc_printf("</i><br>\n");
178 __calendar_Cleanup(&v);
181 void tmplput_new_messages_section(StrBuf * Target, WCTemplputParams * TP) {
182 new_messages_section();
184 void tmplput_tasks_section(StrBuf * Target, WCTemplputParams * TP) {
187 void tmplput_calendar_section(StrBuf * Target, WCTemplputParams * TP) {
195 void display_summary_page(void) {
196 output_headers(1, 1, 1, 0, 0, 0);
197 do_template("summary_page");
202 void InitModule_SUMMARY(void) {
203 RegisterNamespace("TIME:NOW", 0, 0, tmplput_output_date, NULL, CTX_NONE);
204 WebcitAddUrlHandler(HKEY("summary"), "", 0, display_summary_page, ANONYMOUS);
205 WebcitAddUrlHandler(HKEY("new_messages_html"), "", 0, new_messages_section, AJAX);
206 WebcitAddUrlHandler(HKEY("tasks_inner_html"), "", 0, tasks_section, AJAX);
207 WebcitAddUrlHandler(HKEY("calendar_inner_html"), "", 0, calendar_section, AJAX);