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