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 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
383 wprintf("<label for=\"view_name\">");
384 wprintf(_("View as:"));
386 "<select name=\"newview\" size=\"1\" "
387 "id=\"view_name\" class=\"selectbox\" "
388 "OnChange=\"location.href=viewomatic.newview.options"
389 "[selectedIndex].value\">\n");
391 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
393 * Only offer the views that make sense, given the default
394 * view for the room. For example, don't offer a Calendar
395 * view in a non-Calendar room.
399 || (i == WC->wc_default_view) /**< default */
400 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
401 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
402 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
405 wprintf("<option %s value=\"changeview?view=%d\">",
406 ((i == WC->wc_view) ? "selected" : ""),
408 escputs(viewdefs[i]);
409 wprintf("</option>\n");
412 wprintf("</select></form>\n");
417 * \brief Display a search box
419 void embed_search_o_matic(void) {
420 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
421 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
422 wprintf("<label for=\"search_name\">");
423 wprintf(_("Search: "));
424 wprintf("</label> <input "
425 "type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
426 "id=\"search_name\" class=\"inputbox\">\n"
428 wprintf("</select></form>\n");
433 * \brief Embed the room banner
435 * \param got The information returned from a GOTO server command
436 * \param navbar_style Determines which navigation buttons to display
440 void embed_room_banner(char *got, int navbar_style) {
442 char sanitized_roomname[256];
445 * We need to have the information returned by a GOTO server command.
446 * If it isn't supplied, we fake it by issuing our own GOTO.
449 serv_printf("GOTO %s", WC->wc_roomname);
450 serv_getln(buf, sizeof buf);
454 /** The browser needs some information for its own use */
455 wprintf("<script type=\"text/javascript\"> \n"
456 " room_is_trash = %d; \n"
462 * If the user happens to select the "make this my start page" link,
463 * we want it to remember the URL as a "/dotskip" one instead of
464 * a "skip" or "gotonext" or something like that.
466 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
469 /** Check for new mail. */
470 WC->new_mail = extract_int(&got[4], 9);
471 WC->wc_view = extract_int(&got[4], 11);
473 stresc(sanitized_roomname, WC->wc_roomname, 1, 1);
474 svprintf("ROOMNAME", WCS_STRING, "%s", sanitized_roomname);
475 svprintf("NUMMSGS", WCS_STRING,
476 _("%d new of %d messages"),
477 extract_int(&got[4], 1),
478 extract_int(&got[4], 2)
480 svcallback("ROOMPIC", embed_room_graphic);
481 svcallback("ROOMINFO", readinfo);
482 svcallback("VIEWOMATIC", embed_view_o_matic);
483 svcallback("SEARCHOMATIC", embed_search_o_matic);
484 svcallback("START", offer_start_page);
486 do_template("roombanner");
487 if (navbar_style != navbar_none) {
489 wprintf("<div id=\"navbar\"><ul>");
491 if (navbar_style == navbar_default) wprintf(
492 "<li class=\"ungoto\">"
493 "<a href=\"ungoto\">"
494 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
495 "<span class=\"navbar_link\">%s</span></A>"
496 "</li>\n", _("Ungoto")
499 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
501 "<li class=\"newmess\">"
502 "<a href=\"readnew\">"
503 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
504 "<span class=\"navbar_link\">%s</span></A>"
505 "</li>\n", _("Read new messages")
509 if (navbar_style == navbar_default) {
510 switch(WC->wc_view) {
511 case VIEW_ADDRESSBOOK:
513 "<li class=\"viewcontacts\">"
514 "<a href=\"readfwd\">"
515 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
517 "<span class=\"navbar_link\">"
519 "</span></a></li>\n", _("View contacts")
524 "<li class=\"staskday\">"
525 "<a href=\"readfwd?calview=day\">"
526 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
528 "<span class=\"navbar_link\">"
530 "</span></a></li>\n", _("Day view")
533 "<li class=\"monthview\">"
534 "<a href=\"readfwd?calview=month\">"
535 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
537 "<span class=\"navbar_link\">"
539 "</span></a></li>\n", _("Month view")
544 "<li class=\"monthview\">"
545 "<a href=\"readfwd?calview=month\">"
546 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
548 "<span class=\"navbar_link\">"
550 "</span></a></li>\n", _("Calendar list")
555 "<li class=\"taskmanag\">"
556 "<a href=\"readfwd\">"
557 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
559 "<span class=\"navbar_link\">"
561 "</span></a></li>\n", _("View tasks")
566 "<li class=\"viewnotes\">"
567 "<a href=\"readfwd\">"
568 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
570 "<span class=\"navbar_link\">"
572 "</span></a></li>\n", _("View notes")
577 "<li class=\"readallmess\">"
578 "<a href=\"readfwd\">"
579 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
581 "<span class=\"navbar_link\">"
583 "</span></a></li>\n", _("View message list")
588 "<li class=\"readallmess\">"
589 "<a href=\"readfwd\">"
590 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
592 "<span class=\"navbar_link\">"
594 "</span></a></li>\n", _("Wiki home")
599 "<li class=\"readallmess\">"
600 "<a href=\"readfwd\">"
601 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
603 "<span class=\"navbar_link\">"
605 "</span></a></li>\n", _("Read all messages")
611 if (navbar_style == navbar_default) {
612 switch(WC->wc_view) {
613 case VIEW_ADDRESSBOOK:
615 "<li class=\"addnewcontact\">"
616 "<a href=\"display_enter\">"
617 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
618 "border=\"0\"><span class=\"navbar_link\">"
620 "</span></a></li>\n", _("Add new contact")
625 wprintf("<li class=\"addevent\"><a href=\"display_enter");
626 if (strlen(bstr("year")) > 0) wprintf("?year=%s", bstr("year"));
627 if (strlen(bstr("month")) > 0) wprintf("?month=%s", bstr("month"));
628 if (strlen(bstr("day")) > 0) wprintf("?day=%s", bstr("day"));
630 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
631 "border=\"0\"><span class=\"navbar_link\">"
633 "</span></a></li>\n", _("Add new event")
638 "<li class=\"newmess\">"
639 "<a href=\"display_enter\">"
640 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
641 "border=\"0\"><span class=\"navbar_link\">"
643 "</span></a></li>\n", _("Add new task")
648 "<li class=\"enternewnote\">"
649 "<a href=\"javascript:add_new_note();\">"
650 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
651 "border=\"0\"><span class=\"navbar_link\">"
653 "</span></a></li>\n", _("Add new note")
657 safestrncpy(buf, bstr("page"), sizeof buf);
660 "<li class=\"newmess\">"
661 "<a href=\"display_enter?wikipage=%s\">"
662 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
663 "border=\"0\"><span class=\"navbar_link\">"
665 "</span></a></li>\n", buf, _("Edit this page")
670 "<li class=\"newmess\">"
671 "<a href=\"display_enter\">"
672 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
673 "border=\"0\"><span class=\"navbar_link\">"
675 "</span></a></li>\n", _("Write mail")
680 "<li class=\"newmess\">"
681 "<a href=\"display_enter\">"
682 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
683 "border=\"0\"><span class=\"navbar_link\">"
685 "</span></a></li>\n", _("Enter a message")
691 if (navbar_style == navbar_default) wprintf(
692 "<li class=\"skipthisroom\">"
695 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
696 "<span class=\"navbar_link\">%s</span></a>"
698 _("Leave all messages marked as unread, go to next room with unread messages"),
702 if (navbar_style == navbar_default) wprintf(
703 "<li class=\"markngo\">"
704 "<a href=\"gotonext\" "
706 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
707 "<span class=\"navbar_link\">%s</span></a>"
709 _("Mark all messages as read, go to next room with unread messages"),
713 wprintf("</ul></div>\n");
720 * \brief back end routine to take the session to a new room
721 * \param gname room to go to
724 int gotoroom(char *gname)
727 static long ls = (-1L);
730 /** store ungoto information */
731 strcpy(WC->ugname, WC->wc_roomname);
734 /** move to the new room */
735 serv_printf("GOTO %s", gname);
736 serv_getln(buf, sizeof buf);
740 serv_puts("GOTO _BASEROOM_");
741 serv_getln(buf, sizeof buf);
748 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
749 WC->room_flags = extract_int(&buf[4], 4);
750 /* highest_msg_read = extract_int(&buf[4],6);
751 maxmsgnum = extract_int(&buf[4],5);
753 WC->is_mailbox = extract_int(&buf[4],7);
754 ls = extract_long(&buf[4], 6);
755 WC->wc_floor = extract_int(&buf[4], 10);
756 WC->wc_view = extract_int(&buf[4], 11);
757 WC->wc_default_view = extract_int(&buf[4], 12);
758 WC->wc_is_trash = extract_int(&buf[4], 13);
759 WC->room_flags2 = extract_int(&buf[4], 14);
762 WC->is_room_aide = WC->is_aide;
764 WC->is_room_aide = (char) extract_int(&buf[4], 8);
766 remove_march(WC->wc_roomname);
767 if (!strcasecmp(gname, "_BASEROOM_"))
775 * \brief Locate the room on the march list which we most want to go to.
777 * is measured given a "weight" of preference based on various factors.
778 * \param desired_floor the room number on the citadel server
779 * \return the roomname
781 char *pop_march(int desired_floor)
783 static char TheRoom[128];
785 int TheOrder = 32767;
788 struct march *mptr = NULL;
790 strcpy(TheRoom, "_BASEROOM_");
791 if (WC->march == NULL)
794 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
796 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
797 weight = weight + 10000;
798 if (mptr->march_floor == desired_floor)
799 weight = weight + 5000;
801 weight = weight + ((128 - (mptr->march_floor)) * 128);
802 weight = weight + (128 - (mptr->march_order));
804 if (weight > TheWeight) {
806 strcpy(TheRoom, mptr->march_name);
807 TheFloor = mptr->march_floor;
808 TheOrder = mptr->march_order;
817 *\brief Goto next room having unread messages.
818 * We want to skip over rooms that the user has already been to, and take the
819 * user back to the lobby when done. The room we end up in is placed in
820 * newroom - which is set to 0 (the lobby) initially.
821 * We start the search in the current room rather than the beginning to prevent
822 * two or more concurrent users from dragging each other back to the same room.
827 struct march *mptr, *mptr2;
832 * First check to see if the march-mode list is already allocated.
833 * If it is, pop the first room off the list and go there.
836 if (WC->march == NULL) {
838 serv_getln(buf, sizeof buf);
840 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
841 extract_token(room_name, buf, 0, '|', sizeof room_name);
842 if (strcasecmp(room_name, WC->wc_roomname)) {
843 mptr = (struct march *) malloc(sizeof(struct march));
845 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
846 mptr->march_floor = extract_int(buf, 2);
847 mptr->march_order = extract_int(buf, 3);
848 if (WC->march == NULL) {
852 while (mptr2->next != NULL)
859 * add _BASEROOM_ to the end of the march list, so the user will end up
860 * in the system base room (usually the Lobby>) at the end of the loop
862 mptr = (struct march *) malloc(sizeof(struct march));
864 strcpy(mptr->march_name, "_BASEROOM_");
865 if (WC->march == NULL) {
869 while (mptr2->next != NULL)
874 * ...and remove the room we're currently in, so a <G>oto doesn't make us
875 * walk around in circles
877 remove_march(WC->wc_roomname);
879 if (WC->march != NULL) {
880 strcpy(next_room, pop_march(-1));
882 strcpy(next_room, "_BASEROOM_");
886 smart_goto(next_room);
891 * \brief goto next room
892 * \param next_room next room to go to
894 void smart_goto(char *next_room) {
902 * \brief mark all messages in current room as having been read
904 void slrp_highest(void)
908 serv_puts("SLRP HIGHEST");
909 serv_getln(buf, sizeof buf);
914 * \brief un-goto the previous room
920 if (!strcmp(WC->ugname, "")) {
921 smart_goto(WC->wc_roomname);
924 serv_printf("GOTO %s", WC->ugname);
925 serv_getln(buf, sizeof buf);
927 smart_goto(WC->wc_roomname);
930 if (WC->uglsn >= 0L) {
931 serv_printf("SLRP %ld", WC->uglsn);
932 serv_getln(buf, sizeof buf);
934 strcpy(buf, WC->ugname);
935 strcpy(WC->ugname, "");
944 * \brief Set/clear/read the "self-service list subscribe" flag for a room
946 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
947 * \return return the new value.
950 int self_service(int newval) {
951 int current_value = 0;
957 int flags, floor, order, view, flags2;
960 serv_getln(buf, sizeof buf);
961 if (buf[0] != '2') return(0);
963 extract_token(name, &buf[4], 0, '|', sizeof name);
964 extract_token(password, &buf[4], 1, '|', sizeof password);
965 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
966 flags = extract_int(&buf[4], 3);
967 floor = extract_int(&buf[4], 4);
968 order = extract_int(&buf[4], 5);
969 view = extract_int(&buf[4], 6);
970 flags2 = extract_int(&buf[4], 7);
972 if (flags2 & QR2_SELFLIST) {
980 flags2 = flags2 | QR2_SELFLIST;
982 else if (newval == 0) {
983 flags2 = flags2 & ~QR2_SELFLIST;
986 return(current_value);
989 if (newval != current_value) {
990 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
991 name, password, dirname, flags,
992 floor, order, view, flags2);
993 serv_getln(buf, sizeof buf);
1006 * \brief display the form for editing a room
1008 void display_editroom(void)
1013 char remote_room[128];
1016 char er_password[10];
1017 char er_dirname[15];
1018 char er_roomaide[26];
1025 char *not_shared_with;
1028 int floorpolicy = 0;
1032 if (strlen(tab) == 0) tab = "admin";
1036 serv_getln(buf, sizeof buf);
1038 if (buf[0] != '2') {
1039 strcpy(WC->ImportantMessage, &buf[4]);
1040 display_main_menu();
1043 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1044 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1045 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1046 er_flags = extract_int(&buf[4], 3);
1047 er_floor = extract_int(&buf[4], 4);
1048 er_flags2 = extract_int(&buf[4], 7);
1050 output_headers(1, 1, 1, 0, 0, 0);
1052 /** print the tabbed dialog */
1054 "<div class=\"fix_scrollbar_bug\">"
1055 "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
1057 "<TD> </TD>\n");
1059 if (!strcmp(tab, "admin")) {
1060 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1063 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1065 wprintf(_("Administration"));
1066 if (!strcmp(tab, "admin")) {
1067 wprintf("</SPAN></TD>\n");
1070 wprintf("</A></TD>\n");
1073 wprintf("<TD> </TD>\n");
1075 if (!strcmp(tab, "config")) {
1076 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1079 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=config\">");
1081 wprintf(_("Configuration"));
1082 if (!strcmp(tab, "config")) {
1083 wprintf("</SPAN></TD>\n");
1086 wprintf("</A></TD>\n");
1089 wprintf("<TD> </TD>\n");
1091 if (!strcmp(tab, "expire")) {
1092 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1095 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1097 wprintf(_("Message expire policy"));
1098 if (!strcmp(tab, "expire")) {
1099 wprintf("</SPAN></TD>\n");
1102 wprintf("</A></TD>\n");
1105 wprintf("<TD> </TD>\n");
1107 if (!strcmp(tab, "access")) {
1108 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1111 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=access\">");
1113 wprintf(_("Access controls"));
1114 if (!strcmp(tab, "access")) {
1115 wprintf("</SPAN></TD>\n");
1118 wprintf("</A></TD>\n");
1121 wprintf("<TD> </TD>\n");
1123 if (!strcmp(tab, "sharing")) {
1124 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1127 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1129 wprintf(_("Sharing"));
1130 if (!strcmp(tab, "sharing")) {
1131 wprintf("</SPAN></TD>\n");
1134 wprintf("</A></TD>\n");
1137 wprintf("<TD> </TD>\n");
1139 if (!strcmp(tab, "listserv")) {
1140 wprintf("<TD class=\"roomops_cell_label\"><SPAN CLASS=\"tablabel\">");
1143 wprintf("<TD class=\"roomops_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1145 wprintf(_("Mailing list service"));
1146 if (!strcmp(tab, "listserv")) {
1147 wprintf("</SPAN></TD>\n");
1150 wprintf("</A></TD>\n");
1153 wprintf("<TD> </TD>\n");
1155 wprintf("</TR></TABLE></div>\n");
1156 /** end tabbed dialog */
1158 /** begin content of whatever tab is open now */
1159 wprintf("<div class=\"fix_scrollbar_bug\">"
1160 "<TABLE class=\"roomops_background\">\n"
1163 if (!strcmp(tab, "admin")) {
1165 "<LI><a href=\"delete_room\" "
1166 "onClick=\"return confirm('");
1167 wprintf(_("Are you sure you want to delete this room?"));
1168 wprintf("');\">\n");
1169 wprintf(_("Delete this room"));
1171 "<LI><a href=\"display_editroompic\">\n");
1172 wprintf(_("Set or change the icon for this room's banner"));
1174 "<LI><a href=\"display_editinfo\">\n");
1175 wprintf(_("Edit this room's Info file"));
1180 if (!strcmp(tab, "config")) {
1181 wprintf("<FORM METHOD=\"POST\" action=\"editroom\">\n");
1182 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1184 wprintf("<UL><LI>");
1185 wprintf(_("Name of room: "));
1186 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1192 wprintf(_("Resides on floor: "));
1193 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
1194 for (i = 0; i < 128; ++i)
1195 if (strlen(floorlist[i]) > 0) {
1196 wprintf("<OPTION ");
1198 wprintf("SELECTED ");
1199 wprintf("VALUE=\"%d\">", i);
1200 escputs(floorlist[i]);
1201 wprintf("</OPTION>\n");
1203 wprintf("</SELECT>\n");
1206 wprintf(_("Type of room:"));
1209 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1210 if ((er_flags & QR_PRIVATE) == 0)
1211 wprintf("CHECKED ");
1213 wprintf(_("Public (automatically appears to everyone)"));
1216 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1217 if ((er_flags & QR_PRIVATE) &&
1218 (er_flags & QR_GUESSNAME))
1219 wprintf("CHECKED ");
1221 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1223 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1224 if ((er_flags & QR_PRIVATE) &&
1225 (er_flags & QR_PASSWORDED))
1226 wprintf("CHECKED ");
1228 wprintf(_("Private - require password: "));
1229 wprintf("\n<INPUT TYPE=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1232 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1233 if ((er_flags & QR_PRIVATE)
1234 && ((er_flags & QR_GUESSNAME) == 0)
1235 && ((er_flags & QR_PASSWORDED) == 0))
1236 wprintf("CHECKED ");
1238 wprintf(_("Private - invitation only"));
1240 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1242 wprintf(_("If private, cause current users to forget room"));
1244 wprintf("\n</UL>\n");
1246 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1247 if (er_flags & QR_PREFONLY)
1248 wprintf("CHECKED ");
1250 wprintf(_("Preferred users only"));
1252 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1253 if (er_flags & QR_READONLY)
1254 wprintf("CHECKED ");
1256 wprintf(_("Read-only room"));
1258 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1259 if (er_flags2 & QR2_COLLABDEL)
1260 wprintf("CHECKED ");
1262 wprintf(_("All users allowed to post may also delete messages"));
1264 /** directory stuff */
1265 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1266 if (er_flags & QR_DIRECTORY)
1267 wprintf("CHECKED ");
1269 wprintf(_("File directory room"));
1271 wprintf("\n<UL><LI>");
1272 wprintf(_("Directory name: "));
1273 wprintf("<INPUT TYPE=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1276 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1277 if (er_flags & QR_UPLOAD)
1278 wprintf("CHECKED ");
1280 wprintf(_("Uploading allowed"));
1282 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1283 if (er_flags & QR_DOWNLOAD)
1284 wprintf("CHECKED ");
1286 wprintf(_("Downloading allowed"));
1288 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1289 if (er_flags & QR_VISDIR)
1290 wprintf("CHECKED ");
1292 wprintf(_("Visible directory"));
1295 /** end of directory stuff */
1297 wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1298 if (er_flags & QR_NETWORK)
1299 wprintf("CHECKED ");
1301 wprintf(_("Network shared room"));
1303 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1304 if (er_flags & QR_PERMANENT)
1305 wprintf("CHECKED ");
1307 wprintf(_("Permanent (does not auto-purge)"));
1309 wprintf("\n<LI><INPUT TYPE=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1310 if (er_flags2 & QR2_SUBJECTREQ)
1311 wprintf("CHECKED ");
1313 wprintf(_("Subject Required (Force users to specify a message subject)"));
1315 /** start of anon options */
1318 wprintf(_("Anonymous messages"));
1321 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1322 if (((er_flags & QR_ANONONLY) == 0)
1323 && ((er_flags & QR_ANONOPT) == 0))
1324 wprintf("CHECKED ");
1326 wprintf(_("No anonymous messages"));
1328 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1329 if (er_flags & QR_ANONONLY)
1330 wprintf("CHECKED ");
1332 wprintf(_("All messages are anonymous"));
1334 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1335 if (er_flags & QR_ANONOPT)
1336 wprintf("CHECKED ");
1338 wprintf(_("Prompt user when entering messages"));
1341 /* end of anon options */
1344 wprintf(_("Room aide: "));
1346 serv_getln(buf, sizeof buf);
1347 if (buf[0] != '2') {
1348 wprintf("<em>%s</em>\n", &buf[4]);
1350 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1351 wprintf("<INPUT TYPE=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1354 wprintf("</UL><CENTER>\n");
1355 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1356 "<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1358 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1366 /** Sharing the room with other Citadel nodes... */
1367 if (!strcmp(tab, "sharing")) {
1369 shared_with = strdup("");
1370 not_shared_with = strdup("");
1372 /** Learn the current configuration */
1373 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1374 serv_getln(buf, sizeof buf);
1375 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1376 extract_token(node, buf, 0, '|', sizeof node);
1377 not_shared_with = realloc(not_shared_with,
1378 strlen(not_shared_with) + 32);
1379 strcat(not_shared_with, node);
1380 strcat(not_shared_with, "\n");
1384 serv_getln(buf, sizeof buf);
1385 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1386 extract_token(cmd, buf, 0, '|', sizeof cmd);
1387 extract_token(node, buf, 1, '|', sizeof node);
1388 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1389 if (!strcasecmp(cmd, "ignet_push_share")) {
1390 shared_with = realloc(shared_with,
1391 strlen(shared_with) + 32);
1392 strcat(shared_with, node);
1393 if (strlen(remote_room) > 0) {
1394 strcat(shared_with, "|");
1395 strcat(shared_with, remote_room);
1397 strcat(shared_with, "\n");
1401 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1402 extract_token(buf, shared_with, i, '\n', sizeof buf);
1403 extract_token(node, buf, 0, '|', sizeof node);
1404 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1405 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1406 if (!strcasecmp(node, cmd)) {
1407 remove_token(not_shared_with, j, '\n');
1412 /** Display the stuff */
1413 wprintf("<CENTER><br />"
1414 "<TABLE border=1 cellpadding=5><TR>"
1416 wprintf(_("Shared with"));
1417 wprintf("</I></B></TD>"
1419 wprintf(_("Not shared with"));
1420 wprintf("</I></B></TD></TR>\n"
1421 "<TR><TD VALIGN=TOP>\n");
1423 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1424 wprintf(_("Remote node name"));
1425 wprintf("</TD><TD>");
1426 wprintf(_("Remote room name"));
1427 wprintf("</TD><TD>");
1428 wprintf(_("Actions"));
1429 wprintf("</TD></TR>\n");
1431 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1432 extract_token(buf, shared_with, i, '\n', sizeof buf);
1433 extract_token(node, buf, 0, '|', sizeof node);
1434 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1435 if (strlen(node) > 0) {
1436 wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
1437 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1438 wprintf("<TR><TD>%s</TD>\n", node);
1441 if (strlen(remote_room) > 0) {
1442 escputs(remote_room);
1448 wprintf("<INPUT TYPE=\"hidden\" NAME=\"line\" "
1449 "VALUE=\"ignet_push_share|");
1451 if (strlen(remote_room) > 0) {
1453 urlescputs(remote_room);
1456 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1457 "VALUE=\"sharing\">\n");
1458 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1459 "VALUE=\"remove\">\n");
1460 wprintf("<INPUT TYPE=\"submit\" "
1461 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1462 wprintf("</TD></TR></FORM>\n");
1466 wprintf("</TABLE>\n");
1467 wprintf("</TD><TD VALIGN=TOP>\n");
1468 wprintf("<TABLE border=0 cellpadding=5><TR class=\"roomops_cell\"><TD>");
1469 wprintf(_("Remote node name"));
1470 wprintf("</TD><TD>");
1471 wprintf(_("Remote room name"));
1472 wprintf("</TD><TD>");
1473 wprintf(_("Actions"));
1474 wprintf("</TD></TR>\n");
1476 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1477 extract_token(node, not_shared_with, i, '\n', sizeof node);
1478 if (strlen(node) > 0) {
1479 wprintf("<FORM METHOD=\"POST\" action=\"netedit\">");
1480 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1481 wprintf("<TR><TD>");
1484 "<INPUT TYPE=\"INPUT\" "
1488 wprintf("<INPUT TYPE=\"hidden\" "
1490 "VALUE=\"ignet_push_share|");
1493 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" "
1494 "VALUE=\"sharing\">\n");
1495 wprintf("<INPUT TYPE=\"hidden\" NAME=\"cmd\" "
1496 "VALUE=\"add\">\n");
1497 wprintf("<INPUT TYPE=\"submit\" "
1498 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1499 wprintf("</TD></TR></FORM>\n");
1503 wprintf("</TABLE>\n");
1504 wprintf("</TD></TR>"
1505 "</TABLE></CENTER><br />\n"
1506 "<I><B>%s</B><UL><LI>", _("Notes:"));
1507 wprintf(_("When sharing a room, "
1508 "it must be shared from both ends. Adding a node to "
1509 "the 'shared' list sends messages out, but in order to"
1510 " receive messages, the other nodes must be configured"
1511 " to send messages out to your system as well. "
1512 "<LI>If the remote room name is blank, it is assumed "
1513 "that the room name is identical on the remote node."
1514 "<LI>If the remote room name is different, the remote "
1515 "node must also configure the name of the room here."
1521 /** Mailing list management */
1522 if (!strcmp(tab, "listserv")) {
1524 wprintf("<br /><center>"
1525 "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
1526 "<TR><TD VALIGN=TOP>");
1528 wprintf(_("<i>The contents of this room are being "
1529 "mailed <b>as individual messages</b> "
1530 "to the following list recipients:"
1531 "</i><br /><br />\n"));
1534 serv_getln(buf, sizeof buf);
1535 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1536 extract_token(cmd, buf, 0, '|', sizeof cmd);
1537 if (!strcasecmp(cmd, "listrecp")) {
1538 extract_token(recp, buf, 1, '|', sizeof recp);
1541 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1544 wprintf(_("(remove)"));
1545 wprintf("</A><br />");
1548 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1549 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1550 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1551 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1552 wprintf("<INPUT TYPE=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1553 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1554 wprintf("</FORM>\n");
1556 wprintf("</TD><TD VALIGN=TOP>\n");
1558 wprintf(_("<i>The contents of this room are being "
1559 "mailed <b>in digest form</b> "
1560 "to the following list recipients:"
1561 "</i><br /><br />\n"));
1564 serv_getln(buf, sizeof buf);
1565 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1566 extract_token(cmd, buf, 0, '|', sizeof cmd);
1567 if (!strcasecmp(cmd, "digestrecp")) {
1568 extract_token(recp, buf, 1, '|', sizeof recp);
1571 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1575 wprintf(_("(remove)"));
1576 wprintf("</A><br />");
1579 wprintf("<br /><FORM METHOD=\"POST\" action=\"netedit\">\n"
1580 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1581 "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1582 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1583 wprintf("<INPUT TYPE=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1584 wprintf("<INPUT TYPE=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1585 wprintf("</FORM>\n");
1587 wprintf("</TD></TR></TABLE>\n");
1589 /** Pop open an address book -- begin **/
1590 wprintf("<div align=right>"
1591 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1593 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1598 _("Add recipients from Contacts or other address books"),
1599 _("Add recipients from Contacts or other address books")
1601 /** Pop open an address book -- end **/
1604 if (self_service(999) == 1) {
1605 wprintf(_("This room is configured to allow "
1606 "self-service subscribe/unsubscribe requests."));
1607 wprintf("<a href=\"toggle_self_service?newval=0&tab=listserv\">");
1608 wprintf(_("Click to disable."));
1609 wprintf("</A><br />\n");
1610 wprintf(_("The URL for subscribe/unsubscribe is: "));
1611 wprintf("<TT>%s://%s/listsub</TT><br />\n",
1612 (is_https ? "https" : "http"),
1616 wprintf(_("This room is <i>not</i> configured to allow "
1617 "self-service subscribe/unsubscribe requests."));
1618 wprintf(" <a href=\"toggle_self_service?newval=1&"
1620 wprintf(_("Click to enable."));
1621 wprintf("</A><br />\n");
1625 wprintf("</CENTER>\n");
1629 /** Mailing list management */
1630 if (!strcmp(tab, "expire")) {
1632 serv_puts("GPEX room");
1633 serv_getln(buf, sizeof buf);
1634 if (buf[0] == '2') {
1635 roompolicy = extract_int(&buf[4], 0);
1636 roomvalue = extract_int(&buf[4], 1);
1639 serv_puts("GPEX floor");
1640 serv_getln(buf, sizeof buf);
1641 if (buf[0] == '2') {
1642 floorpolicy = extract_int(&buf[4], 0);
1643 floorvalue = extract_int(&buf[4], 1);
1646 wprintf("<br /><FORM METHOD=\"POST\" action=\"set_room_policy\">\n");
1647 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1648 wprintf("<TABLE border=0 cellspacing=5>\n");
1649 wprintf("<TR><TD>");
1650 wprintf(_("Message expire policy for this room"));
1652 escputs(WC->wc_roomname);
1653 wprintf(")</TD><TD>");
1654 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1655 ((roompolicy == 0) ? "CHECKED" : "") );
1656 wprintf(_("Use the default policy for this floor"));
1657 wprintf("<br />\n");
1658 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1659 ((roompolicy == 1) ? "CHECKED" : "") );
1660 wprintf(_("Never automatically expire messages"));
1661 wprintf("<br />\n");
1662 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1663 ((roompolicy == 2) ? "CHECKED" : "") );
1664 wprintf(_("Expire by message count"));
1665 wprintf("<br />\n");
1666 wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1667 ((roompolicy == 3) ? "CHECKED" : "") );
1668 wprintf(_("Expire by message age"));
1670 wprintf(_("Number of messages or days: "));
1671 wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1672 wprintf("</TD></TR>\n");
1674 if (WC->axlevel >= 6) {
1675 wprintf("<TR><TD COLSPAN=2><hr /></TD></TR>\n");
1676 wprintf("<TR><TD>");
1677 wprintf(_("Message expire policy for this floor"));
1679 escputs(floorlist[WC->wc_floor]);
1680 wprintf(")</TD><TD>");
1681 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1682 ((floorpolicy == 0) ? "CHECKED" : "") );
1683 wprintf(_("Use the system default"));
1684 wprintf("<br />\n");
1685 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1686 ((floorpolicy == 1) ? "CHECKED" : "") );
1687 wprintf(_("Never automatically expire messages"));
1688 wprintf("<br />\n");
1689 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1690 ((floorpolicy == 2) ? "CHECKED" : "") );
1691 wprintf(_("Expire by message count"));
1692 wprintf("<br />\n");
1693 wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1694 ((floorpolicy == 3) ? "CHECKED" : "") );
1695 wprintf(_("Expire by message age"));
1697 wprintf(_("Number of messages or days: "));
1698 wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1702 wprintf("<CENTER>\n");
1703 wprintf("<TR><TD COLSPAN=2><hr /><CENTER>\n");
1704 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1706 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1707 wprintf("</CENTER></TD><TR>\n");
1709 wprintf("</TABLE>\n"
1710 "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1716 /** Mailing list management */
1717 if (!strcmp(tab, "access")) {
1721 /** end content of whatever tab is open now */
1722 wprintf("</TD></TR></TABLE></div>\n");
1724 address_book_popup();
1730 * \brief Toggle self-service list subscription
1732 void toggle_self_service(void) {
1735 newval = atoi(bstr("newval"));
1736 self_service(newval);
1743 * \brief save new parameters for a room
1749 char er_password[10];
1750 char er_dirname[15];
1751 char er_roomaide[26];
1754 int er_listingorder;
1760 if (strlen(bstr("ok_button")) == 0) {
1761 strcpy(WC->ImportantMessage,
1762 _("Cancelled. Changes were not saved."));
1767 serv_getln(buf, sizeof buf);
1769 if (buf[0] != '2') {
1770 strcpy(WC->ImportantMessage, &buf[4]);
1774 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1775 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1776 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1777 er_flags = extract_int(&buf[4], 3);
1778 er_listingorder = extract_int(&buf[4], 5);
1779 er_defaultview = extract_int(&buf[4], 6);
1780 er_flags2 = extract_int(&buf[4], 7);
1782 strcpy(er_roomaide, bstr("er_roomaide"));
1783 if (strlen(er_roomaide) == 0) {
1785 serv_getln(buf, sizeof buf);
1786 if (buf[0] != '2') {
1787 strcpy(er_roomaide, "");
1789 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1792 strcpy(buf, bstr("er_name"));
1794 if (strlen(buf) > 0) {
1795 strcpy(er_name, buf);
1798 strcpy(buf, bstr("er_password"));
1800 if (strlen(buf) > 0)
1801 strcpy(er_password, buf);
1803 strcpy(buf, bstr("er_dirname"));
1805 if (strlen(buf) > 0)
1806 strcpy(er_dirname, buf);
1808 strcpy(buf, bstr("type"));
1809 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
1811 if (!strcmp(buf, "invonly")) {
1812 er_flags |= (QR_PRIVATE);
1814 if (!strcmp(buf, "hidden")) {
1815 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
1817 if (!strcmp(buf, "passworded")) {
1818 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
1820 if (!strcmp(bstr("prefonly"), "yes")) {
1821 er_flags |= QR_PREFONLY;
1823 er_flags &= ~QR_PREFONLY;
1826 if (!strcmp(bstr("readonly"), "yes")) {
1827 er_flags |= QR_READONLY;
1829 er_flags &= ~QR_READONLY;
1832 if (!strcmp(bstr("collabdel"), "yes")) {
1833 er_flags2 |= QR2_COLLABDEL;
1835 er_flags2 &= ~QR2_COLLABDEL;
1838 if (!strcmp(bstr("permanent"), "yes")) {
1839 er_flags |= QR_PERMANENT;
1841 er_flags &= ~QR_PERMANENT;
1844 if (!strcmp(bstr("subjectreq"), "yes")) {
1845 er_flags2 |= QR2_SUBJECTREQ;
1847 er_flags2 &= ~QR2_SUBJECTREQ;
1850 if (!strcmp(bstr("network"), "yes")) {
1851 er_flags |= QR_NETWORK;
1853 er_flags &= ~QR_NETWORK;
1856 if (!strcmp(bstr("directory"), "yes")) {
1857 er_flags |= QR_DIRECTORY;
1859 er_flags &= ~QR_DIRECTORY;
1862 if (!strcmp(bstr("ulallowed"), "yes")) {
1863 er_flags |= QR_UPLOAD;
1865 er_flags &= ~QR_UPLOAD;
1868 if (!strcmp(bstr("dlallowed"), "yes")) {
1869 er_flags |= QR_DOWNLOAD;
1871 er_flags &= ~QR_DOWNLOAD;
1874 if (!strcmp(bstr("visdir"), "yes")) {
1875 er_flags |= QR_VISDIR;
1877 er_flags &= ~QR_VISDIR;
1880 strcpy(buf, bstr("anon"));
1882 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
1883 if (!strcmp(buf, "anononly"))
1884 er_flags |= QR_ANONONLY;
1885 if (!strcmp(buf, "anon2"))
1886 er_flags |= QR_ANONOPT;
1889 if (!strcmp(bstr("bump"), "yes"))
1892 er_floor = atoi(bstr("er_floor"));
1894 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
1895 er_name, er_password, er_dirname, er_flags, bump, er_floor,
1896 er_listingorder, er_defaultview, er_flags2);
1898 serv_getln(buf, sizeof buf);
1899 if (buf[0] != '2') {
1900 strcpy(WC->ImportantMessage, &buf[4]);
1906 if (strlen(er_roomaide) > 0) {
1907 sprintf(buf, "SETA %s", er_roomaide);
1909 serv_getln(buf, sizeof buf);
1910 if (buf[0] != '2') {
1911 strcpy(WC->ImportantMessage, &buf[4]);
1912 display_main_menu();
1917 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
1924 * \brief Display form for Invite, Kick, and show Who Knows a room
1926 void do_invt_kick(void) {
1927 char buf[SIZ], room[SIZ], username[SIZ];
1930 serv_getln(buf, sizeof buf);
1932 if (buf[0] != '2') {
1936 extract_token(room, &buf[4], 0, '|', sizeof room);
1938 strcpy(username, bstr("username"));
1940 if (strlen(bstr("kick_button")) > 0) {
1941 sprintf(buf, "KICK %s", username);
1943 serv_getln(buf, sizeof buf);
1945 if (buf[0] != '2') {
1946 strcpy(WC->ImportantMessage, &buf[4]);
1948 sprintf(WC->ImportantMessage,
1949 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
1954 if (strlen(bstr("invite_button")) > 0) {
1955 sprintf(buf, "INVT %s", username);
1957 serv_getln(buf, sizeof buf);
1959 if (buf[0] != '2') {
1960 strcpy(WC->ImportantMessage, &buf[4]);
1962 sprintf(WC->ImportantMessage,
1963 _("<B><I>User %s invited to room %s.</I></B>\n"),
1974 * \brief Display form for Invite, Kick, and show Who Knows a room
1976 void display_whok(void)
1978 char buf[SIZ], room[SIZ], username[SIZ];
1981 serv_getln(buf, sizeof buf);
1983 if (buf[0] != '2') {
1987 extract_token(room, &buf[4], 0, '|', sizeof room);
1990 wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP><TD>");
1991 wprintf(_("The users listed below have access to this room. "
1992 "To remove a user from the access list, select the user "
1993 "name from the list and click 'Kick'."));
1994 wprintf("<br /><br />");
1996 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
1997 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1998 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
1999 wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2001 serv_getln(buf, sizeof buf);
2002 if (buf[0] == '1') {
2003 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2004 extract_token(username, buf, 0, '|', sizeof username);
2005 wprintf("<OPTION>");
2010 wprintf("</SELECT><br />\n");
2012 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2013 wprintf("</FORM></CENTER>\n");
2015 wprintf("</TD><TD>");
2016 wprintf(_("To grant another user access to this room, enter the "
2017 "user name in the box below and click 'Invite'."));
2018 wprintf("<br /><br />");
2020 wprintf("<CENTER><FORM METHOD=\"POST\" action=\"do_invt_kick\">\n");
2021 wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2022 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2023 wprintf(_("Invite:"));
2025 wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
2026 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2027 "<input type=\"submit\" value=\"%s\">"
2028 "</FORM></CENTER>\n", _("Invite"));
2030 wprintf("</TD></TR></TABLE>\n");
2037 * \brief display the form for entering a new room
2039 void display_entroom(void)
2044 serv_puts("CRE8 0");
2045 serv_getln(buf, sizeof buf);
2047 if (buf[0] != '2') {
2048 strcpy(WC->ImportantMessage, &buf[4]);
2049 display_main_menu();
2053 output_headers(1, 1, 2, 0, 0, 0);
2054 wprintf("<div id=\"banner\">\n"
2055 "<TABLE class=\"roomops_banner\"><TR><TD>"
2056 "<SPAN CLASS=\"titlebar\">");
2057 wprintf(_("Create a new room"));
2059 "</TD></TR></TABLE>\n"
2060 "</div>\n<div id=\"content\">\n"
2063 wprintf("<div class=\"fix_scrollbar_bug\">"
2064 "<table class=\"roomops_background\"><tr><td>\n");
2066 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2067 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2069 wprintf("<UL><LI>");
2070 wprintf(_("Name of room: "));
2071 wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2074 wprintf(_("Resides on floor: "));
2076 wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
2077 for (i = 0; i < 128; ++i)
2078 if (strlen(floorlist[i]) > 0) {
2079 wprintf("<OPTION ");
2080 wprintf("VALUE=\"%d\">", i);
2081 escputs(floorlist[i]);
2082 wprintf("</OPTION>\n");
2084 wprintf("</SELECT>\n");
2087 * Our clever little snippet of JavaScript automatically selects
2088 * a public room if the view is set to Bulletin Board or wiki, and
2089 * it selects a mailbox room otherwise. The user can override this,
2090 * of course. We also disable the floor selector for mailboxes.
2093 wprintf(_("Default view for room: "));
2094 wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\" OnChange=\""
2095 " if ( (this.form.er_view.value == 0) "
2096 " || (this.form.er_view.value == 6) ) { "
2097 " this.form.type[0].checked=true; "
2098 " this.form.er_floor.disabled = false; "
2101 " this.form.type[4].checked=true; "
2102 " this.form.er_floor.disabled = true; "
2105 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2106 if (is_view_allowed_as_default(i)) {
2107 wprintf("<OPTION %s VALUE=\"%d\">",
2108 ((i == 0) ? "SELECTED" : ""), i );
2109 escputs(viewdefs[i]);
2110 wprintf("</OPTION>\n");
2113 wprintf("</SELECT>\n");
2116 wprintf(_("Type of room:"));
2119 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2120 wprintf("CHECKED OnChange=\""
2121 " if (this.form.type[0].checked == true) { "
2122 " this.form.er_floor.disabled = false; "
2125 wprintf(_("Public (automatically appears to everyone)"));
2127 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2128 " if (this.form.type[1].checked == true) { "
2129 " this.form.er_floor.disabled = false; "
2132 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2134 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2135 " if (this.form.type[2].checked == true) { "
2136 " this.form.er_floor.disabled = false; "
2139 wprintf(_("Private - require password: "));
2140 wprintf("<INPUT TYPE=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2142 wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2143 " if (this.form.type[3].checked == true) { "
2144 " this.form.er_floor.disabled = false; "
2147 wprintf(_("Private - invitation only"));
2149 wprintf("\n<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2151 " if (this.form.type[4].checked == true) { "
2152 " this.form.er_floor.disabled = true; "
2155 wprintf(_("Personal (mailbox for you only)"));
2157 wprintf("\n</UL>\n");
2159 wprintf("<CENTER>\n");
2160 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Create new room"));
2162 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2163 wprintf("</CENTER>\n");
2164 wprintf("</FORM>\n<hr />");
2165 serv_printf("MESG roomaccess");
2166 serv_getln(buf, sizeof buf);
2167 if (buf[0] == '1') {
2170 wprintf("</td></tr></table></div>\n");
2178 * \brief support function for entroom() -- sets the default view
2180 void er_set_default_view(int newview) {
2193 serv_getln(buf, sizeof buf);
2194 if (buf[0] != '2') return;
2196 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2197 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2198 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2199 rm_bits1 = extract_int(&buf[4], 3);
2200 rm_floor = extract_int(&buf[4], 4);
2201 rm_listorder = extract_int(&buf[4], 5);
2202 rm_bits2 = extract_int(&buf[4], 7);
2204 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2205 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2206 rm_listorder, newview, rm_bits2
2208 serv_getln(buf, sizeof buf);
2214 * \brief enter a new room
2221 char er_password[SIZ];
2226 if (strlen(bstr("ok_button")) == 0) {
2227 strcpy(WC->ImportantMessage,
2228 _("Cancelled. No new room was created."));
2229 display_main_menu();
2232 strcpy(er_name, bstr("er_name"));
2233 strcpy(er_type, bstr("type"));
2234 strcpy(er_password, bstr("er_password"));
2235 er_floor = atoi(bstr("er_floor"));
2236 er_view = atoi(bstr("er_view"));
2239 if (!strcmp(er_type, "hidden"))
2241 if (!strcmp(er_type, "passworded"))
2243 if (!strcmp(er_type, "invonly"))
2245 if (!strcmp(er_type, "personal"))
2248 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2249 er_name, er_num_type, er_password, er_floor, 0, er_view);
2251 serv_getln(buf, sizeof buf);
2252 if (buf[0] != '2') {
2253 strcpy(WC->ImportantMessage, &buf[4]);
2254 display_main_menu();
2258 do_change_view(er_view); /* Now go there */
2263 * \brief display the screen to enter a private room
2265 void display_private(char *rname, int req_pass)
2267 output_headers(1, 1, 2, 0, 0, 0);
2268 wprintf("<div id=\"banner\">\n"
2269 "<TABLE class=\"roomops_banner\"><TR><TD>"
2270 "<SPAN CLASS=\"titlebar\">");
2271 wprintf(_("Go to a hidden room"));
2273 "</TD></TR></TABLE>\n"
2274 "</div>\n<div id=\"content\">\n"
2277 wprintf("<div class=\"fix_scrollbar_bug\">"
2278 "<table class=\"roomops_background\"><tr><td>\n");
2280 wprintf("<CENTER>\n");
2282 wprintf(_("If you know the name of a hidden (guess-name) or "
2283 "passworded room, you can enter that room by typing "
2284 "its name below. Once you gain access to a private "
2285 "room, it will appear in your regular room listings "
2286 "so you don't have to keep returning here."));
2287 wprintf("\n<br /><br />");
2289 wprintf("<FORM METHOD=\"POST\" action=\"goto_private\">\n");
2290 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2292 wprintf("<table border=\"0\" cellspacing=\"5\" "
2293 "cellpadding=\"5\" class=\"roomops_background_alt\">\n"
2295 wprintf(_("Enter room name:"));
2297 "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
2298 "VALUE=\"%s\" MAXLENGTH=\"128\">\n", rname);
2301 wprintf("</TD></TR><TR><TD>");
2302 wprintf(_("Enter room password:"));
2303 wprintf("</TD><TD>");
2304 wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
2306 wprintf("</TD></TR></TABLE><br />\n");
2308 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
2310 "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">",
2314 wprintf("</FORM>\n");
2315 wprintf("</td></tr></table></div>\n");
2320 * \brief goto a private room
2322 void goto_private(void)
2327 if (strlen(bstr("ok_button")) == 0) {
2328 display_main_menu();
2331 strcpy(hold_rm, WC->wc_roomname);
2332 strcpy(buf, "GOTO ");
2333 strcat(buf, bstr("gr_name"));
2335 strcat(buf, bstr("gr_pass"));
2337 serv_getln(buf, sizeof buf);
2339 if (buf[0] == '2') {
2340 smart_goto(bstr("gr_name"));
2343 if (!strncmp(buf, "540", 3)) {
2344 display_private(bstr("gr_name"), 1);
2347 output_headers(1, 1, 1, 0, 0, 0);
2348 wprintf("%s\n", &buf[4]);
2355 * \brief display the screen to zap a room
2357 void display_zap(void)
2359 output_headers(1, 1, 2, 0, 0, 0);
2361 wprintf("<div id=\"banner\">\n");
2362 wprintf("<TABLE class=\"roomops_zap\"><TR><TD>");
2363 wprintf("<SPAN CLASS=\"titlebar\">");
2364 wprintf(_("Zap (forget/unsubscribe) the current room"));
2365 wprintf("</SPAN>\n");
2366 wprintf("</TD></TR></TABLE>\n");
2367 wprintf("</div>\n<div id=\"content\">\n");
2369 wprintf(_("If you select this option, <em>%s</em> will "
2370 "disappear from your room list. Is this what you wish "
2371 "to do?<br />\n"), WC->wc_roomname);
2373 wprintf("<FORM METHOD=\"POST\" action=\"zap\">\n");
2374 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2375 wprintf("<INPUT TYPE=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2377 wprintf("<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2378 wprintf("</FORM>\n");
2389 char final_destination[SIZ];
2392 * If the forget-room routine fails for any reason, we fall back
2393 * to the current room; otherwise, we go to the Lobby
2395 strcpy(final_destination, WC->wc_roomname);
2397 if (strlen(bstr("ok_button")) > 0) {
2398 serv_printf("GOTO %s", WC->wc_roomname);
2399 serv_getln(buf, sizeof buf);
2400 if (buf[0] == '2') {
2402 serv_getln(buf, sizeof buf);
2403 if (buf[0] == '2') {
2404 strcpy(final_destination, "_BASEROOM_");
2408 smart_goto(final_destination);
2414 * \brief Delete the current room
2416 void delete_room(void)
2420 serv_puts("KILL 1");
2421 serv_getln(buf, sizeof buf);
2422 if (buf[0] != '2') {
2423 strcpy(WC->ImportantMessage, &buf[4]);
2424 display_main_menu();
2427 smart_goto("_BASEROOM_");
2434 * \brief Perform changes to a room's network configuration
2436 void netedit(void) {
2446 if (strlen(bstr("line"))==0) {
2451 strcpy(line, bstr("prefix"));
2452 strcat(line, bstr("line"));
2453 strcat(line, bstr("suffix"));
2462 serv_getln(buf, sizeof buf);
2463 if (buf[0] != '1') {
2469 /** This loop works for add *or* remove. Spiffy, eh? */
2470 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2471 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2472 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2473 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2474 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2475 if ( (strcasecmp(cmpa0, cmpb0))
2476 || (strcasecmp(cmpa1, cmpb1)) ) {
2477 fprintf(fp, "%s\n", buf);
2483 serv_getln(buf, sizeof buf);
2484 if (buf[0] != '4') {
2490 while (fgets(buf, sizeof buf, fp) != NULL) {
2491 buf[strlen(buf)-1] = 0;
2495 if (strlen(bstr("add_button")) > 0) {
2496 num_addrs = num_tokens(bstr("line"), ',');
2497 if (num_addrs < 2) {
2498 /* just adding one node or address */
2502 /* adding multiple addresses separated by commas */
2503 for (i=0; i<num_addrs; ++i) {
2504 strcpy(line, bstr("prefix"));
2505 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2508 strcat(line, bstr("suffix"));
2522 * \brief Convert a room name to a folder-ish-looking name.
2523 * \param folder the folderish name
2524 * \param room the room name
2525 * \param floor the floor name
2526 * \param is_mailbox is it a mailbox?
2528 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2533 * For mailboxes, just do it straight...
2536 sprintf(folder, "My folders|%s", room);
2540 * Otherwise, prefix the floor name as a "public folders" moniker
2543 sprintf(folder, "%s|%s", floorlist[floor], room);
2547 * Replace "\" characters with "|" for pseudo-folder-delimiting
2549 for (i=0; i<strlen(folder); ++i) {
2550 if (folder[i] == '\\') folder[i] = '|';
2558 * \brief Back end for change_view()
2559 * \param newview set newview???
2561 void do_change_view(int newview) {
2564 serv_printf("VIEW %d", newview);
2565 serv_getln(buf, sizeof buf);
2566 WC->wc_view = newview;
2567 smart_goto(WC->wc_roomname);
2573 * \brief Change the view for this room
2575 void change_view(void) {
2578 view = atol(bstr("view"));
2579 do_change_view(view);
2584 * \brief One big expanded tree list view --- like a folder list
2585 * \param fold the folder to view
2586 * \param max_folders how many folders???
2587 * \param num_floors hom many floors???
2589 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2593 int has_subfolders = 0;
2596 parents = malloc(max_folders * sizeof(int));
2598 /** BEGIN TREE MENU */
2599 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2601 /** include NanoTree */
2602 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2604 /** initialize NanoTree */
2605 wprintf("<script type=\"text/javascript\"> \n"
2606 " showRootNode = false; \n"
2607 " sortNodes = false; \n"
2608 " dragable = false; \n"
2610 " function standardClick(treeNode) { \n"
2613 " var closedGif = 'static/folder_closed.gif'; \n"
2614 " var openGif = 'static/folder_open.gif'; \n"
2616 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2620 for (i=0; i<max_folders; ++i) {
2623 if ((i+1) < max_folders) {
2624 if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
2625 && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
2630 levels = num_tokens(fold[i].name, '|');
2631 parents[levels] = i;
2633 wprintf("var node%d = new TreeNode(%d, '", i, i);
2635 if (fold[i].selectable) {
2636 wprintf("<a href=\"dotgoto?room=");
2637 urlescputs(fold[i].room);
2642 wprintf("<SPAN CLASS=\"roomlist_floor\">");
2644 else if (fold[i].hasnewmsgs) {
2645 wprintf("<SPAN CLASS=\"roomlist_new\">");
2648 wprintf("<SPAN CLASS=\"roomlist_old\">");
2650 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2655 if (has_subfolders) {
2656 wprintf("new Array(closedGif, openGif)");
2658 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2659 wprintf("'static/viewcontacts_16x.gif'");
2661 else if (fold[i].view == VIEW_CALENDAR) {
2662 wprintf("'static/calarea_16x.gif'");
2664 else if (fold[i].view == VIEW_CALBRIEF) {
2665 wprintf("'static/calarea_16x.gif'");
2667 else if (fold[i].view == VIEW_TASKS) {
2668 wprintf("'static/taskmanag_16x.gif'");
2670 else if (fold[i].view == VIEW_NOTES) {
2671 wprintf("'static/storenotes_16x.gif'");
2673 else if (fold[i].view == VIEW_MAILBOX) {
2674 wprintf("'static/privatemess_16x.gif'");
2677 wprintf("'static/chatrooms_16x.gif'");
2680 urlescputs(fold[i].name);
2684 wprintf("rootNode.addChild(node%d);\n", i);
2687 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2691 wprintf("container = document.getElementById('roomlist_div'); \n"
2697 /** END TREE MENU */
2701 * \brief Boxes and rooms and lists ... oh my!
2702 * \param fold the folder to view
2703 * \param max_folders how many folders???
2704 * \param num_floors hom many floors???
2706 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
2708 char floor_name[256];
2709 char old_floor_name[256];
2711 int levels, oldlevels;
2714 static int columns = 3;
2715 int boxes_per_column = 0;
2716 int current_column = 0;
2719 strcpy(floor_name, "");
2720 strcpy(old_floor_name, "");
2723 while (nf % columns != 0) ++nf;
2724 boxes_per_column = (nf / columns);
2725 if (boxes_per_column < 1) boxes_per_column = 1;
2727 /** Outer table (for columnization) */
2728 wprintf("<TABLE BORDER=0 WIDTH=96%% CELLPADDING=5>"
2729 "<tr><td valign=top>");
2733 for (i=0; i<max_folders; ++i) {
2735 levels = num_tokens(fold[i].name, '|');
2736 extract_token(floor_name, fold[i].name, 0,
2737 '|', sizeof floor_name);
2739 if ( (strcasecmp(floor_name, old_floor_name))
2740 && (strlen(old_floor_name) > 0) ) {
2742 do_template("endbox");
2745 if ((num_boxes % boxes_per_column) == 0) {
2747 if (current_column < columns) {
2748 wprintf("</td><td valign=top>\n");
2752 strcpy(old_floor_name, floor_name);
2755 /** Begin inner box */
2756 stresc(boxtitle, floor_name, 1, 0);
2757 svprintf("BOXTITLE", WCS_STRING, boxtitle);
2758 do_template("beginbox");
2765 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2766 if (fold[i].selectable) {
2767 wprintf("<a href=\"dotgoto?room=");
2768 urlescputs(fold[i].room);
2774 if (fold[i].hasnewmsgs) {
2775 wprintf("<SPAN CLASS=\"roomlist_new\">");
2778 wprintf("<SPAN CLASS=\"roomlist_old\">");
2780 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2783 if (fold[i].selectable) {
2789 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2790 wprintf(" (INBOX)");
2792 wprintf("<br />\n");
2795 /** End the final inner box */
2796 do_template("endbox");
2798 wprintf("</TD></TR></TABLE>\n");
2802 * \brief print a floor div???
2803 * \param which_floordiv name of the floordiv???
2805 void set_floordiv_expanded(char *which_floordiv) {
2806 begin_ajax_response();
2807 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
2808 end_ajax_response();
2812 * \brief view the iconbar
2813 * \param fold the folder to view
2814 * \param max_folders how many folders???
2815 * \param num_floors hom many floors???
2817 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
2819 char floor_name[256];
2820 char old_floor_name[256];
2821 char floordivtitle[256];
2822 char floordiv_id[32];
2823 int levels, oldlevels;
2825 int num_drop_targets = 0;
2828 strcpy(floor_name, "");
2829 strcpy(old_floor_name, "");
2833 for (i=0; i<max_folders; ++i) {
2835 levels = num_tokens(fold[i].name, '|');
2836 extract_token(floor_name, fold[i].name, 0,
2837 '|', sizeof floor_name);
2839 if ( (strcasecmp(floor_name, old_floor_name))
2840 && (strlen(old_floor_name) > 0) ) {
2841 /** End inner box */
2843 wprintf("</div>\n"); /** floordiv */
2845 strcpy(old_floor_name, floor_name);
2849 stresc(floordivtitle, floor_name, 0, 0);
2850 sprintf(floordiv_id, "floordiv%d", i);
2851 wprintf("<span class=\"ib_roomlist_floor\" "
2852 "onClick=\"expand_floor('%s')\">"
2853 "%s</span><br>\n", floordiv_id, floordivtitle);
2854 wprintf("<div id=\"%s\" style=\"display:%s\">",
2856 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
2863 wprintf("<div id=\"roomdiv%d\">", i);
2865 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
2867 /** choose the icon */
2868 if (fold[i].view == VIEW_ADDRESSBOOK) {
2869 icon = "viewcontacts_16x.gif" ;
2871 else if (fold[i].view == VIEW_CALENDAR) {
2872 icon = "calarea_16x.gif" ;
2874 else if (fold[i].view == VIEW_CALBRIEF) {
2875 icon = "calarea_16x.gif" ;
2877 else if (fold[i].view == VIEW_TASKS) {
2878 icon = "taskmanag_16x.gif" ;
2880 else if (fold[i].view == VIEW_NOTES) {
2881 icon = "storenotes_16x.gif" ;
2883 else if (fold[i].view == VIEW_MAILBOX) {
2884 icon = "privatemess_16x.gif" ;
2887 icon = "chatrooms_16x.gif" ;
2890 if (fold[i].selectable) {
2891 wprintf("<a href=\"dotgoto?room=");
2892 urlescputs(fold[i].room);
2894 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
2899 if (fold[i].hasnewmsgs) {
2900 wprintf("<SPAN CLASS=\"ib_roomlist_new\">");
2903 wprintf("<SPAN CLASS=\"ib_roomlist_old\">");
2905 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2907 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
2908 wprintf(" (INBOX)");
2911 if (fold[i].selectable) {
2918 wprintf("</div>\n"); /** roomdiv */
2921 wprintf("</div>\n"); /** floordiv */
2924 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
2925 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
2927 num_drop_targets = 0;
2929 for (i=0; i<max_folders; ++i) {
2930 levels = num_tokens(fold[i].name, '|');
2932 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
2933 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
2934 jsescputs(fold[i].room);
2940 wprintf("num_drop_targets = %d;\n", num_drop_targets);
2941 if (strlen(WC->floordiv_expanded) > 1) {
2942 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
2946 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
2952 * \brief Show the room list.
2953 * (only should get called by
2954 * knrooms() because that's where output_headers() is called from)
2955 * \param viewpref the view preferences???
2958 void list_all_rooms_by_floor(char *viewpref) {
2961 struct folder *fold = NULL;
2963 int max_folders = 0;
2964 int alloc_folders = 0;
2968 int num_floors = 1; /** add an extra one for private folders */
2970 /** If our cached folder list is very old, burn it. */
2971 if (WC->cache_fold != NULL) {
2972 if ((time(NULL) - WC->cache_timestamp) > 300) {
2973 free(WC->cache_fold);
2974 WC->cache_fold = NULL;
2978 /** Can we do the iconbar roomlist from cache? */
2979 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
2980 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
2984 /** Grab the floor table so we know how to build the list... */
2987 /** Start with the mailboxes */
2990 fold = malloc(sizeof(struct folder));
2991 memset(fold, 0, sizeof(struct folder));
2992 strcpy(fold[0].name, "My folders");
2993 fold[0].is_mailbox = 1;
2995 /** Then add floors */
2997 serv_getln(buf, sizeof buf);
2998 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2999 if (max_folders >= alloc_folders) {
3000 alloc_folders = max_folders + 100;
3001 fold = realloc(fold,
3002 alloc_folders * sizeof(struct folder));
3004 memset(&fold[max_folders], 0, sizeof(struct folder));
3005 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3010 /** refresh the messages index for this room */
3011 // serv_puts("GOTO ");
3012 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3013 /** Now add rooms */
3015 serv_getln(buf, sizeof buf);
3016 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3017 if (max_folders >= alloc_folders) {
3018 alloc_folders = max_folders + 100;
3019 fold = realloc(fold,
3020 alloc_folders * sizeof(struct folder));
3022 memset(&fold[max_folders], 0, sizeof(struct folder));
3023 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3024 ra_flags = extract_int(buf, 5);
3025 flags = extract_int(buf, 1);
3026 fold[max_folders].floor = extract_int(buf, 2);
3027 fold[max_folders].hasnewmsgs =
3028 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3029 if (flags & QR_MAILBOX) {
3030 fold[max_folders].is_mailbox = 1;
3032 fold[max_folders].view = extract_int(buf, 6);
3033 room_to_folder(fold[max_folders].name,
3034 fold[max_folders].room,
3035 fold[max_folders].floor,
3036 fold[max_folders].is_mailbox);
3037 fold[max_folders].selectable = 1;
3041 /** Bubble-sort the folder list */
3042 for (i=0; i<max_folders; ++i) {
3043 for (j=0; j<(max_folders-1)-i; ++j) {
3044 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3045 swap = strcasecmp(fold[j].name, fold[j+1].name);
3048 if ( (fold[j+1].is_mailbox)
3049 && (!fold[j].is_mailbox)) {
3057 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3058 memcpy(&fold[j], &fold[j+1],
3059 sizeof(struct folder));
3060 memcpy(&fold[j+1], &ftmp,
3061 sizeof(struct folder));
3067 if (!strcasecmp(viewpref, "folders")) {
3068 do_folder_view(fold, max_folders, num_floors);
3070 else if (!strcasecmp(viewpref, "hackish_view")) {
3071 for (i=0; i<max_folders; ++i) {
3072 escputs(fold[i].name);
3073 wprintf("<br />\n");
3076 else if (!strcasecmp(viewpref, "iconbar")) {
3077 do_iconbar_view(fold, max_folders, num_floors);
3080 do_rooms_view(fold, max_folders, num_floors);
3083 /* Don't free the folder list ... cache it for future use! */
3084 if (WC->cache_fold != NULL) {
3085 free(WC->cache_fold);
3087 WC->cache_fold = fold;
3088 WC->cache_max_folders = max_folders;
3089 WC->cache_num_floors = num_floors;
3090 WC->cache_timestamp = time(NULL);
3095 * \brief Do either a known rooms list or a folders list, depending on the
3100 char listviewpref[SIZ];
3102 output_headers(1, 1, 2, 0, 0, 0);
3104 /** Determine whether the user is trying to change views */
3105 if (bstr("view") != NULL) {
3106 if (strlen(bstr("view")) > 0) {
3107 set_preference("roomlistview", bstr("view"), 1);
3111 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3113 if ( (strcasecmp(listviewpref, "folders"))
3114 && (strcasecmp(listviewpref, "table")) ) {
3115 strcpy(listviewpref, "rooms");
3119 wprintf("<div id=\"banner\">\n"
3120 "<TABLE class=\"roomops_banner\"><TR><TD>"
3121 "<SPAN CLASS=\"titlebar\">"
3123 if (!strcasecmp(listviewpref, "rooms")) {
3124 wprintf(_("Room list"));
3126 if (!strcasecmp(listviewpref, "folders")) {
3127 wprintf(_("Folder list"));
3129 if (!strcasecmp(listviewpref, "table")) {
3130 wprintf(_("Room list"));
3132 wprintf("</SPAN></TD>\n");
3134 /** offer the ability to switch views */
3135 wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
3136 "<SELECT NAME=\"newview\" SIZE=\"1\" "
3137 "OnChange=\"location.href=roomlistomatic.newview.options"
3138 "[selectedIndex].value\">\n");
3140 wprintf("<OPTION %s VALUE=\"knrooms&view=rooms\">"
3143 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3146 wprintf("<OPTION %s VALUE=\"knrooms&view=folders\">"
3147 "View as folder list"
3149 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3152 wprintf("</SELECT><br />");
3154 wprintf("</FORM></TD></TR></TABLE>\n");
3157 "<div id=\"content\">\n");
3159 /** Display the room list in the user's preferred format */
3160 list_all_rooms_by_floor(listviewpref);
3167 * \brief Set the message expire policy for this room and/or floor
3169 void set_room_policy(void) {
3172 if (strlen(bstr("ok_button")) == 0) {
3173 strcpy(WC->ImportantMessage,
3174 _("Cancelled. Changes were not saved."));
3179 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3180 serv_getln(buf, sizeof buf);
3181 strcpy(WC->ImportantMessage, &buf[4]);
3183 if (WC->axlevel >= 6) {
3184 strcat(WC->ImportantMessage, "<br />\n");
3185 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3186 serv_getln(buf, sizeof buf);
3187 strcat(WC->ImportantMessage, &buf[4]);