5 * \defgroup RoomOps Lots of different room-related operations.
6 * \ingroup CitadelCommunitacion
11 char floorlist[128][SIZ]; /**< list of our floor names */
13 char *viewdefs[8]; /**< the different kinds of available views */
16 * \brief initialize the viewdefs with localized strings
18 void initialize_viewdefs(void) {
19 viewdefs[0] = _("Bulletin Board");
20 viewdefs[1] = _("Mail Folder");
21 viewdefs[2] = _("Address Book");
22 viewdefs[3] = _("Calendar");
23 viewdefs[4] = _("Task List");
24 viewdefs[5] = _("Notes List");
25 viewdefs[6] = _("Wiki");
26 viewdefs[7] = _("Calendar List");
30 * \brief Determine which views are allowed as the default for creating a new room.
32 * \param which_view The view ID being queried.
34 int is_view_allowed_as_default(int which_view)
37 case VIEW_BBS: return(1);
38 case VIEW_MAILBOX: return(1);
39 case VIEW_ADDRESSBOOK: return(1);
40 case VIEW_CALENDAR: return(1);
41 case VIEW_TASKS: return(1);
42 case VIEW_NOTES: return(1);
43 case VIEW_WIKI: return(0); /**< because it isn't finished yet */
44 case VIEW_CALBRIEF: return(0);
45 default: return(0); /**< should never get here */
51 * \brief load the list of floors
53 void load_floorlist(void)
58 for (a = 0; a < 128; ++a)
62 serv_getln(buf, sizeof buf);
64 strcpy(floorlist[0], "Main Floor");
67 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
68 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
74 * \brief Free a session's march list
76 * \param wcf Pointer to session being cleared
78 void free_march_list(struct wcsession *wcf)
82 while (wcf->march != NULL) {
83 mptr = wcf->march->next;
93 * \brief remove a room from the march list
95 void remove_march(char *aaa)
97 struct march *mptr, *mptr2;
99 if (WC->march == NULL)
102 if (!strcasecmp(WC->march->march_name, aaa)) {
103 mptr = WC->march->next;
109 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
110 if (!strcasecmp(mptr->march_name, aaa)) {
111 mptr2->next = mptr->next;
124 * \brief display rooms in tree structure???
125 * \param rp the roomlist to build a tree from
127 void room_tree_list(struct roomlisting *rp)
136 room_tree_list(rp->lnext);
138 strcpy(rmname, rp->rlname);
141 wprintf("<a href=\"dotgoto&room=");
145 escputs1(rmname, 1, 1);
146 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
148 else if (f & QR_DIRECTORY)
150 else if (f & QR_NETWORK)
154 wprintf("</A><TT> </TT>\n");
156 room_tree_list(rp->rnext);
162 * \brief Room ordering stuff (compare first by floor, then by order)
163 * \param r1 first roomlist to compare
164 * \param r2 second roomlist co compare
165 * \return are they the same???
167 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
169 if ((r1 == NULL) && (r2 == NULL))
175 if (r1->rlfloor < r2->rlfloor)
177 if (r1->rlfloor > r2->rlfloor)
179 if (r1->rlorder < r2->rlorder)
181 if (r1->rlorder > r2->rlorder)
188 * \brief Common code for all room listings
189 * \param variety what???
191 void listrms(char *variety)
196 struct roomlisting *rl = NULL;
197 struct roomlisting *rp;
198 struct roomlisting *rs;
200 /** Ask the server for a room list */
202 serv_getln(buf, sizeof buf);
208 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
210 rp = malloc(sizeof(struct roomlisting));
211 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
212 rp->rlflags = extract_int(buf, 1);
213 rp->rlfloor = extract_int(buf, 2);
214 rp->rlorder = extract_int(buf, 3);
223 if (rordercmp(rp, rs) < 0) {
224 if (rs->lnext == NULL) {
231 if (rs->rnext == NULL) {
244 * If no rooms were listed, print an nbsp to make the cell
245 * borders show up anyway.
247 if (num_rooms == 0) wprintf(" ");
252 * \brief list all forgotten rooms
254 void zapped_list(void)
256 output_headers(1, 1, 0, 0, 0, 0);
258 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
259 do_template("beginbox");
263 wprintf("<br /><br />\n");
264 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
265 do_template("endbox");
271 * \brief read this room's info file (set v to 1 for verbose mode)
278 int fullinfo_len = 0;
281 serv_getln(buf, sizeof buf);
284 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
285 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
286 strcpy(&fullinfo[fullinfo_len], buf);
287 fullinfo_len += strlen(buf);
291 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
292 strcpy(&briefinfo[50], "...");
294 wprintf("<div class=\"infos\" "
295 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
298 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
299 wprintf("<img class=\"close_infos\" "
300 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
301 "src=\"static/closewindow.gif\" alt=\"%s\">",
316 * \brief Display room banner icon.
317 * The server doesn't actually
318 * need the room name, but we supply it in order to
319 * keep the browser from using a cached icon from
322 void embed_room_graphic(void) {
325 serv_puts("OIMG _roompic_");
326 serv_getln(buf, sizeof buf);
328 wprintf("<IMG HEIGHT=64 src=\"image&name=_roompic_&room=");
329 urlescputs(WC->wc_roomname);
332 serv_getln(buf, sizeof buf);
334 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
335 wprintf("<img height=48 width=48 src=\""
336 "static/viewcontacts_48x.gif"
340 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
341 wprintf("<img height=48 width=48 src=\""
342 "static/calarea_48x.gif"
346 else if (WC->wc_view == VIEW_TASKS) {
347 wprintf("<img height=48 width=48 src=\""
348 "static/taskmanag_48x.gif"
352 else if (WC->wc_view == VIEW_NOTES) {
353 wprintf("<img height=48 width=48 src=\""
354 "static/storenotes_48x.gif"
358 else if (WC->wc_view == VIEW_MAILBOX) {
359 wprintf("<img height=48 width=48 src=\""
360 "static/privatemess_48x.gif"
365 wprintf("<img height=48 width=48 src=\""
366 "static/chatrooms_48x.gif"
376 * \brief Display the current view and offer an option to change it
378 void embed_view_o_matic(void) {
381 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n"
382 "<label for=\"view_name\">");
383 wprintf(_("View as:"));
385 "<select name=\"newview\" size=\"1\" "
386 "id=\"view_name\" class=\"selectbox\" "
387 "OnChange=\"location.href=viewomatic.newview.options"
388 "[selectedIndex].value\">\n");
390 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
392 * Only offer the views that make sense, given the default
393 * view for the room. For example, don't offer a Calendar
394 * view in a non-Calendar room.
398 || (i == WC->wc_default_view) /**< default */
399 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
400 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
401 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
404 wprintf("<option %s value=\"changeview?view=%d\">",
405 ((i == WC->wc_view) ? "selected" : ""),
407 escputs(viewdefs[i]);
408 wprintf("</option>\n");
411 wprintf("</select></form>\n");
416 * \brief Display a search box
418 void embed_search_o_matic(void) {
419 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n"
420 "<label for=\"search_name\">");
421 wprintf(_("Search: "));
422 wprintf("</label> <input "
423 "type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
424 "id=\"search_name\" class=\"inputbox\">\n"
426 wprintf("</select></form>\n");
431 * \brief Embed the room banner
433 * \param got The information returned from a GOTO server command
434 * \param navbar_style Determines which navigation buttons to display
438 void embed_room_banner(char *got, int navbar_style) {
442 * We need to have the information returned by a GOTO server command.
443 * If it isn't supplied, we fake it by issuing our own GOTO.
446 serv_printf("GOTO %s", WC->wc_roomname);
447 serv_getln(buf, sizeof buf);
451 /** The browser needs some information for its own use */
452 wprintf("<script type=\"text/javascript\"> \n"
453 " room_is_trash = %d; \n"
459 * If the user happens to select the "make this my start page" link,
460 * we want it to remember the URL as a "/dotskip" one instead of
461 * a "skip" or "gotonext" or something like that.
463 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
466 /** Check for new mail. */
467 WC->new_mail = extract_int(&got[4], 9);
468 WC->wc_view = extract_int(&got[4], 11);
470 svprintf("ROOMNAME", WCS_STRING, "%s", WC->wc_roomname);
471 svprintf("NUMMSGS", WCS_STRING,
472 _("%d new of %d messages"),
473 extract_int(&got[4], 1),
474 extract_int(&got[4], 2)
476 svcallback("ROOMPIC", embed_room_graphic);
477 svcallback("ROOMINFO", readinfo);
478 svcallback("VIEWOMATIC", embed_view_o_matic);
479 svcallback("SEARCHOMATIC", embed_search_o_matic);
480 svcallback("START", offer_start_page);
482 do_template("roombanner");
483 if (navbar_style != navbar_none) {
485 wprintf("<div id=\"navbar\">\n"
490 if (navbar_style == navbar_default) wprintf(
491 "<li class=\"ungoto\">"
492 "<a href=\"ungoto\">"
493 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
494 "<span class=\"navbar_link\">%s</span></A>"
495 "</li>\n", _("Ungoto")
498 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
500 "<li class=\"newmess\">"
501 "<a href=\"readnew\">"
502 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
503 "<span class=\"navbar_link\">%s</span></A>"
504 "</li>\n", _("Read new messages")
508 if (navbar_style == navbar_default) {
509 switch(WC->wc_view) {
510 case VIEW_ADDRESSBOOK:
512 "<li class=\"viewcontacts\">"
513 "<a href=\"readfwd\">"
514 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
516 "<span class=\"navbar_link\">"
518 "</span></a></li>\n", _("View contacts")
523 "<li class=\"staskday\">"
524 "<a href=\"readfwd?calview=day\">"
525 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
527 "<span class=\"navbar_link\">"
529 "</span></a></li>\n", _("Day view")
532 "<li class=\"monthview\">"
533 "<a href=\"readfwd?calview=month\">"
534 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
536 "<span class=\"navbar_link\">"
538 "</span></a></li>\n", _("Month view")
543 "<li class=\"monthview\">"
544 "<a href=\"readfwd?calview=month\">"
545 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
547 "<span class=\"navbar_link\">"
549 "</span></a></li>\n", _("Calendar list")
554 "<li class=\"taskmanag\">"
555 "<a href=\"readfwd\">"
556 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
558 "<span class=\"navbar_link\">"
560 "</span></a></li>\n", _("View tasks")
565 "<li class=\"viewnotes\">"
566 "<a href=\"readfwd\">"
567 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
569 "<span class=\"navbar_link\">"
571 "</span></a></li>\n", _("View notes")
576 "<li class=\"readallmess\">"
577 "<a href=\"readfwd\">"
578 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
580 "<span class=\"navbar_link\">"
582 "</span></a></li>\n", _("View message list")
587 "<li class=\"readallmess\">"
588 "<a href=\"readfwd\">"
589 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
591 "<span class=\"navbar_link\">"
593 "</span></a></li>\n", _("Wiki home")
598 "<li class=\"readallmess\">"
599 "<a href=\"readfwd\">"
600 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
602 "<span class=\"navbar_link\">"
604 "</span></a></li>\n", _("Read all messages")
610 if (navbar_style == navbar_default) {
611 switch(WC->wc_view) {
612 case VIEW_ADDRESSBOOK:
614 "<li class=\"addnewcontact\">"
615 "<a href=\"display_enter\">"
616 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
617 "border=\"0\"><span class=\"navbar_link\">"
619 "</span></a></li>\n", _("Add new contact")
624 wprintf("<li class=\"addevent\"><a href=\"display_enter");
625 if (strlen(bstr("year")) > 0) wprintf("?year=%s", bstr("year"));
626 if (strlen(bstr("month")) > 0) wprintf("?month=%s", bstr("month"));
627 if (strlen(bstr("day")) > 0) wprintf("?day=%s", bstr("day"));
629 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
630 "border=\"0\"><span class=\"navbar_link\">"
632 "</span></a></li>\n", _("Add new event")
637 "<li class=\"newmess\">"
638 "<a href=\"display_enter\">"
639 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
640 "border=\"0\"><span class=\"navbar_link\">"
642 "</span></a></li>\n", _("Add new task")
647 "<li class=\"enternewnote\">"
648 "<a href=\"javascript:add_new_note();\">"
649 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
650 "border=\"0\"><span class=\"navbar_link\">"
652 "</span></a></li>\n", _("Add new note")
656 safestrncpy(buf, bstr("page"), sizeof buf);
659 "<li class=\"newmess\">"
660 "<a href=\"display_enter?wikipage=%s\">"
661 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
662 "border=\"0\"><span class=\"navbar_link\">"
664 "</span></a></li>\n", buf, _("Edit this page")
669 "<li class=\"newmess\">"
670 "<a href=\"display_enter\">"
671 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
672 "border=\"0\"><span class=\"navbar_link\">"
674 "</span></a></li>\n", _("Write mail")
679 "<li class=\"newmess\">"
680 "<a href=\"display_enter\">"
681 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
682 "border=\"0\"><span class=\"navbar_link\">"
684 "</span></a></li>\n", _("Enter a message")
690 if (navbar_style == navbar_default) wprintf(
691 "<li class=\"skipthisroom\">"
694 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
695 "<span class=\"navbar_link\">%s</span></a>"
697 _("Leave all messages marked as unread, go to next room with unread messages"),
701 if (navbar_style == navbar_default) wprintf(
702 "<li class=\"markngo\">"
703 "<a href=\"gotonext\" "
705 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
706 "<span class=\"navbar_link\">%s</span></a>"
708 _("Mark all messages as read, go to next room with unread messages"),
712 wprintf("</ul></div>\n");
719 * \brief back end routine to take the session to a new room
720 * \param gname room to go to
723 int gotoroom(char *gname)
726 static long ls = (-1L);
729 /** store ungoto information */
730 strcpy(WC->ugname, WC->wc_roomname);
733 /** move to the new room */
734 serv_printf("GOTO %s", gname);
735 serv_getln(buf, sizeof buf);
739 serv_puts("GOTO _BASEROOM_");
740 serv_getln(buf, sizeof buf);
747 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
748 WC->room_flags = extract_int(&buf[4], 4);
749 /* highest_msg_read = extract_int(&buf[4],6);
750 maxmsgnum = extract_int(&buf[4],5);
752 WC->is_mailbox = extract_int(&buf[4],7);
753 ls = extract_long(&buf[4], 6);
754 WC->wc_floor = extract_int(&buf[4], 10);
755 WC->wc_view = extract_int(&buf[4], 11);
756 WC->wc_default_view = extract_int(&buf[4], 12);
757 WC->wc_is_trash = extract_int(&buf[4], 13);
758 WC->room_flags2 = extract_int(&buf[4], 14);
761 WC->is_room_aide = WC->is_aide;
763 WC->is_room_aide = (char) extract_int(&buf[4], 8);
765 remove_march(WC->wc_roomname);
766 if (!strcasecmp(gname, "_BASEROOM_"))
774 * \brief Locate the room on the march list which we most want to go to.
776 * is measured given a "weight" of preference based on various factors.
777 * \param desired_floor the room number on the citadel server
778 * \return the roomname
780 char *pop_march(int desired_floor)
782 static char TheRoom[128];
784 int TheOrder = 32767;
787 struct march *mptr = NULL;
789 strcpy(TheRoom, "_BASEROOM_");
790 if (WC->march == NULL)
793 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
795 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
796 weight = weight + 10000;
797 if (mptr->march_floor == desired_floor)
798 weight = weight + 5000;
800 weight = weight + ((128 - (mptr->march_floor)) * 128);
801 weight = weight + (128 - (mptr->march_order));
803 if (weight > TheWeight) {
805 strcpy(TheRoom, mptr->march_name);
806 TheFloor = mptr->march_floor;
807 TheOrder = mptr->march_order;
816 *\brief Goto next room having unread messages.
817 * We want to skip over rooms that the user has already been to, and take the
818 * user back to the lobby when done. The room we end up in is placed in
819 * newroom - which is set to 0 (the lobby) initially.
820 * We start the search in the current room rather than the beginning to prevent
821 * two or more concurrent users from dragging each other back to the same room.
826 struct march *mptr, *mptr2;
831 * First check to see if the march-mode list is already allocated.
832 * If it is, pop the first room off the list and go there.
835 if (WC->march == NULL) {
837 serv_getln(buf, sizeof buf);
839 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
840 extract_token(room_name, buf, 0, '|', sizeof room_name);
841 if (strcasecmp(room_name, WC->wc_roomname)) {
842 mptr = (struct march *) malloc(sizeof(struct march));
844 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
845 mptr->march_floor = extract_int(buf, 2);
846 mptr->march_order = extract_int(buf, 3);
847 if (WC->march == NULL) {
851 while (mptr2->next != NULL)
858 * add _BASEROOM_ to the end of the march list, so the user will end up
859 * in the system base room (usually the Lobby>) at the end of the loop
861 mptr = (struct march *) malloc(sizeof(struct march));
863 strcpy(mptr->march_name, "_BASEROOM_");
864 if (WC->march == NULL) {
868 while (mptr2->next != NULL)
873 * ...and remove the room we're currently in, so a <G>oto doesn't make us
874 * walk around in circles
876 remove_march(WC->wc_roomname);
878 if (WC->march != NULL) {
879 strcpy(next_room, pop_march(-1));
881 strcpy(next_room, "_BASEROOM_");
885 smart_goto(next_room);
890 * \brief goto next room
891 * \param next_room next room to go to
893 void smart_goto(char *next_room) {
901 * \brief mark all messages in current room as having been read
903 void slrp_highest(void)
907 serv_puts("SLRP HIGHEST");
908 serv_getln(buf, sizeof buf);
913 * \brief un-goto the previous room
919 if (!strcmp(WC->ugname, "")) {
920 smart_goto(WC->wc_roomname);
923 serv_printf("GOTO %s", WC->ugname);
924 serv_getln(buf, sizeof buf);
926 smart_goto(WC->wc_roomname);
929 if (WC->uglsn >= 0L) {
930 serv_printf("SLRP %ld", WC->uglsn);
931 serv_getln(buf, sizeof buf);
933 strcpy(buf, WC->ugname);
934 strcpy(WC->ugname, "");
943 * \brief Set/clear/read the "self-service list subscribe" flag for a room
945 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
946 * \return return the new value.
949 int self_service(int newval) {
950 int current_value = 0;
956 int flags, floor, order, view, flags2;
959 serv_getln(buf, sizeof buf);
960 if (buf[0] != '2') return(0);
962 extract_token(name, &buf[4], 0, '|', sizeof name);
963 extract_token(password, &buf[4], 1, '|', sizeof password);
964 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
965 flags = extract_int(&buf[4], 3);
966 floor = extract_int(&buf[4], 4);
967 order = extract_int(&buf[4], 5);
968 view = extract_int(&buf[4], 6);
969 flags2 = extract_int(&buf[4], 7);
971 if (flags2 & QR2_SELFLIST) {
979 flags2 = flags2 | QR2_SELFLIST;
981 else if (newval == 0) {
982 flags2 = flags2 & ~QR2_SELFLIST;
985 return(current_value);
988 if (newval != current_value) {
989 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
990 name, password, dirname, flags,
991 floor, order, view, flags2);
992 serv_getln(buf, sizeof buf);
1005 * \brief display the form for editing a room
1007 void display_editroom(void)
1012 char remote_room[128];
1015 char er_password[10];
1016 char er_dirname[15];
1017 char er_roomaide[26];
1024 char *not_shared_with;
1027 int floorpolicy = 0;
1031 if (strlen(tab) == 0) tab = "admin";
1035 serv_getln(buf, sizeof buf);
1037 if (buf[0] != '2') {
1038 strcpy(WC->ImportantMessage, &buf[4]);
1039 display_main_menu();
1042 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1043 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1044 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1045 er_flags = extract_int(&buf[4], 3);
1046 er_floor = extract_int(&buf[4], 4);
1047 er_flags2 = extract_int(&buf[4], 7);
1049 output_headers(1, 1, 1, 0, 0, 0);
1051 /** print the tabbed dialog */
1053 "<div class=\"fix_scrollbar_bug\">"
1054 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
1056 "<TD> </TD>\n");
1058 if (!strcmp(tab, "admin")) {
1059 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1062 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1064 wprintf(_("Administration"));
1065 if (!strcmp(tab, "admin")) {
1066 wprintf("</SPAN></TD>\n");
1069 wprintf("</A></TD>\n");
1072 wprintf("<TD> </TD>\n");
1074 if (!strcmp(tab, "config")) {
1075 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1078 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=config\">");
1080 wprintf(_("Configuration"));
1081 if (!strcmp(tab, "config")) {
1082 wprintf("</SPAN></TD>\n");
1085 wprintf("</A></TD>\n");
1088 wprintf("<TD> </TD>\n");
1090 if (!strcmp(tab, "expire")) {
1091 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1094 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1096 wprintf(_("Message expire policy"));
1097 if (!strcmp(tab, "expire")) {
1098 wprintf("</SPAN></TD>\n");
1101 wprintf("</A></TD>\n");
1104 wprintf("<TD> </TD>\n");
1106 if (!strcmp(tab, "access")) {
1107 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1110 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=access\">");
1112 wprintf(_("Access controls"));
1113 if (!strcmp(tab, "access")) {
1114 wprintf("</SPAN></TD>\n");
1117 wprintf("</A></TD>\n");
1120 wprintf("<TD> </TD>\n");
1122 if (!strcmp(tab, "sharing")) {
1123 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1126 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1128 wprintf(_("Sharing"));
1129 if (!strcmp(tab, "sharing")) {
1130 wprintf("</SPAN></TD>\n");
1133 wprintf("</A></TD>\n");
1136 wprintf("<TD> </TD>\n");
1138 if (!strcmp(tab, "listserv")) {
1139 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1142 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1144 wprintf(_("Mailing list service"));
1145 if (!strcmp(tab, "listserv")) {
1146 wprintf("</SPAN></TD>\n");
1149 wprintf("</A></TD>\n");
1152 wprintf("<TD> </TD>\n");
1154 wprintf("</TR></TABLE></div>\n");
1155 /** end tabbed dialog */
1157 /** begin content of whatever tab is open now */
1158 wprintf("<div class=\"fix_scrollbar_bug\">"
1159 "<TABLE class=\"roomops_background\">\n"
1162 if (!strcmp(tab, "admin")) {
1164 "<LI><a href=\"delete_room\" "
1165 "onClick=\"return confirm('");
1166 wprintf(_("Are you sure you want to delete this room?"));
1167 wprintf("');\">\n");
1168 wprintf(_("Delete this room"));
1170 "<LI><a href=\"display_editroompic\">\n");
1171 wprintf(_("Set or change the icon for this room's banner"));
1173 "<LI><a href=\"display_editinfo\">\n");
1174 wprintf(_("Edit this room's Info file"));
1179 if (!strcmp(tab, "config")) {
1180 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1182 wprintf("<UL><LI>");
1183 wprintf(_("Name of room: "));
1184 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1190 wprintf(_("Resides on floor: "));
1191 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1192 for (i = 0; i < 128; ++i)
1193 if (strlen(floorlist[i]) > 0) {
1194 wprintf("<OPTION ");
1196 wprintf("SELECTED ");
1197 wprintf("VALUE=\"%d\">", i);
1198 escputs(floorlist[i]);
1199 wprintf("</OPTION>\n");
1201 wprintf("</SELECT>\n");
1204 wprintf(_("Type of room:"));
1207 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1208 if ((er_flags & QR_PRIVATE) == 0)
1209 wprintf("CHECKED ");
1211 wprintf(_("Public (automatically appears to everyone)"));
1214 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1215 if ((er_flags & QR_PRIVATE) &&
1216 (er_flags & QR_GUESSNAME))
1217 wprintf("CHECKED ");
1219 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1221 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1222 if ((er_flags & QR_PRIVATE) &&
1223 (er_flags & QR_PASSWORDED))
1224 wprintf("CHECKED ");
1226 wprintf(_("Private - require password: "));
1227 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1230 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1231 if ((er_flags & QR_PRIVATE)
1232 && ((er_flags & QR_GUESSNAME) == 0)
1233 && ((er_flags & QR_PASSWORDED) == 0))
1234 wprintf("CHECKED ");
1236 wprintf(_("Private - invitation only"));
1238 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1240 wprintf(_("If private, cause current users to forget room"));
1242 wprintf("\n</UL>\n");
1244 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1245 if (er_flags & QR_PREFONLY)
1246 wprintf("CHECKED ");
1248 wprintf(_("Preferred users only"));
1250 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1251 if (er_flags & QR_READONLY)
1252 wprintf("CHECKED ");
1254 wprintf(_("Read-only room"));
1256 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1257 if (er_flags2 & QR2_COLLABDEL)
1258 wprintf("CHECKED ");
1260 wprintf(_("All users allowed to post may also delete messages"));
1262 /** directory stuff */
1263 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1264 if (er_flags & QR_DIRECTORY)
1265 wprintf("CHECKED ");
1267 wprintf(_("File directory room"));
1269 wprintf("\n<UL><LI>");
1270 wprintf(_("Directory name: "));
1271 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1274 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1275 if (er_flags & QR_UPLOAD)
1276 wprintf("CHECKED ");
1278 wprintf(_("Uploading allowed"));
1280 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1281 if (er_flags & QR_DOWNLOAD)
1282 wprintf("CHECKED ");
1284 wprintf(_("Downloading allowed"));
1286 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1287 if (er_flags & QR_VISDIR)
1288 wprintf("CHECKED ");
1290 wprintf(_("Visible directory"));
1293 /** end of directory stuff */
1295 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1296 if (er_flags & QR_NETWORK)
1297 wprintf("CHECKED ");
1299 wprintf(_("Network shared room"));
1301 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1302 if (er_flags & QR_PERMANENT)
1303 wprintf("CHECKED ");
1305 wprintf(_("Permanent (does not auto-purge)"));
1307 /** start of anon options */
1310 wprintf(_("Anonymous messages"));
1313 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1314 if (((er_flags & QR_ANONONLY) == 0)
1315 && ((er_flags & QR_ANONOPT) == 0))
1316 wprintf("CHECKED ");
1318 wprintf(_("No anonymous messages"));
1320 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1321 if (er_flags & QR_ANONONLY)
1322 wprintf("CHECKED ");
1324 wprintf(_("All messages are anonymous"));
1326 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1327 if (er_flags & QR_ANONOPT)
1328 wprintf("CHECKED ");
1330 wprintf(_("Prompt user when entering messages"));
1333 /* end of anon options */
1336 wprintf(_("Room aide: "));
1338 serv_getln(buf, sizeof buf);
1339 if (buf[0] != '2') {
1340 wprintf("<em>%s</em>\n", &buf[4]);
1342 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1343 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1346 wprintf("</UL><CENTER>\n");
1347 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1348 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1350 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1358 /** Sharing the room with other Citadel nodes... */
1359 if (!strcmp(tab, "sharing")) {
1361 shared_with = strdup("");
1362 not_shared_with = strdup("");
1364 /** Learn the current configuration */
1365 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1366 serv_getln(buf, sizeof buf);
1367 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1368 extract_token(node, buf, 0, '|', sizeof node);
1369 not_shared_with = realloc(not_shared_with,
1370 strlen(not_shared_with) + 32);
1371 strcat(not_shared_with, node);
1372 strcat(not_shared_with, "\n");
1376 serv_getln(buf, sizeof buf);
1377 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1378 extract_token(cmd, buf, 0, '|', sizeof cmd);
1379 extract_token(node, buf, 1, '|', sizeof node);
1380 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1381 if (!strcasecmp(cmd, "ignet_push_share")) {
1382 shared_with = realloc(shared_with,
1383 strlen(shared_with) + 32);
1384 strcat(shared_with, node);
1385 if (strlen(remote_room) > 0) {
1386 strcat(shared_with, "|");
1387 strcat(shared_with, remote_room);
1389 strcat(shared_with, "\n");
1393 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1394 extract_token(buf, shared_with, i, '\n', sizeof buf);
1395 extract_token(node, buf, 0, '|', sizeof node);
1396 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1397 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1398 if (!strcasecmp(node, cmd)) {
1399 remove_token(not_shared_with, j, '\n');
1404 /** Display the stuff */
1405 wprintf("<CENTER><br />"
1406 "<TABLE border=1 cellpadding=5><TR>"
1408 wprintf(_("Shared with"));
1409 wprintf("</I></B></TD>"
1411 wprintf(_("Not shared with"));
1412 wprintf("</I></B></TD></TR>\n"
1413 "<TR><TD VALIGN=TOP>\n");
1415 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1416 wprintf(_("Remote node name"));
1417 wprintf("</TD><TD>");
1418 wprintf(_("Remote room name"));
1419 wprintf("</TD><TD>");
1420 wprintf(_("Actions"));
1421 wprintf("</TD></TR>\n");
1423 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1424 extract_token(buf, shared_with, i, '\n', sizeof buf);
1425 extract_token(node, buf, 0, '|', sizeof node);
1426 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1427 if (strlen(node) > 0) {
1428 wprintf("<FORM METHOD=\"POST\" "
1429 "action=\"netedit\">"
1430 "<TR><TD>%s</TD>\n", node);
1433 if (strlen(remote_room) > 0) {
1434 escputs(remote_room);
1440 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1441 "VALUE=\"ignet_push_share|");
1443 if (strlen(remote_room) > 0) {
1445 urlescputs(remote_room);
1448 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1449 "VALUE=\"sharing\">\n");
1450 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1451 "VALUE=\"remove\">\n");
1452 wprintf("<INPUT TYPE=\"submit\" "
1453 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1454 wprintf("</TD></TR></FORM>\n");
1458 wprintf("</TABLE>\n");
1459 wprintf("</TD><TD VALIGN=TOP>\n");
1460 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1461 wprintf(_("Remote node name"));
1462 wprintf("</TD><TD>");
1463 wprintf(_("Remote room name"));
1464 wprintf("</TD><TD>");
1465 wprintf(_("Actions"));
1466 wprintf("</TD></TR>\n");
1468 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1469 extract_token(node, not_shared_with, i, '\n', sizeof node);
1470 if (strlen(node) > 0) {
1471 wprintf("<FORM METHOD=\"POST\" "
1472 "action=\"netedit\">"
1476 "<INPUT TYPE=\"INPUT\" "
1480 wprintf("<INPUT TYPE=\"hidden\" "
1482 "VALUE=\"ignet_push_share|");
1485 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1486 "VALUE=\"sharing\">\n");
1487 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1488 "VALUE=\"add\">\n");
1489 wprintf("<INPUT TYPE=\"submit\" "
1490 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1491 wprintf("</TD></TR></FORM>\n");
1495 wprintf("</TABLE>\n");
1496 wprintf("</TD></TR>"
1497 "</TABLE></CENTER><br />\n"
1498 "<I><B>%s</B><UL><LI>", _("Notes:"));
1499 wprintf(_("When sharing a room, "
1500 "it must be shared from both ends. Adding a node to "
1501 "the 'shared' list sends messages out, but in order to"
1502 " receive messages, the other nodes must be configured"
1503 " to send messages out to your system as well. "
1504 "<LI>If the remote room name is blank, it is assumed "
1505 "that the room name is identical on the remote node."
1506 "<LI>If the remote room name is different, the remote "
1507 "node must also configure the name of the room here."
1513 /** Mailing list management */
1514 if (!strcmp(tab, "listserv")) {
1516 wprintf("<br /><center>"
1517 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1518 "<TR><TD VALIGN=TOP>");
1520 wprintf(_("<i>The contents of this room are being "
1521 "mailed <b>as individual messages</b> "
1522 "to the following list recipients:"
1523 "</i><br /><br />\n"));
1526 serv_getln(buf, sizeof buf);
1527 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1528 extract_token(cmd, buf, 0, '|', sizeof cmd);
1529 if (!strcasecmp(cmd, "listrecp")) {
1530 extract_token(recp, buf, 1, '|', sizeof recp);
1533 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1536 wprintf(_("(remove)"));
1537 wprintf("</A><br />");
1540 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1541 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1542 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1543 wprintf("<INPUT TYPE=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1544 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1545 wprintf("</FORM>\n");
1547 wprintf("</TD><TD VALIGN=TOP>\n");
1549 wprintf(_("<i>The contents of this room are being "
1550 "mailed <b>in digest form</b> "
1551 "to the following list recipients:"
1552 "</i><br /><br />\n"));
1555 serv_getln(buf, sizeof buf);
1556 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1557 extract_token(cmd, buf, 0, '|', sizeof cmd);
1558 if (!strcasecmp(cmd, "digestrecp")) {
1559 extract_token(recp, buf, 1, '|', sizeof recp);
1562 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1566 wprintf(_("(remove)"));
1567 wprintf("</A><br />");
1570 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1571 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1572 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1573 wprintf("<INPUT TYPE=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1574 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1575 wprintf("</FORM>\n");
1577 wprintf("</TD></TR></TABLE>\n");
1579 /** Pop open an address book -- begin **/
1580 wprintf("<div align=right>"
1581 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1583 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1588 _("Add recipients from Contacts or other address books"),
1589 _("Add recipients from Contacts or other address books")
1591 /** Pop open an address book -- end **/
1594 if (self_service(999) == 1) {
1595 wprintf(_("This room is configured to allow "
1596 "self-service subscribe/unsubscribe requests."));
1597 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1598 wprintf(_("Click to disable."));
1599 wprintf("</A><br />\n");
1600 wprintf(_("The URL for subscribe/unsubscribe is: "));
1601 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1602 (is_https ? "https" : "http"),
1606 wprintf(_("This room is <i>not</i> configured to allow "
1607 "self-service subscribe/unsubscribe requests."));
1608 wprintf(" <a href=\"toggle_self_service?newval=1&"
1610 wprintf(_("Click to enable."));
1611 wprintf("</A><br />\n");
1615 wprintf("</CENTER>\n");
1619 /** Mailing list management */
1620 if (!strcmp(tab, "expire")) {
1622 serv_puts("GPEX room");
1623 serv_getln(buf, sizeof buf);
1624 if (buf[0] == '2') {
1625 roompolicy = extract_int(&buf[4], 0);
1626 roomvalue = extract_int(&buf[4], 1);
1629 serv_puts("GPEX floor");
1630 serv_getln(buf, sizeof buf);
1631 if (buf[0] == '2') {
1632 floorpolicy = extract_int(&buf[4], 0);
1633 floorvalue = extract_int(&buf[4], 1);
1636 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1637 wprintf("<TABLE border=0 cellspacing=5>\n");
1638 wprintf("<TR><TD>");
1639 wprintf(_("Message expire policy for this room"));
1641 escputs(WC->wc_roomname);
1642 wprintf(")</TD><TD>");
1643 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1644 ((roompolicy == 0) ? "CHECKED" : "") );
1645 wprintf(_("Use the default policy for this floor"));
1646 wprintf("<br />\n");
1647 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1648 ((roompolicy == 1) ? "CHECKED" : "") );
1649 wprintf(_("Never automatically expire messages"));
1650 wprintf("<br />\n");
1651 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1652 ((roompolicy == 2) ? "CHECKED" : "") );
1653 wprintf(_("Expire by message count"));
1654 wprintf("<br />\n");
1655 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1656 ((roompolicy == 3) ? "CHECKED" : "") );
1657 wprintf(_("Expire by message age"));
1659 wprintf(_("Number of messages or days: "));
1660 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1661 wprintf("</TD></TR>\n");
1663 if (WC->axlevel >= 6) {
1664 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1665 wprintf("<TR><TD>");
1666 wprintf(_("Message expire policy for this floor"));
1668 escputs(floorlist[WC->wc_floor]);
1669 wprintf(")</TD><TD>");
1670 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1671 ((floorpolicy == 0) ? "CHECKED" : "") );
1672 wprintf(_("Use the system default"));
1673 wprintf("<br />\n");
1674 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1675 ((floorpolicy == 1) ? "CHECKED" : "") );
1676 wprintf(_("Never automatically expire messages"));
1677 wprintf("<br />\n");
1678 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1679 ((floorpolicy == 2) ? "CHECKED" : "") );
1680 wprintf(_("Expire by message count"));
1681 wprintf("<br />\n");
1682 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1683 ((floorpolicy == 3) ? "CHECKED" : "") );
1684 wprintf(_("Expire by message age"));
1686 wprintf(_("Number of messages or days: "));
1687 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1691 wprintf("<CENTER>\n");
1692 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1693 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1695 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1696 wprintf("</CENTER></TD><TR>\n");
1698 wprintf("</TABLE>\n"
1699 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1705 /** Mailing list management */
1706 if (!strcmp(tab, "access")) {
1710 /** end content of whatever tab is open now */
1711 wprintf("</TD></TR></TABLE></div>\n");
1713 address_book_popup();
1719 * \brief Toggle self-service list subscription
1721 void toggle_self_service(void) {
1724 newval = atoi(bstr("newval"));
1725 self_service(newval);
1732 * \brief save new parameters for a room
1738 char er_password[10];
1739 char er_dirname[15];
1740 char er_roomaide[26];
1743 int er_listingorder;
1749 if (strlen(bstr("ok_button")) == 0) {
1750 strcpy(WC->ImportantMessage,
1751 _("Cancelled. Changes were not saved."));
1756 serv_getln(buf, sizeof buf);
1758 if (buf[0] != '2') {
1759 strcpy(WC->ImportantMessage, &buf[4]);
1763 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1764 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1765 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1766 er_flags = extract_int(&buf[4], 3);
1767 er_listingorder = extract_int(&buf[4], 5);
1768 er_defaultview = extract_int(&buf[4], 6);
1769 er_flags2 = extract_int(&buf[4], 7);
1771 strcpy(er_roomaide, bstr("er_roomaide"));
1772 if (strlen(er_roomaide) == 0) {
1774 serv_getln(buf, sizeof buf);
1775 if (buf[0] != '2') {
1776 strcpy(er_roomaide, "");
1778 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1781 strcpy(buf, bstr("er_name"));
1783 if (strlen(buf) > 0) {
1784 strcpy(er_name, buf);
1787 strcpy(buf, bstr("er_password"));
1789 if (strlen(buf) > 0)
1790 strcpy(er_password, buf);
1792 strcpy(buf, bstr("er_dirname"));
1794 if (strlen(buf) > 0)
1795 strcpy(er_dirname, buf);
1797 strcpy(buf, bstr("type"));
1798 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1800 if (!strcmp(buf, "invonly")) {
1801 er_flags |= (QR_PRIVATE);
1803 if (!strcmp(buf, "hidden")) {
1804 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1806 if (!strcmp(buf, "passworded")) {
1807 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1809 if (!strcmp(bstr("prefonly"), "yes")) {
1810 er_flags |= QR_PREFONLY;
1812 er_flags &= ~QR_PREFONLY;
1815 if (!strcmp(bstr("readonly"), "yes")) {
1816 er_flags |= QR_READONLY;
1818 er_flags &= ~QR_READONLY;
1821 if (!strcmp(bstr("collabdel"), "yes")) {
1822 er_flags2 |= QR2_COLLABDEL;
1824 er_flags2 &= ~QR2_COLLABDEL;
1827 if (!strcmp(bstr("permanent"), "yes")) {
1828 er_flags |= QR_PERMANENT;
1830 er_flags &= ~QR_PERMANENT;
1833 if (!strcmp(bstr("network"), "yes")) {
1834 er_flags |= QR_NETWORK;
1836 er_flags &= ~QR_NETWORK;
1839 if (!strcmp(bstr("directory"), "yes")) {
1840 er_flags |= QR_DIRECTORY;
1842 er_flags &= ~QR_DIRECTORY;
1845 if (!strcmp(bstr("ulallowed"), "yes")) {
1846 er_flags |= QR_UPLOAD;
1848 er_flags &= ~QR_UPLOAD;
1851 if (!strcmp(bstr("dlallowed"), "yes")) {
1852 er_flags |= QR_DOWNLOAD;
1854 er_flags &= ~QR_DOWNLOAD;
1857 if (!strcmp(bstr("visdir"), "yes")) {
1858 er_flags |= QR_VISDIR;
1860 er_flags &= ~QR_VISDIR;
1863 strcpy(buf, bstr("anon"));
1865 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1866 if (!strcmp(buf, "anononly"))
1867 er_flags |= QR_ANONONLY;
1868 if (!strcmp(buf, "anon2"))
1869 er_flags |= QR_ANONOPT;
1872 if (!strcmp(bstr("bump"), "yes"))
1875 er_floor = atoi(bstr("er_floor"));
1877 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
1878 er_name, er_password, er_dirname, er_flags, bump, er_floor,
1879 er_listingorder, er_defaultview, er_flags2);
1881 serv_getln(buf, sizeof buf);
1882 if (buf[0] != '2') {
1883 strcpy(WC->ImportantMessage, &buf[4]);
1889 if (strlen(er_roomaide) > 0) {
1890 sprintf(buf, "SETA %s", er_roomaide);
1892 serv_getln(buf, sizeof buf);
1893 if (buf[0] != '2') {
1894 strcpy(WC->ImportantMessage, &buf[4]);
1895 display_main_menu();
1900 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1907 * \brief Display form for Invite, Kick, and show Who Knows a room
1909 void do_invt_kick(void) {
1910 char buf[SIZ], room[SIZ], username[SIZ];
1913 serv_getln(buf, sizeof buf);
1915 if (buf[0] != '2') {
1919 extract_token(room, &buf[4], 0, '|', sizeof room);
1921 strcpy(username, bstr("username"));
1923 if (strlen(bstr("kick_button")) > 0) {
1924 sprintf(buf, "KICK %s", username);
1926 serv_getln(buf, sizeof buf);
1928 if (buf[0] != '2') {
1929 strcpy(WC->ImportantMessage, &buf[4]);
1931 sprintf(WC->ImportantMessage,
1932 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1937 if (strlen(bstr("invite_button")) > 0) {
1938 sprintf(buf, "INVT %s", username);
1940 serv_getln(buf, sizeof buf);
1942 if (buf[0] != '2') {
1943 strcpy(WC->ImportantMessage, &buf[4]);
1945 sprintf(WC->ImportantMessage,
1946 _("<B><I>User %s invited to room %s.</I></B>\n"),
1957 * \brief Display form for Invite, Kick, and show Who Knows a room
1959 void display_whok(void)
1961 char buf[SIZ], room[SIZ], username[SIZ];
1964 serv_getln(buf, sizeof buf);
1966 if (buf[0] != '2') {
1970 extract_token(room, &buf[4], 0, '|', sizeof room);
1973 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1974 wprintf(_("The users listed below have access to this room. "
1975 "To remove a user from the access list, select the user "
1976 "name from the list and click 'Kick'."));
1977 wprintf("<br /><br />");
1979 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1980 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1981 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
1983 serv_getln(buf, sizeof buf);
1984 if (buf[0] == '1') {
1985 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1986 extract_token(username, buf, 0, '|', sizeof username);
1987 wprintf("<OPTION>");
1992 wprintf("</SELECT><br />\n");
1994 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
1995 wprintf("</FORM></CENTER>\n");
1997 wprintf("</TD><TD>");
1998 wprintf(_("To grant another user access to this room, enter the "
1999 "user name in the box below and click 'Invite'."));
2000 wprintf("<br /><br />");
2002 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
2003 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2004 wprintf(_("Invite:"));
2006 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
2007 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2008 "<input type=\"submit\" value=\"%s\">"
2009 "</FORM></CENTER>\n", _("Invite"));
2011 wprintf("</TD></TR></TABLE>\n");
2018 * \brief display the form for entering a new room
2020 void display_entroom(void)
2025 serv_puts("CRE8 0");
2026 serv_getln(buf, sizeof buf);
2028 if (buf[0] != '2') {
2029 strcpy(WC->ImportantMessage, &buf[4]);
2030 display_main_menu();
2034 output_headers(1, 1, 2, 0, 0, 0);
2035 wprintf("<div id=\"banner\">\n"
2036 "<TABLE class=\"roomops_banner\"><TR><TD>"
2037 "<SPAN CLASS=\"titlebar\">");
2038 wprintf(_("Create a new room"));
2040 "</TD></TR></TABLE>\n"
2041 "</div>\n<div id=\"content\">\n"
2044 wprintf("<div class=\"fix_scrollbar_bug\">"
2045 "<table class=\"roomops_background\"><tr><td>\n");
2047 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2049 wprintf("<UL><LI>");
2050 wprintf(_("Name of room: "));
2051 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2054 wprintf(_("Resides on floor: "));
2056 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
2057 for (i = 0; i < 128; ++i)
2058 if (strlen(floorlist[i]) > 0) {
2059 wprintf("<OPTION ");
2060 wprintf("VALUE=\"%d\">", i);
2061 escputs(floorlist[i]);
2062 wprintf("</OPTION>\n");
2064 wprintf("</SELECT>\n");
2067 * Our clever little snippet of JavaScript automatically selects
2068 * a public room if the view is set to Bulletin Board or wiki, and
2069 * it selects a mailbox room otherwise. The user can override this,
2070 * of course. We also disable the floor selector for mailboxes.
2073 wprintf(_("Default view for room: "));
2074 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
2075 " if ( (this.form.er_view.value == 0) "
2076 " || (this.form.er_view.value == 6) ) { "
2077 " this.form.type[0].checked=true; "
2078 " this.form.er_floor.disabled = false; "
2081 " this.form.type[4].checked=true; "
2082 " this.form.er_floor.disabled = true; "
2085 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2086 if (is_view_allowed_as_default(i)) {
2087 wprintf("<OPTION %s VALUE=\"%d\">",
2088 ((i == 0) ? "SELECTED" : ""), i );
2089 escputs(viewdefs[i]);
2090 wprintf("</OPTION>\n");
2093 wprintf("</SELECT>\n");
2096 wprintf(_("Type of room:"));
2099 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2100 wprintf("CHECKED OnChange=\""
2101 " if (this.form.type[0].checked == true) { "
2102 " this.form.er_floor.disabled = false; "
2105 wprintf(_("Public (automatically appears to everyone)"));
2107 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2108 " if (this.form.type[1].checked == true) { "
2109 " this.form.er_floor.disabled = false; "
2112 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2114 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2115 " if (this.form.type[2].checked == true) { "
2116 " this.form.er_floor.disabled = false; "
2119 wprintf(_("Private - require password: "));
2120 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2122 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2123 " if (this.form.type[3].checked == true) { "
2124 " this.form.er_floor.disabled = false; "
2127 wprintf(_("Private - invitation only"));
2129 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2131 " if (this.form.type[4].checked == true) { "
2132 " this.form.er_floor.disabled = true; "
2135 wprintf(_("Personal (mailbox for you only)"));
2137 wprintf("\n</UL>\n");
2139 wprintf("<CENTER>\n");
2140 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2142 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2143 wprintf("</CENTER>\n");
2144 wprintf("</FORM>\n<hr />");
2145 serv_printf("MESG roomaccess");
2146 serv_getln(buf, sizeof buf);
2147 if (buf[0] == '1') {
2150 wprintf("</td></tr></table></div>\n");
2158 * \brief support function for entroom() -- sets the default view
2160 void er_set_default_view(int newview) {
2173 serv_getln(buf, sizeof buf);
2174 if (buf[0] != '2') return;
2176 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2177 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2178 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2179 rm_bits1 = extract_int(&buf[4], 3);
2180 rm_floor = extract_int(&buf[4], 4);
2181 rm_listorder = extract_int(&buf[4], 5);
2182 rm_bits2 = extract_int(&buf[4], 7);
2184 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2185 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2186 rm_listorder, newview, rm_bits2
2188 serv_getln(buf, sizeof buf);
2194 * \brief enter a new room
2201 char er_password[SIZ];
2206 if (strlen(bstr("ok_button")) == 0) {
2207 strcpy(WC->ImportantMessage,
2208 _("Cancelled. No new room was created."));
2209 display_main_menu();
2212 strcpy(er_name, bstr("er_name"));
2213 strcpy(er_type, bstr("type"));
2214 strcpy(er_password, bstr("er_password"));
2215 er_floor = atoi(bstr("er_floor"));
2216 er_view = atoi(bstr("er_view"));
2219 if (!strcmp(er_type, "hidden"))
2221 if (!strcmp(er_type, "passworded"))
2223 if (!strcmp(er_type, "invonly"))
2225 if (!strcmp(er_type, "personal"))
2228 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2229 er_name, er_num_type, er_password, er_floor, 0, er_view);
2231 serv_getln(buf, sizeof buf);
2232 if (buf[0] != '2') {
2233 strcpy(WC->ImportantMessage, &buf[4]);
2234 display_main_menu();
2238 do_change_view(er_view); /* Now go there */
2243 * \brief display the screen to enter a private room
2245 void display_private(char *rname, int req_pass)
2247 output_headers(1, 1, 2, 0, 0, 0);
2248 wprintf("<div id=\"banner\">\n"
2249 "<TABLE class=\"roomops_banner\"><TR><TD>"
2250 "<SPAN CLASS=\"titlebar\">");
2251 wprintf(_("Go to a hidden room"));
2253 "</TD></TR></TABLE>\n"
2254 "</div>\n<div id=\"content\">\n"
2257 wprintf("<div class=\"fix_scrollbar_bug\">"
2258 "<table class=\"roomops_background\"><tr><td>\n");
2260 wprintf("<CENTER>\n");
2262 wprintf(_("If you know the name of a hidden (guess-name) or "
2263 "passworded room, you can enter that room by typing "
2264 "its name below. Once you gain access to a private "
2265 "room, it will appear in your regular room listings "
2266 "so you don't have to keep returning here."));
2267 wprintf("\n<br /><br />");
2269 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2271 wprintf("<table border=\"0\" cellspacing=\"5\" "
2272 "cellpadding=\"5\" class=\"roomops_background_alt\">\n"
2274 wprintf(_("Enter room name:"));
2276 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2277 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2280 wprintf("</TD></TR><TR><TD>");
2281 wprintf(_("Enter room password:"));
2282 wprintf("</TD><TD>");
2283 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2285 wprintf("</TD></TR></TABLE><br />\n");
2287 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2289 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2293 wprintf("</FORM>\n");
2294 wprintf("</td></tr></table></div>\n");
2299 * \brief goto a private room
2301 void goto_private(void)
2306 if (strlen(bstr("ok_button")) == 0) {
2307 display_main_menu();
2310 strcpy(hold_rm, WC->wc_roomname);
2311 strcpy(buf, "GOTO ");
2312 strcat(buf, bstr("gr_name"));
2314 strcat(buf, bstr("gr_pass"));
2316 serv_getln(buf, sizeof buf);
2318 if (buf[0] == '2') {
2319 smart_goto(bstr("gr_name"));
2322 if (!strncmp(buf, "540", 3)) {
2323 display_private(bstr("gr_name"), 1);
2326 output_headers(1, 1, 1, 0, 0, 0);
2327 wprintf("%s\n", &buf[4]);
2334 * \brief display the screen to zap a room
2336 void display_zap(void)
2338 output_headers(1, 1, 2, 0, 0, 0);
2340 wprintf("<div id=\"banner\">\n");
2341 wprintf("<TABLE class=\"roomops_zap\"><TR><TD>");
2342 wprintf("<SPAN CLASS=\"titlebar\">");
2343 wprintf(_("Zap (forget/unsubscribe) the current room"));
2344 wprintf("</SPAN>\n");
2345 wprintf("</TD></TR></TABLE>\n");
2346 wprintf("</div>\n<div id=\"content\">\n");
2348 wprintf(_("If you select this option, <em>%s</em> will "
2349 "disappear from your room list. Is this what you wish "
2350 "to do?<br />\n"), WC->wc_roomname);
2352 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2353 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2355 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2356 wprintf("</FORM>\n");
2367 char final_destination[SIZ];
2370 * If the forget-room routine fails for any reason, we fall back
2371 * to the current room; otherwise, we go to the Lobby
2373 strcpy(final_destination, WC->wc_roomname);
2375 if (strlen(bstr("ok_button")) > 0) {
2376 serv_printf("GOTO %s", WC->wc_roomname);
2377 serv_getln(buf, sizeof buf);
2378 if (buf[0] == '2') {
2380 serv_getln(buf, sizeof buf);
2381 if (buf[0] == '2') {
2382 strcpy(final_destination, "_BASEROOM_");
2386 smart_goto(final_destination);
2392 * \brief Delete the current room
2394 void delete_room(void)
2398 serv_puts("KILL 1");
2399 serv_getln(buf, sizeof buf);
2400 if (buf[0] != '2') {
2401 strcpy(WC->ImportantMessage, &buf[4]);
2402 display_main_menu();
2405 smart_goto("_BASEROOM_");
2412 * \brief Perform changes to a room's network configuration
2414 void netedit(void) {
2424 if (strlen(bstr("line"))==0) {
2429 strcpy(line, bstr("prefix"));
2430 strcat(line, bstr("line"));
2431 strcat(line, bstr("suffix"));
2440 serv_getln(buf, sizeof buf);
2441 if (buf[0] != '1') {
2447 /** This loop works for add *or* remove. Spiffy, eh? */
2448 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2449 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2450 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2451 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2452 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2453 if ( (strcasecmp(cmpa0, cmpb0))
2454 || (strcasecmp(cmpa1, cmpb1)) ) {
2455 fprintf(fp, "%s\n", buf);
2461 serv_getln(buf, sizeof buf);
2462 if (buf[0] != '4') {
2468 while (fgets(buf, sizeof buf, fp) != NULL) {
2469 buf[strlen(buf)-1] = 0;
2473 if (strlen(bstr("add_button")) > 0) {
2474 num_addrs = num_tokens(bstr("line"), ',');
2475 if (num_addrs < 2) {
2476 /* just adding one node or address */
2480 /* adding multiple addresses separated by commas */
2481 for (i=0; i<num_addrs; ++i) {
2482 strcpy(line, bstr("prefix"));
2483 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2486 strcat(line, bstr("suffix"));
2500 * \brief Convert a room name to a folder-ish-looking name.
2501 * \param folder the folderish name
2502 * \param room the room name
2503 * \param floor the floor name
2504 * \param is_mailbox is it a mailbox?
2506 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2511 * For mailboxes, just do it straight...
2514 sprintf(folder, "My folders|%s", room);
2518 * Otherwise, prefix the floor name as a "public folders" moniker
2521 sprintf(folder, "%s|%s", floorlist[floor], room);
2525 * Replace "\" characters with "|" for pseudo-folder-delimiting
2527 for (i=0; i<strlen(folder); ++i) {
2528 if (folder[i] == '\\') folder[i] = '|';
2536 * \brief Back end for change_view()
2537 * \param newview set newview???
2539 void do_change_view(int newview) {
2542 serv_printf("VIEW %d", newview);
2543 serv_getln(buf, sizeof buf);
2544 WC->wc_view = newview;
2545 smart_goto(WC->wc_roomname);
2551 * \brief Change the view for this room
2553 void change_view(void) {
2556 view = atol(bstr("view"));
2557 do_change_view(view);
2562 * \brief One big expanded tree list view --- like a folder list
2563 * \param fold the folder to view
2564 * \param max_folders how many folders???
2565 * \param num_floors hom many floors???
2567 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2571 int has_subfolders = 0;
2574 parents = malloc(max_folders * sizeof(int));
2576 /** BEGIN TREE MENU */
2577 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2579 /** include NanoTree */
2580 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2582 /** initialize NanoTree */
2583 wprintf("<script type=\"text/javascript\"> \n"
2584 " showRootNode = false; \n"
2585 " sortNodes = false; \n"
2586 " dragable = false; \n"
2588 " function standardClick(treeNode) { \n"
2591 " var closedGif = 'static/folder_closed.gif'; \n"
2592 " var openGif = 'static/folder_open.gif'; \n"
2594 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2598 for (i=0; i<max_folders; ++i) {
2601 if ((i+1) < max_folders) {
2602 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2603 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2608 levels = num_tokens(fold[i].name, '|');
2609 parents[levels] = i;
2611 wprintf("var node%d = new TreeNode(%d, '", i, i);
2613 if (fold[i].selectable) {
2614 wprintf("<a href=\"dotgoto?room=");
2615 urlescputs(fold[i].room);
2620 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2622 else if (fold[i].hasnewmsgs) {
2623 wprintf("<SPAN CLASS=\"roomlist_new\">");
2626 wprintf("<SPAN CLASS=\"roomlist_old\">");
2628 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2633 if (has_subfolders) {
2634 wprintf("new Array(closedGif, openGif)");
2636 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2637 wprintf("'static/viewcontacts_16x.gif'");
2639 else if (fold[i].view == VIEW_CALENDAR) {
2640 wprintf("'static/calarea_16x.gif'");
2642 else if (fold[i].view == VIEW_CALBRIEF) {
2643 wprintf("'static/calarea_16x.gif'");
2645 else if (fold[i].view == VIEW_TASKS) {
2646 wprintf("'static/taskmanag_16x.gif'");
2648 else if (fold[i].view == VIEW_NOTES) {
2649 wprintf("'static/storenotes_16x.gif'");
2651 else if (fold[i].view == VIEW_MAILBOX) {
2652 wprintf("'static/privatemess_16x.gif'");
2655 wprintf("'static/chatrooms_16x.gif'");
2658 urlescputs(fold[i].name);
2662 wprintf("rootNode.addChild(node%d);\n", i);
2665 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2669 wprintf("container = document.getElementById('roomlist_div'); \n"
2675 /** END TREE MENU */
2679 * \brief Boxes and rooms and lists ... oh my!
2680 * \param fold the folder to view
2681 * \param max_folders how many folders???
2682 * \param num_floors hom many floors???
2684 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2686 char floor_name[256];
2687 char old_floor_name[256];
2689 int levels, oldlevels;
2692 static int columns = 3;
2693 int boxes_per_column = 0;
2694 int current_column = 0;
2697 strcpy(floor_name, "");
2698 strcpy(old_floor_name, "");
2701 while (nf % columns != 0) ++nf;
2702 boxes_per_column = (nf / columns);
2703 if (boxes_per_column < 1) boxes_per_column = 1;
2705 /** Outer table (for columnization) */
2706 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2707 "<tr><td valign=top>");
2711 for (i=0; i<max_folders; ++i) {
2713 levels = num_tokens(fold[i].name, '|');
2714 extract_token(floor_name, fold[i].name, 0,
2715 '|', sizeof floor_name);
2717 if ( (strcasecmp(floor_name, old_floor_name))
2718 && (strlen(old_floor_name) > 0) ) {
2720 do_template("endbox");
2723 if ((num_boxes % boxes_per_column) == 0) {
2725 if (current_column < columns) {
2726 wprintf("</td><td valign=top>\n");
2730 strcpy(old_floor_name, floor_name);
2733 /** Begin inner box */
2734 stresc(boxtitle, floor_name, 1, 0);
2735 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2736 do_template("beginbox");
2743 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2744 if (fold[i].selectable) {
2745 wprintf("<a href=\"dotgoto?room=");
2746 urlescputs(fold[i].room);
2752 if (fold[i].hasnewmsgs) {
2753 wprintf("<SPAN CLASS=\"roomlist_new\">");
2756 wprintf("<SPAN CLASS=\"roomlist_old\">");
2758 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2761 if (fold[i].selectable) {
2767 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2768 wprintf(" (INBOX)");
2770 wprintf("<br />\n");
2773 /** End the final inner box */
2774 do_template("endbox");
2776 wprintf("</TD></TR></TABLE>\n");
2780 * \brief print a floor div???
2781 * \param which_floordiv name of the floordiv???
2783 void set_floordiv_expanded(char *which_floordiv) {
2784 begin_ajax_response();
2785 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2786 end_ajax_response();
2790 * \brief view the iconbar
2791 * \param fold the folder to view
2792 * \param max_folders how many folders???
2793 * \param num_floors hom many floors???
2795 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2797 char floor_name[256];
2798 char old_floor_name[256];
2799 char floordivtitle[256];
2800 char floordiv_id[32];
2801 int levels, oldlevels;
2803 int num_drop_targets = 0;
2806 strcpy(floor_name, "");
2807 strcpy(old_floor_name, "");
2811 for (i=0; i<max_folders; ++i) {
2813 levels = num_tokens(fold[i].name, '|');
2814 extract_token(floor_name, fold[i].name, 0,
2815 '|', sizeof floor_name);
2817 if ( (strcasecmp(floor_name, old_floor_name))
2818 && (strlen(old_floor_name) > 0) ) {
2819 /** End inner box */
2821 wprintf("</div>\n"); /** floordiv */
2823 strcpy(old_floor_name, floor_name);
2827 stresc(floordivtitle, floor_name, 0, 0);
2828 sprintf(floordiv_id, "floordiv%d", i);
2829 wprintf("<span class=\"ib_roomlist_floor\" "
2830 "onClick=\"expand_floor('%s')\">"
2831 "%s</span><br>\n", floordiv_id, floordivtitle);
2832 wprintf("<div id=\"%s\" style=\"display:%s\">",
2834 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2841 wprintf("<div id=\"roomdiv%d\">", i);
2843 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2845 /** choose the icon */
2846 if (fold[i].view == VIEW_ADDRESSBOOK) {
2847 icon = "viewcontacts_16x.gif" ;
2849 else if (fold[i].view == VIEW_CALENDAR) {
2850 icon = "calarea_16x.gif" ;
2852 else if (fold[i].view == VIEW_CALBRIEF) {
2853 icon = "calarea_16x.gif" ;
2855 else if (fold[i].view == VIEW_TASKS) {
2856 icon = "taskmanag_16x.gif" ;
2858 else if (fold[i].view == VIEW_NOTES) {
2859 icon = "storenotes_16x.gif" ;
2861 else if (fold[i].view == VIEW_MAILBOX) {
2862 icon = "privatemess_16x.gif" ;
2865 icon = "chatrooms_16x.gif" ;
2868 if (fold[i].selectable) {
2869 wprintf("<a href=\"dotgoto?room=");
2870 urlescputs(fold[i].room);
2872 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2877 if (fold[i].hasnewmsgs) {
2878 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2881 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2883 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2885 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2886 wprintf(" (INBOX)");
2889 if (fold[i].selectable) {
2896 wprintf("</div>\n"); /** roomdiv */
2899 wprintf("</div>\n"); /** floordiv */
2902 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2903 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2905 num_drop_targets = 0;
2907 for (i=0; i<max_folders; ++i) {
2908 levels = num_tokens(fold[i].name, '|');
2910 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2911 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2912 jsescputs(fold[i].room);
2918 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2919 if (strlen(WC->floordiv_expanded) > 1) {
2920 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2924 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2930 * \brief Show the room list.
2931 * (only should get called by
2932 * knrooms() because that's where output_headers() is called from)
2933 * \param viewpref the view preferences???
2936 void list_all_rooms_by_floor(char *viewpref) {
2939 struct folder *fold = NULL;
2941 int max_folders = 0;
2942 int alloc_folders = 0;
2946 int num_floors = 1; /** add an extra one for private folders */
2948 /** If our cached folder list is very old, burn it. */
2949 if (WC->cache_fold != NULL) {
2950 if ((time(NULL) - WC->cache_timestamp) > 300) {
2951 free(WC->cache_fold);
2952 WC->cache_fold = NULL;
2956 /** Can we do the iconbar roomlist from cache? */
2957 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2958 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2962 /** Grab the floor table so we know how to build the list... */
2965 /** Start with the mailboxes */
2968 fold = malloc(sizeof(struct folder));
2969 memset(fold, 0, sizeof(struct folder));
2970 strcpy(fold[0].name, "My folders");
2971 fold[0].is_mailbox = 1;
2973 /** Then add floors */
2975 serv_getln(buf, sizeof buf);
2976 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2977 if (max_folders >= alloc_folders) {
2978 alloc_folders = max_folders + 100;
2979 fold = realloc(fold,
2980 alloc_folders * sizeof(struct folder));
2982 memset(&fold[max_folders], 0, sizeof(struct folder));
2983 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
2988 /** refresh the messages index for this room */
2989 // serv_puts("GOTO ");
2990 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
2991 /** Now add rooms */
2993 serv_getln(buf, sizeof buf);
2994 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2995 if (max_folders >= alloc_folders) {
2996 alloc_folders = max_folders + 100;
2997 fold = realloc(fold,
2998 alloc_folders * sizeof(struct folder));
3000 memset(&fold[max_folders], 0, sizeof(struct folder));
3001 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3002 ra_flags = extract_int(buf, 5);
3003 flags = extract_int(buf, 1);
3004 fold[max_folders].floor = extract_int(buf, 2);
3005 fold[max_folders].hasnewmsgs =
3006 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3007 if (flags & QR_MAILBOX) {
3008 fold[max_folders].is_mailbox = 1;
3010 fold[max_folders].view = extract_int(buf, 6);
3011 room_to_folder(fold[max_folders].name,
3012 fold[max_folders].room,
3013 fold[max_folders].floor,
3014 fold[max_folders].is_mailbox);
3015 fold[max_folders].selectable = 1;
3019 /** Bubble-sort the folder list */
3020 for (i=0; i<max_folders; ++i) {
3021 for (j=0; j<(max_folders-1)-i; ++j) {
3022 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3023 swap = strcasecmp(fold[j].name, fold[j+1].name);
3026 if ( (fold[j+1].is_mailbox)
3027 && (!fold[j].is_mailbox)) {
3035 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3036 memcpy(&fold[j], &fold[j+1],
3037 sizeof(struct folder));
3038 memcpy(&fold[j+1], &ftmp,
3039 sizeof(struct folder));
3045 if (!strcasecmp(viewpref, "folders")) {
3046 do_folder_view(fold, max_folders, num_floors);
3048 else if (!strcasecmp(viewpref, "hackish_view")) {
3049 for (i=0; i<max_folders; ++i) {
3050 escputs(fold[i].name);
3051 wprintf("<br />\n");
3054 else if (!strcasecmp(viewpref, "iconbar")) {
3055 do_iconbar_view(fold, max_folders, num_floors);
3058 do_rooms_view(fold, max_folders, num_floors);
3061 /* Don't free the folder list ... cache it for future use! */
3062 if (WC->cache_fold != NULL) {
3063 free(WC->cache_fold);
3065 WC->cache_fold = fold;
3066 WC->cache_max_folders = max_folders;
3067 WC->cache_num_floors = num_floors;
3068 WC->cache_timestamp = time(NULL);
3073 * \brief Do either a known rooms list or a folders list, depending on the
3078 char listviewpref[SIZ];
3080 output_headers(1, 1, 2, 0, 0, 0);
3082 /** Determine whether the user is trying to change views */
3083 if (bstr("view") != NULL) {
3084 if (strlen(bstr("view")) > 0) {
3085 set_preference("roomlistview", bstr("view"), 1);
3089 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3091 if ( (strcasecmp(listviewpref, "folders"))
3092 && (strcasecmp(listviewpref, "table")) ) {
3093 strcpy(listviewpref, "rooms");
3097 wprintf("<div id=\"banner\">\n"
3098 "<TABLE class=\"roomops_banner\"><TR><TD>"
3099 "<SPAN CLASS=\"titlebar\">"
3101 if (!strcasecmp(listviewpref, "rooms")) {
3102 wprintf(_("Room list"));
3104 if (!strcasecmp(listviewpref, "folders")) {
3105 wprintf(_("Folder list"));
3107 if (!strcasecmp(listviewpref, "table")) {
3108 wprintf(_("Room list"));
3110 wprintf("</SPAN></TD>\n");
3112 /** offer the ability to switch views */
3113 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
3114 "<SELECT NAME=\"newview\" SIZE=\"1\" "
3115 "OnChange=\"location.href=roomlistomatic.newview.options"
3116 "[selectedIndex].value\">\n");
3118 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
3121 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3124 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
3125 "View as folder list"
3127 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3130 wprintf("</SELECT><br />");
3132 wprintf("</FORM></TD></TR></TABLE>\n");
3135 "<div id=\"content\">\n");
3137 /** Display the room list in the user's preferred format */
3138 list_all_rooms_by_floor(listviewpref);
3145 * \brief Set the message expire policy for this room and/or floor
3147 void set_room_policy(void) {
3150 if (strlen(bstr("ok_button")) == 0) {
3151 strcpy(WC->ImportantMessage,
3152 _("Cancelled. Changes were not saved."));
3157 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3158 serv_getln(buf, sizeof buf);
3159 strcpy(WC->ImportantMessage, &buf[4]);
3161 if (WC->axlevel >= 6) {
3162 strcat(WC->ImportantMessage, "<br />\n");
3163 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3164 serv_getln(buf, sizeof buf);
3165 strcat(WC->ImportantMessage, &buf[4]);