Removed some spurious debugging statements
[citadel.git] / webcit / iconbar.c
1 /*
2  * $Id$
3  *
4  * Displays and customizes the iconbar.
5  */
6
7 #include "webcit.h"
8
9
10 /** Values for ib_displayas */
11 #define IB_PICTEXT      0 /**< picture and text */
12 #define IB_PICONLY      1 /**< just a picture */
13 #define IB_TEXTONLY     2 /**< just text */
14
15
16 void do_iconbar(void);
17 void do_iconbar_roomlist(void);
18
19 /**
20  * \brief draw the icon bar?????
21  */
22 void do_selected_iconbar(void) {
23         if (WC->current_iconbar == current_iconbar_roomlist) {
24                 do_iconbar_roomlist();
25         }
26         else {
27                 do_iconbar();
28         }
29 }
30
31 void DontDeleteThis(void *Data){};
32
33 #define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a) - 1, b)
34
35 long IconbarIsENABLED(const char *key, size_t keylen, long defval)
36 {
37         void *Data;
38         if (GetHash(WC->IconBarSetttings, key, keylen,
39                     &Data))
40                 return (long) Data;
41         else 
42                 return defval;
43 }
44
45 static char nbuf[32];
46 inline const char *PrintInt(void *Prefstr)
47 {
48         snprintf(nbuf, sizeof(nbuf), "%ld", (long)Prefstr);
49         return nbuf;
50 }
51
52 void LoadIconSettings(void)
53 {
54         struct wcsession *WCC = WC;
55         StrBuf *iconbar = NULL;
56         StrBuf *buf = NewStrBuf();;
57         StrBuf *key = NewStrBuf();
58         long val;
59         int i, nTokens;
60
61         WCC->current_iconbar = current_iconbar_menu;
62         if (WCC->IconBarSetttings == NULL)
63                 WCC->IconBarSetttings = NewHash(1, NULL);
64         /**
65          * The initialized values of these variables also happen to
66          * specify the default values for users who haven't customized
67          * their iconbars.  These should probably be set in a master
68          * configuration somewhere.
69          */
70
71         if (get_preference("iconbar", &iconbar)) {
72                 nTokens = StrBufNum_tokens(iconbar, ',');
73                 for (i=0; i<nTokens; ++i) {
74                         StrBufExtract_token(buf, iconbar, i, ',');
75                         StrBufExtract_token(key, buf, 0, '=');
76                         val = StrBufExtract_long(buf, 1, '=');
77                         Put(WCC->IconBarSetttings, 
78                             ChrPtr(key), StrLength(key),
79                             (void*)val, DontDeleteThis);
80                 }
81         }
82         dbg_PrintHash(WCC->IconBarSetttings, PrintInt, NULL);
83
84         FreeStrBuf(&key);
85         FreeStrBuf(&buf);
86 }
87
88
89 /**
90  * \brief draw the icon bar???
91  */
92 void do_iconbar(void) {
93         int ib_displayas = IB_PICTEXT;  /**< pictures and text, pictures, text */
94
95         LoadIconSettings();
96         ib_displayas = IconbarIsEnabled("ib_displayas", IB_PICTEXT);
97
98 /** Site logo */
99         if (IconbarIsEnabled("ib_logo", 0)) {
100                 if (ib_displayas != IB_TEXTONLY) {
101                         wprintf("<div class=\"logo\"> <img "
102                                 "src=\"image&name=hello\" alt=\"&nbsp;\"> "
103                                 "</div>\n"
104                         );
105                 }
106                 wprintf("\n");
107         }
108
109 /** 'Powered by Citadel' logo */
110         if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
111                 "<div class=\"logo_citadel\"> "
112                 "<a href=\"http://www.citadel.org\" "
113                 "title=\"%s\"> "
114                 "<img "
115                 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
116                 "</div>\n",
117                 _("Find out more about Citadel"),
118                 _("CITADEL")
119         );
120
121         wprintf("<ul id=\"button\">\n");
122
123         wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_room_list()\">");
124         wprintf(_("switch to room list"));
125         wprintf("</a></li>");
126
127 /** Summary page icon */
128         if (IconbarIsEnabled("ib_summary", 1)) {
129                 wprintf("<li><a href=\"summary\" "
130                         "title=\"%s\" "
131                         ">", _("Your summary page")
132                 );
133                 if (ib_displayas != IB_TEXTONLY) {
134                         wprintf("<img alt=\"\" "
135                                 "src=\"static/summscreen_32x.gif\">");
136                 }
137                 if (ib_displayas != IB_PICONLY) {
138                         wprintf(_("Summary"));
139                 }
140                 wprintf("</a></li>\n");
141         }
142
143 /** Inbox icon */
144         if (IconbarIsEnabled("ib_inbox", 1)) {
145                 wprintf("<li>"
146                         "<a href=\"dotgoto?room=_MAIL_\" "
147                         "title=\"%s\" "
148                         ">",
149                         _("Go to your email inbox")
150                 );
151                 if (ib_displayas != IB_TEXTONLY) {
152                         wprintf("<img alt=\"\" "
153                                 "src=\"static/privatemess_32x.gif\">");
154                 }
155                 if (ib_displayas != IB_PICONLY) {
156                         wprintf(_("Mail"));
157                         if (WC->new_mail != WC->remember_new_mail) {
158 /*
159                                 if (WC->new_mail > 0) {
160                                         wprintf(" <b>(%d)</b>", WC->new_mail);
161                                 }
162 */
163                                 WC->remember_new_mail = WC->new_mail;
164                         }
165                 }
166                 wprintf("</a></li>\n");
167         }
168
169 /** Calendar icon */
170         if (IconbarIsEnabled("ib_calendar", 1)) {
171                 wprintf("<li>"
172                         "<a href=\"dotgoto?room=_CALENDAR_\" "
173                         "title=\"%s\" "
174                         ">",
175                         _("Go to your personal calendar")
176                 );
177                 if (ib_displayas != IB_TEXTONLY) {
178                         wprintf("<img alt=\"\" "
179                         "src=\"static/calarea_32x.gif\">");
180                 }
181                 if (ib_displayas != IB_PICONLY) {
182                         wprintf(_("Calendar"));
183                 }
184                 wprintf("</a></li>\n");
185         }
186
187 /** Contacts icon */
188         if (IconbarIsEnabled("ib_contacts", 1)) {
189                 wprintf("<li>"
190                         "<a href=\"dotgoto?room=_CONTACTS_\" "
191                         "title=\"%s\" "
192                         ">",
193                         _("Go to your personal address book")
194                 );
195                 if (ib_displayas != IB_TEXTONLY) {
196                         wprintf("<img alt=\"\" "
197                         "src=\"static/viewcontacts_32x.gif\">");
198                 }
199                 if (ib_displayas != IB_PICONLY) {
200                         wprintf(_("Contacts"));
201                 }
202                 wprintf("</a></li>\n");
203         }
204
205 /** Notes icon */
206         if (IconbarIsEnabled("ib_notes", 1)) {
207                 wprintf("<li>"
208                         "<a href=\"dotgoto?room=_NOTES_\" "
209                         "title=\"%s\" "
210                         ">",
211                         _("Go to your personal notes")
212                 );
213                 if (ib_displayas != IB_TEXTONLY) {
214                         wprintf("<img alt=\"\" "
215                         "src=\"static/storenotes_32x.gif\">");
216                 }
217                 if (ib_displayas != IB_PICONLY) {
218                         wprintf(_("Notes"));
219                 }
220                 wprintf("</a></li>\n");
221         }
222
223 /** Tasks icon */
224         if (IconbarIsEnabled("ib_tasks", 1))  {
225                 wprintf("<li>"
226                         "<a href=\"dotgoto?room=_TASKS_\" "
227                         "title=\"%s\" "
228                         ">",
229                         _("Go to your personal task list")
230                 );
231                 if (ib_displayas != IB_TEXTONLY) {
232                         wprintf("<img alt=\"\" "
233                         "src=\"static/taskmanag_32x.gif\">");
234                 }
235                 if (ib_displayas != IB_PICONLY) {
236                         wprintf(_("Tasks"));
237                 }
238                 wprintf("</a></li>\n");
239         }
240
241 /** Rooms icon */
242         if (IconbarIsEnabled("ib_rooms", 1)) {
243                 wprintf("<li>"
244                         "<a href=\"knrooms\" title=\"%s\" >",
245                         _("List all of your accessible rooms")
246                 );
247                 if (ib_displayas != IB_TEXTONLY) {
248                         wprintf("<img alt=\"\" "
249                         "src=\"static/chatrooms_32x.gif\">");
250                 }
251                 if (ib_displayas != IB_PICONLY) {
252                         wprintf(_("Rooms"));
253                 }
254                 wprintf("</a></li>\n");
255         }
256
257 /** Users icon */
258         if (IconbarIsEnabled("ib_users", 1)) {
259                 wprintf("<li>"
260                         "<a href=\"who\" title=\"%s\" "
261                         ">",
262                         _("See who is online right now")
263                 );
264                 if (ib_displayas != IB_TEXTONLY) {
265                         wprintf("<img alt=\"\" "
266                         "src=\"static/usermanag_32x.gif\">");
267                 }
268                 if (ib_displayas != IB_PICONLY) {
269                         wprintf(_("Who is online?"));
270                 }
271                  
272                 wprintf("</a>\n");
273
274                 if (IconbarIsEnabled("ib_users", 0)) {
275                         wprintf("<ul id=\"wholist\">");
276                         wprintf("</ul></li>\n");
277                 }
278         }
279
280 /** Chat icon */
281         if (IconbarIsEnabled("ib_chat", 1)) {
282                 wprintf("<li>"
283                         "<a href=\"#\" onClick=\"window.open('chat', "
284                         "'ctdl_chat_window', "
285                         "'toolbar=no,location=no,directories=no,copyhistory=no,"
286                         "status=no,scrollbars=yes,resizable=yes');\""
287                         ">"
288                 );
289                 if (ib_displayas != IB_TEXTONLY) {
290                         wprintf("<img alt=\"\" "
291                         "src=\"static/citadelchat_32x.gif\">");
292                 }
293                 if (ib_displayas != IB_PICONLY) {
294                         wprintf(_("Chat"));
295                 }
296                 wprintf("</a></li>\n");
297         }
298
299 /** Advanced Options icon */
300         if (IconbarIsEnabled("ib_advanced", 1)) {
301                 wprintf("<li>"
302                         "<a href=\"display_main_menu\" "
303                         "title=\"%s\" "
304                         ">",
305                         _("Advanced Options Menu: Advanced Room commands, Account Info, and Chat")
306                 );
307                 if (ib_displayas != IB_TEXTONLY) {
308                         wprintf("<img alt=\"\" "
309                         "src=\"static/advanpage2_32x.gif\">");
310                 }
311                 if (ib_displayas != IB_PICONLY) {
312                         wprintf(_("Advanced"));
313                 }
314                 wprintf("</a></li>\n");
315         }
316
317         if ((WC->axlevel >= 6) || (WC->is_room_aide)) {
318                 wprintf("<li>"
319                         "<a href=\"display_aide_menu\" "
320                         "title=\"%s\" "
321                         ">",
322                         _("Room and system administration functions")
323                 );
324                 if (ib_displayas != IB_TEXTONLY) {
325                         wprintf("<img alt=\"\" "
326                         "src=\"static/advanpage2_32x.gif\">");
327                 }
328                 if (ib_displayas != IB_PICONLY) {
329                         wprintf(_("Administration"));
330                 }
331                 wprintf("</a></li>\n");
332         }
333
334         wprintf("<li>"
335                 "<a href=\"termquit\" title=\"%s\" "
336                 "onClick=\"return confirm('%s');\">",
337                 _("Log off"),
338                 _("Log off now?")
339                 
340         );
341         if (ib_displayas != IB_TEXTONLY) {
342         wprintf("<img alt=\"\" "
343                 "src=\"static/logoff_32x.gif\">");
344         }
345         if (ib_displayas != IB_PICONLY) {
346                 wprintf(_("Log off"));
347         }
348         wprintf("</a></li>\n");
349
350         wprintf(
351                 "<li class=\"switch\">"
352                 "<a href=\"display_customize_iconbar\" "
353                 "title=\"%s\" "
354                 ">%s"
355                 "</a></li>\n",
356                 _("Customize this menu"),
357                 _("customize this menu")
358         );
359
360         wprintf("</ul>\n");
361
362         if (IconbarIsEnabled("ib_users", 0)) {
363                 wprintf(
364                         "<script type=\"text/javascript\"> "
365                         " new Ajax.PeriodicalUpdater('wholist', 'wholist_section', { method: 'get', frequency: 30 } );"
366                         "</script> \n"
367                         );
368         }
369 }
370
371
372 /**
373  * \brief roomtree view of the iconbar
374  * If the user has toggled the icon bar over to a room list, here's where
375  * we generate its innerHTML...
376  */
377 void do_iconbar_roomlist(void) {
378                                 
379         WC->current_iconbar = current_iconbar_roomlist;
380
381         /**
382          * The initialized values of these variables also happen to
383          * specify the default values for users who haven't customized
384          * their iconbars.  These should probably be set in a master
385          * configuration somewhere.
386          */
387         int ib_displayas;
388
389         LoadIconSettings();
390
391         ib_displayas = IconbarIsEnabled("ib_displayas", IB_PICTEXT);    /* pictures and text, pictures, text */
392
393 /** Site logo */
394         if (IconbarIsEnabled("ib_logo", 0)) {
395                 if (ib_displayas != IB_TEXTONLY) {
396                         wprintf("<div class=\"logo\"> <img "
397                                 "src=\"image&name=hello\" alt=\"&nbsp;\"> "
398                                 "</div>\n"
399                         );
400                 }
401         }
402
403 /** 'Powered by Citadel' logo */
404         if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
405                 "<div class=\"logo_citadel\"> "
406                 "<a href=\"http://www.citadel.org\" "
407                 "title=\"%s\"> "
408                 "<img "
409                 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
410                 "</div>\n",
411                 _("Find out more about Citadel"),
412                 _("CITADEL")
413         );
414
415         wprintf("<ul id=\"button\">\n");
416
417         wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_menu_buttons()\">");
418         wprintf(_("switch to menu"));
419         wprintf("</a></li>");
420
421         wprintf("<li>"
422                 "<a href=\"termquit\" title=\"%s\" "
423                 "onClick=\"return confirm('%s');\">",
424                 _("Log off"),
425                 _("Log off now?")
426                 
427         );
428         if (ib_displayas != IB_TEXTONLY) {
429         wprintf("<img alt=\"\" "
430                 "src=\"static/logoff_32x.gif\">");
431         }
432         if (ib_displayas != IB_PICONLY) {
433                 wprintf(_("Log off"));
434         }
435         wprintf("</a></li>\n");
436
437         wprintf("</ul>\n");
438
439         /** embed the room list */
440         list_all_rooms_by_floor("iconbar");
441
442         wprintf("</div>\n");
443 }
444
445
446 /**
447  * \brief display a customized version of the iconbar
448  */
449 void display_customize_iconbar(void) {
450         int i;
451         int bar = 0;
452         long val;
453
454         int ib_displayas;
455
456         LoadIconSettings();
457
458         output_headers(1, 1, 2, 0, 0, 0);
459         wprintf("<div id=\"banner\">");
460         wprintf("<h1>");
461         wprintf(_("Customize the icon bar"));
462         wprintf("</h1></div>\n");
463
464         wprintf("<div id=\"content\" class=\"service\">\n");
465
466         wprintf("<div class=\"fix_scrollbar_bug\">");
467
468         wprintf("<form method=\"post\" action=\"commit_iconbar\">\n");
469         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
470
471         wprintf("<table class=\"altern\" >\n");
472         wprintf("<tr><td></td><td colspan=\"2\"><b>");
473         wprintf(_("Display icons as:"));
474         wprintf("</b>");
475         ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT);
476         for (i=0; i<=2; ++i) {
477                 wprintf("<input type=\"radio\" name=\"ib_displayas\" value=\"%d\"", i);
478                 if (ib_displayas == i) wprintf(" CHECKED");
479                 wprintf(">");
480                 if (i == IB_PICTEXT)    wprintf(_("pictures and text"));
481                 if (i == IB_PICONLY)    wprintf(_("pictures only"));
482                 if (i == IB_TEXTONLY)   wprintf(_("text only"));
483                 wprintf("\n");
484         }
485         wprintf("<br />\n");
486
487         wprintf(_("Select the icons you would like to see displayed "
488                 "in the 'icon bar' menu on the left side of the "
489                 "screen."));
490         wprintf("</td></tr>\n");
491
492         bar = 1 - bar;
493         val = IconbarIsEnabled("ib_logo", 0);
494         wprintf("<tr class=\"%s\"><td>"
495                 "<input type=\"radio\" name=\"ib_logo\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
496                 "<input type=\"radio\" name=\"ib_logo\" value=\"no\" %s> %s <br />"
497                 "</td><td>"
498                 "<img src=\"image&name=hello\" width=\"48\" alt=\"&nbsp;\">"
499                 "</td><td>"
500                 "<b>%s</b><br />"
501                 "%s"
502                 "</td></tr>\n",
503                 (bar ? "even" : "odd"),
504                 (val ? "CHECKED" : ""),_("Yes"),
505                 (!val ? "CHECKED" : ""),_("No"),
506                 _("Site logo"),
507                 _("An icon describing this site")
508         );
509
510         bar = 1 - bar;
511         val = IconbarIsEnabled("ib_summary", 1);
512         wprintf("<tr class=\"%s\"><td>"
513                 "<input type=\"radio\" name=\"ib_summary\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
514                 "<input type=\"radio\" name=\"ib_summary\" value=\"no\" %s> %s <br />"
515                 "</td><td>"
516                 "<img src=\"static/summscreen_48x.gif\" alt=\"&nbsp;\">"
517                 "</td><td>"
518                 "<b>%s</b><br />"
519                 "%s"
520                 "</td></tr>\n",
521                 (bar ? "even" : "odd"),
522                 (val ? "CHECKED" : ""),_("Yes"),
523                 (!val ? "CHECKED" : ""),_("No"),
524                 _("Summary"),
525                 _("Your summary page")
526         );
527
528         bar = 1 - bar;
529         val = IconbarIsEnabled("ib_inbox", 1);
530         wprintf("<tr class=\"%s\"><td>"
531                 "<input type=\"radio\" name=\"ib_inbox\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
532                 "<input type=\"radio\" name=\"ib_inbox\" value=\"no\" %s> %s <br />"
533                 "</td><td>"
534                 "<img src=\"static/privatemess_48x.gif\" alt=\"&nbsp;\">"
535                 "</td><td>"
536                 "<b>%s</b><br />"
537                 "%s"
538                 "</td></tr>\n",
539                 (bar ? "even" : "odd"),
540                 (val ? "CHECKED" : ""),_("Yes"),
541                 (!val ? "CHECKED" : ""),_("No"),
542                 _("Mail (inbox)"),
543                 _("A shortcut to your email Inbox")
544         );
545
546         bar = 1 - bar;
547         val = IconbarIsEnabled("ib_contacts", 1);
548         wprintf("<tr class=\"%s\"><td>"
549                 "<input type=\"radio\" name=\"ib_contacts\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
550                 "<input type=\"radio\" name=\"ib_contacts\" value=\"no\" %s> %s <br />"
551                 "</td><td>"
552                 "<img src=\"static/viewcontacts_48x.gif\" alt=\"&nbsp;\">"
553                 "</td><td>"
554                 "<b>%s</b><br />"
555                 "%s"
556                 "</td></tr>\n",
557                 (bar ? "even" : "odd"),
558                 (val ? "CHECKED" : ""),_("Yes"),
559                 (!val ? "CHECKED" : ""),_("No"),
560                 _("Contacts"),
561                 _("Your personal address book")
562         );
563
564         bar = 1 - bar;
565         val = IconbarIsEnabled("ib_notes", 1);
566         wprintf("<tr class=\"%s\"><td>"
567                 "<input type=\"radio\" name=\"ib_notes\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
568                 "<input type=\"radio\" name=\"ib_notes\" value=\"no\" %s> %s <br />"
569                 "</td><td>"
570                 "<img src=\"static/storenotes_48x.gif\" alt=\"&nbsp;\">"
571                 "</td><td>"
572                 "<b>%s</b><br />"
573                 "%s"
574                 "</td></tr>\n",
575                 (bar ? "even" : "odd"),
576                 (val ? "CHECKED" : ""),_("Yes"),
577                 (!val ? "CHECKED" : ""),_("No"),
578                 _("Notes"),
579                 _("Your personal notes")
580         );
581
582         bar = 1 - bar;
583         val = IconbarIsEnabled("ib_calendar", 1);
584         wprintf("<tr class=\"%s\"><td>"
585                 "<input type=\"radio\" name=\"ib_calendar\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
586                 "<input type=\"radio\" name=\"ib_calendar\" value=\"no\" %s> %s <br />"
587                 "</td><td>"
588                 "<img src=\"static/calarea_48x.gif\" alt=\"&nbsp;\">"
589                 "</td><td>"
590                 "<b>%s</b><br />"
591                 "%s"
592                 "</td></tr>\n",
593                 (bar ? "even" : "odd"),
594                 (val ? "CHECKED" : ""),_("Yes"),
595                 (!val ? "CHECKED" : ""),_("No"),
596                 _("Calendar"),
597                 _("A shortcut to your personal calendar")
598         );
599
600         bar = 1 - bar;
601         val = IconbarIsEnabled("ib_tasks", 1);
602         wprintf("<tr class=\"%s\"><td>"
603                 "<input type=\"radio\" name=\"ib_tasks\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
604                 "<input type=\"radio\" name=\"ib_tasks\" value=\"no\" %s> %s <br />"
605                 "</td><td>"
606                 "<img src=\"static/taskmanag_48x.gif\" alt=\"&nbsp;\">"
607                 "</td><td>"
608                 "<b>%s</b><br />"
609                 "%s"
610                 "</td></tr>\n",
611                 (bar ? "even" : "odd"),
612                 (val ? "CHECKED" : ""),_("Yes"),
613                 (!val ? "CHECKED" : ""),_("No"),
614                 _("Tasks"),
615                 _("A shortcut to your personal task list")
616         );
617
618         bar = 1 - bar;
619         val = IconbarIsEnabled("ib_rooms", 1);
620         wprintf("<tr class=\"%s\"><td>"
621                 "<input type=\"radio\" name=\"ib_rooms\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
622                 "<input type=\"radio\" name=\"ib_rooms\" value=\"no\" %s> %s <br />"
623                 "</td><td>"
624                 "<img src=\"static/chatrooms_48x.gif\" alt=\"&nbsp;\">"
625                 "</td><td>"
626                 "<b>%s</b><br />"
627                 "%s"
628                 "</td></tr>\n",
629                 (bar ? "even" : "odd"),
630                 (val ? "CHECKED" : ""),_("Yes"),
631                 (!val ? "CHECKED" : ""),_("No"),
632                 _("Rooms"),
633                 _("Clicking this icon displays a list of all accessible "
634                 "rooms (or folders) available.")
635         );
636
637         bar = 1 - bar;
638         val = IconbarIsEnabled("ib_users", 1);
639         wprintf("<tr class=\"%s\"><td>"
640                 "<input type=\"radio\" name=\"ib_users\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
641                 "<input type=\"radio\" name=\"ib_users\" value=\"no\" %s> %s <br />"
642                 "<input type=\"radio\" name=\"ib_users\" value=\"yeslist\" %s> %s"
643                 "</td><td>"
644                 "<img src=\"static/usermanag_48x.gif\" alt=\"&nbsp;\">"
645                 "</td><td>"
646                 "<b>%s</b>"
647                 "<br />%s"
648                 "</td></tr>\n",
649                 (bar ? "even" : "odd"),
650                 (val ? "CHECKED" : ""),_("Yes"),
651                 (!val ? "CHECKED" : ""),_("No"),
652                 ((val > 1) ? "CHECKED" : ""),_("Yes with users list"),
653                 _("Who is online?"),
654                 _("Clicking this icon displays a list of all users "
655                 "currently logged in.")
656         );
657
658         bar = 1 - bar;
659         val = IconbarIsEnabled("ib_chat", 1);
660         wprintf("<tr class=\"%s\"><td>"
661                 "<input type=\"radio\" name=\"ib_chat\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
662                 "<input type=\"radio\" name=\"ib_chat\" value=\"no\" %s> %s <br />"
663                 "</td><td>"
664                 "<img src=\"static/citadelchat_48x.gif\" alt=\"&nbsp;\">"
665                 "</td><td>"
666                 "<b>%s</b><br />"
667                 "%s"
668                 "</td></tr>\n",
669                 (bar ? "even" : "odd"),
670                 (val ? "CHECKED" : ""),_("Yes"),
671                 (!val ? "CHECKED" : ""),_("No"),
672                 _("Chat"),
673                 _("Clicking this icon enters real-time chat mode "
674                 "with other users in the same room.")
675                 
676         );
677
678         bar = 1 - bar;
679         val = IconbarIsEnabled("ib_advanced", 1);
680         wprintf("<tr class=\"%s\"><td>"
681                 "<input type=\"radio\" name=\"ib_advanced\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
682                 "<input type=\"radio\" name=\"ib_advanced\" value=\"no\" %s> %s <br />"
683                 "</td><td>"
684                 "<img src=\"static/advanpage2_48x.gif\" alt=\"&nbsp;\">"
685                 "</td><td>"
686                 "<b>%s</b><br />"
687                 "%s"
688                 "</td></tr>\n",
689                 (bar ? "even" : "odd"),
690                 (val ? "CHECKED" : ""),_("Yes"),
691                 (!val ? "CHECKED" : ""),_("No"),
692                 _("Advanced options"),
693                 _("Access to the complete menu of Citadel functions.")
694
695         );
696
697         bar = 1 - bar;
698         val = IconbarIsEnabled("ib_citadel", 1);
699         wprintf("<tr class=\"%s\"><td>"
700                 "<input type=\"radio\" name=\"ib_citadel\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
701                 "<input type=\"radio\" name=\"ib_citadel\" value=\"no\" %s> %s <br />"
702                 "</td><td>"
703                 "<img border=\"0\" width=\"48\" height=\"48\" "
704                 "src=\"static/citadel-logo.gif\" alt=\"&nbsp;\">"
705                 "</td><td>"
706                 "<b>%s</b><br />"
707                 "%s"
708                 "</td></tr>\n",
709                 (bar ? "even" : "odd"),
710                 (val ? "CHECKED" : ""),_("Yes"),
711                 (!val ? "CHECKED" : ""),_("No"),
712                 _("Citadel logo"),
713                 _("Displays the 'Powered by Citadel' icon")
714         );
715
716         wprintf("</table><br />\n"
717                 "<center>"
718                 "<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
719                 "&nbsp;"
720                 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
721                 "</center>\n",
722                 _("Save changes"),
723                 _("Cancel")
724         );
725
726         wprintf("</form></div>\n");
727         wDumpContent(2);
728 }
729
730 /**
731  * \brief commit the changes of an edited iconbar ????
732  */
733 void commit_iconbar(void) {
734         StrBuf *iconbar;
735         StrBuf *buf;
736         int i;
737
738         char *boxen[] = {
739                 "ib_logo",
740                 "ib_summary",
741                 "ib_inbox",
742                 "ib_calendar",
743                 "ib_contacts",
744                 "ib_notes",
745                 "ib_tasks",
746                 "ib_rooms",
747                 "ib_users",
748                 "ib_chat",
749                 "ib_advanced",
750                 "ib_logoff",
751                 "ib_citadel"
752         };
753
754         if (!havebstr("ok_button")) {
755                 display_main_menu();
756                 return;
757         }
758
759         iconbar = NewStrBuf();
760         buf = NewStrBuf();
761         StrBufPrintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
762         for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
763                 char *Val;
764                 if (!strcasecmp(BSTR(boxen[i]), "yes")) {
765                         Val = "1";
766                 }
767                 else if (!strcasecmp(BSTR(boxen[i]), "yeslist")) {
768                         Val = "2";
769                 }
770                 else {
771                         Val = "0";
772                 }
773                 StrBufPrintf(buf, ",%s=%s", boxen[i], Val);
774                 StrBufAppendBuf(iconbar, buf, 0);
775
776         }
777         FreeStrBuf(&buf);
778         set_preference("iconbar", iconbar, 1);
779
780         output_headers(1, 1, 2, 0, 0, 0);
781         wprintf("<div id=\"banner\">\n");
782         wprintf("<h1>");
783         wprintf(_("Customize the icon bar"));
784         wprintf("</h1></div>\n");
785
786         wprintf("<div id=\"content\" class=\"service\">\n");
787         wprintf(
788                 "<center><table border=1 bgcolor=\"#ffffff\"><tr><td>"
789                 "<img src=\"static/advanpage2_48x.gif\">"
790                 "&nbsp;");
791         wprintf(_("Your icon bar has been updated.  Please select any of its "
792                 "choices to continue."));
793         wprintf("</td></tr></table>\n");
794         wDumpContent(2);
795         dbg_PrintHash(WC->IconBarSetttings, PrintInt, NULL);
796 }
797
798
799 void 
800 InitModule_ICONBAR
801 (void)
802 {
803         WebcitAddUrlHandler(HKEY("iconbar_ajax_menu"), do_iconbar, AJAX);
804         WebcitAddUrlHandler(HKEY("iconbar_ajax_rooms"), do_iconbar_roomlist, AJAX);
805         WebcitAddUrlHandler(HKEY("display_customize_iconbar"), display_customize_iconbar, 0);
806         WebcitAddUrlHandler(HKEY("commit_iconbar"), commit_iconbar, 0);
807 }
808
809
810 /*@}*/