4 * Displays and customizes the iconbar.
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 */
16 void do_iconbar(void);
17 void do_iconbar_roomlist(void);
20 * \brief draw the icon bar?????
22 void do_selected_iconbar(void) {
23 if (WC->current_iconbar == current_iconbar_roomlist) {
24 do_iconbar_roomlist();
31 void DontDeleteThis(void *Data){};
33 #define IconbarIsEnabled(a, b) IconbarIsENABLED(a, sizeof(a) - 1, b)
35 long IconbarIsENABLED(const char *key, size_t keylen, long defval)
38 if (GetHash(WC->IconBarSetttings, key, keylen,
46 inline const char *PrintInt(void *Prefstr)
48 snprintf(nbuf, sizeof(nbuf), "%ld", (long)Prefstr);
52 void LoadIconSettings(void)
54 struct wcsession *WCC = WC;
55 StrBuf *iconbar = NULL;
56 StrBuf *buf = NewStrBuf();;
57 StrBuf *key = NewStrBuf();
61 WCC->current_iconbar = current_iconbar_menu;
62 if (WCC->IconBarSetttings == NULL)
63 WCC->IconBarSetttings = NewHash(1, NULL);
65 * The initialized values of these variables also happen to
66 * specify the default values for users who haven't customized
67 * their iconbars. These should probably be set in a master
68 * configuration somewhere.
71 if (get_preference("iconbar", &iconbar)) {
72 nTokens = StrBufNum_tokens(iconbar, ',');
73 for (i=0; i<nTokens; ++i) {
74 StrBufExtract_token(buf, iconbar, i, ',');
75 StrBufExtract_token(key, buf, 0, '=');
76 val = StrBufExtract_long(buf, 1, '=');
77 Put(WCC->IconBarSetttings,
78 ChrPtr(key), StrLength(key),
79 (void*)val, DontDeleteThis);
82 dbg_PrintHash(WCC->IconBarSetttings, PrintInt, NULL);
90 * \brief draw the icon bar???
92 void do_iconbar(void) {
93 int ib_displayas = IB_PICTEXT; /**< pictures and text, pictures, text */
96 ib_displayas = IconbarIsEnabled("ib_displayas", IB_PICTEXT);
99 if (IconbarIsEnabled("ib_logo", 0)) {
100 if (ib_displayas != IB_TEXTONLY) {
101 wprintf("<div class=\"logo\"> <img "
102 "src=\"image&name=hello\" alt=\" \"> "
109 /** 'Powered by Citadel' logo */
110 if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
111 "<div class=\"logo_citadel\"> "
112 "<a href=\"http://www.citadel.org\" "
115 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
117 _("Find out more about Citadel"),
121 wprintf("<ul id=\"button\">\n");
123 wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_room_list()\">");
124 wprintf(_("switch to room list"));
125 wprintf("</a></li>");
127 /** Summary page icon */
128 if (IconbarIsEnabled("ib_summary", 1)) {
129 wprintf("<li><a href=\"summary\" "
131 ">", _("Your summary page")
133 if (ib_displayas != IB_TEXTONLY) {
134 wprintf("<img alt=\"\" "
135 "src=\"static/summscreen_32x.gif\">");
137 if (ib_displayas != IB_PICONLY) {
138 wprintf(_("Summary"));
140 wprintf("</a></li>\n");
144 if (IconbarIsEnabled("ib_inbox", 1)) {
146 "<a href=\"dotgoto?room=_MAIL_\" "
149 _("Go to your email inbox")
151 if (ib_displayas != IB_TEXTONLY) {
152 wprintf("<img alt=\"\" "
153 "src=\"static/privatemess_32x.gif\">");
155 if (ib_displayas != IB_PICONLY) {
157 if (WC->new_mail != WC->remember_new_mail) {
159 if (WC->new_mail > 0) {
160 wprintf(" <b>(%d)</b>", WC->new_mail);
163 WC->remember_new_mail = WC->new_mail;
166 wprintf("</a></li>\n");
170 if (IconbarIsEnabled("ib_calendar", 1)) {
172 "<a href=\"dotgoto?room=_CALENDAR_\" "
175 _("Go to your personal calendar")
177 if (ib_displayas != IB_TEXTONLY) {
178 wprintf("<img alt=\"\" "
179 "src=\"static/calarea_32x.gif\">");
181 if (ib_displayas != IB_PICONLY) {
182 wprintf(_("Calendar"));
184 wprintf("</a></li>\n");
188 if (IconbarIsEnabled("ib_contacts", 1)) {
190 "<a href=\"dotgoto?room=_CONTACTS_\" "
193 _("Go to your personal address book")
195 if (ib_displayas != IB_TEXTONLY) {
196 wprintf("<img alt=\"\" "
197 "src=\"static/viewcontacts_32x.gif\">");
199 if (ib_displayas != IB_PICONLY) {
200 wprintf(_("Contacts"));
202 wprintf("</a></li>\n");
206 if (IconbarIsEnabled("ib_notes", 1)) {
208 "<a href=\"dotgoto?room=_NOTES_\" "
211 _("Go to your personal notes")
213 if (ib_displayas != IB_TEXTONLY) {
214 wprintf("<img alt=\"\" "
215 "src=\"static/storenotes_32x.gif\">");
217 if (ib_displayas != IB_PICONLY) {
220 wprintf("</a></li>\n");
224 if (IconbarIsEnabled("ib_tasks", 1)) {
226 "<a href=\"dotgoto?room=_TASKS_\" "
229 _("Go to your personal task list")
231 if (ib_displayas != IB_TEXTONLY) {
232 wprintf("<img alt=\"\" "
233 "src=\"static/taskmanag_32x.gif\">");
235 if (ib_displayas != IB_PICONLY) {
238 wprintf("</a></li>\n");
242 if (IconbarIsEnabled("ib_rooms", 1)) {
244 "<a href=\"knrooms\" title=\"%s\" >",
245 _("List all of your accessible rooms")
247 if (ib_displayas != IB_TEXTONLY) {
248 wprintf("<img alt=\"\" "
249 "src=\"static/chatrooms_32x.gif\">");
251 if (ib_displayas != IB_PICONLY) {
254 wprintf("</a></li>\n");
258 if (IconbarIsEnabled("ib_users", 1)) {
260 "<a href=\"who\" title=\"%s\" "
262 _("See who is online right now")
264 if (ib_displayas != IB_TEXTONLY) {
265 wprintf("<img alt=\"\" "
266 "src=\"static/usermanag_32x.gif\">");
268 if (ib_displayas != IB_PICONLY) {
269 wprintf(_("Who is online?"));
274 if (IconbarIsEnabled("ib_users", 0)) {
275 wprintf("<ul id=\"wholist\">");
276 wprintf("</ul></li>\n");
281 if (IconbarIsEnabled("ib_chat", 1)) {
283 "<a href=\"#\" onClick=\"window.open('chat', "
284 "'ctdl_chat_window', "
285 "'toolbar=no,location=no,directories=no,copyhistory=no,"
286 "status=no,scrollbars=yes,resizable=yes');\""
289 if (ib_displayas != IB_TEXTONLY) {
290 wprintf("<img alt=\"\" "
291 "src=\"static/citadelchat_32x.gif\">");
293 if (ib_displayas != IB_PICONLY) {
296 wprintf("</a></li>\n");
299 /** Advanced Options icon */
300 if (IconbarIsEnabled("ib_advanced", 1)) {
302 "<a href=\"display_main_menu\" "
305 _("Advanced Options Menu: Advanced Room commands, Account Info, and Chat")
307 if (ib_displayas != IB_TEXTONLY) {
308 wprintf("<img alt=\"\" "
309 "src=\"static/advanpage2_32x.gif\">");
311 if (ib_displayas != IB_PICONLY) {
312 wprintf(_("Advanced"));
314 wprintf("</a></li>\n");
317 if ((WC->axlevel >= 6) || (WC->is_room_aide)) {
319 "<a href=\"display_aide_menu\" "
322 _("Room and system administration functions")
324 if (ib_displayas != IB_TEXTONLY) {
325 wprintf("<img alt=\"\" "
326 "src=\"static/advanpage2_32x.gif\">");
328 if (ib_displayas != IB_PICONLY) {
329 wprintf(_("Administration"));
331 wprintf("</a></li>\n");
335 "<a href=\"termquit\" title=\"%s\" "
336 "onClick=\"return confirm('%s');\">",
341 if (ib_displayas != IB_TEXTONLY) {
342 wprintf("<img alt=\"\" "
343 "src=\"static/logoff_32x.gif\">");
345 if (ib_displayas != IB_PICONLY) {
346 wprintf(_("Log off"));
348 wprintf("</a></li>\n");
351 "<li class=\"switch\">"
352 "<a href=\"display_customize_iconbar\" "
356 _("Customize this menu"),
357 _("customize this menu")
362 if (IconbarIsEnabled("ib_users", 0)) {
364 "<script type=\"text/javascript\"> "
365 " new Ajax.PeriodicalUpdater('wholist', 'wholist_section', { method: 'get', frequency: 30 } );"
373 * \brief roomtree view of the iconbar
374 * If the user has toggled the icon bar over to a room list, here's where
375 * we generate its innerHTML...
377 void do_iconbar_roomlist(void) {
379 WC->current_iconbar = current_iconbar_roomlist;
382 * The initialized values of these variables also happen to
383 * specify the default values for users who haven't customized
384 * their iconbars. These should probably be set in a master
385 * configuration somewhere.
391 ib_displayas = IconbarIsEnabled("ib_displayas", IB_PICTEXT); /* pictures and text, pictures, text */
394 if (IconbarIsEnabled("ib_logo", 0)) {
395 if (ib_displayas != IB_TEXTONLY) {
396 wprintf("<div class=\"logo\"> <img "
397 "src=\"image&name=hello\" alt=\" \"> "
403 /** 'Powered by Citadel' logo */
404 if (IconbarIsEnabled("ib_citadel", 1) && (ib_displayas != IB_TEXTONLY)) wprintf(
405 "<div class=\"logo_citadel\"> "
406 "<a href=\"http://www.citadel.org\" "
409 "src=\"static/citadel-logo.gif\" alt=\"%s\"></a> "
411 _("Find out more about Citadel"),
415 wprintf("<ul id=\"button\">\n");
417 wprintf("<li class=\"switch\"><a href=\"javascript:switch_to_menu_buttons()\">");
418 wprintf(_("switch to menu"));
419 wprintf("</a></li>");
422 "<a href=\"termquit\" title=\"%s\" "
423 "onClick=\"return confirm('%s');\">",
428 if (ib_displayas != IB_TEXTONLY) {
429 wprintf("<img alt=\"\" "
430 "src=\"static/logoff_32x.gif\">");
432 if (ib_displayas != IB_PICONLY) {
433 wprintf(_("Log off"));
435 wprintf("</a></li>\n");
439 /** embed the room list */
440 list_all_rooms_by_floor("iconbar");
447 * \brief display a customized version of the iconbar
449 void display_customize_iconbar(void) {
458 output_headers(1, 1, 2, 0, 0, 0);
459 wprintf("<div id=\"banner\">");
461 wprintf(_("Customize the icon bar"));
462 wprintf("</h1></div>\n");
464 wprintf("<div id=\"content\" class=\"service\">\n");
466 wprintf("<div class=\"fix_scrollbar_bug\">");
468 wprintf("<form method=\"post\" action=\"commit_iconbar\">\n");
469 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
471 wprintf("<table class=\"altern\" >\n");
472 wprintf("<tr><td></td><td colspan=\"2\"><b>");
473 wprintf(_("Display icons as:"));
475 ib_displayas = IconbarIsEnabled("ib_displayas",IB_PICTEXT);
476 for (i=0; i<=2; ++i) {
477 wprintf("<input type=\"radio\" name=\"ib_displayas\" value=\"%d\"", i);
478 if (ib_displayas == i) wprintf(" CHECKED");
480 if (i == IB_PICTEXT) wprintf(_("pictures and text"));
481 if (i == IB_PICONLY) wprintf(_("pictures only"));
482 if (i == IB_TEXTONLY) wprintf(_("text only"));
487 wprintf(_("Select the icons you would like to see displayed "
488 "in the 'icon bar' menu on the left side of the "
490 wprintf("</td></tr>\n");
493 val = IconbarIsEnabled("ib_logo", 0);
494 wprintf("<tr class=\"%s\"><td>"
495 "<input type=\"radio\" name=\"ib_logo\" value=\"yes\" %s> %s "
496 "<input type=\"radio\" name=\"ib_logo\" value=\"no\" %s> %s <br />"
498 "<img src=\"image&name=hello\" width=\"48\" alt=\" \">"
503 (bar ? "even" : "odd"),
504 (val ? "CHECKED" : ""),_("Yes"),
505 (!val ? "CHECKED" : ""),_("No"),
507 _("An icon describing this site")
511 val = IconbarIsEnabled("ib_summary", 1);
512 wprintf("<tr class=\"%s\"><td>"
513 "<input type=\"radio\" name=\"ib_summary\" value=\"yes\" %s> %s "
514 "<input type=\"radio\" name=\"ib_summary\" value=\"no\" %s> %s <br />"
516 "<img src=\"static/summscreen_48x.gif\" alt=\" \">"
521 (bar ? "even" : "odd"),
522 (val ? "CHECKED" : ""),_("Yes"),
523 (!val ? "CHECKED" : ""),_("No"),
525 _("Your summary page")
529 val = IconbarIsEnabled("ib_inbox", 1);
530 wprintf("<tr class=\"%s\"><td>"
531 "<input type=\"radio\" name=\"ib_inbox\" value=\"yes\" %s> %s "
532 "<input type=\"radio\" name=\"ib_inbox\" value=\"no\" %s> %s <br />"
534 "<img src=\"static/privatemess_48x.gif\" alt=\" \">"
539 (bar ? "even" : "odd"),
540 (val ? "CHECKED" : ""),_("Yes"),
541 (!val ? "CHECKED" : ""),_("No"),
543 _("A shortcut to your email Inbox")
547 val = IconbarIsEnabled("ib_contacts", 1);
548 wprintf("<tr class=\"%s\"><td>"
549 "<input type=\"radio\" name=\"ib_contacts\" value=\"yes\" %s> %s "
550 "<input type=\"radio\" name=\"ib_contacts\" value=\"no\" %s> %s <br />"
552 "<img src=\"static/viewcontacts_48x.gif\" alt=\" \">"
557 (bar ? "even" : "odd"),
558 (val ? "CHECKED" : ""),_("Yes"),
559 (!val ? "CHECKED" : ""),_("No"),
561 _("Your personal address book")
565 val = IconbarIsEnabled("ib_notes", 1);
566 wprintf("<tr class=\"%s\"><td>"
567 "<input type=\"radio\" name=\"ib_notes\" value=\"yes\" %s> %s "
568 "<input type=\"radio\" name=\"ib_notes\" value=\"no\" %s> %s <br />"
570 "<img src=\"static/storenotes_48x.gif\" alt=\" \">"
575 (bar ? "even" : "odd"),
576 (val ? "CHECKED" : ""),_("Yes"),
577 (!val ? "CHECKED" : ""),_("No"),
579 _("Your personal notes")
583 val = IconbarIsEnabled("ib_calendar", 1);
584 wprintf("<tr class=\"%s\"><td>"
585 "<input type=\"radio\" name=\"ib_calendar\" value=\"yes\" %s> %s "
586 "<input type=\"radio\" name=\"ib_calendar\" value=\"no\" %s> %s <br />"
588 "<img src=\"static/calarea_48x.gif\" alt=\" \">"
593 (bar ? "even" : "odd"),
594 (val ? "CHECKED" : ""),_("Yes"),
595 (!val ? "CHECKED" : ""),_("No"),
597 _("A shortcut to your personal calendar")
601 val = IconbarIsEnabled("ib_tasks", 1);
602 wprintf("<tr class=\"%s\"><td>"
603 "<input type=\"radio\" name=\"ib_tasks\" value=\"yes\" %s> %s "
604 "<input type=\"radio\" name=\"ib_tasks\" value=\"no\" %s> %s <br />"
606 "<img src=\"static/taskmanag_48x.gif\" alt=\" \">"
611 (bar ? "even" : "odd"),
612 (val ? "CHECKED" : ""),_("Yes"),
613 (!val ? "CHECKED" : ""),_("No"),
615 _("A shortcut to your personal task list")
619 val = IconbarIsEnabled("ib_rooms", 1);
620 wprintf("<tr class=\"%s\"><td>"
621 "<input type=\"radio\" name=\"ib_rooms\" value=\"yes\" %s> %s "
622 "<input type=\"radio\" name=\"ib_rooms\" value=\"no\" %s> %s <br />"
624 "<img src=\"static/chatrooms_48x.gif\" alt=\" \">"
629 (bar ? "even" : "odd"),
630 (val ? "CHECKED" : ""),_("Yes"),
631 (!val ? "CHECKED" : ""),_("No"),
633 _("Clicking this icon displays a list of all accessible "
634 "rooms (or folders) available.")
638 val = IconbarIsEnabled("ib_users", 1);
639 wprintf("<tr class=\"%s\"><td>"
640 "<input type=\"radio\" name=\"ib_users\" value=\"yes\" %s> %s "
641 "<input type=\"radio\" name=\"ib_users\" value=\"no\" %s> %s <br />"
642 "<input type=\"radio\" name=\"ib_users\" value=\"yeslist\" %s> %s"
644 "<img src=\"static/usermanag_48x.gif\" alt=\" \">"
649 (bar ? "even" : "odd"),
650 (val ? "CHECKED" : ""),_("Yes"),
651 (!val ? "CHECKED" : ""),_("No"),
652 ((val > 1) ? "CHECKED" : ""),_("Yes with users list"),
654 _("Clicking this icon displays a list of all users "
655 "currently logged in.")
659 val = IconbarIsEnabled("ib_chat", 1);
660 wprintf("<tr class=\"%s\"><td>"
661 "<input type=\"radio\" name=\"ib_chat\" value=\"yes\" %s> %s "
662 "<input type=\"radio\" name=\"ib_chat\" value=\"no\" %s> %s <br />"
664 "<img src=\"static/citadelchat_48x.gif\" alt=\" \">"
669 (bar ? "even" : "odd"),
670 (val ? "CHECKED" : ""),_("Yes"),
671 (!val ? "CHECKED" : ""),_("No"),
673 _("Clicking this icon enters real-time chat mode "
674 "with other users in the same room.")
679 val = IconbarIsEnabled("ib_advanced", 1);
680 wprintf("<tr class=\"%s\"><td>"
681 "<input type=\"radio\" name=\"ib_advanced\" value=\"yes\" %s> %s "
682 "<input type=\"radio\" name=\"ib_advanced\" value=\"no\" %s> %s <br />"
684 "<img src=\"static/advanpage2_48x.gif\" alt=\" \">"
689 (bar ? "even" : "odd"),
690 (val ? "CHECKED" : ""),_("Yes"),
691 (!val ? "CHECKED" : ""),_("No"),
692 _("Advanced options"),
693 _("Access to the complete menu of Citadel functions.")
698 val = IconbarIsEnabled("ib_citadel", 1);
699 wprintf("<tr class=\"%s\"><td>"
700 "<input type=\"radio\" name=\"ib_citadel\" value=\"yes\" %s> %s "
701 "<input type=\"radio\" name=\"ib_citadel\" value=\"no\" %s> %s <br />"
703 "<img border=\"0\" width=\"48\" height=\"48\" "
704 "src=\"static/citadel-logo.gif\" alt=\" \">"
709 (bar ? "even" : "odd"),
710 (val ? "CHECKED" : ""),_("Yes"),
711 (!val ? "CHECKED" : ""),_("No"),
713 _("Displays the 'Powered by Citadel' icon")
716 wprintf("</table><br />\n"
718 "<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
720 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">"
726 wprintf("</form></div>\n");
731 * \brief commit the changes of an edited iconbar ????
733 void commit_iconbar(void) {
754 if (!havebstr("ok_button")) {
759 iconbar = NewStrBuf();
761 StrBufPrintf(iconbar, "ib_displayas=%d", ibstr("ib_displayas"));
762 for (i=0; i<(sizeof(boxen)/sizeof(char *)); ++i) {
764 if (!strcasecmp(BSTR(boxen[i]), "yes")) {
767 else if (!strcasecmp(BSTR(boxen[i]), "yeslist")) {
773 StrBufPrintf(buf, ",%s=%s", boxen[i], Val);
774 StrBufAppendBuf(iconbar, buf, 0);
778 set_preference("iconbar", iconbar, 1);
780 output_headers(1, 1, 2, 0, 0, 0);
781 wprintf("<div id=\"banner\">\n");
783 wprintf(_("Customize the icon bar"));
784 wprintf("</h1></div>\n");
786 wprintf("<div id=\"content\" class=\"service\">\n");
788 "<center><table border=1 bgcolor=\"#ffffff\"><tr><td>"
789 "<img src=\"static/advanpage2_48x.gif\">"
791 wprintf(_("Your icon bar has been updated. Please select any of its "
792 "choices to continue."));
793 wprintf("</td></tr></table>\n");
795 dbg_PrintHash(WC->IconBarSetttings, PrintInt, NULL);
803 WebcitAddUrlHandler(HKEY("iconbar_ajax_menu"), do_iconbar, AJAX);
804 WebcitAddUrlHandler(HKEY("iconbar_ajax_rooms"), do_iconbar_roomlist, AJAX);
805 WebcitAddUrlHandler(HKEY("display_customize_iconbar"), display_customize_iconbar, 0);
806 WebcitAddUrlHandler(HKEY("commit_iconbar"), commit_iconbar, 0);