6d4d1faf8d2614605fa93a04d8c476ef5874135d
[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%%>"
22                 "<tr><td colspan=\"2\">\n");
23
24         svprintf("BOXTITLE", WCS_STRING, _("Basic commands"));
25         do_template("beginbox");
26
27         wprintf("\n"
28                 "<table border=0 cellspacing=1 cellpadding=1 width=99%%>"
29                 "<tr>"
30                 "<td>");        /**< start of first column */
31
32         wprintf("<ul class=\"adminitems\">");
33
34         wprintf("<li><a href=\"knrooms\">");
35         wprintf(_("List known rooms"));
36         wprintf("</a><span>");
37         wprintf(_("Where can I go from here?"));
38         wprintf("</span></li>\n");
39
40         wprintf("<li><a href=\"gotonext\">");
41         wprintf(_("Goto next room"));
42         wprintf("</a><span>");
43         wprintf(_("...with <em>unread</em> messages"));
44         wprintf("</span></li>\n");
45
46         wprintf("<li><a href=\"skip\">");
47         wprintf(_("Skip to next room"));
48         wprintf("</a><span>");
49         wprintf(_("(come back here later)"));
50         wprintf("</span></li>\n");
51
52         if ((!IsEmptyStr(WC->ugname)) && (strcasecmp(WC->ugname, WC->wc_roomname))) {
53                 wprintf("<li><a href=\"ungoto\">");
54                 wprintf(_("Ungoto"));
55                 wprintf("</a><span>");
56                 wprintf(_("(oops! Back to %s)"), WC->ugname);
57                 wprintf("</span></li>\n");
58         }
59
60         wprintf("</ul>\n");
61
62         wprintf("</td><td>\n"); /* start of second column */
63
64         wprintf("<ul class=\"adminitems\">");
65
66         wprintf("<li><a href=\"readnew\">");
67         wprintf(_("Read new messages"));
68         wprintf("</a><span>");
69         wprintf(_("...in this room"));
70         wprintf("</span></li>\n");
71
72         wprintf("<li><a href=\"readfwd\">");
73         wprintf(_("Read all messages"));
74         wprintf("</a><span>");
75         wprintf(_("...old <EM>and</EM> new"));
76         wprintf("</span></li>\n");
77
78         wprintf("<li><a href=\"display_enter\">");
79         wprintf(_("Enter a message"));
80         wprintf("</a><span>");
81         wprintf(_("(post in this room)"));
82         wprintf("</span></li>\n");
83
84         if (WC->room_flags & QR_VISDIR) {
85                 wprintf("<li><a href=\"display_room_directory\">");
86                 wprintf(_("File library"));
87                 wprintf("</a><span>");
88                 wprintf(_("(List files available for download)"));
89                 wprintf("</span></li>\n");
90         }
91
92         wprintf("</ul>\n");
93
94         wprintf("</td><td>");   /* start of third column */
95
96         wprintf("<ul class=\"adminitems\">");
97
98         wprintf("<li><a href=\"summary\">");
99         wprintf(_("Summary page"));
100         wprintf("</a><span>");
101         wprintf(_("Summary of my account"));
102         wprintf("</span></li>\n");
103
104         wprintf("<li><a href=\"userlist\">\n");
105         wprintf(_("User list"));
106         wprintf("</a><span>");
107         wprintf(_("(all registered users)"));
108         wprintf("</span></li>\n");
109
110         wprintf("<li><a href=\"termquit\" TARGET=\"_top\">");
111         wprintf(_("Log off"));
112         wprintf("</a><span>");
113         wprintf(_("Bye!"));
114         wprintf("</span></li>\n");
115
116         wprintf("</ul>\n");
117
118         wprintf("</td></tr></table>\n");
119         do_template("endbox");
120
121         wprintf("</td></tr>"
122                 "<tr valign=top><td width=50%%>");
123
124         print_menu_box(_("Your info"), "adminitems", 6,
125                        "display_preferences", _("Change your preferences and settings"),
126                        "display_reg", _("Update your contact information"),
127                        "display_changepw", _("Change your password"),
128                        "display_editbio", _("Enter your 'bio'"),
129                        "display_editpic", _("Edit your online photo"), 
130                        "display_sieve", _("View/edit server-side mail filters"));
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)) 
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\" class=\"service\">\n");
163         wprintf("<h1>");
164         wprintf(_("System Administration Menu"));
165         wprintf("</h1>");
166         wprintf("</div>");
167
168         wprintf("<div id=\"content\">");
169
170         wprintf("<div class=\"fix_scrollbar_bug\">"
171                 "<table border=0 width=99%%> "
172                 "<tr valign=top><td width=50%% rowspan=2>");
173
174
175         print_menu_box(_("Global Configuration"), "adminitems", 4,
176                        "display_siteconfig", _("Edit site-wide configuration"), 
177                        "display_inetconf",_("Domain names and Internet mail configuration"),
178                        "display_netconf", _("Configure replication with other Citadel servers"), 
179                        "display_smtpqueue", _("View the outbound SMTP queue"));
180         
181         print_menu_box(_("Shutdown Citadel"), "adminitems", 3, 
182                        "server_shutdown?when=now", _("Restart Now"),
183                        "server_shutdown?when=page", _("Restart after paging users"),
184                        "server_shutdown?when=idle", _("Restart when all users are idle"));
185
186         wprintf("</td><td width=50%%>");
187
188         print_menu_box(_("User account management"), "adminitems", 2, 
189                        "select_user_to_edit", _("Add, change, delete user accounts"),
190                        "validate", _("Validate new users"));
191
192         wprintf("</td></tr><tr><td width=50%%>");
193
194         print_menu_box(_("Rooms and Floors"), "adminitems", 1, 
195                        "display_floorconfig", _("Add, change, or delete floors"));
196
197         wprintf("</td></tr></table></div>");
198         wDumpContent(2);
199 }
200
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                 "<table class=\"mainmenu_banner\"><tr><td>"
213                 "<span class=\"titlebar\">");
214         wprintf(_("Enter a server command"));
215         wprintf("</span></td></tr></table>\n"
216                 "</div>\n<div id=\"content\">\n"
217         );
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 (IsEmptyStr(bstr("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         svprintf("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 /*@}*/