* --pedantic cleanup.
[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                 wprintf(
371                         "<script type=\"text/javascript\"> "
372                         " new Ajax.PeriodicalUpdater('wholist', 'do_template?template=wholist_section', { method: 'get', frequency: 30 } );"
373                         "</script> \n"
374                         );
375         }
376 }
377
378
379 /**
380  * \brief roomtree view of the iconbar
381  * If the user has toggled the icon bar over to a room list, here's where
382  * we generate its innerHTML...
383  */
384 void do_iconbar_roomlist(void) {
385         int ib_displayas;
386                                 
387         WC->current_iconbar = current_iconbar_roomlist;
388
389         /**
390          * The initialized values of these variables also happen to
391          * specify the default values for users who haven't customized
392          * their iconbars.  These should probably be set in a master
393          * configuration somewhere.
394          */
395
396         LoadIconSettings();
397
398         ib_displayas = IconbarIsEnabled("ib_displayas", IB_PICTEXT);    /* pictures and text, pictures, text */
399
400 /** Site logo */
401         if (IconbarIsEnabled("ib_logo", 0)) {
402                 if (ib_displayas != IB_TEXTONLY) {
403                         wprintf("<div class=\"logo\"> <img "
404                                 "src=\"image&name=hello\" alt=\"&nbsp;\"> "
405                                 "</div>\n"
406                         );
407                 }
408         }
409
410 /** 'Powered by Citadel' logo */
411         if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
412                 "<div class=\"logo_citadel\"> "
413                 "<a href=\"http://www.citadel.org\" "
414                 "title=\"%s\"> "
415                 "<img "
416                 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
417                 "</div>\n",
418                 _("Find out more about Citadel"),
419                 _("CITADEL")
420         );
421
422         wprintf("<ul id=\"button\">\n");
423
424         wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_menu_buttons()\">");
425         wprintf(_("switch to menu"));
426         wprintf("</a></li>");
427
428         wprintf("<li>"
429                 "<a href=\"termquit\" title=\"%s\" "
430                 "onClick=\"return confirm('%s');\">",
431                 _("Log off"),
432                 _("Log off now?")
433                 
434         );
435         if (ib_displayas != IB_TEXTONLY) {
436         wprintf("<img alt=\"\" "
437                 "src=\"static/logoff_32x.gif\">");
438         }
439         if (ib_displayas != IB_PICONLY) {
440                 wprintf(_("Log off"));
441         }
442         wprintf("</a></li>\n");
443
444         wprintf("</ul>\n");
445
446         /** embed the room list */
447         list_all_rooms_by_floor("iconbar");
448
449         wprintf("</div>\n");
450 }
451
452
453 /**
454  * \brief display a customized version of the iconbar
455  */
456 void display_customize_iconbar(void) {
457         int i;
458         int bar = 0;
459         long val;
460
461         int ib_displayas;
462
463         LoadIconSettings();
464
465         output_headers(1, 1, 2, 0, 0, 0);
466         wprintf("<div id=\"banner\">");
467         wprintf("<h1>");
468         wprintf(_("Customize the icon bar"));
469         wprintf("</h1></div>\n");
470
471         wprintf("<div id=\"content\" class=\"service\">\n");
472
473         wprintf("<div class=\"fix_scrollbar_bug\">");
474
475         wprintf("<form method=\"post\" action=\"commit_iconbar\">\n");
476         wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
477
478         wprintf("<table class=\"altern\" >\n");
479         wprintf("<tr><td></td><td colspan=\"2\"><b>");
480         wprintf(_("Display icons as:"));
481         wprintf("</b>");
482         ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT);
483         for (i=0; i<=2; ++i) {
484                 wprintf("<input type=\"radio\" name=\"ib_displayas\" value=\"%d\"", i);
485                 if (ib_displayas == i) wprintf(" CHECKED");
486                 wprintf(">");
487                 if (i == IB_PICTEXT)    wprintf(_("pictures and text"));
488                 if (i == IB_PICONLY)    wprintf(_("pictures only"));
489                 if (i == IB_TEXTONLY)   wprintf(_("text only"));
490                 wprintf("\n");
491         }
492         wprintf("<br />\n");
493
494         wprintf(_("Select the icons you would like to see displayed "
495                 "in the 'icon bar' menu on the left side of the "
496                 "screen."));
497         wprintf("</td></tr>\n");
498
499         bar = 1 - bar;
500         val = IconbarIsEnabled("ib_logo", 0);
501         wprintf("<tr class=\"%s\"><td>"
502                 "<input type=\"radio\" name=\"ib_logo\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
503                 "<input type=\"radio\" name=\"ib_logo\" value=\"no\" %s> %s <br />"
504                 "</td><td>"
505                 "<img src=\"image&name=hello\" width=\"48\" alt=\"&nbsp;\">"
506                 "</td><td>"
507                 "<b>%s</b><br />"
508                 "%s"
509                 "</td></tr>\n",
510                 (bar ? "even" : "odd"),
511                 (val ? "CHECKED" : ""),_("Yes"),
512                 (!val ? "CHECKED" : ""),_("No"),
513                 _("Site logo"),
514                 _("An icon describing this site")
515         );
516
517         bar = 1 - bar;
518         val = IconbarIsEnabled("ib_summary", 1);
519         wprintf("<tr class=\"%s\"><td>"
520                 "<input type=\"radio\" name=\"ib_summary\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
521                 "<input type=\"radio\" name=\"ib_summary\" value=\"no\" %s> %s <br />"
522                 "</td><td>"
523                 "<img src=\"static/summscreen_48x.gif\" alt=\"&nbsp;\">"
524                 "</td><td>"
525                 "<b>%s</b><br />"
526                 "%s"
527                 "</td></tr>\n",
528                 (bar ? "even" : "odd"),
529                 (val ? "CHECKED" : ""),_("Yes"),
530                 (!val ? "CHECKED" : ""),_("No"),
531                 _("Summary"),
532                 _("Your summary page")
533         );
534
535         bar = 1 - bar;
536         val = IconbarIsEnabled("ib_inbox", 1);
537         wprintf("<tr class=\"%s\"><td>"
538                 "<input type=\"radio\" name=\"ib_inbox\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
539                 "<input type=\"radio\" name=\"ib_inbox\" value=\"no\" %s> %s <br />"
540                 "</td><td>"
541                 "<img src=\"static/privatemess_48x.gif\" alt=\"&nbsp;\">"
542                 "</td><td>"
543                 "<b>%s</b><br />"
544                 "%s"
545                 "</td></tr>\n",
546                 (bar ? "even" : "odd"),
547                 (val ? "CHECKED" : ""),_("Yes"),
548                 (!val ? "CHECKED" : ""),_("No"),
549                 _("Mail (inbox)"),
550                 _("A shortcut to your email Inbox")
551         );
552
553         bar = 1 - bar;
554         val = IconbarIsEnabled("ib_contacts", 1);
555         wprintf("<tr class=\"%s\"><td>"
556                 "<input type=\"radio\" name=\"ib_contacts\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
557                 "<input type=\"radio\" name=\"ib_contacts\" value=\"no\" %s> %s <br />"
558                 "</td><td>"
559                 "<img src=\"static/viewcontacts_48x.gif\" alt=\"&nbsp;\">"
560                 "</td><td>"
561                 "<b>%s</b><br />"
562                 "%s"
563                 "</td></tr>\n",
564                 (bar ? "even" : "odd"),
565                 (val ? "CHECKED" : ""),_("Yes"),
566                 (!val ? "CHECKED" : ""),_("No"),
567                 _("Contacts"),
568                 _("Your personal address book")
569         );
570
571         bar = 1 - bar;
572         val = IconbarIsEnabled("ib_notes", 1);
573         wprintf("<tr class=\"%s\"><td>"
574                 "<input type=\"radio\" name=\"ib_notes\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
575                 "<input type=\"radio\" name=\"ib_notes\" value=\"no\" %s> %s <br />"
576                 "</td><td>"
577                 "<img src=\"static/storenotes_48x.gif\" alt=\"&nbsp;\">"
578                 "</td><td>"
579                 "<b>%s</b><br />"
580                 "%s"
581                 "</td></tr>\n",
582                 (bar ? "even" : "odd"),
583                 (val ? "CHECKED" : ""),_("Yes"),
584                 (!val ? "CHECKED" : ""),_("No"),
585                 _("Notes"),
586                 _("Your personal notes")
587         );
588
589         bar = 1 - bar;
590         val = IconbarIsEnabled("ib_calendar", 1);
591         wprintf("<tr class=\"%s\"><td>"
592                 "<input type=\"radio\" name=\"ib_calendar\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
593                 "<input type=\"radio\" name=\"ib_calendar\" value=\"no\" %s> %s <br />"
594                 "</td><td>"
595                 "<img src=\"static/calarea_48x.gif\" alt=\"&nbsp;\">"
596                 "</td><td>"
597                 "<b>%s</b><br />"
598                 "%s"
599                 "</td></tr>\n",
600                 (bar ? "even" : "odd"),
601                 (val ? "CHECKED" : ""),_("Yes"),
602                 (!val ? "CHECKED" : ""),_("No"),
603                 _("Calendar"),
604                 _("A shortcut to your personal calendar")
605         );
606
607         bar = 1 - bar;
608         val = IconbarIsEnabled("ib_tasks", 1);
609         wprintf("<tr class=\"%s\"><td>"
610                 "<input type=\"radio\" name=\"ib_tasks\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
611                 "<input type=\"radio\" name=\"ib_tasks\" value=\"no\" %s> %s <br />"
612                 "</td><td>"
613                 "<img src=\"static/taskmanag_48x.gif\" alt=\"&nbsp;\">"
614                 "</td><td>"
615                 "<b>%s</b><br />"
616                 "%s"
617                 "</td></tr>\n",
618                 (bar ? "even" : "odd"),
619                 (val ? "CHECKED" : ""),_("Yes"),
620                 (!val ? "CHECKED" : ""),_("No"),
621                 _("Tasks"),
622                 _("A shortcut to your personal task list")
623         );
624
625         bar = 1 - bar;
626         val = IconbarIsEnabled("ib_rooms", 1);
627         wprintf("<tr class=\"%s\"><td>"
628                 "<input type=\"radio\" name=\"ib_rooms\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
629                 "<input type=\"radio\" name=\"ib_rooms\" value=\"no\" %s> %s <br />"
630                 "</td><td>"
631                 "<img src=\"static/chatrooms_48x.gif\" alt=\"&nbsp;\">"
632                 "</td><td>"
633                 "<b>%s</b><br />"
634                 "%s"
635                 "</td></tr>\n",
636                 (bar ? "even" : "odd"),
637                 (val ? "CHECKED" : ""),_("Yes"),
638                 (!val ? "CHECKED" : ""),_("No"),
639                 _("Rooms"),
640                 _("Clicking this icon displays a list of all accessible "
641                 "rooms (or folders) available.")
642         );
643
644         bar = 1 - bar;
645         val = IconbarIsEnabled("ib_users", 1);
646         wprintf("<tr class=\"%s\"><td>"
647                 "<input type=\"radio\" name=\"ib_users\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
648                 "<input type=\"radio\" name=\"ib_users\" value=\"no\" %s> %s <br />"
649                 "<input type=\"radio\" name=\"ib_users\" value=\"yeslist\" %s> %s"
650                 "</td><td>"
651                 "<img src=\"static/usermanag_48x.gif\" alt=\"&nbsp;\">"
652                 "</td><td>"
653                 "<b>%s</b>"
654                 "<br />%s"
655                 "</td></tr>\n",
656                 (bar ? "even" : "odd"),
657                 (val ? "CHECKED" : ""),_("Yes"),
658                 (!val ? "CHECKED" : ""),_("No"),
659                 ((val > 1) ? "CHECKED" : ""),_("Yes with users list"),
660                 _("Who is online?"),
661                 _("Clicking this icon displays a list of all users "
662                 "currently logged in.")
663         );
664
665         bar = 1 - bar;
666         val = IconbarIsEnabled("ib_chat", 1);
667         wprintf("<tr class=\"%s\"><td>"
668                 "<input type=\"radio\" name=\"ib_chat\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
669                 "<input type=\"radio\" name=\"ib_chat\" value=\"no\" %s> %s <br />"
670                 "</td><td>"
671                 "<img src=\"static/citadelchat_48x.gif\" alt=\"&nbsp;\">"
672                 "</td><td>"
673                 "<b>%s</b><br />"
674                 "%s"
675                 "</td></tr>\n",
676                 (bar ? "even" : "odd"),
677                 (val ? "CHECKED" : ""),_("Yes"),
678                 (!val ? "CHECKED" : ""),_("No"),
679                 _("Chat"),
680                 _("Clicking this icon enters real-time chat mode "
681                 "with other users in the same room.")
682                 
683         );
684
685         bar = 1 - bar;
686         val = IconbarIsEnabled("ib_advanced", 1);
687         wprintf("<tr class=\"%s\"><td>"
688                 "<input type=\"radio\" name=\"ib_advanced\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
689                 "<input type=\"radio\" name=\"ib_advanced\" value=\"no\" %s> %s <br />"
690                 "</td><td>"
691                 "<img src=\"static/advanpage2_48x.gif\" alt=\"&nbsp;\">"
692                 "</td><td>"
693                 "<b>%s</b><br />"
694                 "%s"
695                 "</td></tr>\n",
696                 (bar ? "even" : "odd"),
697                 (val ? "CHECKED" : ""),_("Yes"),
698                 (!val ? "CHECKED" : ""),_("No"),
699                 _("Advanced options"),
700                 _("Access to the complete menu of Citadel functions.")
701
702         );
703
704         bar = 1 - bar;
705         val = IconbarIsEnabled("ib_citadel", 1);
706         wprintf("<tr class=\"%s\"><td>"
707                 "<input type=\"radio\" name=\"ib_citadel\" value=\"yes\" %s> %s &nbsp;&nbsp;&nbsp;"
708                 "<input type=\"radio\" name=\"ib_citadel\" value=\"no\" %s> %s <br />"
709                 "</td><td>"
710                 "<img border=\"0\" width=\"48\" height=\"48\" "
711                 "src=\"static/citadel-logo.gif\" alt=\"&nbsp;\">"
712                 "</td><td>"
713                 "<b>%s</b><br />"
714                 "%s"
715                 "</td></tr>\n",
716                 (bar ? "even" : "odd"),
717                 (val ? "CHECKED" : ""),_("Yes"),
718                 (!val ? "CHECKED" : ""),_("No"),
719                 _("Citadel logo"),
720                 _("Displays the 'Powered by Citadel' icon")
721         );
722
723         wprintf("</table><br />\n"
724                 "<center>"
725                 "<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
726                 "&nbsp;"
727                 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
728                 "</center>\n",
729                 _("Save changes"),
730                 _("Cancel")
731         );
732
733         wprintf("</form></div>\n");
734         wDumpContent(2);
735 }
736
737 /**
738  * \brief commit the changes of an edited iconbar ????
739  */
740 void commit_iconbar(void) {
741         StrBuf *iconbar;
742         StrBuf *buf;
743         int i;
744
745         char *boxen[] = {
746                 "ib_logo",
747                 "ib_summary",
748                 "ib_inbox",
749                 "ib_calendar",
750                 "ib_contacts",
751                 "ib_notes",
752                 "ib_tasks",
753                 "ib_rooms",
754                 "ib_users",
755                 "ib_chat",
756                 "ib_advanced",
757                 "ib_logoff",
758                 "ib_citadel"
759         };
760
761         if (!havebstr("ok_button")) {
762                 display_main_menu();
763                 return;
764         }
765
766         iconbar = NewStrBuf();
767         buf = NewStrBuf();
768         StrBufPrintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
769         for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
770                 char *Val;
771                 if (!strcasecmp(BSTR(boxen[i]), "yes")) {
772                         Val = "1";
773                 }
774                 else if (!strcasecmp(BSTR(boxen[i]), "yeslist")) {
775                         Val = "2";
776                 }
777                 else {
778                         Val = "0";
779                 }
780                 StrBufPrintf(buf, ",%s=%s", boxen[i], Val);
781                 StrBufAppendBuf(iconbar, buf, 0);
782
783         }
784         FreeStrBuf(&buf);
785         set_preference("iconbar", iconbar, 1);
786
787         output_headers(1, 1, 2, 0, 0, 0);
788         wprintf("<div id=\"banner\">\n");
789         wprintf("<h1>");
790         wprintf(_("Customize the icon bar"));
791         wprintf("</h1></div>\n");
792
793         wprintf("<div id=\"content\" class=\"service\">\n");
794         wprintf(
795                 "<center><table border=1 bgcolor=\"#ffffff\"><tr><td>"
796                 "<img src=\"static/advanpage2_48x.gif\">"
797                 "&nbsp;");
798         wprintf(_("Your icon bar has been updated.  Please select any of its "
799                 "choices to continue."));
800         wprintf("</td></tr></table>\n");
801         wDumpContent(2);
802 #ifdef DBG_ICONBAR_HASH
803         dbg_PrintHash(WC->IconBarSetttings, PrintInt, NULL);
804 #endif
805 }
806
807
808 void tmplput_iconbar(StrBuf *Target, int nArgs, WCTemplateToken *Tokens, void *Context, int ContextType)
809 {
810         wcsession *WCC = WC;
811         
812         if ((WCC != NULL) && (WCC->logged_in)) {
813                 wprintf("<div id=\"iconbar\">");
814                 do_selected_iconbar();
815                 /** check for instant messages (these display in a new window) */
816                 page_popup();
817                 wprintf("</div>");
818         }
819 }
820
821 void 
822 InitModule_ICONBAR
823 (void)
824 {
825         WebcitAddUrlHandler(HKEY("iconbar_ajax_menu"), do_iconbar, AJAX);
826         WebcitAddUrlHandler(HKEY("iconbar_ajax_rooms"), do_iconbar_roomlist, AJAX);
827         WebcitAddUrlHandler(HKEY("display_customize_iconbar"), display_customize_iconbar, 0);
828         WebcitAddUrlHandler(HKEY("commit_iconbar"), commit_iconbar, 0);
829         RegisterNamespace("ICONBAR", 0, 0, tmplput_iconbar, 0);
830
831 }
832
833
834 /*@}*/