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
25 * Display today's date in a friendly format
27 void output_date(void) {
33 localtime_r(&now, &tm);
35 wc_strftime(buf, 32, "%A, %x", &tm);
39 void tmplput_output_date(StrBuf *Target, WCTemplputParams *TP)
47 localtime_r(&now, &tm);
49 n = wc_strftime(buf, 32, "%A, %x", &tm);
50 StrBufAppendBufPlain(Target, buf, n, 0);
55 * New messages section
57 void new_messages_section(void) {
61 int number_of_rooms_to_check;
62 char *rooms_to_check = "Mail|Lobby";
65 number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
66 if (number_of_rooms_to_check == 0) return;
68 wc_printf("<table border=\"0\" width=\"100%%\">\n");
69 for (i=0; i<number_of_rooms_to_check; ++i) {
70 extract_token(room, rooms_to_check, i, '|', sizeof room);
72 serv_printf("GOTO %s", room);
73 serv_getln(buf, sizeof buf);
75 extract_token(room, &buf[4], 0, '|', sizeof room);
76 wc_printf("<tr><td><a href=\"dotgoto?room=");
80 wc_printf("</a></td><td>%d/%d</td></tr>\n",
81 extract_int(&buf[4], 1),
82 extract_int(&buf[4], 2)
86 wc_printf("</table>\n");
94 void tasks_section(void) {
100 message_summary *Msg;
103 SharedMessageStatus Stat;
105 memset(&Stat, 0, sizeof(SharedMessageStatus));
106 Stat.maxload = 10000;
107 Stat.lowest_found = (-1);
108 Stat.highest_found = (-1);
110 Buf = NewStrBufPlain(HKEY("_TASKS_"));
114 if (WCC->CurRoom.view != VIEW_TASKS) {
118 num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL);
122 at = GetNewHashPos(WCC->summ, 0);
123 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
124 Msg = (message_summary*) vMsg;
125 tasks_LoadMsgFromServer(NULL, NULL, Msg, 0, 0);
130 if (calendar_summary_view() < 1) {
132 wc_printf(_("(None)"));
133 wc_printf("</i><br>\n");
141 void calendar_section(void) {
148 message_summary *Msg;
152 SharedMessageStatus Stat;
154 memset(&Stat, 0, sizeof(SharedMessageStatus));
155 Stat.maxload = 10000;
156 Stat.lowest_found = (-1);
157 Stat.highest_found = (-1);
159 Buf = NewStrBufPlain(HKEY("_CALENDAR_"));
162 if ( (WC->CurRoom.view != VIEW_CALENDAR) && (WC->CurRoom.view != VIEW_CALBRIEF) ) {
166 num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL);
168 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 RegisterNamespace("TIME:NOW", 0, 0, tmplput_output_date, NULL, CTX_NONE);
205 RegisterNamespace("SUMMARY:NEWMESSAGES_SELECTION", 0, 0, tmplput_new_messages_section, NULL, CTX_NONE);
206 RegisterNamespace("SUMMARY:TASKSSECTION", 0, 0, tmplput_tasks_section, NULL, CTX_NONE);
207 RegisterNamespace("SUMMARY:CALENDAR_SECTION", 0, 0, tmplput_calendar_section, NULL, CTX_NONE);
209 WebcitAddUrlHandler(HKEY("new_messages_html"), "", 0, new_messages_section, AJAX);
210 WebcitAddUrlHandler(HKEY("tasks_inner_html"), "", 0, tasks_section, AJAX);
211 WebcitAddUrlHandler(HKEY("calendar_inner_html"), "", 0, calendar_section, AJAX);
212 WebcitAddUrlHandler(HKEY("mini_calendar"), "", 0, ajax_mini_calendar, AJAX);