Advanced screen : removed a HTML table
[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 class=\"advanced\">"
22                 "<tr><td colspan=\"2\">\n");
23
24         svprintf("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", 6,
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
129         wprintf("</td><td width=50%%>");
130
131         snprintf(buf, SIZ, _("Zap (forget) this room (%s)"), WC->wc_roomname);
132
133         if ((WC->axlevel >= 6) || (WC->is_room_aide)) 
134                 print_menu_box(_("Advanced room commands"),"adminitems", 5,
135                                "display_editroom", _("Edit or delete this room"),
136                                "display_private", _("Go to a 'hidden' room"),
137                                "display_entroom", _("Create a new room"),
138                                "display_zap",buf,
139                                "zapped_list",_("List all forgotten rooms"));
140         else
141                 print_menu_box(_("Advanced room commands"),"adminitems", 4,
142                                "display_private", _("Go to a 'hidden' room"),
143                                "display_entroom", _("Create a new room"),
144                                "display_zap",buf,
145                                "zapped_list",_("List all forgotten rooms"));
146
147         wprintf("</td></tr></table></div>");
148         wDumpContent(2);
149 }
150
151
152 /**
153  * \brief System administration menu
154  */
155 void display_aide_menu(void)
156 {
157         output_headers(1, 1, 2, 0, 0, 0);
158
159         wprintf("<div id=\"banner\">\n");
160         wprintf("<h1>");
161         wprintf(_("System Administration Menu"));
162         wprintf("</h1>");
163         wprintf("</div>\n");
164
165         wprintf("<div id=\"content\" class=\"service\">");
166
167         wprintf("<div class=\"fix_scrollbar_bug\">"
168                 "<table> "
169                 "<tr valign=top><td width=50%% valign=\"top\">");
170
171         print_menu_box(_("Global Configuration"), "adminitems", 4,
172                        "display_siteconfig", _("Edit site-wide configuration"), 
173                        "display_inetconf",_("Domain names and Internet mail configuration"),
174                        "display_netconf", _("Configure replication with other Citadel servers"), 
175                        "display_smtpqueue", _("View the outbound SMTP queue"));
176         
177         wprintf("</td><td width=50%% valign=\"top\">");
178
179         print_menu_box(_("User account management"), "adminitems", 2, 
180                        "select_user_to_edit", _("Add, change, delete user accounts"),
181                        "validate", _("Validate new users"));
182
183         wprintf("</td></tr><tr><td width=50%% valign=\"top\">");
184
185
186         print_menu_box(_("Shutdown Citadel"), "adminitems", 3, 
187                        "server_shutdown?when=now", _("Restart Now"),
188                        "server_shutdown?when=page", _("Restart after paging users"),
189                        "server_shutdown?when=idle", _("Restart when all users are idle"));
190
191         wprintf("</td><td width=50%% valign=\"top\">");
192
193         print_menu_box(_("Rooms and Floors"), "adminitems", 1, 
194                        "display_floorconfig", _("Add, change, or delete floors"));
195
196         wprintf("</td></tr></table></div>");
197         wDumpContent(2);
198 }
199
200
201
202
203
204 /**
205  * \brief Display the screen to enter a generic server command
206  */
207 void display_generic(void)
208 {
209         output_headers(1, 1, 2, 0, 0, 0);
210         wprintf("<div id=\"banner\">\n");
211         wprintf("<h1>");
212         wprintf(_("Enter a server command"));
213         wprintf("</h1>");
214         wprintf("</div>\n");
215
216         wprintf("<div id=\"content\" class=\"service\">\n");
217
218         wprintf("<div class=\"fix_scrollbar_bug\">"
219                 "<table class=\"mainmenu_background\"><tr><td>\n");
220
221         wprintf("<center>");
222         wprintf(_("This screen allows you to enter Citadel server commands which are "
223                 "not supported by WebCit.  If you do not know what that means, "
224                 "then this screen will not be of much use to you."));
225         wprintf("<br />\n");
226
227         wprintf("<form method=\"post\" action=\"do_generic\">\n");
228         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
229
230         wprintf(_("Enter command:"));
231         wprintf("<br /><input type=\"text\" name=\"g_cmd\" size=80 maxlength=\"250\"><br />\n");
232
233         wprintf(_("Command input (if requesting SEND_LISTING transfer mode):"));
234         wprintf("<br /><textarea name=\"g_input\" rows=10 cols=80 width=80></textarea><br />\n");
235
236         wprintf("<font size=-2>");
237         wprintf(_("Detected host header is %s://%s"), (is_https ? "https" : "http"), WC->http_host);
238         wprintf("</font>\n");
239         wprintf("<input type=\"submit\" name=\"sc_button\" value=\"%s\">", _("Send command"));
240         wprintf("&nbsp;");
241         wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\"><br />\n", _("Cancel"));
242
243         wprintf("</form></center>\n");
244         wprintf("</td></tr></table></div>\n");
245         wDumpContent(1);
246 }
247
248 /**
249  * \brief Interactive window to perform generic Citadel server commands.
250  */
251 void do_generic(void)
252 {
253         char buf[SIZ];
254         char gcontent[SIZ];
255         char *junk;
256         size_t len;
257
258         if (IsEmptyStr(bstr("sc_button"))) {
259                 display_main_menu();
260                 return;
261         }
262
263         output_headers(1, 1, 0, 0, 0, 0);
264
265         serv_printf("%s", bstr("g_cmd"));
266         serv_getln(buf, sizeof buf);
267
268         svprintf("BOXTITLE", WCS_STRING, _("Server command results"));
269         do_template("beginbox");
270
271         wprintf("<table border=0><tr><td>Command:</td><td><tt>");
272         escputs(bstr("g_cmd"));
273         wprintf("</tt></td></tr><tr><td>Result:</td><td><tt>");
274         escputs(buf);
275         wprintf("</tt></td></tr></table><br />\n");
276
277         if (buf[0] == '8') {
278                 serv_printf("\n\n000");
279         }
280         if ((buf[0] == '1') || (buf[0] == '8')) {
281                 while (serv_getln(gcontent, sizeof gcontent), strcmp(gcontent, "000")) {
282                         escputs(gcontent);
283                         wprintf("<br />\n");
284                 }
285                 wprintf("000");
286         }
287         if (buf[0] == '4') {
288                 text_to_server(bstr("g_input"));
289                 serv_puts("000");
290         }
291         if (buf[0] == '6') {
292                 len = atol(&buf[4]);
293                 junk = malloc(len);
294                 serv_read(junk, len);
295                 free(junk);
296         }
297         if (buf[0] == '7') {
298                 len = atol(&buf[4]);
299                 junk = malloc(len);
300                 memset(junk, 0, len);
301                 serv_write(junk, len);
302                 free(junk);
303         }
304         wprintf("<hr />");
305         wprintf("<a href=\"display_generic\">Enter another command</a><br />\n");
306         wprintf("<a href=\"display_advanced\">Return to menu</a>\n");
307         do_template("endbox");
308         wDumpContent(1);
309 }
310
311
312 /**
313  * \brief Display the menubar.  
314  * \param as_single_page Set to display HTML headers and footers -- otherwise it's assumed
315  * that the menubar is being embedded in another page.
316  */
317 void display_menubar(int as_single_page) {
318
319         if (as_single_page) {
320                 output_headers(0, 0, 0, 0, 0, 0);
321                 wprintf("<html>\n"
322                         "<head>\n"
323                         "<title>MenuBar</title>\n"
324                         "<style type=\"text/css\">\n"
325                         "body   { text-decoration: none; }\n"
326                         "</style>\n"
327                         "</head>\n");
328                 do_template("background");
329         }
330
331         do_template("menubar");
332
333         if (as_single_page) {
334                 wDumpContent(2);
335         }
336
337
338 }
339
340
341 /*@}*/