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