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[9]; /**< 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");
27 viewdefs[8] = _("Journal");
31 * \brief Determine which views are allowed as the default for creating a new room.
33 * \param which_view The view ID being queried.
35 int is_view_allowed_as_default(int which_view)
38 case VIEW_BBS: return(1);
39 case VIEW_MAILBOX: return(1);
40 case VIEW_ADDRESSBOOK: return(1);
41 case VIEW_CALENDAR: return(1);
42 case VIEW_TASKS: return(1);
43 case VIEW_NOTES: return(1);
44 case VIEW_WIKI: return(0); /**< because it isn't finished yet */
45 case VIEW_CALBRIEF: return(0);
46 case VIEW_JOURNAL: return(0);
47 default: return(0); /**< should never get here */
53 * \brief load the list of floors
55 void load_floorlist(void)
60 for (a = 0; a < 128; ++a)
64 serv_getln(buf, sizeof buf);
66 strcpy(floorlist[0], "Main Floor");
69 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
70 extract_token(floorlist[extract_int(buf, 0)], buf, 1, '|', sizeof floorlist[0]);
76 * \brief Free a session's march list
78 * \param wcf Pointer to session being cleared
80 void free_march_list(struct wcsession *wcf)
84 while (wcf->march != NULL) {
85 mptr = wcf->march->next;
95 * \brief remove a room from the march list
97 void remove_march(char *aaa)
99 struct march *mptr, *mptr2;
101 if (WC->march == NULL)
104 if (!strcasecmp(WC->march->march_name, aaa)) {
105 mptr = WC->march->next;
111 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
112 if (!strcasecmp(mptr->march_name, aaa)) {
113 mptr2->next = mptr->next;
126 * \brief display rooms in tree structure???
127 * \param rp the roomlist to build a tree from
129 void room_tree_list(struct roomlisting *rp)
138 room_tree_list(rp->lnext);
140 strcpy(rmname, rp->rlname);
143 wprintf("<a href=\"dotgoto&room=");
147 escputs1(rmname, 1, 1);
148 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
150 else if (f & QR_DIRECTORY)
152 else if (f & QR_NETWORK)
156 wprintf("</a><tt> </tt>\n");
158 room_tree_list(rp->rnext);
164 * \brief Room ordering stuff (compare first by floor, then by order)
165 * \param r1 first roomlist to compare
166 * \param r2 second roomlist co compare
167 * \return are they the same???
169 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
171 if ((r1 == NULL) && (r2 == NULL))
177 if (r1->rlfloor < r2->rlfloor)
179 if (r1->rlfloor > r2->rlfloor)
181 if (r1->rlorder < r2->rlorder)
183 if (r1->rlorder > r2->rlorder)
190 * \brief Common code for all room listings
191 * \param variety what???
193 void listrms(char *variety)
198 struct roomlisting *rl = NULL;
199 struct roomlisting *rp;
200 struct roomlisting *rs;
202 /** Ask the server for a room list */
204 serv_getln(buf, sizeof buf);
210 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
212 rp = malloc(sizeof(struct roomlisting));
213 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
214 rp->rlflags = extract_int(buf, 1);
215 rp->rlfloor = extract_int(buf, 2);
216 rp->rlorder = extract_int(buf, 3);
225 if (rordercmp(rp, rs) < 0) {
226 if (rs->lnext == NULL) {
233 if (rs->rnext == NULL) {
246 * If no rooms were listed, print an nbsp to make the cell
247 * borders show up anyway.
249 if (num_rooms == 0) wprintf(" ");
254 * \brief list all forgotten rooms
256 void zapped_list(void)
258 output_headers(1, 1, 1, 0, 0, 0);
260 svprintf("BOXTITLE", WCS_STRING, _("Zapped (forgotten) rooms"));
261 do_template("beginbox");
265 wprintf("<br /><br />\n");
266 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
267 do_template("endbox");
273 * \brief read this room's info file (set v to 1 for verbose mode)
280 int fullinfo_len = 0;
283 serv_getln(buf, sizeof buf);
286 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
287 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
288 strcpy(&fullinfo[fullinfo_len], buf);
289 fullinfo_len += strlen(buf);
293 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
294 strcpy(&briefinfo[50], "...");
296 wprintf("<div class=\"infos\" "
297 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
300 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
301 wprintf("<img class=\"close_infos\" "
302 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
303 "src=\"static/closewindow.gif\" alt=\"%s\">",
318 * \brief Display room banner icon.
319 * The server doesn't actually
320 * need the room name, but we supply it in order to
321 * keep the browser from using a cached icon from
324 void embed_room_graphic(void) {
327 serv_puts("OIMG _roompic_");
328 serv_getln(buf, sizeof buf);
330 wprintf("<img height=\"64px\" src=\"image&name=_roompic_&room=");
331 urlescputs(WC->wc_roomname);
334 serv_getln(buf, sizeof buf);
336 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
337 wprintf("<img height=48 width=48 src=\""
338 "static/viewcontacts_48x.gif"
342 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
343 wprintf("<img height=48 width=48 src=\""
344 "static/calarea_48x.gif"
348 else if (WC->wc_view == VIEW_TASKS) {
349 wprintf("<img height=48 width=48 src=\""
350 "static/taskmanag_48x.gif"
354 else if (WC->wc_view == VIEW_NOTES) {
355 wprintf("<img height=48 width=48 src=\""
356 "static/storenotes_48x.gif"
360 else if (WC->wc_view == VIEW_MAILBOX) {
361 wprintf("<img height=48 width=48 src=\""
362 "static/privatemess_48x.gif"
367 wprintf("<img height=48 width=48 src=\""
368 "static/chatrooms_48x.gif"
378 * \brief Display the current view and offer an option to change it
380 void embed_view_o_matic(void) {
383 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
384 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
385 wprintf("<label for=\"view_name\">");
386 wprintf(_("View as:"));
388 "<select name=\"newview\" size=\"1\" "
389 "id=\"view_name\" class=\"selectbox\" "
390 "OnChange=\"location.href=viewomatic.newview.options"
391 "[selectedIndex].value\">\n");
393 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
395 * Only offer the views that make sense, given the default
396 * view for the room. For example, don't offer a Calendar
397 * view in a non-Calendar room.
401 || (i == WC->wc_default_view) /**< default */
402 || ( (i == 0) && (WC->wc_default_view == 1) ) /**< mail or bulletin */
403 || ( (i == 1) && (WC->wc_default_view == 0) ) /**< mail or bulletin */
404 /** || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
407 wprintf("<option %s value=\"changeview?view=%d\">",
408 ((i == WC->wc_view) ? "selected" : ""),
410 escputs(viewdefs[i]);
411 wprintf("</option>\n");
414 wprintf("</select></form>\n");
419 * \brief Display a search box
421 void embed_search_o_matic(void) {
422 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
423 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
424 wprintf("<label for=\"search_name\">");
425 wprintf(_("Search: "));
426 wprintf("</label> <input "
427 "type=\"text\" name=\"query\" size=\"15\" maxlength=\"128\" "
428 "id=\"search_name\" class=\"inputbox\">\n"
430 wprintf("</form>\n");
435 * \brief Embed the room banner
437 * \param got The information returned from a GOTO server command
438 * \param navbar_style Determines which navigation buttons to display
442 void embed_room_banner(char *got, int navbar_style) {
445 char sanitized_roomname[256];
446 char with_files[256];
450 * We need to have the information returned by a GOTO server command.
451 * If it isn't supplied, we fake it by issuing our own GOTO.
454 serv_printf("GOTO %s", WC->wc_roomname);
455 serv_getln(buf, sizeof buf);
459 /** The browser needs some information for its own use */
460 wprintf("<script type=\"text/javascript\"> \n"
461 " room_is_trash = %d; \n"
467 * If the user happens to select the "make this my start page" link,
468 * we want it to remember the URL as a "/dotskip" one instead of
469 * a "skip" or "gotonext" or something like that.
471 snprintf(WC->this_page, sizeof(WC->this_page), "dotskip&room=%s",
474 /** Check for new mail. */
475 WC->new_mail = extract_int(&got[4], 9);
476 WC->wc_view = extract_int(&got[4], 11);
478 /* Is this a directory room and does it contain files and how many? */
479 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
482 serv_getln(buf2, sizeof buf2);
483 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
485 snprintf (with_files, sizeof with_files,
486 "; <a href=\"display_room_directory\"> %d %s </a>",
488 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
491 strcpy (with_files, "");
493 stresc(sanitized_roomname, 256, WC->wc_roomname, 1, 1);
494 svprintf("ROOMNAME", WCS_STRING, "%s", sanitized_roomname);
495 svprintf("NUMMSGS", WCS_STRING,
496 _("%d new of %d messages%s"),
497 extract_int(&got[4], 1),
498 extract_int(&got[4], 2),
501 svcallback("ROOMPIC", embed_room_graphic);
502 svcallback("ROOMINFO", readinfo);
503 svcallback("VIEWOMATIC", embed_view_o_matic);
504 svcallback("SEARCHOMATIC", embed_search_o_matic);
505 svcallback("START", offer_start_page);
507 do_template("roombanner");
508 if (navbar_style != navbar_none) {
510 wprintf("<div id=\"navbar\"><ul>");
512 if (navbar_style == navbar_default) wprintf(
513 "<li class=\"ungoto\">"
514 "<a href=\"ungoto\">"
515 "<img align=\"middle\" src=\"static/ungoto2_24x.gif\" border=\"0\">"
516 "<span class=\"navbar_link\">%s</span></A>"
517 "</li>\n", _("Ungoto")
520 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
522 "<li class=\"newmess\">"
523 "<a href=\"readnew\">"
524 "<img align=\"middle\" src=\"static/newmess2_24x.gif\" border=\"0\">"
525 "<span class=\"navbar_link\">%s</span></A>"
526 "</li>\n", _("Read new messages")
530 if (navbar_style == navbar_default) {
531 switch(WC->wc_view) {
532 case VIEW_ADDRESSBOOK:
534 "<li class=\"viewcontacts\">"
535 "<a href=\"readfwd\">"
536 "<img align=\"middle\" src=\"static/viewcontacts_24x.gif\" "
538 "<span class=\"navbar_link\">"
540 "</span></a></li>\n", _("View contacts")
545 "<li class=\"staskday\">"
546 "<a href=\"readfwd?calview=day\">"
547 "<img align=\"middle\" src=\"static/taskday2_24x.gif\" "
549 "<span class=\"navbar_link\">"
551 "</span></a></li>\n", _("Day view")
554 "<li class=\"monthview\">"
555 "<a href=\"readfwd?calview=month\">"
556 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
558 "<span class=\"navbar_link\">"
560 "</span></a></li>\n", _("Month view")
565 "<li class=\"monthview\">"
566 "<a href=\"readfwd?calview=month\">"
567 "<img align=\"middle\" src=\"static/monthview2_24x.gif\" "
569 "<span class=\"navbar_link\">"
571 "</span></a></li>\n", _("Calendar list")
576 "<li class=\"taskmanag\">"
577 "<a href=\"readfwd\">"
578 "<img align=\"middle\" src=\"static/taskmanag_24x.gif\" "
580 "<span class=\"navbar_link\">"
582 "</span></a></li>\n", _("View tasks")
587 "<li class=\"viewnotes\">"
588 "<a href=\"readfwd\">"
589 "<img align=\"middle\" src=\"static/viewnotes_24x.gif\" "
591 "<span class=\"navbar_link\">"
593 "</span></a></li>\n", _("View notes")
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", _("View message list")
609 "<li class=\"readallmess\">"
610 "<a href=\"readfwd\">"
611 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
613 "<span class=\"navbar_link\">"
615 "</span></a></li>\n", _("Wiki home")
620 "<li class=\"readallmess\">"
621 "<a href=\"readfwd\">"
622 "<img align=\"middle\" src=\"static/readallmess3_24x.gif\" "
624 "<span class=\"navbar_link\">"
626 "</span></a></li>\n", _("Read all messages")
632 if (navbar_style == navbar_default) {
633 switch(WC->wc_view) {
634 case VIEW_ADDRESSBOOK:
636 "<li class=\"addnewcontact\">"
637 "<a href=\"display_enter\">"
638 "<img align=\"middle\" src=\"static/addnewcontact_24x.gif\" "
639 "border=\"0\"><span class=\"navbar_link\">"
641 "</span></a></li>\n", _("Add new contact")
646 wprintf("<li class=\"addevent\"><a href=\"display_enter");
647 if (!IsEmptyStr(bstr("year" ))) wprintf("?year=%s", bstr("year"));
648 if (!IsEmptyStr(bstr("month"))) wprintf("?month=%s", bstr("month"));
649 if (!IsEmptyStr(bstr("day" ))) wprintf("?day=%s", bstr("day"));
651 "<img align=\"middle\" src=\"static/addevent_24x.gif\" "
652 "border=\"0\"><span class=\"navbar_link\">"
654 "</span></a></li>\n", _("Add new event")
659 "<li class=\"newmess\">"
660 "<a href=\"display_enter\">"
661 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
662 "border=\"0\"><span class=\"navbar_link\">"
664 "</span></a></li>\n", _("Add new task")
669 "<li class=\"enternewnote\">"
670 "<a href=\"javascript:add_new_note();\">"
671 "<img align=\"middle\" src=\"static/enternewnote_24x.gif\" "
672 "border=\"0\"><span class=\"navbar_link\">"
674 "</span></a></li>\n", _("Add new note")
678 safestrncpy(buf, bstr("page"), sizeof buf);
681 "<li class=\"newmess\">"
682 "<a href=\"display_enter?wikipage=%s\">"
683 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
684 "border=\"0\"><span class=\"navbar_link\">"
686 "</span></a></li>\n", buf, _("Edit this page")
691 "<li class=\"newmess\">"
692 "<a href=\"display_enter\">"
693 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
694 "border=\"0\"><span class=\"navbar_link\">"
696 "</span></a></li>\n", _("Write mail")
701 "<li class=\"newmess\">"
702 "<a href=\"display_enter\">"
703 "<img align=\"middle\" src=\"static/newmess3_24x.gif\" "
704 "border=\"0\"><span class=\"navbar_link\">"
706 "</span></a></li>\n", _("Enter a message")
712 if (navbar_style == navbar_default) wprintf(
713 "<li class=\"skipthisroom\">"
716 "<img align=\"middle\" src=\"static/skipthisroom_24x.gif\" border=\"0\">"
717 "<span class=\"navbar_link\">%s</span></a>"
719 _("Leave all messages marked as unread, go to next room with unread messages"),
723 if (navbar_style == navbar_default) wprintf(
724 "<li class=\"markngo\">"
725 "<a href=\"gotonext\" "
727 "<img align=\"middle\" src=\"static/markngo_24x.gif\" border=\"0\">"
728 "<span class=\"navbar_link\">%s</span></a>"
730 _("Mark all messages as read, go to next room with unread messages"),
734 wprintf("</ul></div>\n");
741 * \brief back end routine to take the session to a new room
742 * \param gname room to go to
745 int gotoroom(char *gname)
748 static long ls = (-1L);
751 /** store ungoto information */
752 strcpy(WC->ugname, WC->wc_roomname);
755 /** move to the new room */
756 serv_printf("GOTO %s", gname);
757 serv_getln(buf, sizeof buf);
761 serv_puts("GOTO _BASEROOM_");
762 serv_getln(buf, sizeof buf);
769 extract_token(WC->wc_roomname, &buf[4], 0, '|', sizeof WC->wc_roomname);
770 WC->room_flags = extract_int(&buf[4], 4);
771 /* highest_msg_read = extract_int(&buf[4],6);
772 maxmsgnum = extract_int(&buf[4],5);
774 WC->is_mailbox = extract_int(&buf[4],7);
775 ls = extract_long(&buf[4], 6);
776 WC->wc_floor = extract_int(&buf[4], 10);
777 WC->wc_view = extract_int(&buf[4], 11);
778 WC->wc_default_view = extract_int(&buf[4], 12);
779 WC->wc_is_trash = extract_int(&buf[4], 13);
780 WC->room_flags2 = extract_int(&buf[4], 14);
783 WC->is_room_aide = WC->is_aide;
785 WC->is_room_aide = (char) extract_int(&buf[4], 8);
787 remove_march(WC->wc_roomname);
788 if (!strcasecmp(gname, "_BASEROOM_"))
796 * \brief Locate the room on the march list which we most want to go to.
798 * is measured given a "weight" of preference based on various factors.
799 * \param desired_floor the room number on the citadel server
800 * \return the roomname
802 char *pop_march(int desired_floor)
804 static char TheRoom[128];
806 int TheOrder = 32767;
809 struct march *mptr = NULL;
811 strcpy(TheRoom, "_BASEROOM_");
812 if (WC->march == NULL)
815 for (mptr = WC->march; mptr != NULL; mptr = mptr->next) {
817 if ((strcasecmp(mptr->march_name, "_BASEROOM_")))
818 weight = weight + 10000;
819 if (mptr->march_floor == desired_floor)
820 weight = weight + 5000;
822 weight = weight + ((128 - (mptr->march_floor)) * 128);
823 weight = weight + (128 - (mptr->march_order));
825 if (weight > TheWeight) {
827 strcpy(TheRoom, mptr->march_name);
828 TheFloor = mptr->march_floor;
829 TheOrder = mptr->march_order;
838 *\brief Goto next room having unread messages.
839 * We want to skip over rooms that the user has already been to, and take the
840 * user back to the lobby when done. The room we end up in is placed in
841 * newroom - which is set to 0 (the lobby) initially.
842 * We start the search in the current room rather than the beginning to prevent
843 * two or more concurrent users from dragging each other back to the same room.
848 struct march *mptr, *mptr2;
853 * First check to see if the march-mode list is already allocated.
854 * If it is, pop the first room off the list and go there.
857 if (WC->march == NULL) {
859 serv_getln(buf, sizeof buf);
861 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
862 extract_token(room_name, buf, 0, '|', sizeof room_name);
863 if (strcasecmp(room_name, WC->wc_roomname)) {
864 mptr = (struct march *) malloc(sizeof(struct march));
866 safestrncpy(mptr->march_name, room_name, sizeof mptr->march_name);
867 mptr->march_floor = extract_int(buf, 2);
868 mptr->march_order = extract_int(buf, 3);
869 if (WC->march == NULL) {
873 while (mptr2->next != NULL)
880 * add _BASEROOM_ to the end of the march list, so the user will end up
881 * in the system base room (usually the Lobby>) at the end of the loop
883 mptr = (struct march *) malloc(sizeof(struct march));
885 mptr->march_order = 0;
886 mptr->march_floor = 0;
887 strcpy(mptr->march_name, "_BASEROOM_");
888 if (WC->march == NULL) {
892 while (mptr2->next != NULL)
897 * ...and remove the room we're currently in, so a <G>oto doesn't make us
898 * walk around in circles
900 remove_march(WC->wc_roomname);
902 if (WC->march != NULL) {
903 strcpy(next_room, pop_march(-1));
905 strcpy(next_room, "_BASEROOM_");
909 smart_goto(next_room);
914 * \brief goto next room
915 * \param next_room next room to go to
917 void smart_goto(char *next_room) {
925 * \brief mark all messages in current room as having been read
927 void slrp_highest(void)
931 serv_puts("SLRP HIGHEST");
932 serv_getln(buf, sizeof buf);
937 * \brief un-goto the previous room
943 if (!strcmp(WC->ugname, "")) {
944 smart_goto(WC->wc_roomname);
947 serv_printf("GOTO %s", WC->ugname);
948 serv_getln(buf, sizeof buf);
950 smart_goto(WC->wc_roomname);
953 if (WC->uglsn >= 0L) {
954 serv_printf("SLRP %ld", WC->uglsn);
955 serv_getln(buf, sizeof buf);
957 strcpy(buf, WC->ugname);
958 strcpy(WC->ugname, "");
962 typedef struct __room_states {
977 * \brief Set/clear/read the "self-service list subscribe" flag for a room
979 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
980 * \return return the new value.
983 int self_service(int newval) {
984 int current_value = 0;
990 int flags, floor, order, view, flags2;
993 serv_getln(buf, sizeof buf);
994 if (buf[0] != '2') return(0);
996 extract_token(name, &buf[4], 0, '|', sizeof name);
997 extract_token(password, &buf[4], 1, '|', sizeof password);
998 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
999 flags = extract_int(&buf[4], 3);
1000 floor = extract_int(&buf[4], 4);
1001 order = extract_int(&buf[4], 5);
1002 view = extract_int(&buf[4], 6);
1003 flags2 = extract_int(&buf[4], 7);
1005 if (flags2 & QR2_SELFLIST) {
1013 flags2 = flags2 | QR2_SELFLIST;
1015 else if (newval == 0) {
1016 flags2 = flags2 & ~QR2_SELFLIST;
1019 return(current_value);
1022 if (newval != current_value) {
1023 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1024 name, password, dirname, flags,
1025 floor, order, view, flags2);
1026 serv_getln(buf, sizeof buf);
1034 is_selflist(room_states *RoomFlags)
1036 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1040 is_publiclist(room_states *RoomFlags)
1042 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1046 is_moderatedlist(room_states *RoomFlags)
1048 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1052 * \brief Set/clear/read the "self-service list subscribe" flag for a room
1054 * \param newval set to 0 to clear, 1 to set, any other value to leave unchanged.
1055 * \return return the new value.
1058 int get_roomflags(room_states *RoomOps)
1063 serv_getln(buf, sizeof buf);
1064 if (buf[0] != '2') return(0);
1066 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1067 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1068 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1069 RoomOps->flags = extract_int(&buf[4], 3);
1070 RoomOps->floor = extract_int(&buf[4], 4);
1071 RoomOps->order = extract_int(&buf[4], 5);
1072 RoomOps->view = extract_int(&buf[4], 6);
1073 RoomOps->flags2 = extract_int(&buf[4], 7);
1077 int set_roomflags(room_states *RoomOps)
1081 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1090 serv_getln(buf, sizeof buf);
1100 * \brief display the form for editing a room
1102 void display_editroom(void)
1107 char remote_room[128];
1110 char er_password[10];
1111 char er_dirname[15];
1112 char er_roomaide[26];
1119 char *not_shared_with;
1122 int floorpolicy = 0;
1124 char pop3_host[128];
1129 if (IsEmptyStr(tab)) tab = "admin";
1132 output_headers(1, 1, 1, 0, 0, 0);
1134 wprintf("<div class=\"fix_scrollbar_bug\">");
1136 /** print the tabbed dialog */
1137 wprintf("<ul class=\"tabbed_dialog\">\n");
1139 wprintf("<li class=\"tablabel ");
1140 if (!strcmp(tab, "admin")) {
1141 wprintf(" tab_cell_label\">");
1142 wprintf(_("Administration"));
1145 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=admin\">");
1146 wprintf(_("Administration"));
1151 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1153 wprintf("<li class=\"tablabel ");
1154 if (!strcmp(tab, "config")) {
1155 wprintf(" tab_cell_label\">");
1156 wprintf(_("Configuration"));
1159 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=config\">");
1160 wprintf(_("Configuration"));
1165 wprintf("<li class=\"tablabel ");
1166 if (!strcmp(tab, "expire")) {
1167 wprintf(" tab_cell_label\">");
1168 wprintf(_("Message expire policy"));
1171 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=expire\">");
1172 wprintf(_("Message expire policy"));
1177 wprintf("<li class=\"tablabel ");
1178 if (!strcmp(tab, "access")) {
1179 wprintf(" tab_cell_label\">");
1180 wprintf(_("Access controls"));
1183 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=access\">");
1184 wprintf(_("Access controls"));
1189 wprintf("<li class=\"tablabel ");
1190 if (!strcmp(tab, "sharing")) {
1191 wprintf(" tab_cell_label\">");
1192 wprintf(_("Sharing"));
1195 wprintf(" tab_cell_edit\"><a href=\"display_editroom&tab=sharing\">");
1196 wprintf(_("Sharing"));
1201 wprintf("<li class=\"tablabel ");
1202 if (!strcmp(tab, "listserv")) {
1203 wprintf(" tab_cell_label\">");
1204 wprintf(_("Mailing list service"));
1207 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=listserv\">");
1208 wprintf(_("Mailing list service"));
1215 wprintf("<li class=\"tablabel ");
1216 if (!strcmp(tab, "feeds")) {
1217 wprintf(" tab_cell_label\">");
1218 wprintf(_("Remote retrieval"));
1221 wprintf("< tab_cell_edit\"><a href=\"display_editroom&tab=feeds\">");
1222 wprintf(_("Remote retrieval"));
1228 /** end tabbed dialog */
1230 /** begin content of whatever tab is open now */
1232 if (!strcmp(tab, "admin")) {
1233 wprintf("<div class=\"tabcontent\">");
1235 "<li><a href=\"delete_room\" "
1236 "onClick=\"return confirm('");
1237 wprintf(_("Are you sure you want to delete this room?"));
1238 wprintf("');\">\n");
1239 wprintf(_("Delete this room"));
1241 "<li><a href=\"display_editroompic\">\n");
1242 wprintf(_("Set or change the icon for this room's banner"));
1244 "<li><a href=\"display_editinfo\">\n");
1245 wprintf(_("Edit this room's Info file"));
1251 if (!strcmp(tab, "config")) {
1252 wprintf("<div class=\"tabcontent\">");
1254 serv_getln(buf, sizeof buf);
1256 if (!strncmp(buf, "550", 3)) {
1257 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1258 _("Higher access is required to access this function.")
1261 else if (buf[0] != '2') {
1262 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1265 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1266 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1267 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1268 er_flags = extract_int(&buf[4], 3);
1269 er_floor = extract_int(&buf[4], 4);
1270 er_flags2 = extract_int(&buf[4], 7);
1272 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1273 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1275 wprintf("<ul><li>");
1276 wprintf(_("Name of room: "));
1277 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1283 wprintf(_("Resides on floor: "));
1284 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1285 if (er_flags & QR_MAILBOX)
1286 wprintf("disabled >\n");
1287 for (i = 0; i < 128; ++i)
1288 if (!IsEmptyStr(floorlist[i])) {
1289 wprintf("<OPTION ");
1291 wprintf("SELECTED ");
1292 wprintf("VALUE=\"%d\">", i);
1293 escputs(floorlist[i]);
1294 wprintf("</OPTION>\n");
1296 wprintf("</select>\n");
1299 wprintf(_("Type of room:"));
1302 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1303 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1304 wprintf("CHECKED ");
1305 wprintf("OnChange=\""
1306 " if (this.form.type[0].checked == true) { "
1307 " this.form.er_floor.disabled = false; "
1310 wprintf(_("Public (automatically appears to everyone)"));
1313 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1314 if ((er_flags & QR_PRIVATE) &&
1315 (er_flags & QR_GUESSNAME))
1316 wprintf("CHECKED ");
1317 wprintf(" OnChange=\""
1318 " if (this.form.type[1].checked == true) { "
1319 " this.form.er_floor.disabled = false; "
1322 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1324 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1325 if ((er_flags & QR_PRIVATE) &&
1326 (er_flags & QR_PASSWORDED))
1327 wprintf("CHECKED ");
1328 wprintf(" OnChange=\""
1329 " if (this.form.type[2].checked == true) { "
1330 " this.form.er_floor.disabled = false; "
1333 wprintf(_("Private - require password: "));
1334 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1337 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1338 if ((er_flags & QR_PRIVATE)
1339 && ((er_flags & QR_GUESSNAME) == 0)
1340 && ((er_flags & QR_PASSWORDED) == 0))
1341 wprintf("CHECKED ");
1342 wprintf(" OnChange=\""
1343 " if (this.form.type[3].checked == true) { "
1344 " this.form.er_floor.disabled = false; "
1347 wprintf(_("Private - invitation only"));
1349 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1350 if (er_flags & QR_MAILBOX)
1351 wprintf("CHECKED ");
1352 wprintf (" OnChange=\""
1353 " if (this.form.type[4].checked == true) { "
1354 " this.form.er_floor.disabled = true; "
1357 wprintf(_("Personal (mailbox for you only)"));
1359 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1361 wprintf(_("If private, cause current users to forget room"));
1363 wprintf("\n</ul>\n");
1365 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1366 if (er_flags & QR_PREFONLY)
1367 wprintf("CHECKED ");
1369 wprintf(_("Preferred users only"));
1371 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1372 if (er_flags & QR_READONLY)
1373 wprintf("CHECKED ");
1375 wprintf(_("Read-only room"));
1377 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1378 if (er_flags2 & QR2_COLLABDEL)
1379 wprintf("CHECKED ");
1381 wprintf(_("All users allowed to post may also delete messages"));
1383 /** directory stuff */
1384 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1385 if (er_flags & QR_DIRECTORY)
1386 wprintf("CHECKED ");
1388 wprintf(_("File directory room"));
1390 wprintf("\n<ul><li>");
1391 wprintf(_("Directory name: "));
1392 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1395 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1396 if (er_flags & QR_UPLOAD)
1397 wprintf("CHECKED ");
1399 wprintf(_("Uploading allowed"));
1401 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1402 if (er_flags & QR_DOWNLOAD)
1403 wprintf("CHECKED ");
1405 wprintf(_("Downloading allowed"));
1407 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1408 if (er_flags & QR_VISDIR)
1409 wprintf("CHECKED ");
1411 wprintf(_("Visible directory"));
1414 /** end of directory stuff */
1416 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1417 if (er_flags & QR_NETWORK)
1418 wprintf("CHECKED ");
1420 wprintf(_("Network shared room"));
1422 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1423 if (er_flags & QR_PERMANENT)
1424 wprintf("CHECKED ");
1426 wprintf(_("Permanent (does not auto-purge)"));
1428 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1429 if (er_flags2 & QR2_SUBJECTREQ)
1430 wprintf("CHECKED ");
1432 wprintf(_("Subject Required (Force users to specify a message subject)"));
1434 /** start of anon options */
1437 wprintf(_("Anonymous messages"));
1440 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1441 if (((er_flags & QR_ANONONLY) == 0)
1442 && ((er_flags & QR_ANONOPT) == 0))
1443 wprintf("CHECKED ");
1445 wprintf(_("No anonymous messages"));
1447 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1448 if (er_flags & QR_ANONONLY)
1449 wprintf("CHECKED ");
1451 wprintf(_("All messages are anonymous"));
1453 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1454 if (er_flags & QR_ANONOPT)
1455 wprintf("CHECKED ");
1457 wprintf(_("Prompt user when entering messages"));
1460 /* end of anon options */
1463 wprintf(_("Room aide: "));
1465 serv_getln(buf, sizeof buf);
1466 if (buf[0] != '2') {
1467 wprintf("<em>%s</em>\n", &buf[4]);
1469 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1470 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1473 wprintf("</ul><CENTER>\n");
1474 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1475 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1477 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1487 /** Sharing the room with other Citadel nodes... */
1488 if (!strcmp(tab, "sharing")) {
1489 wprintf("<div class=\"tabcontent\">");
1491 shared_with = strdup("");
1492 not_shared_with = strdup("");
1494 /** Learn the current configuration */
1495 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1496 serv_getln(buf, sizeof buf);
1497 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1498 extract_token(node, buf, 0, '|', sizeof node);
1499 not_shared_with = realloc(not_shared_with,
1500 strlen(not_shared_with) + 32);
1501 strcat(not_shared_with, node);
1502 strcat(not_shared_with, "\n");
1506 serv_getln(buf, sizeof buf);
1507 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1508 extract_token(cmd, buf, 0, '|', sizeof cmd);
1509 extract_token(node, buf, 1, '|', sizeof node);
1510 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1511 if (!strcasecmp(cmd, "ignet_push_share")) {
1512 shared_with = realloc(shared_with,
1513 strlen(shared_with) + 32);
1514 strcat(shared_with, node);
1515 if (!IsEmptyStr(remote_room)) {
1516 strcat(shared_with, "|");
1517 strcat(shared_with, remote_room);
1519 strcat(shared_with, "\n");
1523 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1524 extract_token(buf, shared_with, i, '\n', sizeof buf);
1525 extract_token(node, buf, 0, '|', sizeof node);
1526 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1527 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1528 if (!strcasecmp(node, cmd)) {
1529 remove_token(not_shared_with, j, '\n');
1534 /** Display the stuff */
1535 wprintf("<CENTER><br />"
1536 "<table border=1 cellpadding=5><tr>"
1538 wprintf(_("Shared with"));
1539 wprintf("</I></B></td>"
1541 wprintf(_("Not shared with"));
1542 wprintf("</I></B></td></tr>\n"
1543 "<tr><td VALIGN=TOP>\n");
1545 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1546 wprintf(_("Remote node name"));
1547 wprintf("</td><td>");
1548 wprintf(_("Remote room name"));
1549 wprintf("</td><td>");
1550 wprintf(_("Actions"));
1551 wprintf("</td></tr>\n");
1553 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1554 extract_token(buf, shared_with, i, '\n', sizeof buf);
1555 extract_token(node, buf, 0, '|', sizeof node);
1556 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1557 if (!IsEmptyStr(node)) {
1558 wprintf("<form method=\"POST\" action=\"netedit\">");
1559 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1560 wprintf("<tr><td>%s</td>\n", node);
1563 if (!IsEmptyStr(remote_room)) {
1564 escputs(remote_room);
1570 wprintf("<input type=\"hidden\" NAME=\"line\" "
1571 "VALUE=\"ignet_push_share|");
1573 if (!IsEmptyStr(remote_room)) {
1575 urlescputs(remote_room);
1578 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1579 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1580 wprintf("<input type=\"submit\" "
1581 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1582 wprintf("</td></tr></form>\n");
1586 wprintf("</table>\n");
1587 wprintf("</td><td VALIGN=TOP>\n");
1588 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1589 wprintf(_("Remote node name"));
1590 wprintf("</td><td>");
1591 wprintf(_("Remote room name"));
1592 wprintf("</td><td>");
1593 wprintf(_("Actions"));
1594 wprintf("</td></tr>\n");
1596 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1597 extract_token(node, not_shared_with, i, '\n', sizeof node);
1598 if (!IsEmptyStr(node)) {
1599 wprintf("<form method=\"POST\" action=\"netedit\">");
1600 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1601 wprintf("<tr><td>");
1604 "<input type=\"INPUT\" "
1608 wprintf("<input type=\"hidden\" "
1610 "VALUE=\"ignet_push_share|");
1613 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1614 "VALUE=\"sharing\">\n");
1615 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1616 "VALUE=\"add\">\n");
1617 wprintf("<input type=\"submit\" "
1618 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1619 wprintf("</td></tr></form>\n");
1623 wprintf("</table>\n");
1624 wprintf("</td></tr>"
1625 "</table></CENTER><br />\n"
1626 "<I><B>%s</B><ul><li>", _("Notes:"));
1627 wprintf(_("When sharing a room, "
1628 "it must be shared from both ends. Adding a node to "
1629 "the 'shared' list sends messages out, but in order to"
1630 " receive messages, the other nodes must be configured"
1631 " to send messages out to your system as well. "
1632 "<li>If the remote room name is blank, it is assumed "
1633 "that the room name is identical on the remote node."
1634 "<li>If the remote room name is different, the remote "
1635 "node must also configure the name of the room here."
1642 /** Mailing list management */
1643 if (!strcmp(tab, "listserv")) {
1644 room_states RoomFlags;
1645 wprintf("<div class=\"tabcontent\">");
1647 wprintf("<br /><center>"
1648 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1649 "<tr><td VALIGN=TOP>");
1651 wprintf(_("<i>The contents of this room are being "
1652 "mailed <b>as individual messages</b> "
1653 "to the following list recipients:"
1654 "</i><br /><br />\n"));
1657 serv_getln(buf, sizeof buf);
1658 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1659 extract_token(cmd, buf, 0, '|', sizeof cmd);
1660 if (!strcasecmp(cmd, "listrecp")) {
1661 extract_token(recp, buf, 1, '|', sizeof recp);
1664 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line=listrecp|");
1667 wprintf(_("(remove)"));
1668 wprintf("</A><br />");
1671 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1672 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1673 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1674 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1675 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1676 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1677 wprintf("</form>\n");
1679 wprintf("</td><td VALIGN=TOP>\n");
1681 wprintf(_("<i>The contents of this room are being "
1682 "mailed <b>in digest form</b> "
1683 "to the following list recipients:"
1684 "</i><br /><br />\n"));
1687 serv_getln(buf, sizeof buf);
1688 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1689 extract_token(cmd, buf, 0, '|', sizeof cmd);
1690 if (!strcasecmp(cmd, "digestrecp")) {
1691 extract_token(recp, buf, 1, '|', sizeof recp);
1694 wprintf(" <a href=\"netedit&cmd=remove&tab=listserv&line="
1698 wprintf(_("(remove)"));
1699 wprintf("</A><br />");
1702 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1703 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1704 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1705 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1706 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1707 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1708 wprintf("</form>\n");
1710 wprintf("</td></tr></table>\n");
1712 /** Pop open an address book -- begin **/
1713 wprintf("<div align=right>"
1714 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1716 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1721 _("Add recipients from Contacts or other address books"),
1722 _("Add recipients from Contacts or other address books")
1724 /** Pop open an address book -- end **/
1726 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1728 get_roomflags (&RoomFlags);
1730 /* Self Service subscription? */
1731 wprintf("<table><tr><td>\n");
1732 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1733 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1734 " <tr><td colspan=\"2\">\n",
1735 (is_selflist(&RoomFlags))?"checked":"");
1736 wprintf(_("The URL for subscribe/unsubscribe is: "));
1737 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1738 (is_https ? "https" : "http"),
1740 /* Public posting? */
1741 wprintf("<tr><td>");
1742 wprintf(_("Allow non-subscribers to mail to this room."));
1743 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1744 (is_publiclist(&RoomFlags))?"checked":"");
1746 /* Moderated List? */
1747 wprintf("<tr><td>");
1748 wprintf(_("Room post publication needs Aide permission."));
1749 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1750 (is_moderatedlist(&RoomFlags))?"checked":"");
1753 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1754 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1755 wprintf("</table></form>");
1758 wprintf("</CENTER>\n");
1763 /** Configuration of The Dreaded Auto-Purger */
1764 if (!strcmp(tab, "expire")) {
1765 wprintf("<div class=\"tabcontent\">");
1767 serv_puts("GPEX room");
1768 serv_getln(buf, sizeof buf);
1769 if (!strncmp(buf, "550", 3)) {
1770 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1771 _("Higher access is required to access this function.")
1774 else if (buf[0] != '2') {
1775 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1778 roompolicy = extract_int(&buf[4], 0);
1779 roomvalue = extract_int(&buf[4], 1);
1781 serv_puts("GPEX floor");
1782 serv_getln(buf, sizeof buf);
1783 if (buf[0] == '2') {
1784 floorpolicy = extract_int(&buf[4], 0);
1785 floorvalue = extract_int(&buf[4], 1);
1788 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1789 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1790 wprintf("<table border=0 cellspacing=5>\n");
1791 wprintf("<tr><td>");
1792 wprintf(_("Message expire policy for this room"));
1794 escputs(WC->wc_roomname);
1795 wprintf(")</td><td>");
1796 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1797 ((roompolicy == 0) ? "CHECKED" : "") );
1798 wprintf(_("Use the default policy for this floor"));
1799 wprintf("<br />\n");
1800 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1801 ((roompolicy == 1) ? "CHECKED" : "") );
1802 wprintf(_("Never automatically expire messages"));
1803 wprintf("<br />\n");
1804 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1805 ((roompolicy == 2) ? "CHECKED" : "") );
1806 wprintf(_("Expire by message count"));
1807 wprintf("<br />\n");
1808 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1809 ((roompolicy == 3) ? "CHECKED" : "") );
1810 wprintf(_("Expire by message age"));
1812 wprintf(_("Number of messages or days: "));
1813 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1814 wprintf("</td></tr>\n");
1816 if (WC->axlevel >= 6) {
1817 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1818 wprintf("<tr><td>");
1819 wprintf(_("Message expire policy for this floor"));
1821 escputs(floorlist[WC->wc_floor]);
1822 wprintf(")</td><td>");
1823 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1824 ((floorpolicy == 0) ? "CHECKED" : "") );
1825 wprintf(_("Use the system default"));
1826 wprintf("<br />\n");
1827 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1828 ((floorpolicy == 1) ? "CHECKED" : "") );
1829 wprintf(_("Never automatically expire messages"));
1830 wprintf("<br />\n");
1831 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1832 ((floorpolicy == 2) ? "CHECKED" : "") );
1833 wprintf(_("Expire by message count"));
1834 wprintf("<br />\n");
1835 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1836 ((floorpolicy == 3) ? "CHECKED" : "") );
1837 wprintf(_("Expire by message age"));
1839 wprintf(_("Number of messages or days: "));
1840 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1844 wprintf("<CENTER>\n");
1845 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1846 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1848 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1849 wprintf("</CENTER></td><tr>\n");
1851 wprintf("</table>\n"
1852 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1860 /** Access controls */
1861 if (!strcmp(tab, "access")) {
1862 wprintf("<div class=\"tabcontent\">");
1867 /** Fetch messages from remote locations */
1868 if (!strcmp(tab, "feeds")) {
1869 wprintf("<div class=\"tabcontent\">");
1872 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1873 wprintf("</i><br />\n");
1875 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1876 "<tr class=\"even\"><th>");
1877 wprintf(_("Remote host"));
1878 wprintf("</th><th>");
1879 wprintf(_("User name"));
1880 wprintf("</th><th>");
1881 wprintf(_("Password"));
1882 wprintf("</th><th>");
1883 wprintf(_("Keep messages on server?"));
1884 wprintf("</th><th> </th></tr>");
1887 serv_getln(buf, sizeof buf);
1889 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1890 extract_token(cmd, buf, 0, '|', sizeof cmd);
1891 if (!strcasecmp(cmd, "pop3client")) {
1892 safestrncpy(recp, &buf[11], sizeof recp);
1895 wprintf("<tr class=\"%s\">",
1896 (bg ? "even" : "odd")
1900 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1905 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1909 wprintf("<td>*****</td>"); /* Don't show the password */
1911 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1913 wprintf("<td class=\"button_link\">");
1914 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=pop3client|");
1917 wprintf(_("(remove)"));
1918 wprintf("</a></td>");
1924 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1926 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1927 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1928 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1930 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1933 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1936 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1939 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1942 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1943 wprintf("</td></tr>");
1944 wprintf("</form></table>\n");
1949 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1950 wprintf("</i><br />\n");
1952 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1953 "<tr class=\"even\"><th>");
1954 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1955 wprintf(_("Feed URL"));
1956 wprintf("</th><th>");
1957 wprintf("</th></tr>");
1960 serv_getln(buf, sizeof buf);
1962 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1963 extract_token(cmd, buf, 0, '|', sizeof cmd);
1964 if (!strcasecmp(cmd, "rssclient")) {
1965 safestrncpy(recp, &buf[10], sizeof recp);
1968 wprintf("<tr class=\"%s\">",
1969 (bg ? "even" : "odd")
1973 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1977 wprintf("<td class=\"button_link\">");
1978 wprintf(" <a href=\"netedit&cmd=remove&tab=feeds&line=rssclient|");
1981 wprintf(_("(remove)"));
1982 wprintf("</a></td>");
1988 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1990 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1991 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
1992 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
1994 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
1995 "maxlength=\"256\" name=\"line_pop3host\">\n");
1998 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
1999 wprintf("</td></tr>");
2000 wprintf("</form></table>\n");
2006 /** end content of whatever tab is open now */
2007 wprintf("</div>\n");
2009 address_book_popup();
2015 * \brief Toggle self-service list subscription
2017 void toggle_self_service(void) {
2019 room_states RoomFlags;
2021 get_roomflags (&RoomFlags);
2023 // Yank out the bits we want to change
2024 RoomFlags.flags2 = RoomFlags.flags2 &
2025 !(QR2_SELFLIST|QR2_SMTP_PUBLIC|QR2_MODERATED);
2027 if (!strcasecmp(bstr("QR2_SelfList"), "yes"))
2028 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2029 if (!strcasecmp(bstr("QR2_SMTP_PUBLIC"), "yes"))
2030 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2031 if (!strcasecmp(bstr("QR2_Moderated"), "yes"))
2032 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2034 set_roomflags (&RoomFlags);
2042 * \brief save new parameters for a room
2048 char er_password[10];
2049 char er_dirname[15];
2050 char er_roomaide[26];
2053 int er_listingorder;
2059 if (IsEmptyStr(bstr("ok_button"))) {
2060 strcpy(WC->ImportantMessage,
2061 _("Cancelled. Changes were not saved."));
2066 serv_getln(buf, sizeof buf);
2068 if (buf[0] != '2') {
2069 strcpy(WC->ImportantMessage, &buf[4]);
2073 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
2074 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
2075 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
2076 er_flags = extract_int(&buf[4], 3);
2077 er_listingorder = extract_int(&buf[4], 5);
2078 er_defaultview = extract_int(&buf[4], 6);
2079 er_flags2 = extract_int(&buf[4], 7);
2081 strcpy(er_roomaide, bstr("er_roomaide"));
2082 if (IsEmptyStr(er_roomaide)) {
2084 serv_getln(buf, sizeof buf);
2085 if (buf[0] != '2') {
2086 strcpy(er_roomaide, "");
2088 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
2091 strcpy(buf, bstr("er_name"));
2093 if (!IsEmptyStr(buf)) {
2094 strcpy(er_name, buf);
2097 strcpy(buf, bstr("er_password"));
2099 if (!IsEmptyStr(buf))
2100 strcpy(er_password, buf);
2102 strcpy(buf, bstr("er_dirname"));
2104 if (!IsEmptyStr(buf))
2105 strcpy(er_dirname, buf);
2107 strcpy(buf, bstr("type"));
2108 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2110 if (!strcmp(buf, "invonly")) {
2111 er_flags |= (QR_PRIVATE);
2113 if (!strcmp(buf, "hidden")) {
2114 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2116 if (!strcmp(buf, "passworded")) {
2117 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2119 if (!strcmp(buf, "personal")) {
2120 er_flags |= QR_MAILBOX;
2122 er_flags &= ~QR_MAILBOX;
2125 if (!strcmp(bstr("prefonly"), "yes")) {
2126 er_flags |= QR_PREFONLY;
2128 er_flags &= ~QR_PREFONLY;
2131 if (!strcmp(bstr("readonly"), "yes")) {
2132 er_flags |= QR_READONLY;
2134 er_flags &= ~QR_READONLY;
2138 if (!strcmp(bstr("collabdel"), "yes")) {
2139 er_flags2 |= QR2_COLLABDEL;
2141 er_flags2 &= ~QR2_COLLABDEL;
2144 if (!strcmp(bstr("permanent"), "yes")) {
2145 er_flags |= QR_PERMANENT;
2147 er_flags &= ~QR_PERMANENT;
2150 if (!strcmp(bstr("subjectreq"), "yes")) {
2151 er_flags2 |= QR2_SUBJECTREQ;
2153 er_flags2 &= ~QR2_SUBJECTREQ;
2156 if (!strcmp(bstr("network"), "yes")) {
2157 er_flags |= QR_NETWORK;
2159 er_flags &= ~QR_NETWORK;
2162 if (!strcmp(bstr("directory"), "yes")) {
2163 er_flags |= QR_DIRECTORY;
2165 er_flags &= ~QR_DIRECTORY;
2168 if (!strcmp(bstr("ulallowed"), "yes")) {
2169 er_flags |= QR_UPLOAD;
2171 er_flags &= ~QR_UPLOAD;
2174 if (!strcmp(bstr("dlallowed"), "yes")) {
2175 er_flags |= QR_DOWNLOAD;
2177 er_flags &= ~QR_DOWNLOAD;
2180 if (!strcmp(bstr("visdir"), "yes")) {
2181 er_flags |= QR_VISDIR;
2183 er_flags &= ~QR_VISDIR;
2186 strcpy(buf, bstr("anon"));
2188 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2189 if (!strcmp(buf, "anononly"))
2190 er_flags |= QR_ANONONLY;
2191 if (!strcmp(buf, "anon2"))
2192 er_flags |= QR_ANONOPT;
2195 if (!strcmp(bstr("bump"), "yes"))
2198 er_floor = atoi(bstr("er_floor"));
2200 sprintf(buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2201 er_name, er_password, er_dirname, er_flags, bump, er_floor,
2202 er_listingorder, er_defaultview, er_flags2);
2204 serv_getln(buf, sizeof buf);
2205 if (buf[0] != '2') {
2206 strcpy(WC->ImportantMessage, &buf[4]);
2212 if (!IsEmptyStr(er_roomaide)) {
2213 sprintf(buf, "SETA %s", er_roomaide);
2215 serv_getln(buf, sizeof buf);
2216 if (buf[0] != '2') {
2217 strcpy(WC->ImportantMessage, &buf[4]);
2218 display_main_menu();
2223 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2230 * \brief Display form for Invite, Kick, and show Who Knows a room
2232 void do_invt_kick(void) {
2233 char buf[SIZ], room[SIZ], username[SIZ];
2236 serv_getln(buf, sizeof buf);
2238 if (buf[0] != '2') {
2242 extract_token(room, &buf[4], 0, '|', sizeof room);
2244 strcpy(username, bstr("username"));
2246 if (!IsEmptyStr(bstr("kick_button"))) {
2247 sprintf(buf, "KICK %s", username);
2249 serv_getln(buf, sizeof buf);
2251 if (buf[0] != '2') {
2252 strcpy(WC->ImportantMessage, &buf[4]);
2254 sprintf(WC->ImportantMessage,
2255 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2260 if (!IsEmptyStr(bstr("invite_button"))) {
2261 sprintf(buf, "INVT %s", username);
2263 serv_getln(buf, sizeof buf);
2265 if (buf[0] != '2') {
2266 strcpy(WC->ImportantMessage, &buf[4]);
2268 sprintf(WC->ImportantMessage,
2269 _("<B><I>User %s invited to room %s.</I></B>\n"),
2280 * \brief Display form for Invite, Kick, and show Who Knows a room
2282 void display_whok(void)
2284 char buf[SIZ], room[SIZ], username[SIZ];
2287 serv_getln(buf, sizeof buf);
2289 if (buf[0] != '2') {
2293 extract_token(room, &buf[4], 0, '|', sizeof room);
2296 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2297 wprintf(_("The users listed below have access to this room. "
2298 "To remove a user from the access list, select the user "
2299 "name from the list and click 'Kick'."));
2300 wprintf("<br /><br />");
2302 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2303 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2304 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2305 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2307 serv_getln(buf, sizeof buf);
2308 if (buf[0] == '1') {
2309 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2310 extract_token(username, buf, 0, '|', sizeof username);
2311 wprintf("<OPTION>");
2316 wprintf("</select><br />\n");
2318 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2319 wprintf("</form></CENTER>\n");
2321 wprintf("</td><td>");
2322 wprintf(_("To grant another user access to this room, enter the "
2323 "user name in the box below and click 'Invite'."));
2324 wprintf("<br /><br />");
2326 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2327 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2328 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2329 wprintf(_("Invite:"));
2331 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2332 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2333 "<input type=\"submit\" value=\"%s\">"
2334 "</form></CENTER>\n", _("Invite"));
2335 /** Pop open an address book -- begin **/
2337 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2339 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2342 _("Users"), _("Users")
2344 /** Pop open an address book -- end **/
2346 wprintf("</td></tr></table>\n");
2347 address_book_popup();
2354 * \brief display the form for entering a new room
2356 void display_entroom(void)
2361 serv_puts("CRE8 0");
2362 serv_getln(buf, sizeof buf);
2364 if (buf[0] != '2') {
2365 strcpy(WC->ImportantMessage, &buf[4]);
2366 display_main_menu();
2370 output_headers(1, 1, 1, 0, 0, 0);
2372 svprintf("BOXTITLE", WCS_STRING, _("Create a new room"));
2373 do_template("beginbox");
2375 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2376 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2378 wprintf("<table class=\"altern\"> ");
2380 wprintf("<tr class=\"even\"><td>");
2381 wprintf(_("Name of room: "));
2382 wprintf("</td><td>");
2383 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2384 wprintf("</td></tr>");
2386 wprintf("<tr class=\"odd\"><td>");
2387 wprintf(_("Resides on floor: "));
2388 wprintf("</td><td>");
2390 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2391 for (i = 0; i < 128; ++i)
2392 if (!IsEmptyStr(floorlist[i])) {
2393 wprintf("<option ");
2394 wprintf("value=\"%d\">", i);
2395 escputs(floorlist[i]);
2396 wprintf("</option>\n");
2398 wprintf("</select>\n");
2399 wprintf("</td></tr>");
2402 * Our clever little snippet of JavaScript automatically selects
2403 * a public room if the view is set to Bulletin Board or wiki, and
2404 * it selects a mailbox room otherwise. The user can override this,
2405 * of course. We also disable the floor selector for mailboxes.
2407 wprintf("<tr class=\"even\"><td>");
2408 wprintf(_("Default view for room: "));
2409 wprintf("</td><td>");
2410 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2411 " if ( (this.form.er_view.value == 0) "
2412 " || (this.form.er_view.value == 6) ) { "
2413 " this.form.type[0].checked=true; "
2414 " this.form.er_floor.disabled = false; "
2417 " this.form.type[4].checked=true; "
2418 " this.form.er_floor.disabled = true; "
2421 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2422 if (is_view_allowed_as_default(i)) {
2423 wprintf("<option %s value=\"%d\">",
2424 ((i == 0) ? "selected" : ""), i );
2425 escputs(viewdefs[i]);
2426 wprintf("</option>\n");
2429 wprintf("</select>\n");
2430 wprintf("</td></tr>");
2432 wprintf("<tr class=\"even\"><td>");
2433 wprintf(_("Type of room:"));
2434 wprintf("</td><td>");
2435 wprintf("<ul class=\"adminlist\">\n");
2437 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2438 wprintf("CHECKED OnChange=\""
2439 " if (this.form.type[0].checked == true) { "
2440 " this.form.er_floor.disabled = false; "
2443 wprintf(_("Public (automatically appears to everyone)"));
2446 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2447 " if (this.form.type[1].checked == true) { "
2448 " this.form.er_floor.disabled = false; "
2451 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2454 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2455 " if (this.form.type[2].checked == true) { "
2456 " this.form.er_floor.disabled = false; "
2459 wprintf(_("Private - require password: "));
2460 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2463 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2464 " if (this.form.type[3].checked == true) { "
2465 " this.form.er_floor.disabled = false; "
2468 wprintf(_("Private - invitation only"));
2471 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2473 " if (this.form.type[4].checked == true) { "
2474 " this.form.er_floor.disabled = true; "
2477 wprintf(_("Personal (mailbox for you only)"));
2480 wprintf("\n</ul>\n");
2481 wprintf("</td></tr></table>\n");
2483 wprintf("<div class=\"buttons\">\n");
2484 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2486 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2487 wprintf("</div>\n");
2488 wprintf("</form>\n<hr />");
2489 serv_printf("MESG roomaccess");
2490 serv_getln(buf, sizeof buf);
2491 if (buf[0] == '1') {
2495 do_template("endbox");
2504 * \brief support function for entroom() -- sets the default view
2506 void er_set_default_view(int newview) {
2519 serv_getln(buf, sizeof buf);
2520 if (buf[0] != '2') return;
2522 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2523 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2524 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2525 rm_bits1 = extract_int(&buf[4], 3);
2526 rm_floor = extract_int(&buf[4], 4);
2527 rm_listorder = extract_int(&buf[4], 5);
2528 rm_bits2 = extract_int(&buf[4], 7);
2530 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2531 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2532 rm_listorder, newview, rm_bits2
2534 serv_getln(buf, sizeof buf);
2540 * \brief enter a new room
2547 char er_password[SIZ];
2552 if (IsEmptyStr(bstr("ok_button"))) {
2553 strcpy(WC->ImportantMessage,
2554 _("Cancelled. No new room was created."));
2555 display_main_menu();
2558 strcpy(er_name, bstr("er_name"));
2559 strcpy(er_type, bstr("type"));
2560 strcpy(er_password, bstr("er_password"));
2561 er_floor = atoi(bstr("er_floor"));
2562 er_view = atoi(bstr("er_view"));
2565 if (!strcmp(er_type, "hidden"))
2567 if (!strcmp(er_type, "passworded"))
2569 if (!strcmp(er_type, "invonly"))
2571 if (!strcmp(er_type, "personal"))
2574 sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d",
2575 er_name, er_num_type, er_password, er_floor, 0, er_view);
2577 serv_getln(buf, sizeof buf);
2578 if (buf[0] != '2') {
2579 strcpy(WC->ImportantMessage, &buf[4]);
2580 display_main_menu();
2584 do_change_view(er_view); /* Now go there */
2589 * \brief display the screen to enter a private room
2591 void display_private(char *rname, int req_pass)
2593 output_headers(1, 1, 1, 0, 0, 0);
2595 svprintf("BOXTITLE", WCS_STRING, _("Go to a hidden room"));
2596 do_template("beginbox");
2599 wprintf(_("If you know the name of a hidden (guess-name) or "
2600 "passworded room, you can enter that room by typing "
2601 "its name below. Once you gain access to a private "
2602 "room, it will appear in your regular room listings "
2603 "so you don't have to keep returning here."));
2606 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2607 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2609 wprintf("<table class=\"altern\"> "
2610 "<tr class=\"even\"><td>");
2611 wprintf(_("Enter room name:"));
2613 "<input type=\"text\" name=\"gr_name\" "
2614 "value=\"%s\" maxlength=\"128\">\n", rname);
2617 wprintf("</td></tr><tr class=\"odd\"><td>");
2618 wprintf(_("Enter room password:"));
2619 wprintf("</td><td>");
2620 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2622 wprintf("</td></tr></table>\n");
2624 wprintf("<div class=\"buttons\">\n");
2625 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2627 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2631 wprintf("</div></form>\n");
2633 do_template("endbox");
2639 * \brief goto a private room
2641 void goto_private(void)
2646 if (IsEmptyStr(bstr("ok_button"))) {
2647 display_main_menu();
2650 strcpy(hold_rm, WC->wc_roomname);
2651 strcpy(buf, "GOTO ");
2652 strcat(buf, bstr("gr_name"));
2654 strcat(buf, bstr("gr_pass"));
2656 serv_getln(buf, sizeof buf);
2658 if (buf[0] == '2') {
2659 smart_goto(bstr("gr_name"));
2662 if (!strncmp(buf, "540", 3)) {
2663 display_private(bstr("gr_name"), 1);
2666 output_headers(1, 1, 1, 0, 0, 0);
2667 wprintf("%s\n", &buf[4]);
2674 * \brief display the screen to zap a room
2676 void display_zap(void)
2678 output_headers(1, 1, 2, 0, 0, 0);
2680 wprintf("<div id=\"banner\">\n");
2682 wprintf(_("Zap (forget/unsubscribe) the current room"));
2684 wprintf("</div>\n");
2686 wprintf("<div id=\"content\" class=\"service\">\n");
2688 wprintf(_("If you select this option, <em>%s</em> will "
2689 "disappear from your room list. Is this what you wish "
2690 "to do?<br />\n"), WC->wc_roomname);
2692 wprintf("<form method=\"POST\" action=\"zap\">\n");
2693 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%ld\">\n", WC->nonce);
2694 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2696 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2697 wprintf("</form>\n");
2708 char final_destination[SIZ];
2711 * If the forget-room routine fails for any reason, we fall back
2712 * to the current room; otherwise, we go to the Lobby
2714 strcpy(final_destination, WC->wc_roomname);
2716 if (!IsEmptyStr(bstr("ok_button"))) {
2717 serv_printf("GOTO %s", WC->wc_roomname);
2718 serv_getln(buf, sizeof buf);
2719 if (buf[0] == '2') {
2721 serv_getln(buf, sizeof buf);
2722 if (buf[0] == '2') {
2723 strcpy(final_destination, "_BASEROOM_");
2727 smart_goto(final_destination);
2733 * \brief Delete the current room
2735 void delete_room(void)
2739 serv_puts("KILL 1");
2740 serv_getln(buf, sizeof buf);
2741 if (buf[0] != '2') {
2742 strcpy(WC->ImportantMessage, &buf[4]);
2743 display_main_menu();
2746 smart_goto("_BASEROOM_");
2753 * \brief Perform changes to a room's network configuration
2755 void netedit(void) {
2765 if (!IsEmptyStr(bstr("line_pop3host"))) {
2766 strcpy(line, bstr("prefix"));
2767 strcat(line, bstr("line_pop3host"));
2769 strcat(line, bstr("line_pop3user"));
2771 strcat(line, bstr("line_pop3pass"));
2773 strcat(line, atoi(bstr("line_pop3keep")) ? "1" : "0" );
2774 strcat(line, bstr("suffix"));
2776 else if (!IsEmptyStr(bstr("line"))) {
2777 strcpy(line, bstr("prefix"));
2778 strcat(line, bstr("line"));
2779 strcat(line, bstr("suffix"));
2794 serv_getln(buf, sizeof buf);
2795 if (buf[0] != '1') {
2801 /** This loop works for add *or* remove. Spiffy, eh? */
2802 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2803 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2804 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2805 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2806 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2807 if ( (strcasecmp(cmpa0, cmpb0))
2808 || (strcasecmp(cmpa1, cmpb1)) ) {
2809 fprintf(fp, "%s\n", buf);
2815 serv_getln(buf, sizeof buf);
2816 if (buf[0] != '4') {
2822 while (fgets(buf, sizeof buf, fp) != NULL) {
2823 buf[strlen(buf)-1] = 0;
2827 if (!IsEmptyStr(bstr("add_button"))) {
2828 num_addrs = num_tokens(bstr("line"), ',');
2829 if (num_addrs < 2) {
2830 /* just adding one node or address */
2834 /* adding multiple addresses separated by commas */
2835 for (i=0; i<num_addrs; ++i) {
2836 strcpy(line, bstr("prefix"));
2837 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2840 strcat(line, bstr("suffix"));
2854 * \brief Convert a room name to a folder-ish-looking name.
2855 * \param folder the folderish name
2856 * \param room the room name
2857 * \param floor the floor name
2858 * \param is_mailbox is it a mailbox?
2860 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2865 * For mailboxes, just do it straight...
2868 sprintf(folder, "My folders|%s", room);
2872 * Otherwise, prefix the floor name as a "public folders" moniker
2875 sprintf(folder, "%s|%s", floorlist[floor], room);
2879 * Replace "\" characters with "|" for pseudo-folder-delimiting
2881 len = strlen (folder);
2882 for (i=0; i<len; ++i) {
2883 if (folder[i] == '\\') folder[i] = '|';
2891 * \brief Back end for change_view()
2892 * \param newview set newview???
2894 void do_change_view(int newview) {
2897 serv_printf("VIEW %d", newview);
2898 serv_getln(buf, sizeof buf);
2899 WC->wc_view = newview;
2900 smart_goto(WC->wc_roomname);
2906 * \brief Change the view for this room
2908 void change_view(void) {
2911 view = atol(bstr("view"));
2912 do_change_view(view);
2917 * \brief One big expanded tree list view --- like a folder list
2918 * \param fold the folder to view
2919 * \param max_folders how many folders???
2920 * \param num_floors hom many floors???
2922 void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
2926 int has_subfolders = 0;
2929 parents = malloc(max_folders * sizeof(int));
2931 /** BEGIN TREE MENU */
2932 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2934 /** include NanoTree */
2935 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2937 /** initialize NanoTree */
2938 wprintf("<script type=\"text/javascript\"> \n"
2939 " showRootNode = false; \n"
2940 " sortNodes = false; \n"
2941 " dragable = false; \n"
2943 " function standardClick(treeNode) { \n"
2946 " var closedGif = 'static/folder_closed.gif'; \n"
2947 " var openGif = 'static/folder_open.gif'; \n"
2949 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2953 for (i=0; i<max_folders; ++i) {
2956 if ((i+1) < max_folders) {
2958 len = strlen(fold[i].name);
2959 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
2960 && (fold[i+1].name[len] == '|') ) {
2965 levels = num_tokens(fold[i].name, '|');
2966 parents[levels] = i;
2968 wprintf("var node%d = new TreeNode(%d, '", i, i);
2970 if (fold[i].selectable) {
2971 wprintf("<a href=\"dotgoto?room=");
2972 urlescputs(fold[i].room);
2977 wprintf("<span class=\"roomlist_floor\">");
2979 else if (fold[i].hasnewmsgs) {
2980 wprintf("<span class=\"roomlist_new\">");
2983 wprintf("<span class=\"roomlist_old\">");
2985 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2990 if (has_subfolders) {
2991 wprintf("new Array(closedGif, openGif)");
2993 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2994 wprintf("'static/viewcontacts_16x.gif'");
2996 else if (fold[i].view == VIEW_CALENDAR) {
2997 wprintf("'static/calarea_16x.gif'");
2999 else if (fold[i].view == VIEW_CALBRIEF) {
3000 wprintf("'static/calarea_16x.gif'");
3002 else if (fold[i].view == VIEW_TASKS) {
3003 wprintf("'static/taskmanag_16x.gif'");
3005 else if (fold[i].view == VIEW_NOTES) {
3006 wprintf("'static/storenotes_16x.gif'");
3008 else if (fold[i].view == VIEW_MAILBOX) {
3009 wprintf("'static/privatemess_16x.gif'");
3012 wprintf("'static/chatrooms_16x.gif'");
3015 urlescputs(fold[i].name);
3019 wprintf("rootNode.addChild(node%d);\n", i);
3022 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
3026 wprintf("container = document.getElementById('roomlist_div'); \n"
3032 /** END TREE MENU */
3036 * \brief Boxes and rooms and lists ... oh my!
3037 * \param fold the folder to view
3038 * \param max_folders how many folders???
3039 * \param num_floors hom many floors???
3041 void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
3043 char floor_name[256];
3044 char old_floor_name[256];
3046 int levels, oldlevels;
3049 static int columns = 3;
3050 int boxes_per_column = 0;
3051 int current_column = 0;
3054 strcpy(floor_name, "");
3055 strcpy(old_floor_name, "");
3058 while (nf % columns != 0) ++nf;
3059 boxes_per_column = (nf / columns);
3060 if (boxes_per_column < 1) boxes_per_column = 1;
3062 /** Outer table (for columnization) */
3063 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3064 "<tr><td valign=top>");
3068 for (i=0; i<max_folders; ++i) {
3070 levels = num_tokens(fold[i].name, '|');
3071 extract_token(floor_name, fold[i].name, 0,
3072 '|', sizeof floor_name);
3074 if ( (strcasecmp(floor_name, old_floor_name))
3075 && (!IsEmptyStr(old_floor_name)) ) {
3077 do_template("endbox");
3081 if ((num_boxes % boxes_per_column) == 0) {
3083 if (current_column < columns) {
3084 wprintf("</td><td valign=top>\n");
3088 strcpy(old_floor_name, floor_name);
3091 /** Begin inner box */
3092 stresc(boxtitle, 256, floor_name, 1, 0);
3093 svprintf("BOXTITLE", WCS_STRING, boxtitle);
3094 do_template("beginbox");
3101 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3102 if (fold[i].selectable) {
3103 wprintf("<a href=\"dotgoto?room=");
3104 urlescputs(fold[i].room);
3110 if (fold[i].hasnewmsgs) {
3111 wprintf("<span class=\"roomlist_new\">");
3114 wprintf("<span class=\"roomlist_old\">");
3116 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3119 if (fold[i].selectable) {
3125 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3126 wprintf(" (INBOX)");
3128 wprintf("<br />\n");
3131 /** End the final inner box */
3132 do_template("endbox");
3134 wprintf("</td></tr></table>\n");
3138 * \brief print a floor div???
3139 * \param which_floordiv name of the floordiv???
3141 void set_floordiv_expanded(char *which_floordiv) {
3142 begin_ajax_response();
3143 safestrncpy(WC->floordiv_expanded, which_floordiv, sizeof WC->floordiv_expanded);
3144 end_ajax_response();
3148 * \brief view the iconbar
3149 * \param fold the folder to view
3150 * \param max_folders how many folders???
3151 * \param num_floors hom many floors???
3153 void do_iconbar_view(struct folder *fold, int max_folders, int num_floors) {
3155 char floor_name[256];
3156 char old_floor_name[256];
3157 char floordivtitle[256];
3158 char floordiv_id[32];
3159 int levels, oldlevels;
3161 int num_drop_targets = 0;
3164 strcpy(floor_name, "");
3165 strcpy(old_floor_name, "");
3169 for (i=0; i<max_folders; ++i) {
3171 levels = num_tokens(fold[i].name, '|');
3172 extract_token(floor_name, fold[i].name, 0,
3173 '|', sizeof floor_name);
3175 if ( (strcasecmp(floor_name, old_floor_name))
3176 && (!IsEmptyStr(old_floor_name)) ) {
3177 /** End inner box */
3179 wprintf("</div>\n"); /** floordiv */
3181 strcpy(old_floor_name, floor_name);
3185 stresc(floordivtitle, 256, floor_name, 0, 0);
3186 sprintf(floordiv_id, "floordiv%d", i);
3187 wprintf("<span class=\"ib_roomlist_floor\" "
3188 "onClick=\"expand_floor('%s')\">"
3189 "%s</span><br>\n", floordiv_id, floordivtitle);
3190 wprintf("<div id=\"%s\" style=\"display:%s\">",
3192 (!strcasecmp(floordiv_id, WC->floordiv_expanded) ? "block" : "none")
3199 wprintf("<div id=\"roomdiv%d\">", i);
3201 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3203 /** choose the icon */
3204 if (fold[i].view == VIEW_ADDRESSBOOK) {
3205 icon = "viewcontacts_16x.gif" ;
3207 else if (fold[i].view == VIEW_CALENDAR) {
3208 icon = "calarea_16x.gif" ;
3210 else if (fold[i].view == VIEW_CALBRIEF) {
3211 icon = "calarea_16x.gif" ;
3213 else if (fold[i].view == VIEW_TASKS) {
3214 icon = "taskmanag_16x.gif" ;
3216 else if (fold[i].view == VIEW_NOTES) {
3217 icon = "storenotes_16x.gif" ;
3219 else if (fold[i].view == VIEW_MAILBOX) {
3220 icon = "privatemess_16x.gif" ;
3223 icon = "chatrooms_16x.gif" ;
3226 if (fold[i].selectable) {
3227 wprintf("<a href=\"dotgoto?room=");
3228 urlescputs(fold[i].room);
3230 wprintf("<img align=\"middle\" border=0 src=\"static/%s\" alt=\"\"> ", icon);
3235 if (fold[i].hasnewmsgs) {
3236 wprintf("<span class=\"ib_roomlist_new\">");
3239 wprintf("<span class=\"ib_roomlist_old\">");
3241 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3243 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3244 wprintf(" (INBOX)");
3247 if (fold[i].selectable) {
3254 wprintf("</div>\n"); /** roomdiv */
3257 wprintf("</div>\n"); /** floordiv */
3260 /** BEGIN: The old invisible pixel trick, to get our JavaScript to initialize */
3261 wprintf("<img src=\"static/blank.gif\" onLoad=\"\n");
3263 num_drop_targets = 0;
3265 for (i=0; i<max_folders; ++i) {
3266 levels = num_tokens(fold[i].name, '|');
3268 wprintf("drop_targets_elements[%d]=$('roomdiv%d');\n", num_drop_targets, i);
3269 wprintf("drop_targets_roomnames[%d]='", num_drop_targets);
3270 jsescputs(fold[i].room);
3276 wprintf("num_drop_targets = %d;\n", num_drop_targets);
3277 if ((WC->floordiv_expanded[0] != '\0')&&
3278 (WC->floordiv_expanded[1] != '\0')){
3279 wprintf("which_div_expanded = '%s';\n", WC->floordiv_expanded);
3283 /** END: The old invisible pixel trick, to get our JavaScript to initialize */
3289 * \brief Show the room list.
3290 * (only should get called by
3291 * knrooms() because that's where output_headers() is called from)
3292 * \param viewpref the view preferences???
3295 void list_all_rooms_by_floor(char *viewpref) {
3298 struct folder *fold = NULL;
3300 int max_folders = 0;
3301 int alloc_folders = 0;
3307 int num_floors = 1; /** add an extra one for private folders */
3311 /** If our cached folder list is very old, burn it. */
3312 if (WC->cache_fold != NULL) {
3313 if ((time(NULL) - WC->cache_timestamp) > 300) {
3314 free(WC->cache_fold);
3315 WC->cache_fold = NULL;
3319 /** Can we do the iconbar roomlist from cache? */
3320 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3321 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3325 /** Grab the floor table so we know how to build the list... */
3328 /** Start with the mailboxes */
3331 fold = malloc(sizeof(struct folder));
3332 memset(fold, 0, sizeof(struct folder));
3333 strcpy(fold[0].name, "My folders");
3334 fold[0].is_mailbox = 1;
3336 /** Then add floors */
3338 serv_getln(buf, sizeof buf);
3339 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3340 if (max_folders >= alloc_folders) {
3341 alloc_folders = max_folders + 100;
3342 fold = realloc(fold,
3343 alloc_folders * sizeof(struct folder));
3345 memset(&fold[max_folders], 0, sizeof(struct folder));
3346 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3347 extract_token(buf3, buf, 0, '|', SIZ);
3348 fold[max_folders].floor = atol (buf3);
3353 for (i=0; i<num_floors; i++)
3354 if (IDMax < fold[i].floor)
3355 IDMax = fold[i].floor;
3356 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3357 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3358 for (i=0; i<num_floors; i++)
3359 floor_mapping[fold[i].floor]=i;
3361 /** refresh the messages index for this room */
3362 // serv_puts("GOTO ");
3363 // while (serv_getln(buf, sizeof buf), strcmp(buf, "000"));
3364 /** Now add rooms */
3366 serv_getln(buf, sizeof buf);
3367 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3368 if (max_folders >= alloc_folders) {
3369 alloc_folders = max_folders + 100;
3370 fold = realloc(fold,
3371 alloc_folders * sizeof(struct folder));
3373 memset(&fold[max_folders], 0, sizeof(struct folder));
3374 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3375 ra_flags = extract_int(buf, 5);
3376 flags = extract_int(buf, 1);
3377 fold[max_folders].floor = extract_int(buf, 2);
3378 fold[max_folders].hasnewmsgs =
3379 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3380 if (flags & QR_MAILBOX) {
3381 fold[max_folders].is_mailbox = 1;
3383 fold[max_folders].view = extract_int(buf, 6);
3384 room_to_folder(fold[max_folders].name,
3385 fold[max_folders].room,
3386 fold[max_folders].floor,
3387 fold[max_folders].is_mailbox);
3388 fold[max_folders].selectable = 1;
3389 /* Increase the room count for the associtaed floor */
3390 if (fold[max_folders].is_mailbox) {
3391 fold[0].num_rooms++;
3394 i = floor_mapping[fold[max_folders].floor];
3395 fold[i].num_rooms++;
3401 * Remove any floors that don't have rooms
3403 get_preference("emptyfloors", buf2, sizeof buf2);
3404 if (buf2[0]==0 || (strcasecmp(buf2, "no") == 0))
3406 for (i=0; i<num_floors; i++)
3408 if (fold[i].num_rooms == 0) {
3409 for (j=i; j<max_folders; j++) {
3410 memcpy(&fold[j], &fold[j+1], sizeof(struct folder));
3419 /** Bubble-sort the folder list */
3420 for (i=0; i<max_folders; ++i) {
3421 for (j=0; j<(max_folders-1)-i; ++j) {
3422 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3423 swap = strcasecmp(fold[j].name, fold[j+1].name);
3426 if ( (fold[j+1].is_mailbox)
3427 && (!fold[j].is_mailbox)) {
3435 memcpy(&ftmp, &fold[j], sizeof(struct folder));
3436 memcpy(&fold[j], &fold[j+1],
3437 sizeof(struct folder));
3438 memcpy(&fold[j+1], &ftmp,
3439 sizeof(struct folder));
3445 if (!strcasecmp(viewpref, "folders")) {
3446 do_folder_view(fold, max_folders, num_floors);
3448 else if (!strcasecmp(viewpref, "hackish_view")) {
3449 for (i=0; i<max_folders; ++i) {
3450 escputs(fold[i].name);
3451 wprintf("<br />\n");
3454 else if (!strcasecmp(viewpref, "iconbar")) {
3455 do_iconbar_view(fold, max_folders, num_floors);
3458 do_rooms_view(fold, max_folders, num_floors);
3461 /* Don't free the folder list ... cache it for future use! */
3462 if (WC->cache_fold != NULL) {
3463 free(WC->cache_fold);
3465 WC->cache_fold = fold;
3466 WC->cache_max_folders = max_folders;
3467 WC->cache_num_floors = num_floors;
3468 WC->cache_timestamp = time(NULL);
3469 free(floor_mapping);
3474 * \brief Do either a known rooms list or a folders list, depending on the
3479 char listviewpref[SIZ];
3481 output_headers(1, 1, 2, 0, 0, 0);
3483 /** Determine whether the user is trying to change views */
3484 if (bstr("view") != NULL) {
3485 if (!IsEmptyStr(bstr("view"))) {
3486 set_preference("roomlistview", bstr("view"), 1);
3490 get_preference("roomlistview", listviewpref, sizeof listviewpref);
3492 if ( (strcasecmp(listviewpref, "folders"))
3493 && (strcasecmp(listviewpref, "table")) ) {
3494 strcpy(listviewpref, "rooms");
3498 wprintf("<div id=\"banner\">\n");
3499 wprintf("<div class=\"room_banner\">");
3501 if (!strcasecmp(listviewpref, "rooms")) {
3502 wprintf(_("Room list"));
3504 if (!strcasecmp(listviewpref, "folders")) {
3505 wprintf(_("Folder list"));
3507 if (!strcasecmp(listviewpref, "table")) {
3508 wprintf(_("Room list"));
3510 wprintf("</h1></div>\n");
3512 /** offer the ability to switch views */
3513 wprintf("<ul class=\"room_actions\">\n");
3514 wprintf("<li class=\"start_page\">");
3517 wprintf("<li><form name=\"roomlistomatic\">\n"
3518 "<select name=\"newview\" size=\"1\" "
3519 "OnChange=\"location.href=roomlistomatic.newview.options"
3520 "[selectedIndex].value\">\n");
3522 wprintf("<option %s value=\"knrooms&view=rooms\">"
3525 ( !strcasecmp(listviewpref, "rooms") ? "SELECTED" : "" )
3528 wprintf("<option %s value=\"knrooms&view=folders\">"
3529 "View as folder list"
3531 ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
3534 wprintf("</select>");
3535 wprintf("</form></li>");
3536 wprintf("</ul></div>\n");
3538 wprintf("<div id=\"content\" class=\"service\">\n");
3540 /** Display the room list in the user's preferred format */
3541 list_all_rooms_by_floor(listviewpref);
3548 * \brief Set the message expire policy for this room and/or floor
3550 void set_room_policy(void) {
3553 if (IsEmptyStr(bstr("ok_button"))) {
3554 strcpy(WC->ImportantMessage,
3555 _("Cancelled. Changes were not saved."));
3560 serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
3561 serv_getln(buf, sizeof buf);
3562 strcpy(WC->ImportantMessage, &buf[4]);
3564 if (WC->axlevel >= 6) {
3565 strcat(WC->ImportantMessage, "<br />\n");
3566 serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
3567 serv_getln(buf, sizeof buf);
3568 strcat(WC->ImportantMessage, &buf[4]);