* Re-added tiny_mce, this time with the language packs
[citadel.git] / webcit / mainmenu.c
blob5233204e15f740a03af1078766a321ced9c25537
1 /*
2 * $Id$
3 */
5 #include "webcit.h"
7 /*
8 * The Main Menu
9 */
10 void display_main_menu(void)
12 begin_burst();
13 output_headers(1, 0, 0, 0, 1, 0);
14 DoTemplate(HKEY("display_main_menu"), NULL, &NoCtx);
15 end_burst();
18 char buf[SIZ];
19 output_headers(1, 1, 1, 0, 0, 0);
21 wprintf("<div class=\"fix_scrollbar_bug\">"
22 "<table width=\"100%%\" cellspacing=\"10\" cellpadding=\"0\">"
23 "<tr><td colspan=\"2\" class=\"advanced\">\n");
25 svput("BOXTITLE", WCS_STRING, _("Basic commands"));
26 do_template("beginbox", NULL);
28 / * start of first column * /
29 wprintf("<ul class=\"adminitems col1\">");
31 wprintf("<li><a href=\"knrooms\">");
32 wprintf(_("List known rooms"));
33 wprintf("</a><span>");
34 wprintf(_("Where can I go from here?"));
35 wprintf("</span></li>\n");
37 wprintf("<li><a href=\"gotonext\">");
38 wprintf(_("Goto next room"));
39 wprintf("</a><span>");
40 wprintf(_("...with <em>unread</em> messages"));
41 wprintf("</span></li>\n");
43 wprintf("<li><a href=\"skip\">");
44 wprintf(_("Skip to next room"));
45 wprintf("</a><span>");
46 wprintf(_("(come back here later)"));
47 wprintf("</span></li>\n");
49 if ((!IsEmptyStr(WC->ugname)) && (strcasecmp(WC->ugname, WC->wc_roomname))) {
50 wprintf("<li><a href=\"ungoto\">");
51 wprintf(_("Ungoto"));
52 wprintf("</a><span>");
53 wprintf(_("(oops! Back to %s)"), WC->ugname);
54 wprintf("</span></li>\n");
57 wprintf("</ul>\n");
59 / * start of second column * /
61 wprintf("<ul class=\"adminitems col2\">");
63 wprintf("<li><a href=\"readnew\">");
64 wprintf(_("Read new messages"));
65 wprintf("</a><span>");
66 wprintf(_("...in this room"));
67 wprintf("</span></li>\n");
69 wprintf("<li><a href=\"readfwd\">");
70 wprintf(_("Read all messages"));
71 wprintf("</a><span>");
72 wprintf(_("...old <EM>and</EM> new"));
73 wprintf("</span></li>\n");
75 wprintf("<li><a href=\"display_enter\">");
76 wprintf(_("Enter a message"));
77 wprintf("</a><span>");
78 wprintf(_("(post in this room)"));
79 wprintf("</span></li>\n");
81 if (WC->room_flags & QR_VISDIR) {
82 wprintf("<li><a href=\"display_room_directory\">");
83 wprintf(_("File library"));
84 wprintf("</a><span>");
85 wprintf(_("(List files available for download)"));
86 wprintf("</span></li>\n");
89 wprintf("</ul>\n");
91 / * start of third column * /
93 wprintf("<ul class=\"adminitems lastcol\">");
95 wprintf("<li><a href=\"summary\">");
96 wprintf(_("Summary page"));
97 wprintf("</a><span>");
98 wprintf(_("Summary of my account"));
99 wprintf("</span></li>\n");
101 wprintf("<li><a href=\"userlist\">\n");
102 wprintf(_("User list"));
103 wprintf("</a><span>");
104 wprintf(_("(all registered users)"));
105 wprintf("</span></li>\n");
107 wprintf("<li><a href=\"termquit\" TARGET=\"_top\">");
108 wprintf(_("Log off"));
109 wprintf("</a><span>");
110 wprintf(_("Bye!"));
111 wprintf("</span></li>\n");
113 wprintf("</ul>\n");
115 wprintf("&nbsp;");
117 do_template("endbox", NULL);
119 wprintf("</td></tr>"
120 "<tr valign=top><td width=50%%>");
122 print_menu_box(_("Your info"), "adminitems", 8,
123 "display_preferences", _("Change your preferences and settings"),
124 "display_reg", _("Update your contact information"),
125 "display_changepw", _("Change your password"),
126 "display_editbio", _("Enter your 'bio'"),
127 "display_editpic", _("Edit your online photo"),
128 "display_sieve", _("View/edit server-side mail filters"),
129 "display_pushemail", _("Edit your push email settings"),
130 "display_openids", _("Manage your OpenIDs")
133 wprintf("</td><td width=50%%>");
135 snprintf(buf, SIZ, _("Zap (forget) this room (%s)"), WC->wc_roomname);
137 if ( (WC->axlevel >= 6) || (WC->is_room_aide) || (WC->is_mailbox) )
138 print_menu_box(_("Advanced room commands"),"adminitems", 5,
139 "display_editroom", _("Edit or delete this room"),
140 "display_private", _("Go to a 'hidden' room"),
141 "display_entroom", _("Create a new room"),
142 "display_zap",buf,
143 "zapped_list",_("List all forgotten rooms"));
144 else
145 print_menu_box(_("Advanced room commands"),"adminitems", 4,
146 "display_private", _("Go to a 'hidden' room"),
147 "display_entroom", _("Create a new room"),
148 "display_zap",buf,
149 "zapped_list",_("List all forgotten rooms"));
151 wprintf("</td></tr></table></div>");
152 wDumpContent(2);
158 * System administration menu
160 void display_aide_menu(void)
162 begin_burst();
163 output_headers(1, 0, 0, 0, 1, 0);
164 DoTemplate(HKEY("display_aide_menu"), NULL, &NoCtx);
165 end_burst();
167 output_headers(1, 1, 2, 0, 0, 0);
169 wprintf("<div id=\"banner\">\n");
170 wprintf("<h1>");
171 wprintf(_("System Administration Menu"));
172 wprintf("</h1>");
173 wprintf("</div>\n");
175 wprintf("<div id=\"content\" class=\"service\">");
177 wprintf("<div class=\"fix_scrollbar_bug\">"
178 "<table> "
179 "<tr valign=top><td width=50%% valign=\"top\">");
181 print_menu_box(_("Global Configuration"), "adminitems", 4,
182 "display_siteconfig", _("Edit site-wide configuration"),
183 "display_inetconf",_("Domain names and Internet mail configuration"),
184 "display_netconf", _("Configure replication with other Citadel servers"),
185 "display_smtpqueue", _("View the outbound SMTP queue"));
187 wprintf("</td><td width=50%% valign=\"top\">");
189 print_menu_box(_("User account management"), "adminitems", 2,
190 "select_user_to_edit", _("Add, change, delete user accounts"),
191 "validate", _("Validate new users"));
193 wprintf("</td></tr><tr><td width=50%% valign=\"top\">");
196 print_menu_box(_("Shutdown Citadel"), "adminitems", 3,
197 "server_shutdown?when=now", _("Restart Now"),
198 "server_shutdown?when=page", _("Restart after paging users"),
199 "server_shutdown?when=idle", _("Restart when all users are idle"));
201 wprintf("</td><td width=50%% valign=\"top\">");
203 print_menu_box(_("Rooms and Floors"), "adminitems", 1,
204 "display_floorconfig", _("Add, change, or delete floors"));
206 wprintf("</td></tr></table></div>");
207 wDumpContent(2);
214 * Display the screen to enter a generic server command
216 void display_generic(void)
218 output_headers(1, 1, 2, 0, 0, 0);
219 wprintf("<div id=\"banner\">\n");
220 wprintf("<h1>");
221 wprintf(_("Enter a server command"));
222 wprintf("</h1>");
223 wprintf("</div>\n");
225 wprintf("<div id=\"content\" class=\"service\">\n");
227 wprintf("<div class=\"fix_scrollbar_bug\">"
228 "<table class=\"mainmenu_background\"><tr><td>\n");
230 wprintf("<center>");
231 wprintf(_("This screen allows you to enter Citadel server commands which are "
232 "not supported by WebCit. If you do not know what that means, "
233 "then this screen will not be of much use to you."));
234 wprintf("<br />\n");
236 wprintf("<form method=\"post\" action=\"do_generic\">\n");
237 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
239 wprintf(_("Enter command:"));
240 wprintf("<br /><input type=\"text\" name=\"g_cmd\" size=80 maxlength=\"250\"><br />\n");
242 wprintf(_("Command input (if requesting SEND_LISTING transfer mode):"));
243 wprintf("<br /><textarea name=\"g_input\" rows=10 cols=80 width=80></textarea><br />\n");
245 wprintf("<font size=-2>");
246 wprintf(_("Detected host header is %s://%s"), (is_https ? "https" : "http"), ChrPtr(WC->http_host));
247 wprintf("</font>\n");
248 wprintf("<input type=\"submit\" name=\"sc_button\" value=\"%s\">", _("Send command"));
249 wprintf("&nbsp;");
250 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\"><br />\n", _("Cancel"));
252 wprintf("</form></center>\n");
253 wprintf("</td></tr></table></div>\n");
254 wDumpContent(1);
258 * Interactive window to perform generic Citadel server commands.
260 void do_generic(void)
262 char buf[SIZ];
263 char gcontent[SIZ];
264 char *junk;
265 size_t len;
267 if (!havebstr("sc_button")) {
268 display_main_menu();
269 return;
272 output_headers(1, 1, 0, 0, 0, 0);
274 serv_printf("%s", bstr("g_cmd"));
275 serv_getln(buf, sizeof buf);
277 svput("BOXTITLE", WCS_STRING, _("Server command results"));
278 do_template("beginboxx", NULL);
280 wprintf("<table border=0><tr><td>Command:</td><td><tt>");
281 escputs(bstr("g_cmd"));
282 wprintf("</tt></td></tr><tr><td>Result:</td><td><tt>");
283 escputs(buf);
284 wprintf("</tt></td></tr></table><br />\n");
286 if (buf[0] == '8') {
287 serv_printf("\n\n000");
289 if ((buf[0] == '1') || (buf[0] == '8')) {
290 while (serv_getln(gcontent, sizeof gcontent), strcmp(gcontent, "000")) {
291 escputs(gcontent);
292 wprintf("<br />\n");
294 wprintf("000");
296 if (buf[0] == '4') {
297 text_to_server(bstr("g_input"));
298 serv_puts("000");
300 if (buf[0] == '6') {
301 len = atol(&buf[4]);
302 junk = malloc(len);
303 serv_read(junk, len);
304 free(junk);
306 if (buf[0] == '7') {
307 len = atol(&buf[4]);
308 junk = malloc(len);
309 memset(junk, 0, len);
310 serv_write(junk, len);
311 free(junk);
313 wprintf("<hr />");
314 wprintf("<a href=\"display_generic\">Enter another command</a><br />\n");
315 wprintf("<a href=\"display_advanced\">Return to menu</a>\n");
316 do_template("endbox", NULL);
317 wDumpContent(1);
322 * Display the menubar.
324 * Set 'as_single_page' to display HTML headers and footers -- otherwise it's assumed
325 * that the menubar is being embedded in another page.
327 void display_menubar(int as_single_page) {
329 if (as_single_page) {
330 output_headers(0, 0, 0, 0, 0, 0);
331 wprintf("<html>\n"
332 "<head>\n"
333 "<title>MenuBar</title>\n"
334 "<style type=\"text/css\">\n"
335 "body { text-decoration: none; }\n"
336 "</style>\n"
337 "</head>\n");
338 do_template("background", NULL);
341 do_template("menubar", NULL);
343 if (as_single_page) {
344 wDumpContent(2);
352 * Display the wait / input dialog while restarting the server.
354 void display_shutdown(void)
356 char buf[SIZ];
357 char *when;
359 when=bstr("when");
360 if (strcmp(when, "now") == 0){
361 serv_printf("DOWN 1");
362 serv_getln(buf, sizeof buf);
363 if (atol(buf) == 500)
364 { /* upsie. maybe the server is not running as daemon? */
366 safestrncpy(WC->ImportantMessage,
367 &buf[4],
368 sizeof WC->ImportantMessage);
370 begin_burst();
371 output_headers(1, 0, 0, 0, 1, 0);
372 DoTemplate(HKEY("display_serverrestart"), NULL, &NoCtx);
373 end_burst();
374 lingering_close(WC->http_sock);
375 sleeeeeeeeeep(10);
376 serv_printf("NOOP");
377 serv_printf("NOOP");
379 else if (strcmp(when, "page") == 0) {
380 char *message;
382 message = bstr("message");
383 if ((message == NULL) || (IsEmptyStr(message)))
385 begin_burst();
386 output_headers(1, 0, 0, 0, 1, 0);
387 DoTemplate(HKEY("display_serverrestartpage"), NULL, &NoCtx);
388 end_burst();
390 else
392 serv_printf("SEXP broadcast|%s", message);
393 serv_getln(buf, sizeof buf); /* TODO: should we care? */
394 begin_burst();
395 output_headers(1, 0, 0, 0, 1, 0);
396 DoTemplate(HKEY("display_serverrestartpagedo"), NULL, &NoCtx);
397 end_burst();
400 else if (!strcmp(when, "idle")) {
401 serv_printf("SCDN 3");
402 serv_getln(buf, sizeof buf);
404 if (atol(buf) == 500)
405 { /* upsie. maybe the server is not running as daemon? */
406 safestrncpy(WC->ImportantMessage,
407 &buf[4],
408 sizeof WC->ImportantMessage);
410 begin_burst();
411 output_headers(1, 0, 0, 0, 1, 0);
412 DoTemplate(HKEY("display_aide_menu"), NULL, &NoCtx);
413 end_burst();
417 void _display_menubar(void) { display_menubar(0); }
419 void
420 InitModule_MAINMENU
421 (void)
423 WebcitAddUrlHandler(HKEY("display_aide_menu"), display_aide_menu, 0);
424 WebcitAddUrlHandler(HKEY("server_shutdown"), display_shutdown, 0);
425 WebcitAddUrlHandler(HKEY("display_main_menu"), display_main_menu, 0);
426 WebcitAddUrlHandler(HKEY("display_generic"), display_generic, 0);
427 WebcitAddUrlHandler(HKEY("do_generic"), do_generic, 0);
428 WebcitAddUrlHandler(HKEY("display_menubar"), _display_menubar, 0);