Temporarily disable OpenID functionality for release
[citadel.git] / webcit / mainmenu.c
1 /*
2  * $Id$
3  */
4 /**
5  * \defgroup DispAdvancedMenu Displays the "advanced" (main) menu.
6  * \ingroup MenuInfrastructure
7  *
8  */
9 /*@{*/
10 #include "webcit.h"
11
12 /**
13  * \brief The Main Menu
14  */
15 void display_main_menu(void)
16 {
17         char buf[SIZ];
18         output_headers(1, 1, 1, 0, 0, 0);
19
20         wprintf("<div class=\"fix_scrollbar_bug\">"
21                 "<table width=\"100%%\" cellspacing=\"10px\" cellpadding=\"0\">"
22                 "<tr><td colspan=\"2\" class=\"advanced\">\n");
23
24         svput("BOXTITLE", WCS_STRING, _("Basic commands"));
25         do_template("beginbox");
26
27         /**< start of first column */
28         wprintf("<ul class=\"adminitems col1\">");
29
30         wprintf("<li><a href=\"knrooms\">");
31         wprintf(_("List known rooms"));
32         wprintf("</a><span>");
33         wprintf(_("Where can I go from here?"));
34         wprintf("</span></li>\n");
35
36         wprintf("<li><a href=\"gotonext\">");
37         wprintf(_("Goto next room"));
38         wprintf("</a><span>");
39         wprintf(_("...with <em>unread</em> messages"));
40         wprintf("</span></li>\n");
41
42         wprintf("<li><a href=\"skip\">");
43         wprintf(_("Skip to next room"));
44         wprintf("</a><span>");
45         wprintf(_("(come back here later)"));
46         wprintf("</span></li>\n");
47
48         if ((!IsEmptyStr(WC->ugname)) && (strcasecmp(WC->ugname, WC->wc_roomname))) {
49                 wprintf("<li><a href=\"ungoto\">");
50                 wprintf(_("Ungoto"));
51                 wprintf("</a><span>");
52                 wprintf(_("(oops! Back to %s)"), WC->ugname);
53                 wprintf("</span></li>\n");
54         }
55
56         wprintf("</ul>\n");
57
58         /* start of second column */
59
60         wprintf("<ul class=\"adminitems col2\">");
61
62         wprintf("<li><a href=\"readnew\">");
63         wprintf(_("Read new messages"));
64         wprintf("</a><span>");
65         wprintf(_("...in this room"));
66         wprintf("</span></li>\n");
67
68         wprintf("<li><a href=\"readfwd\">");
69         wprintf(_("Read all messages"));
70         wprintf("</a><span>");
71         wprintf(_("...old <EM>and</EM> new"));
72         wprintf("</span></li>\n");
73
74         wprintf("<li><a href=\"display_enter\">");
75         wprintf(_("Enter a message"));
76         wprintf("</a><span>");
77         wprintf(_("(post in this room)"));
78         wprintf("</span></li>\n");
79
80         if (WC->room_flags & QR_VISDIR) {
81                 wprintf("<li><a href=\"display_room_directory\">");
82                 wprintf(_("File library"));
83                 wprintf("</a><span>");
84                 wprintf(_("(List files available for download)"));
85                 wprintf("</span></li>\n");
86         }
87
88         wprintf("</ul>\n");
89
90         /* start of third column */
91
92         wprintf("<ul class=\"adminitems lastcol\">");
93
94         wprintf("<li><a href=\"summary\">");
95         wprintf(_("Summary page"));
96         wprintf("</a><span>");
97         wprintf(_("Summary of my account"));
98         wprintf("</span></li>\n");
99
100         wprintf("<li><a href=\"userlist\">\n");
101         wprintf(_("User list"));
102         wprintf("</a><span>");
103         wprintf(_("(all registered users)"));
104         wprintf("</span></li>\n");
105
106         wprintf("<li><a href=\"termquit\" TARGET=\"_top\">");
107         wprintf(_("Log off"));
108         wprintf("</a><span>");
109         wprintf(_("Bye!"));
110         wprintf("</span></li>\n");
111
112         wprintf("</ul>\n");
113
114         wprintf("&nbsp;");
115
116         do_template("endbox");
117
118         wprintf("</td></tr>"
119                 "<tr valign=top><td width=50%%>");
120
121         print_menu_box(_("Your info"), "adminitems", /* 8 */ 7,
122                        "display_preferences", _("Change your preferences and settings"),
123                        "display_reg", _("Update your contact information"),
124                        "display_changepw", _("Change your password"),
125                        "display_editbio", _("Enter your 'bio'"),
126                        "display_editpic", _("Edit your online photo"), 
127                        "display_sieve", _("View/edit server-side mail filters"),
128                        "display_pushemail", _("Edit your push email settings") /* ,
129                        "display_openids", _("Manage your OpenIDs") */
130         );
131
132         wprintf("</td><td width=50%%>");
133
134         snprintf(buf, SIZ, _("Zap (forget) this room (%s)"), WC->wc_roomname);
135
136         if ( (WC->axlevel >= 6) || (WC->is_room_aide) || (WC->is_mailbox) )
137                 print_menu_box(_("Advanced room commands"),"adminitems", 5,
138                                "display_editroom", _("Edit or delete this room"),
139                                "display_private", _("Go to a 'hidden' room"),
140                                "display_entroom", _("Create a new room"),
141                                "display_zap",buf,
142                                "zapped_list",_("List all forgotten rooms"));
143         else
144                 print_menu_box(_("Advanced room commands"),"adminitems", 4,
145                                "display_private", _("Go to a 'hidden' room"),
146                                "display_entroom", _("Create a new room"),
147                                "display_zap",buf,
148                                "zapped_list",_("List all forgotten rooms"));
149
150         wprintf("</td></tr></table></div>");
151         wDumpContent(2);
152 }
153
154
155 /**
156  * \brief System administration menu
157  */
158 void display_aide_menu(void)
159 {
160         output_headers(1, 1, 2, 0, 0, 0);
161
162         wprintf("<div id=\"banner\">\n");
163         wprintf("<h1>");
164         wprintf(_("System Administration Menu"));
165         wprintf("</h1>");
166         wprintf("</div>\n");
167
168         wprintf("<div id=\"content\" class=\"service\">");
169
170         wprintf("<div class=\"fix_scrollbar_bug\">"
171                 "<table> "
172                 "<tr valign=top><td width=50%% valign=\"top\">");
173
174         print_menu_box(_("Global Configuration"), "adminitems", 4,
175                        "display_siteconfig", _("Edit site-wide configuration"), 
176                        "display_inetconf",_("Domain names and Internet mail configuration"),
177                        "display_netconf", _("Configure replication with other Citadel servers"), 
178                        "display_smtpqueue", _("View the outbound SMTP queue"));
179         
180         wprintf("</td><td width=50%% valign=\"top\">");
181
182         print_menu_box(_("User account management"), "adminitems", 2, 
183                        "select_user_to_edit", _("Add, change, delete user accounts"),
184                        "validate", _("Validate new users"));
185
186         wprintf("</td></tr><tr><td width=50%% valign=\"top\">");
187
188
189         print_menu_box(_("Shutdown Citadel"), "adminitems", 3, 
190                        "server_shutdown?when=now", _("Restart Now"),
191                        "server_shutdown?when=page", _("Restart after paging users"),
192                        "server_shutdown?when=idle", _("Restart when all users are idle"));
193
194         wprintf("</td><td width=50%% valign=\"top\">");
195
196         print_menu_box(_("Rooms and Floors"), "adminitems", 1, 
197                        "display_floorconfig", _("Add, change, or delete floors"));
198
199         wprintf("</td></tr></table></div>");
200         wDumpContent(2);
201 }
202
203
204
205 /**
206  * \brief Display the screen to enter a generic server command
207  */
208 void display_generic(void)
209 {
210         output_headers(1, 1, 2, 0, 0, 0);
211         wprintf("<div id=\"banner\">\n");
212         wprintf("<h1>");
213         wprintf(_("Enter a server command"));
214         wprintf("</h1>");
215         wprintf("</div>\n");
216
217         wprintf("<div id=\"content\" class=\"service\">\n");
218
219         wprintf("<div class=\"fix_scrollbar_bug\">"
220                 "<table class=\"mainmenu_background\"><tr><td>\n");
221
222         wprintf("<center>");
223         wprintf(_("This screen allows you to enter Citadel server commands which are "
224                 "not supported by WebCit.  If you do not know what that means, "
225                 "then this screen will not be of much use to you."));
226         wprintf("<br />\n");
227
228         wprintf("<form method=\"post\" action=\"do_generic\">\n");
229         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
230
231         wprintf(_("Enter command:"));
232         wprintf("<br /><input type=\"text\" name=\"g_cmd\" size=80 maxlength=\"250\"><br />\n");
233
234         wprintf(_("Command input (if requesting SEND_LISTING transfer mode):"));
235         wprintf("<br /><textarea name=\"g_input\" rows=10 cols=80 width=80></textarea><br />\n");
236
237         wprintf("<font size=-2>");
238         wprintf(_("Detected host header is %s://%s"), (is_https ? "https" : "http"), WC->http_host);
239         wprintf("</font>\n");
240         wprintf("<input type=\"submit\" name=\"sc_button\" value=\"%s\">", _("Send command"));
241         wprintf("&nbsp;");
242         wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\"><br />\n", _("Cancel"));
243
244         wprintf("</form></center>\n");
245         wprintf("</td></tr></table></div>\n");
246         wDumpContent(1);
247 }
248
249 /**
250  * \brief Interactive window to perform generic Citadel server commands.
251  */
252 void do_generic(void)
253 {
254         char buf[SIZ];
255         char gcontent[SIZ];
256         char *junk;
257         size_t len;
258
259         if (!havebstr("sc_button")) {
260                 display_main_menu();
261                 return;
262         }
263
264         output_headers(1, 1, 0, 0, 0, 0);
265
266         serv_printf("%s", bstr("g_cmd"));
267         serv_getln(buf, sizeof buf);
268
269         svput("BOXTITLE", WCS_STRING, _("Server command results"));
270         do_template("beginbox");
271
272         wprintf("<table border=0><tr><td>Command:</td><td><tt>");
273         escputs(bstr("g_cmd"));
274         wprintf("</tt></td></tr><tr><td>Result:</td><td><tt>");
275         escputs(buf);
276         wprintf("</tt></td></tr></table><br />\n");
277
278         if (buf[0] == '8') {
279                 serv_printf("\n\n000");
280         }
281         if ((buf[0] == '1') || (buf[0] == '8')) {
282                 while (serv_getln(gcontent, sizeof gcontent), strcmp(gcontent, "000")) {
283                         escputs(gcontent);
284                         wprintf("<br />\n");
285                 }
286                 wprintf("000");
287         }
288         if (buf[0] == '4') {
289                 text_to_server(bstr("g_input"));
290                 serv_puts("000");
291         }
292         if (buf[0] == '6') {
293                 len = atol(&buf[4]);
294                 junk = malloc(len);
295                 serv_read(junk, len);
296                 free(junk);
297         }
298         if (buf[0] == '7') {
299                 len = atol(&buf[4]);
300                 junk = malloc(len);
301                 memset(junk, 0, len);
302                 serv_write(junk, len);
303                 free(junk);
304         }
305         wprintf("<hr />");
306         wprintf("<a href=\"display_generic\">Enter another command</a><br />\n");
307         wprintf("<a href=\"display_advanced\">Return to menu</a>\n");
308         do_template("endbox");
309         wDumpContent(1);
310 }
311
312
313 /**
314  * \brief Display the menubar.  
315  * \param as_single_page Set to display HTML headers and footers -- otherwise it's assumed
316  * that the menubar is being embedded in another page.
317  */
318 void display_menubar(int as_single_page) {
319
320         if (as_single_page) {
321                 output_headers(0, 0, 0, 0, 0, 0);
322                 wprintf("<html>\n"
323                         "<head>\n"
324                         "<title>MenuBar</title>\n"
325                         "<style type=\"text/css\">\n"
326                         "body   { text-decoration: none; }\n"
327                         "</style>\n"
328                         "</head>\n");
329                 do_template("background");
330         }
331
332         do_template("menubar");
333
334         if (as_single_page) {
335                 wDumpContent(2);
336         }
337
338
339 }
340
341
342 /**
343  * \brief Display the wait / input dialog while restarting the server.
344  */
345 void display_shutdown(void)
346 {
347         char buf[SIZ];
348         char *when;
349         
350         when=bstr("when");
351         if (!strcmp(when, "now")){
352                 serv_printf("DOWN 1");
353                 serv_getln(buf, sizeof buf);
354                 if (atol(buf) == 500)
355                 { /* upsie. maybe the server is not running as daemon? */
356                         wprintf("<html><head></head><body>Attention: %s</body></html>", &buf[4]);
357
358                 }
359                 else {
360                         wprintf("<html>\n"
361                                 "<head>\n"
362                                 "<meta http-equiv=\"refresh\" content=\"15; URL=knrooms\"/>\n"
363                                 "</head>\n"
364                                 "<body bgcolor=\"#FFFFFF\">\n"
365                                 "<img src=\"static/throbber.gif\" /> <font color=\"#AAAAAA\">%s </font>"
366                                 "</body>\n</html>\n",
367                                 _("Please wait while the Citadel server is restarted... ")
368                                 );
369                 }
370                 wDumpContent(0);
371                 lingering_close(WC->http_sock);
372                 sleeeeeeeeeep(10);
373                 serv_printf("NOOP");
374                 serv_printf("NOOP");
375         }
376         else if (!strcmp(when, "page")) {
377                 char *message;
378                
379                 message = bstr("message");
380                 if ((message == NULL) || (IsEmptyStr(message)))
381                 {
382                         output_headers(1, 1, 1, 0, 0, 0);
383                         svput("BOXTITLE", WCS_STRING, _("Message to your Users:"));
384                         do_template("beginbox");
385                         wprintf("<form action=\"server_shutdown\">\n"
386                                 "<input type=\"hidden\" name=\"when\" value=\"page\">\n"
387                                 "<input type=\"text\" name=\"message\" value=\"%s\">\n"
388                                 "<input type=\"submit\" value=\"go\">\n"
389                                 "</form>\n",
390                                 _("The citadel server has to be restarted. It 'll be back in a minute.")
391                                 );
392                         do_template("endbox");
393                         wDumpContent(1);
394
395                         
396                 }
397                 else
398                 {
399                         // TODO: page the users... wait longer...
400                         serv_printf("SEXP broadcast|%s", message);
401                         serv_getln(buf, sizeof buf); // should we care?
402                         wprintf("<html>\n"
403                                 "<head>\n"
404                                 "<meta http-equiv=\"refresh\" content=\"15; URL=knrooms\"/>\n"
405                                 "</head>\n"
406                                 "<body bgcolor=\"#FFFFFF\">\n"
407                                 "<img src=\"static/throbber.gif\" /> <font color=\"#AAAAAA\">%s </font>"
408                                 "</body>\n</html>\n",
409                                 _("Please wait while your users are being paged, the citadel server will be restarted after that... "));
410                         
411                 }
412         }
413         else if (!strcmp(when, "idle")) {
414                 serv_printf("SCDN 3");
415                 serv_getln(buf, sizeof buf);
416                 if (atol(buf) == 500)
417                 { /* upsie. maybe the server is not running as daemon? */
418                         wprintf("<html><head></head><body>Attention: %s</body></html>", &buf[4]);
419
420                 }
421         }
422 }
423
424
425 /*@}*/