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);
40 * New messages section
42 void new_messages_section(void) {
46 int number_of_rooms_to_check;
47 char *rooms_to_check = "Mail|Lobby";
50 number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
51 if (number_of_rooms_to_check == 0) return;
53 wc_printf("<table border=\"0\" width=\"100%%\">\n");
54 for (i=0; i<number_of_rooms_to_check; ++i) {
55 extract_token(room, rooms_to_check, i, '|', sizeof room);
57 serv_printf("GOTO %s", room);
58 serv_getln(buf, sizeof buf);
60 extract_token(room, &buf[4], 0, '|', sizeof room);
61 wc_printf("<tr><td><a href=\"dotgoto?room=");
65 wc_printf("</a></td><td>%d/%d</td></tr>\n",
66 extract_int(&buf[4], 1),
67 extract_int(&buf[4], 2)
71 wc_printf("</table>\n");
79 void tasks_section(void) {
88 SharedMessageStatus Stat;
90 memset(&Stat, 0, sizeof(SharedMessageStatus));
92 Stat.lowest_found = (-1);
93 Stat.highest_found = (-1);
95 Buf = NewStrBufPlain(HKEY("_TASKS_"));
99 if (WCC->CurRoom.view != VIEW_TASKS) {
103 num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL);
107 at = GetNewHashPos(WCC->summ, 0);
108 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
109 Msg = (message_summary*) vMsg;
110 tasks_LoadMsgFromServer(NULL, NULL, Msg, 0, 0);
115 if (calendar_summary_view() < 1) {
117 wc_printf(_("(None)"));
118 wc_printf("</i><br>\n");
126 void calendar_section(void) {
133 message_summary *Msg;
137 SharedMessageStatus Stat;
139 memset(&Stat, 0, sizeof(SharedMessageStatus));
140 Stat.maxload = 10000;
141 Stat.lowest_found = (-1);
142 Stat.highest_found = (-1);
144 Buf = NewStrBufPlain(HKEY("_CALENDAR_"));
147 if ( (WC->CurRoom.view != VIEW_CALENDAR) && (WC->CurRoom.view != VIEW_CALBRIEF) ) {
151 num_msgs = load_msg_ptrs("MSGS ALL", &Stat, NULL);
153 calendar_GetParamsGetServerCall(&Stat,
160 at = GetNewHashPos(WCC->summ, 0);
161 while (GetNextHashPos(WCC->summ, at, &HKLen, &HashKey, &vMsg)) {
162 Msg = (message_summary*) vMsg;
163 calendar_LoadMsgFromServer(NULL, &v, Msg, 0, 0);
167 if (calendar_summary_view() < 1) {
169 wc_printf(_("(Nothing)"));
170 wc_printf("</i><br>\n");
172 __calendar_Cleanup(&v);
176 * Server info section (fluff, really)
178 void server_info_section(void) {
182 snprintf(message, sizeof message,
183 _("You are connected to %s, running %s with %s, server build %s and located in %s. Your system administrator is %s."),
184 ChrPtr(WCC->serv_info->serv_humannode),
185 ChrPtr(WCC->serv_info->serv_software),
187 ChrPtr(WCC->serv_info->serv_svn_revision),
188 ChrPtr(WCC->serv_info->serv_bbs_city),
189 ChrPtr(WCC->serv_info->serv_sysadm));
194 * Now let's do three columns of crap. All portals and all groupware
195 * clients seem to want to do three columns, so we'll do three
196 * columns too. Conformity is not inherently a virtue, but there are
197 * a lot of really shallow people out there, and even though they're
198 * not people I consider worthwhile, I still want them to use WebCit.
200 void summary_inner_div(void) {
202 wc_printf("<table width=\"98%%\" cellspacing=\"3\" cellpadding=\"0\">");
203 wc_printf("<tr valign=top>");
208 wc_printf("<td width=\"33%%\">");
209 wc_printf("<div class=\"box\">");
210 wc_printf("<div class=\"boxlabel\">");
211 wc_printf(_("Messages"));
212 wc_printf("</div><div class=\"boxcontent\">");
213 wc_printf("<div id=\"msg_inner\">");
214 new_messages_section();
215 wc_printf("</div></div></div>");
221 wc_printf("<td width=\"33%%\">");
222 wc_printf("<div class=\"box\">");
223 wc_printf("<div class=\"boxlabel\">");
224 wc_printf(_("Tasks"));
225 wc_printf("</div><div class=\"boxcontent\">");
226 wc_printf("<div id=\"tasks_inner\">");
228 wc_printf("</div></div></div>");
234 wc_printf("<td width=\"33%%\">");
235 wc_printf("<div class=\"box\">");
236 wc_printf("<div class=\"boxlabel\">");
237 wc_printf(_("Today on your calendar"));
238 wc_printf("</div><div class=\"boxcontent\">");
239 wc_printf("<div id=\"calendar_inner\">");
241 wc_printf("</div></div></div>");
244 wc_printf("</tr><tr valign=top>");
247 * Row Two - Column One
249 wc_printf("<td colspan=2>");
250 wc_printf("<div class=\"box\">");
251 wc_printf("<div class=\"boxlabel\">");
252 wc_printf(_("Who's online now"));
253 wc_printf("</div><div class=\"boxcontent\">");
254 wc_printf("<div id=\"who_inner\">");
255 do_template("who_summary");
256 wc_printf("</div></div></div>");
260 * Row Two - Column Two
262 wc_printf("<td width=\"33%%\">");
263 wc_printf("<div class=\"box\">");
264 wc_printf("<div class=\"boxlabel\">");
265 wc_printf(_("About this server"));
266 wc_printf("</div><div class=\"boxcontent\">");
267 wc_printf("<div id=\"info_inner\">");
268 server_info_section();
269 wc_printf("</div></div></div>");
276 wc_printf("</tr></table>");
281 * Display this user's summary page
286 output_headers(1, 1, 2, 0, 0, 0);
287 wc_printf("<div id=\"banner\" class=\"banner\">\n");
288 wc_printf("<table border=0><tr>");
289 wc_printf("<td><img src=\"static/webcit_icons/essen/32x32/summary.png\" alt=\"\"></td>");
290 wc_printf("<td><h1>");
291 snprintf(title, sizeof title, _("Summary page for %s"),
292 ( (WC->logged_in) ? ChrPtr(WC->wc_fullname) : ChrPtr(WC->serv_info->serv_humannode))
295 wc_printf("</h1><h2>");
297 wc_printf("</h2></td></tr></table>");
298 wc_printf("<div id=\"actiondiv\">");
299 wc_printf("<ul class=\"room_actions\">\n");
300 wc_printf("<li class=\"start_page\">");
301 offer_start_page(NULL, &NoCtx);
302 wc_printf("</li></ul>");
303 wc_printf("</div>"); /* actiondiv */
304 wc_printf("</div>"); /* banner */
307 * You guessed it ... we're going to refresh using ajax.
308 * In the future we might consider updating individual sections of the summary
309 * instead of the whole thing.
311 wc_printf("<div id=\"content\" class=\"service\">\n");
313 wc_printf("</div>\n");
316 "<script type=\"text/javascript\"> "
317 " new Ajax.PeriodicalUpdater('msg_inner', 'new_messages_html', "
318 " { method: 'get', frequency: 60 } ); "
319 " new Ajax.PeriodicalUpdater('tasks_inner', 'tasks_inner_html', "
320 " { method: 'get', frequency: 120 } ); "
321 " new Ajax.PeriodicalUpdater('calendar_inner', 'calendar_inner_html', "
322 " { method: 'get', frequency: 90 } ); "
323 " new Ajax.PeriodicalUpdater('do_template', 'template=who_summary', "
324 " { method: 'get', frequency: 30 } ); "
335 WebcitAddUrlHandler(HKEY("new_messages_html"), "", 0, new_messages_section, AJAX);
336 WebcitAddUrlHandler(HKEY("tasks_inner_html"), "", 0, tasks_section, AJAX);
337 WebcitAddUrlHandler(HKEY("calendar_inner_html"), "", 0, calendar_section, AJAX);
338 WebcitAddUrlHandler(HKEY("mini_calendar"), "", 0, ajax_mini_calendar, AJAX);
339 WebcitAddUrlHandler(HKEY("summary"), "", 0, summary, 0);
340 WebcitAddUrlHandler(HKEY("summary_inner_div"), "", 0, summary_inner_div, AJAX);