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