* subst.c summary.c sysmsgs.c : i18n
[citadel.git] / webcit / summary.c
1 /*
2  * $Id$
3  *
4  * Displays the "Summary Page"
5  */
6
7 #include "webcit.h"
8
9 /*
10  * Display today's date in a friendly format
11  */
12 void output_date(void) {
13         struct tm tm;
14         time_t now;
15
16         static char *wdays[7];
17         static char *months[12];
18
19         wdays[0] = _("Sunday");
20         wdays[1] = _("Monday");
21         wdays[2] = _("Tuesday");
22         wdays[3] = _("Wednesday");
23         wdays[4] = _("Thursday");
24         wdays[5] = _("Friday");
25         wdays[6] = _("Saturday");
26
27         months[0] = _("January");
28         months[1] = _("February");
29         months[2] = _("March");
30         months[3] = _("April");
31         months[4] = _("May");
32         months[5] = _("June");
33         months[6] = _("July");
34         months[7] = _("August");
35         months[8] = _("September");
36         months[9] = _("October");
37         months[10] = _("November");
38         months[12] = _("December");
39
40         time(&now);
41         localtime_r(&now, &tm);
42
43         wprintf("%s, %s %d, %d",
44                 wdays[tm.tm_wday],
45                 months[tm.tm_mon],
46                 tm.tm_mday,
47                 tm.tm_year + 1900
48         );
49 }
50
51
52
53
54 /*
55  * Dummy section
56  */
57 void dummy_section(void) {
58         svprintf("BOXTITLE", WCS_STRING, "(dummy section)");
59         do_template("beginbox");
60         wprintf(_("(nothing)"));
61         do_template("endbox");
62 }
63
64
65 /*
66  * New messages section
67  */
68 void new_messages_section(void) {
69         char buf[SIZ];
70         char room[SIZ];
71         int i;
72         int number_of_rooms_to_check;
73         char *rooms_to_check = "Mail|Lobby";
74
75         svprintf("BOXTITLE", WCS_STRING, _("Messages"));
76         do_template("beginbox");
77
78         number_of_rooms_to_check = num_tokens(rooms_to_check, '|');
79         if (number_of_rooms_to_check == 0) return;
80
81         wprintf("<TABLE BORDER=0 WIDTH=100%%>\n");
82         for (i=0; i<number_of_rooms_to_check; ++i) {
83                 extract_token(room, rooms_to_check, i, '|', sizeof room);
84
85                 serv_printf("GOTO %s", room);
86                 serv_getln(buf, sizeof buf);
87                 if (buf[0] == '2') {
88                         extract_token(room, &buf[4], 0, '|', sizeof room);
89                         wprintf("<TR><TD><A HREF=\"/dotgoto?room=");
90                         urlescputs(room);
91                         wprintf("\">");
92                         escputs(room);
93                         wprintf("</A></TD><TD>%d/%d</TD></TR>\n",
94                                 extract_int(&buf[4], 1),
95                                 extract_int(&buf[4], 2)
96                         );
97                 }
98         }
99         wprintf("</TABLE>\n");
100         do_template("endbox");
101
102 }
103
104
105 /*
106  * Wholist section
107  */
108 void wholist_section(void) {
109         char buf[SIZ];
110         char user[SIZ];
111
112         svprintf("BOXTITLE", WCS_STRING, _("Who's&nbsp;online&nbsp;now"));
113         do_template("beginbox");
114         serv_puts("RWHO");
115         serv_getln(buf, sizeof buf);
116         if (buf[0] == '1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
117                 extract_token(user, buf, 1, '|', sizeof user);
118                 escputs(user);
119                 wprintf("<br />\n");
120         }
121         do_template("endbox");
122 }
123
124
125 /*
126  * Task list section
127  */
128 void tasks_section(void) {
129 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
130         int num_msgs = 0;
131         int i;
132 #endif
133
134         svprintf("BOXTITLE", WCS_STRING, _("Tasks"));
135         do_template("beginbox");
136 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
137         gotoroom("_TASKS_");
138         if (WC->wc_view != VIEW_TASKS) {
139                 num_msgs = 0;
140         }
141         else {
142                 num_msgs = load_msg_ptrs("MSGS ALL", 0);
143         }
144
145         if (num_msgs < 1) {
146                 wprintf("<i>");
147                 wprintf(_("(None)"));
148                 wprintf("</i><br />\n");
149         }
150         else {
151                 for (i=0; i<num_msgs; ++i) {
152                         display_task(WC->msgarr[i]);
153                 }
154         }
155
156         calendar_summary_view();
157
158 #else /* WEBCIT_WITH_CALENDAR_SERVICE */
159         wprintf("<I>");
160         wprintf(_("(This server does not support task lists)"));
161         wprintf("</I>\n");
162 #endif /* WEBCIT_WITH_CALENDAR_SERVICE */
163         do_template("endbox");
164 }
165
166
167 /*
168  * Calendar section
169  */
170 void calendar_section(void) {
171 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
172         int num_msgs = 0;
173         int i;
174 #endif
175
176         svprintf("BOXTITLE", WCS_STRING, _("Today&nbsp;on&nbsp;your&nbsp;calendar"));
177         do_template("beginbox");
178 #ifdef WEBCIT_WITH_CALENDAR_SERVICE
179         gotoroom("_CALENDAR_");
180         if (WC->wc_view != VIEW_CALENDAR) {
181                 num_msgs = 0;
182         }
183         else {
184                 num_msgs = load_msg_ptrs("MSGS ALL", 0);
185         }
186
187         if (num_msgs < 1) {
188                 wprintf("<i>");
189                 wprintf(_("(Nothing)"));
190                 wprintf("</i><br />\n");
191         }
192         else {
193                 for (i=0; i<num_msgs; ++i) {
194                         display_calendar(WC->msgarr[i]);
195                 }
196                 calendar_summary_view();
197         }
198
199 #else /* WEBCIT_WITH_CALENDAR_SERVICE */
200         wprintf("<I>");
201         wprintf(_("(This server does not support calendars)"));
202         wprintf("</I>\n");
203 #endif /* WEBCIT_WITH_CALENDAR_SERVICE */
204         do_template("endbox");
205 }
206
207 /*
208  * Server info section (fluff, really)
209  */
210 void server_info_section(void) {
211         char message[512];
212
213         svprintf("BOXTITLE", WCS_STRING, _("About&nbsp;this&nbsp;server"));
214         do_template("beginbox");
215
216         snprintf(message, sizeof message,
217                 _("You are connected to %s, running %s with %s, and located in %s.  Your system administrator is %s."),
218                 serv_info.serv_humannode,
219                 serv_info.serv_software,
220                 SERVER,
221                 serv_info.serv_bbs_city,
222                 serv_info.serv_sysadm);
223         escputs(message);
224         do_template("endbox");
225 }
226
227
228 /*
229  * Display this user's summary page
230  */
231 void summary(void) {
232         char title[256];
233
234         output_headers(1, 1, 2, 0, 1, 0, 0);
235         wprintf("<div id=\"banner\">\n");
236         wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=#444455><TR>"
237                 "<TD><IMG SRC=\"/static/summscreen_48x.gif\"></TD><TD>"
238                 "<SPAN CLASS=\"titlebar\">"
239         );
240
241         snprintf(title, sizeof title, _("Summary page for %s"), WC->wc_username);
242         escputs(title);
243         wprintf("</SPAN></TD><TD>\n");
244         wprintf("</TD><TD ALIGN=RIGHT><SPAN CLASS=\"titlebar\">");
245         output_date();
246         wprintf("</SPAN><br />");
247         offer_start_page();
248         wprintf("</TD></TR></TABLE>\n");
249         wprintf("</div>\n<div id=\"content\">\n");
250
251         /*
252          * Now let's do three columns of crap.  All portals and all groupware
253          * clients seem to want to do three columns, so we'll do three
254          * columns too.  Conformity is not inherently a virtue, but there are
255          * a lot of really shallow people out there, and even though they're
256          * not people I consider worthwhile, I still want them to use WebCit.
257          */
258
259         wprintf("<div id=\"fix_scrollbar_bug\">"
260                 "<table border=0 width=100%%><tr valign=top>");
261
262         /*
263          * Column One
264          */
265         wprintf("<td width=33%%>");
266         wholist_section();
267
268         /*
269          * Column Two
270          */
271         wprintf("</td><td width=33%%>");
272         server_info_section();
273         wprintf("<br />");
274         tasks_section();
275
276         /*
277          * Column Three
278          */
279         wprintf("</td><td width=33%%>");
280         new_messages_section();
281         wprintf("<br />");
282         calendar_section();
283
284         /*
285          * End of columns
286          */
287         wprintf("</td></tr></table></div>\n");
288         wDumpContent(1);
289 }