userlist: removed (not logged in) message on iconbar
[citadel.git] / webcit / summary.c
1 /*
2  * $Id$
3  */
4 /**
5  * \defgroup SymaryFuncs Displays the "Summary Page"
6  * \ingroup WebcitDisplayItems
7  */
8 /*@{*/
9 #include "webcit.h"
10
11 /**
12  * \brief Display today's date in a friendly format
13  */
14 void output_date(void) {
15         struct tm tm;
16         time_t now;
17         char buf[128];
18
19         time(&now);
20         localtime_r(&now, &tm);
21
22         wc_strftime(buf, 32, "%A, %x", &tm);
23         wprintf("%s", buf);
24 }
25
26
27
28
29 /**
30  * \brief Dummy section
31  */
32 void dummy_section(void) {
33         svprintf("BOXTITLE", WCS_STRING, "(dummy section)");
34         do_template("beginbox");
35         wprintf(_("(nothing)"));
36         do_template("endbox");
37 }
38
39
40 /**
41  * \brief New messages section
42  */
43 void new_messages_section(void) {
44         char buf[SIZ];
45         char room[SIZ];
46         int i;
47         int number_of_rooms_to_check;
48         char *rooms_to_check = "Mail|Lobby";
49
50
51         number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
52         if (number_of_rooms_to_check == 0) return;
53
54         wprintf("<table border=0 width=100%%>\n");
55         for (i=0; i<number_of_rooms_to_check; ++i) {
56                 extract_token(room, rooms_to_check, i, '|', sizeof room);
57
58                 serv_printf("GOTO %s", room);
59                 serv_getln(buf, sizeof buf);
60                 if (buf[0] == '2') {
61                         extract_token(room, &buf[4], 0, '|', sizeof room);
62                         wprintf("<tr><td><a href=\"dotgoto?room=");
63                         urlescputs(room);
64                         wprintf("\">");
65                         escputs(room);
66                         wprintf("</a></td><td>%d/%d</td></tr>\n",
67                                 extract_int(&buf[4], 1),
68                                 extract_int(&buf[4], 2)
69                         );
70                 }
71         }
72         wprintf("</table>\n");
73
74 }
75
76
77 /**
78  * \brief Wholist section
79  */
80 void wholist_section(void) {
81         char buf[SIZ];
82         char user[SIZ];
83
84         serv_puts("RWHO");
85         serv_getln(buf, sizeof buf);
86         if (buf[0] == '1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
87                 extract_token(user, buf, 1, '|', sizeof user);
88                 if (strcmp(user, NLI)) {
89                         wprintf("<li><a href=\"showuser?who=");
90                         urlescputs(user);
91                         wprintf("\">");
92                         escputs(user);
93                         wprintf("</a></li>");
94                 }
95         }
96 }
97
98
99 /**
100  * \brief Task list section
101  */
102 void tasks_section(void) {
103 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
104         int num_msgs = 0;
105         int i;
106 #endif
107
108 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
109         gotoroom("_TASKS_");
110         if (WC->wc_view != VIEW_TASKS) {
111                 num_msgs = 0;
112         }
113         else {
114                 num_msgs = load_msg_ptrs("MSGS ALL", 0);
115         }
116
117         if (num_msgs < 1) {
118                 wprintf("<i>");
119                 wprintf(_("(None)"));
120                 wprintf("</i><br />\n");
121         }
122         else {
123                 for (i=0; i<num_msgs; ++i) {
124                         display_task(WC->msgarr[i]);
125                 }
126         }
127
128         calendar_summary_view();
129
130 #else /* WEBCIT_WITH_CALENDAR_SERVICE */
131         wprintf("<i>");
132         wprintf(_("(This server does not support task lists)"));
133         wprintf("</i>\n");
134 #endif /* WEBCIT_WITH_CALENDAR_SERVICE */
135 }
136
137
138 /**
139  * \brief Calendar section
140  */
141 void calendar_section(void) {
142 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
143         int num_msgs = 0;
144         int i;
145 #endif
146
147 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
148         gotoroom("_CALENDAR_");
149         if ( (WC->wc_view != VIEW_CALENDAR) && (WC->wc_view != VIEW_CALBRIEF) ) {
150                 num_msgs = 0;
151         }
152         else {
153                 num_msgs = load_msg_ptrs("MSGS ALL", 0);
154         }
155
156         if (num_msgs < 1) {
157                 wprintf("<i>");
158                 wprintf(_("(Nothing)"));
159                 wprintf("</i><br />\n");
160         }
161         else {
162                 for (i=0; i<num_msgs; ++i) {
163                         display_calendar(WC->msgarr[i]);
164                 }
165                 calendar_summary_view();
166         }
167
168 #else /* WEBCIT_WITH_CALENDAR_SERVICE */
169         wprintf("<i>");
170         wprintf(_("(This server does not support calendars)"));
171         wprintf("</i>\n");
172 #endif /* WEBCIT_WITH_CALENDAR_SERVICE */
173 }
174
175 /**
176  * \brief Server info section (fluff, really)
177  */
178 void server_info_section(void) {
179         char message[512];
180
181         snprintf(message, sizeof message,
182                 _("You are connected to %s, running %s with %s, and located in %s.  Your system administrator is %s."),
183                 serv_info.serv_humannode,
184                 serv_info.serv_software,
185                 SERVER,
186                 serv_info.serv_bbs_city,
187                 serv_info.serv_sysadm);
188         escputs(message);
189 }
190
191 /**
192  * \brief summary of inner div????
193  */
194
195
196
197 void summary_inner_div(void) {
198         /**
199          * Now let's do three columns of crap.  All portals and all groupware
200          * clients seem to want to do three columns, so we'll do three
201          * columns too.  Conformity is not inherently a virtue, but there are
202          * a lot of really shallow people out there, and even though they're
203          * not people I consider worthwhile, I still want them to use WebCit.
204          */
205
206         wprintf("<div class=\"fix_scrollbar_bug\">"
207                 "<table border=0 width=100%%><tr valign=top>");
208
209         /**
210          * Column One
211          */
212         wprintf("<td width=33%%>");
213         wprintf("<div class=\"box\">"); 
214         wprintf("<div class=\"boxlabel\">");    
215         wprintf(_("Messages"));
216         wprintf("</div><div class=\"boxcontent\">");    
217         wprintf("<div id=\"msg_inner\">");      
218         new_messages_section();
219         wprintf("</div></div></div>");
220         wprintf("</td>");
221
222         /**
223          * Column Two 
224          */
225         wprintf("<td width=33%%>");
226         wprintf("<div class=\"box\">"); 
227         wprintf("<div class=\"boxlabel\">");    
228         wprintf(_("Tasks"));
229         wprintf("</div><div class=\"boxcontent\">");    
230         wprintf("<div id=\"tasks_inner\">");    
231         tasks_section();
232         wprintf("</div></div></div>");
233         wprintf("</td>");
234
235         /**
236          * Column Three
237          */
238         wprintf("<td width=33%%>");
239         wprintf("<div class=\"box\">"); 
240         wprintf("<div class=\"boxlabel\">");    
241         wprintf(_("Today&nbsp;on&nbsp;your&nbsp;calendar"));
242         wprintf("</div><div class=\"boxcontent\">");    
243         wprintf("<div id=\"calendar_inner\">"); 
244         calendar_section();
245         wprintf("</div></div></div>");
246         wprintf("</td>");
247
248         wprintf("</tr><tr valign=top>");
249         wprintf("<td colspan=3><br/></td>");
250         wprintf("</tr><tr valign=top>");
251
252         /**
253          * Row Two - Column One
254          */
255         wprintf("<td colspan=2>");
256         wprintf("<div class=\"box\">"); 
257         wprintf("<div class=\"boxlabel\">");    
258         wprintf(_("Who's&nbsp;online&nbsp;now"));
259         wprintf("</div><div class=\"boxcontent\">");    
260         wprintf("<div id=\"who_inner\">");      
261         who_inner_div(); 
262         wprintf("</div></div></div>");
263         wprintf("</td>");
264
265         /**
266          * Row Two - Column Two
267          */
268         wprintf("<td width=33%%>");
269         wprintf("<div class=\"box\">"); 
270         wprintf("<div class=\"boxlabel\">");    
271         wprintf(_("About&nbsp;this&nbsp;server"));
272         wprintf("</div><div class=\"boxcontent\">");    
273         wprintf("<div id=\"info_inner\">");     
274         server_info_section();
275         wprintf("</div></div></div>");
276         wprintf("</td>");
277
278
279         /**
280          * End of columns
281          */
282         wprintf("</tr></table>");
283 }
284
285
286 /**
287  * \brief Display this user's summary page
288  */
289 void summary(void) {
290         char title[256];
291
292         output_headers(1, 1, 2, 0, 0, 0);
293         wprintf("<div id=\"banner\">\n");
294         wprintf("<div class=\"service_banner\">\n");
295         wprintf("<img src=\"static/summscreen_48x.gif\">");
296         wprintf("<h1>");
297         snprintf(title, sizeof title, _("Summary page for %s"), WC->wc_fullname);
298         escputs(title);
299         wprintf("</h1><h2>\n");
300         output_date();
301         wprintf("</h2></div>");
302         wprintf("<ul><li class=\"start_page\">");
303         offer_start_page();
304         wprintf("</li></ul>");
305         wprintf("</div>");
306
307         /**
308          * You guessed it ... we're going to refresh using ajax.
309          * In the future we might consider updating individual sections of the summary
310          * instead of the whole thing.
311          */
312         wprintf("<div id=\"content\">\n");
313         summary_inner_div();
314         wprintf("</div>\n");
315
316         wprintf(
317                 "<script type=\"text/javascript\">                                      "
318                 " new Ajax.PeriodicalUpdater('msg_inner', 'new_messages_html',          "
319                 "                            { method: 'get', frequency: 60 }  );       "
320                 " new Ajax.PeriodicalUpdater('tasks_inner', 'tasks_inner_html',         "
321                 "                            { method: 'get', frequency: 120 }  );      "
322                 " new Ajax.PeriodicalUpdater('calendar_inner', 'calendar_inner_html',           "
323                 "                            { method: 'get', frequency: 90 }  );       "
324                 " new Ajax.PeriodicalUpdater('who_inner', 'who_inner_html',             "
325                 "                            { method: 'get', frequency: 30 }  );       "
326                 "</script>                                                              \n"
327         );
328
329         wDumpContent(1);
330 }
331
332
333 /*@}*/