3 * Lots of different room-related operations.
11 char floorlist[MAX_FLOORS][SIZ]; /* list of our floor names */
13 char *viewdefs[9]; /* the different kinds of available views */
15 /* See GetFloorListHash and GetRoomListHash for info on these.
16 * Basically we pull LFLR/LKRA etc. and set up a room HashList with these keys.
19 void display_whok(void);
22 * Initialize the viewdefs with localized strings
24 void initialize_viewdefs(void) {
25 viewdefs[0] = _("Bulletin Board");
26 viewdefs[1] = _("Mail Folder");
27 viewdefs[2] = _("Address Book");
28 viewdefs[3] = _("Calendar");
29 viewdefs[4] = _("Task List");
30 viewdefs[5] = _("Notes List");
31 viewdefs[6] = _("Wiki");
32 viewdefs[7] = _("Calendar List");
33 viewdefs[8] = _("Journal");
37 * Determine which views are allowed as the default for creating a new room.
39 int is_view_allowed_as_default(int which_view)
42 case VIEW_BBS: return(1);
43 case VIEW_MAILBOX: return(1);
44 case VIEW_ADDRESSBOOK: return(1);
45 case VIEW_CALENDAR: return(1);
46 case VIEW_TASKS: return(1);
47 case VIEW_NOTES: return(1);
48 case VIEW_WIKI: return(0); /* because it isn't finished yet */
49 case VIEW_CALBRIEF: return(0);
50 case VIEW_JOURNAL: return(0);
51 default: return(0); /* should never get here */
57 * load the list of floors
59 void load_floorlist(StrBuf *Buf)
64 for (a = 0; a < MAX_FLOORS; ++a)
68 StrBuf_ServGetln(Buf);
69 if (GetServerStatus(Buf, NULL) != 1) {
70 strcpy(floorlist[0], "Main Floor");
73 while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
74 if ( (StrLength(Buf)==3) &&
75 !strcmp(ChrPtr(Buf), "000")) {
79 extract_token(floorlist[StrBufExtract_int(Buf, 0, '|')], ChrPtr(Buf), 1, '|', sizeof floorlist[0]);
87 * display rooms in tree structure
89 void room_tree_list(struct roomlisting *rp)
98 room_tree_list(rp->lnext);
100 strcpy(rmname, rp->rlname);
103 wprintf("<a href=\"dotgoto?room=");
107 escputs1(rmname, 1, 1);
108 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
110 else if (f & QR_DIRECTORY)
112 else if (f & QR_NETWORK)
116 wprintf("</a><tt> </tt>\n");
118 room_tree_list(rp->rnext);
124 * Room ordering stuff (compare first by floor, then by order)
126 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
128 if ((r1 == NULL) && (r2 == NULL))
134 if (r1->rlfloor < r2->rlfloor)
136 if (r1->rlfloor > r2->rlfloor)
138 if (r1->rlorder < r2->rlorder)
140 if (r1->rlorder > r2->rlorder)
147 * Common code for all room listings
149 void listrms(char *variety)
154 struct roomlisting *rl = NULL;
155 struct roomlisting *rp;
156 struct roomlisting *rs;
158 /* Ask the server for a room list */
160 serv_getln(buf, sizeof buf);
166 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
168 rp = malloc(sizeof(struct roomlisting));
169 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
170 rp->rlflags = extract_int(buf, 1);
171 rp->rlfloor = extract_int(buf, 2);
172 rp->rlorder = extract_int(buf, 3);
181 if (rordercmp(rp, rs) < 0) {
182 if (rs->lnext == NULL) {
189 if (rs->rnext == NULL) {
202 * If no rooms were listed, print an nbsp to make the cell
203 * borders show up anyway.
205 if (num_rooms == 0) wprintf(" ");
210 * list all forgotten rooms
212 void zapped_list(void)
214 WCTemplputParams SubTP;
217 output_headers(1, 1, 1, 0, 0, 0);
218 memset(&SubTP, 0, sizeof(WCTemplputParams));
219 Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
220 SubTP.Filter.ContextType = CTX_STRBUF;
222 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
228 wprintf("<br /><br />\n");
229 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
230 do_template("endbox", NULL);
236 * read this room's info file (set v to 1 for verbose mode)
238 void readinfo(StrBuf *Target, WCTemplputParams *TP)
243 int fullinfo_len = 0;
246 serv_getln(buf, sizeof buf);
249 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
250 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
251 strcpy(&fullinfo[fullinfo_len], buf);
252 fullinfo_len += strlen(buf);
256 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
257 strcpy(&briefinfo[50], "...");
259 wprintf("<div class=\"infos\" "
260 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
264 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
265 wprintf("<img class=\"close_infos\" "
266 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
267 "src=\"static/closewindow.gif\" alt=\"%s\" width=\"16\" height=\"16\">",
282 * Display room banner icon.
283 * The server doesn't actually need the room name, but we supply it in
284 * order to keep the browser from using a cached icon from another room.
286 void embed_room_graphic(StrBuf *Target, WCTemplputParams *TP)
290 serv_puts("OIMG _roompic_");
291 serv_getln(buf, sizeof buf);
293 wprintf("<img height=\"64px\" src=\"image?name=_roompic_&room=");
294 urlescputs(ChrPtr(WC->wc_roomname));
297 serv_getln(buf, sizeof buf);
299 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
300 wprintf("<img class=\"roompic\" alt=\"\" src=\""
301 "static/viewcontacts_48x.gif"
305 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
306 wprintf("<img class=\"roompic\" alt=\"\" src=\""
307 "static/calarea_48x.gif"
308 "\" width=\"48\" height=\"48\">"
311 else if (WC->wc_view == VIEW_TASKS) {
312 wprintf("<img class=\"roompic\" alt=\"\" src=\""
313 "static/taskmanag_48x.gif"
314 "\" width=\"48\" height=\"48\">"
317 else if (WC->wc_view == VIEW_NOTES) {
318 wprintf("<img class=\"roompic\" alt=\"\" src=\""
319 "static/storenotes_48x.gif"
320 "\" width=\"48\" height=\"48\">"
323 else if (WC->wc_view == VIEW_MAILBOX) {
324 wprintf("<img class=\"roompic\" alt=\"\" src=\""
325 "static/privatemess_48x.gif"
326 "\" width=\"48\" height=\"48\">"
330 wprintf("<img class=\"roompic\" alt=\"\" src=\""
331 "static/chatrooms_48x.gif"
332 "\" width=\"48\" height=\"48\">"
341 * Display the current view and offer an option to change it
343 void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
347 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
348 wprintf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
349 wprintf("<label for=\"view_name\">");
350 wprintf(_("View as:"));
352 "<select name=\"newview\" size=\"1\" "
353 "id=\"view_name\" class=\"selectbox\" "
354 "OnChange=\"location.href=viewomatic.newview.options"
355 "[selectedIndex].value\">\n");
357 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
359 * Only offer the views that make sense, given the default
360 * view for the room. For example, don't offer a Calendar
361 * view in a non-Calendar room.
365 || (i == WC->wc_default_view) /* default */
366 || ( (i == 0) && (WC->wc_default_view == 1) ) /* mail or bulletin */
367 || ( (i == 1) && (WC->wc_default_view == 0) ) /* mail or bulletin */
368 /* || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
371 wprintf("<option %s value=\"changeview?view=%d\">",
372 ((i == WC->wc_view) ? "selected" : ""),
374 escputs(viewdefs[i]);
375 wprintf("</option>\n");
378 wprintf("</select></div></form>\n");
383 * Display a search box
385 void embed_search_o_matic(StrBuf *Target, WCTemplputParams *TP)
387 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
388 wprintf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
389 wprintf("<label for=\"srchquery\">");
390 wprintf(_("Search: "));
391 wprintf("</label><input ");
392 wprintf("%s", WC->serv_info->serv_fulltext_enabled ? "" : "disabled ");
393 wprintf("type=\"text\" name=\"query\" id=\"srchquery\" size=\"15\" maxlength=\"128\" class=\"inputbox\">\n"
395 wprintf("</div></form>\n");
400 * Embed the room banner
402 * got The information returned from a GOTO server command
403 * navbar_style Determines which navigation buttons to display
407 void embed_room_banner(char *got, int navbar_style) {
411 char with_files[256];
415 * We need to have the information returned by a GOTO server command.
416 * If it isn't supplied, we fake it by issuing our own GOTO.
419 memset(buf, '0', 20);
421 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
422 serv_getln(buf, sizeof buf);
426 /* The browser needs some information for its own use */
427 wprintf("<script type=\"text/javascript\"> \n"
428 " room_is_trash = %d; \n"
434 * If the user happens to select the "make this my start page" link,
435 * we want it to remember the URL as a "/dotskip" one instead of
436 * a "skip" or "gotonext" or something like that.
438 if (WCC->Hdr->this_page == NULL) {
439 WCC->Hdr->this_page = NewStrBuf();
441 StrBufPrintf(WCC->Hdr->this_page,
443 ChrPtr(WC->wc_roomname)
446 /* Check for new mail. */
447 WC->new_mail = extract_int(&got[4], 9);
448 WC->wc_view = extract_int(&got[4], 11);
450 /* Is this a directory room and does it contain files and how many? */
451 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
454 serv_getln(buf2, sizeof buf2);
455 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
457 snprintf (with_files, sizeof with_files,
458 "; <a href=\"do_template?template=files\"> %d %s </a>",
460 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
463 strcpy (with_files, "");
465 svprintf(HKEY("NUMMSGS"), WCS_STRING,
466 _("%d new of %d messages%s"),
467 extract_int(&got[4], 1),
468 extract_int(&got[4], 2),
471 svcallback("ROOMPIC", embed_room_graphic);
472 svcallback("ROOMINFO", readinfo);
473 svcallback("VIEWOMATIC", embed_view_o_matic);
474 svcallback("SEARCHOMATIC", embed_search_o_matic);
475 svcallback("START", offer_start_page);
477 do_template("roombanner", NULL);
478 /* roombanner contains this for mobile */
479 if (navbar_style != navbar_none && !WC->is_mobile) {
481 wprintf("<div id=\"navbar\"><ul>");
483 if (navbar_style == navbar_default) wprintf(
484 "<li class=\"ungoto\">"
485 "<a href=\"ungoto\">"
486 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
487 "<span class=\"navbar_link\">%s</span></A>"
488 "</li>\n", _("Ungoto")
491 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
493 "<li class=\"newmess\">"
494 "<a href=\"readnew\">"
495 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
496 "<span class=\"navbar_link\">%s</span></A>"
497 "</li>\n", _("Read new messages")
501 if (navbar_style == navbar_default) {
502 switch(WC->wc_view) {
503 case VIEW_ADDRESSBOOK:
505 "<li class=\"viewcontacts\">"
506 "<a href=\"readfwd\">"
507 "<img src=\"static/viewcontacts_24x.gif\" "
508 "alt=\"\" width=\"24\" height=\"24\">"
509 "<span class=\"navbar_link\">"
511 "</span></a></li>\n", _("View contacts")
516 "<li class=\"staskday\">"
517 "<a href=\"readfwd?calview=day\">"
518 "<img src=\"static/taskday2_24x.gif\" "
519 "alt=\"\" width=\"24\" height=\"24\">"
520 "<span class=\"navbar_link\">"
522 "</span></a></li>\n", _("Day view")
525 "<li class=\"monthview\">"
526 "<a href=\"readfwd?calview=month\">"
527 "<img src=\"static/monthview2_24x.gif\" "
528 "alt=\"\" width=\"24\" height=\"24\">"
529 "<span class=\"navbar_link\">"
531 "</span></a></li>\n", _("Month view")
536 "<li class=\"monthview\">"
537 "<a href=\"readfwd?calview=month\">"
538 "<img src=\"static/monthview2_24x.gif\" "
539 "alt=\"\" width=\"24\" height=\"24\">"
540 "<span class=\"navbar_link\">"
542 "</span></a></li>\n", _("Calendar list")
547 "<li class=\"taskmanag\">"
548 "<a href=\"readfwd\">"
549 "<img src=\"static/taskmanag_24x.gif\" "
550 "alt=\"\" width=\"24\" height=\"24\">"
551 "<span class=\"navbar_link\">"
553 "</span></a></li>\n", _("View tasks")
558 "<li class=\"viewnotes\">"
559 "<a href=\"readfwd\">"
560 "<img src=\"static/viewnotes_24x.gif\" "
561 "alt=\"\" width=\"24\" height=\"24\">"
562 "<span class=\"navbar_link\">"
564 "</span></a></li>\n", _("View notes")
569 "<li class=\"readallmess\">"
570 "<a id=\"m_refresh\" href=\"readfwd\">"
571 "<img src=\"static/readallmess3_24x.gif\" "
572 "alt=\"\" width=\"24\" height=\"24\">"
573 "<span class=\"navbar_link\">"
575 "</span></a></li>\n", _("Refresh message list")
580 "<li class=\"readallmess\">"
581 "<a href=\"readfwd\">"
582 "<img src=\"static/readallmess3_24x.gif\" "
583 "alt=\"\" width=\"24\" height=\"24\">"
584 "<span class=\"navbar_link\">"
586 "</span></a></li>\n", _("Wiki home")
591 "<li class=\"readallmess\">"
592 "<a href=\"readfwd\">"
593 "<img src=\"static/readallmess3_24x.gif\" "
594 "alt=\"\" width=\"24\" height=\"24\">"
595 "<span class=\"navbar_link\">"
597 "</span></a></li>\n", _("Read all messages")
603 if (navbar_style == navbar_default) {
604 switch(WC->wc_view) {
605 case VIEW_ADDRESSBOOK:
607 "<li class=\"addnewcontact\">"
608 "<a href=\"display_enter\">"
609 "<img src=\"static/addnewcontact_24x.gif\" "
610 "alt=\"\" width=\"24\" height=\"24\">"
611 "<span class=\"navbar_link\">"
613 "</span></a></li>\n", _("Add new contact")
618 wprintf("<li class=\"addevent\"><a href=\"display_enter");
619 if (havebstr("year" )) wprintf("?year=%s", bstr("year"));
620 if (havebstr("month")) wprintf("?month=%s", bstr("month"));
621 if (havebstr("day" )) wprintf("?day=%s", bstr("day"));
623 "<img src=\"static/addevent_24x.gif\" "
624 "alt=\"\" width=\"24\" height=\"24\">"
625 "<span class=\"navbar_link\">"
627 "</span></a></li>\n", _("Add new event")
632 "<li class=\"newmess\">"
633 "<a href=\"display_enter\">"
634 "<img src=\"static/newmess3_24x.gif\" "
635 "alt=\"\" width=\"24\" height=\"24\">"
636 "<span class=\"navbar_link\">"
638 "</span></a></li>\n", _("Add new task")
643 "<li class=\"enternewnote\">"
644 "<a href=\"add_new_note\">"
645 "<img src=\"static/enternewnote_24x.gif\" "
646 "alt=\"\" width=\"24\" height=\"24\">"
647 "<span class=\"navbar_link\">"
649 "</span></a></li>\n", _("Add new note")
653 safestrncpy(buf, bstr("page"), sizeof buf);
656 "<li class=\"newmess\">"
657 "<a href=\"display_enter?wikipage=%s\">"
658 "<img src=\"static/newmess3_24x.gif\" "
659 "alt=\"\" width=\"24\" height=\"24\">"
660 "<span class=\"navbar_link\">"
662 "</span></a></li>\n", buf, _("Edit this page")
667 "<li class=\"newmess\">"
668 "<a href=\"display_enter\">"
669 "<img src=\"static/newmess3_24x.gif\" "
670 "alt=\"\" width=\"24\" height=\"24\">"
671 "<span class=\"navbar_link\">"
673 "</span></a></li>\n", _("Write mail")
676 "<li class=\"newmess\">"
677 "<a href=\"javascript:deleteAllSelectedMessages();\">"
678 "<img src=\"static/delete.gif\" "
679 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
681 "</span></a></li>\n", _("Delete")
686 "<li class=\"newmess\">"
687 "<a href=\"display_enter\">"
688 "<img src=\"static/newmess3_24x.gif\" "
689 "alt=\"\" width=\"24\" height=\"24\">"
690 "<span class=\"navbar_link\">"
692 "</span></a></li>\n", _("Enter a message")
698 if (navbar_style == navbar_default) wprintf(
699 "<li class=\"skipthisroom\">"
702 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
703 "width=\"24\" height=\"24\">"
704 "<span class=\"navbar_link\">%s</span></a>"
706 _("Leave all messages marked as unread, go to next room with unread messages"),
710 if (navbar_style == navbar_default) wprintf(
711 "<li class=\"markngo\">"
712 "<a href=\"gotonext\" "
714 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
715 "width=\"24\" height=\"24\">"
716 "<span class=\"navbar_link\">%s</span></a>"
718 _("Mark all messages as read, go to next room with unread messages"),
722 wprintf("</ul></div>\n");
729 * back end routine to take the session to a new room
731 long gotoroom(const StrBuf *gname)
734 static long ls = (-1L);
737 /* store ungoto information */
738 strcpy(WC->ugname, ChrPtr(WC->wc_roomname));
742 /* move to the new room */
743 serv_printf("GOTO %s", ChrPtr(gname));
744 StrBuf_ServGetln(Buf);
745 if (GetServerStatus(Buf, &err) != 2) {
746 serv_puts("GOTO _BASEROOM_");
747 StrBuf_ServGetln(Buf);
749 * well, we know that this is the fallback case,
750 * but we're interested that the first command
751 * didn't work out in first place.
753 if (GetServerStatus(Buf, NULL) != 2) {
759 if (WC->wc_roomname == NULL)
760 WC->wc_roomname = NewStrBuf();
762 FlushStrBuf(WC->wc_roomname);
764 StrBufExtract_token(WC->wc_roomname, Buf, 0, '|');
765 StrBufCutLeft(WC->wc_roomname, 4);
766 WC->room_flags = StrBufExtract_int(Buf, 4, '|');
767 /* highest_msg_read = extract_int(&buf[4],6);
768 maxmsgnum = extract_int(&buf[4],5);
770 WC->is_mailbox = StrBufExtract_int(Buf, 7, '|');
771 ls = StrBufExtract_long(Buf, 6, '|');
772 WC->wc_floor = StrBufExtract_int(Buf, 10, '|');
773 WC->wc_view = StrBufExtract_int(Buf, 11, '|');
774 WC->wc_default_view = StrBufExtract_int(Buf, 12, '|');
775 WC->wc_is_trash = StrBufExtract_int(Buf, 13, '|');
776 WC->room_flags2 = StrBufExtract_int(Buf, 14, '|');
779 WC->is_room_aide = WC->is_aide;
781 WC->is_room_aide = (char) StrBufExtract_int(Buf, 8, '|');
783 remove_march(WC->wc_roomname);
784 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
795 void smart_goto(const StrBuf *next_room) {
803 * mark all messages in current room as having been read
805 void slrp_highest(void)
809 serv_puts("SLRP HIGHEST");
810 serv_getln(buf, sizeof buf);
814 typedef struct __room_states {
829 * Set/clear/read the "self-service list subscribe" flag for a room
831 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
832 * returns the new value.
835 int self_service(int newval) {
836 int current_value = 0;
842 int flags, floor, order, view, flags2;
845 serv_getln(buf, sizeof buf);
846 if (buf[0] != '2') return(0);
848 extract_token(name, &buf[4], 0, '|', sizeof name);
849 extract_token(password, &buf[4], 1, '|', sizeof password);
850 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
851 flags = extract_int(&buf[4], 3);
852 floor = extract_int(&buf[4], 4);
853 order = extract_int(&buf[4], 5);
854 view = extract_int(&buf[4], 6);
855 flags2 = extract_int(&buf[4], 7);
857 if (flags2 & QR2_SELFLIST) {
865 flags2 = flags2 | QR2_SELFLIST;
867 else if (newval == 0) {
868 flags2 = flags2 & ~QR2_SELFLIST;
871 return(current_value);
874 if (newval != current_value) {
875 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
876 name, password, dirname, flags,
877 floor, order, view, flags2);
878 serv_getln(buf, sizeof buf);
885 int is_selflist(room_states *RoomFlags)
887 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
890 int is_publiclist(room_states *RoomFlags)
892 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
895 int is_moderatedlist(room_states *RoomFlags)
897 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
901 * Set/clear/read the "self-service list subscribe" flag for a room
903 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
904 * returns the new value.
907 int get_roomflags(room_states *RoomOps)
912 serv_getln(buf, sizeof buf);
913 if (buf[0] != '2') return(0);
915 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
916 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
917 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
918 RoomOps->flags = extract_int(&buf[4], 3);
919 RoomOps->floor = extract_int(&buf[4], 4);
920 RoomOps->order = extract_int(&buf[4], 5);
921 RoomOps->view = extract_int(&buf[4], 6);
922 RoomOps->flags2 = extract_int(&buf[4], 7);
926 int set_roomflags(room_states *RoomOps)
930 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
939 serv_getln(buf, sizeof buf);
949 * display the form for editing a room
951 void display_editroom(void)
957 char remote_room[128];
960 char er_password[10];
962 char er_roomaide[26];
969 char *not_shared_with;
979 if (IsEmptyStr(tab)) tab = "admin";
984 output_headers(1, 1, 1, 0, 0, 0);
986 wprintf("<div class=\"fix_scrollbar_bug\">");
990 /* print the tabbed dialog */
991 wprintf("<div align=\"center\">");
992 wprintf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
993 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
996 wprintf("<td class=\"");
997 if (!strcmp(tab, "admin")) {
998 wprintf(" tab_cell_label\">");
999 wprintf(_("Administration"));
1002 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1003 wprintf(_("Administration"));
1007 wprintf("<td> </td>\n");
1009 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1011 wprintf("<td class=\"");
1012 if (!strcmp(tab, "config")) {
1013 wprintf(" tab_cell_label\">");
1014 wprintf(_("Configuration"));
1017 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1018 wprintf(_("Configuration"));
1022 wprintf("<td> </td>\n");
1024 wprintf("<td class=\"");
1025 if (!strcmp(tab, "expire")) {
1026 wprintf(" tab_cell_label\">");
1027 wprintf(_("Message expire policy"));
1030 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1031 wprintf(_("Message expire policy"));
1035 wprintf("<td> </td>\n");
1037 wprintf("<td class=\"");
1038 if (!strcmp(tab, "access")) {
1039 wprintf(" tab_cell_label\">");
1040 wprintf(_("Access controls"));
1043 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1044 wprintf(_("Access controls"));
1048 wprintf("<td> </td>\n");
1050 wprintf("<td class=\"");
1051 if (!strcmp(tab, "sharing")) {
1052 wprintf(" tab_cell_label\">");
1053 wprintf(_("Sharing"));
1056 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1057 wprintf(_("Sharing"));
1061 wprintf("<td> </td>\n");
1063 wprintf("<td class=\"");
1064 if (!strcmp(tab, "listserv")) {
1065 wprintf(" tab_cell_label\">");
1066 wprintf(_("Mailing list service"));
1069 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1070 wprintf(_("Mailing list service"));
1074 wprintf("<td> </td>\n");
1078 wprintf("<td class=\"");
1079 if (!strcmp(tab, "feeds")) {
1080 wprintf(" tab_cell_label\">");
1081 wprintf(_("Remote retrieval"));
1084 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1085 wprintf(_("Remote retrieval"));
1089 wprintf("<td> </td>\n");
1091 wprintf("</tr></table>\n");
1092 wprintf("</div>\n");
1093 /* end tabbed dialog */
1095 wprintf("<script type=\"text/javascript\">"
1096 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1100 /* begin content of whatever tab is open now */
1102 if (!strcmp(tab, "admin")) {
1103 wprintf("<div class=\"tabcontent\">");
1105 "<li><a href=\"delete_room\" "
1106 "onClick=\"return confirm('");
1107 wprintf(_("Are you sure you want to delete this room?"));
1108 wprintf("');\">\n");
1109 wprintf(_("Delete this room"));
1111 "<li><a href=\"display_editroompic?which_room=");
1112 urlescputs(ChrPtr(WC->wc_roomname));
1114 wprintf(_("Set or change the icon for this room's banner"));
1116 "<li><a href=\"display_editinfo\">\n");
1117 wprintf(_("Edit this room's Info file"));
1123 if (!strcmp(tab, "config")) {
1124 wprintf("<div class=\"tabcontent\">");
1126 serv_getln(buf, sizeof buf);
1128 if (!strncmp(buf, "550", 3)) {
1129 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1130 _("Higher access is required to access this function.")
1133 else if (buf[0] != '2') {
1134 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1137 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1138 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1139 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1140 er_flags = extract_int(&buf[4], 3);
1141 er_floor = extract_int(&buf[4], 4);
1142 er_flags2 = extract_int(&buf[4], 7);
1144 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1145 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1147 wprintf("<ul><li>");
1148 wprintf(_("Name of room: "));
1149 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1155 wprintf(_("Resides on floor: "));
1156 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1157 if (er_flags & QR_MAILBOX)
1158 wprintf("disabled >\n");
1159 for (i = 0; i < 128; ++i)
1160 if (!IsEmptyStr(floorlist[i])) {
1161 wprintf("<OPTION ");
1163 wprintf("SELECTED ");
1164 wprintf("VALUE=\"%d\">", i);
1165 escputs(floorlist[i]);
1166 wprintf("</OPTION>\n");
1168 wprintf("</select>\n");
1171 wprintf(_("Type of room:"));
1174 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1175 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1176 wprintf("CHECKED ");
1177 wprintf("OnChange=\""
1178 " if (this.form.type[0].checked == true) { "
1179 " this.form.er_floor.disabled = false; "
1182 wprintf(_("Public (automatically appears to everyone)"));
1185 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1186 if ((er_flags & QR_PRIVATE) &&
1187 (er_flags & QR_GUESSNAME))
1188 wprintf("CHECKED ");
1189 wprintf(" OnChange=\""
1190 " if (this.form.type[1].checked == true) { "
1191 " this.form.er_floor.disabled = false; "
1194 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1196 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1197 if ((er_flags & QR_PRIVATE) &&
1198 (er_flags & QR_PASSWORDED))
1199 wprintf("CHECKED ");
1200 wprintf(" OnChange=\""
1201 " if (this.form.type[2].checked == true) { "
1202 " this.form.er_floor.disabled = false; "
1205 wprintf(_("Private - require password: "));
1206 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1209 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1210 if ((er_flags & QR_PRIVATE)
1211 && ((er_flags & QR_GUESSNAME) == 0)
1212 && ((er_flags & QR_PASSWORDED) == 0))
1213 wprintf("CHECKED ");
1214 wprintf(" OnChange=\""
1215 " if (this.form.type[3].checked == true) { "
1216 " this.form.er_floor.disabled = false; "
1219 wprintf(_("Private - invitation only"));
1221 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1222 if (er_flags & QR_MAILBOX)
1223 wprintf("CHECKED ");
1224 wprintf (" OnChange=\""
1225 " if (this.form.type[4].checked == true) { "
1226 " this.form.er_floor.disabled = true; "
1229 wprintf(_("Personal (mailbox for you only)"));
1231 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1233 wprintf(_("If private, cause current users to forget room"));
1235 wprintf("\n</ul>\n");
1237 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1238 if (er_flags & QR_PREFONLY)
1239 wprintf("CHECKED ");
1241 wprintf(_("Preferred users only"));
1243 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1244 if (er_flags & QR_READONLY)
1245 wprintf("CHECKED ");
1247 wprintf(_("Read-only room"));
1249 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1250 if (er_flags2 & QR2_COLLABDEL)
1251 wprintf("CHECKED ");
1253 wprintf(_("All users allowed to post may also delete messages"));
1255 /** directory stuff */
1256 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1257 if (er_flags & QR_DIRECTORY)
1258 wprintf("CHECKED ");
1260 wprintf(_("File directory room"));
1262 wprintf("\n<ul><li>");
1263 wprintf(_("Directory name: "));
1264 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1267 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1268 if (er_flags & QR_UPLOAD)
1269 wprintf("CHECKED ");
1271 wprintf(_("Uploading allowed"));
1273 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1274 if (er_flags & QR_DOWNLOAD)
1275 wprintf("CHECKED ");
1277 wprintf(_("Downloading allowed"));
1279 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1280 if (er_flags & QR_VISDIR)
1281 wprintf("CHECKED ");
1283 wprintf(_("Visible directory"));
1286 /** end of directory stuff */
1288 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1289 if (er_flags & QR_NETWORK)
1290 wprintf("CHECKED ");
1292 wprintf(_("Network shared room"));
1294 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1295 if (er_flags & QR_PERMANENT)
1296 wprintf("CHECKED ");
1298 wprintf(_("Permanent (does not auto-purge)"));
1300 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1301 if (er_flags2 & QR2_SUBJECTREQ)
1302 wprintf("CHECKED ");
1304 wprintf(_("Subject Required (Force users to specify a message subject)"));
1306 /** start of anon options */
1309 wprintf(_("Anonymous messages"));
1312 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1313 if (((er_flags & QR_ANONONLY) == 0)
1314 && ((er_flags & QR_ANONOPT) == 0))
1315 wprintf("CHECKED ");
1317 wprintf(_("No anonymous messages"));
1319 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1320 if (er_flags & QR_ANONONLY)
1321 wprintf("CHECKED ");
1323 wprintf(_("All messages are anonymous"));
1325 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1326 if (er_flags & QR_ANONOPT)
1327 wprintf("CHECKED ");
1329 wprintf(_("Prompt user when entering messages"));
1332 /* end of anon options */
1335 wprintf(_("Room aide: "));
1337 serv_getln(buf, sizeof buf);
1338 if (buf[0] != '2') {
1339 wprintf("<em>%s</em>\n", &buf[4]);
1341 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1342 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1345 wprintf("</ul><CENTER>\n");
1346 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1347 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1349 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1359 /* Sharing the room with other Citadel nodes... */
1360 if (!strcmp(tab, "sharing")) {
1361 wprintf("<div class=\"tabcontent\">");
1363 shared_with = strdup("");
1364 not_shared_with = strdup("");
1366 /** Learn the current configuration */
1367 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1368 serv_getln(buf, sizeof buf);
1369 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1370 extract_token(node, buf, 0, '|', sizeof node);
1371 not_shared_with = realloc(not_shared_with,
1372 strlen(not_shared_with) + 32);
1373 strcat(not_shared_with, node);
1374 strcat(not_shared_with, "\n");
1378 serv_getln(buf, sizeof buf);
1379 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1380 extract_token(cmd, buf, 0, '|', sizeof cmd);
1381 extract_token(node, buf, 1, '|', sizeof node);
1382 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1383 if (!strcasecmp(cmd, "ignet_push_share")) {
1384 shared_with = realloc(shared_with,
1385 strlen(shared_with) + 32);
1386 strcat(shared_with, node);
1387 if (!IsEmptyStr(remote_room)) {
1388 strcat(shared_with, "|");
1389 strcat(shared_with, remote_room);
1391 strcat(shared_with, "\n");
1395 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1396 extract_token(buf, shared_with, i, '\n', sizeof buf);
1397 extract_token(node, buf, 0, '|', sizeof node);
1398 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1399 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1400 if (!strcasecmp(node, cmd)) {
1401 remove_token(not_shared_with, j, '\n');
1406 /* Display the stuff */
1407 wprintf("<CENTER><br />"
1408 "<table border=1 cellpadding=5><tr>"
1410 wprintf(_("Shared with"));
1411 wprintf("</I></B></td>"
1413 wprintf(_("Not shared with"));
1414 wprintf("</I></B></td></tr>\n"
1415 "<tr><td VALIGN=TOP>\n");
1417 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1418 wprintf(_("Remote node name"));
1419 wprintf("</td><td>");
1420 wprintf(_("Remote room name"));
1421 wprintf("</td><td>");
1422 wprintf(_("Actions"));
1423 wprintf("</td></tr>\n");
1425 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1426 extract_token(buf, shared_with, i, '\n', sizeof buf);
1427 extract_token(node, buf, 0, '|', sizeof node);
1428 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1429 if (!IsEmptyStr(node)) {
1430 wprintf("<form method=\"POST\" action=\"netedit\">");
1431 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1432 wprintf("<tr><td>%s</td>\n", node);
1435 if (!IsEmptyStr(remote_room)) {
1436 escputs(remote_room);
1442 wprintf("<input type=\"hidden\" NAME=\"line\" "
1443 "VALUE=\"ignet_push_share|");
1445 if (!IsEmptyStr(remote_room)) {
1447 urlescputs(remote_room);
1450 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1451 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1452 wprintf("<input type=\"submit\" "
1453 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1454 wprintf("</td></tr></form>\n");
1458 wprintf("</table>\n");
1459 wprintf("</td><td VALIGN=TOP>\n");
1460 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1461 wprintf(_("Remote node name"));
1462 wprintf("</td><td>");
1463 wprintf(_("Remote room name"));
1464 wprintf("</td><td>");
1465 wprintf(_("Actions"));
1466 wprintf("</td></tr>\n");
1468 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1469 extract_token(node, not_shared_with, i, '\n', sizeof node);
1470 if (!IsEmptyStr(node)) {
1471 wprintf("<form method=\"POST\" action=\"netedit\">");
1472 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1473 wprintf("<tr><td>");
1476 "<input type=\"INPUT\" "
1480 wprintf("<input type=\"hidden\" "
1482 "VALUE=\"ignet_push_share|");
1485 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1486 "VALUE=\"sharing\">\n");
1487 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1488 "VALUE=\"add\">\n");
1489 wprintf("<input type=\"submit\" "
1490 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1491 wprintf("</td></tr></form>\n");
1495 wprintf("</table>\n");
1496 wprintf("</td></tr>"
1497 "</table></CENTER><br />\n"
1498 "<I><B>%s</B><ul><li>", _("Notes:"));
1499 wprintf(_("When sharing a room, "
1500 "it must be shared from both ends. Adding a node to "
1501 "the 'shared' list sends messages out, but in order to"
1502 " receive messages, the other nodes must be configured"
1503 " to send messages out to your system as well. "
1504 "<li>If the remote room name is blank, it is assumed "
1505 "that the room name is identical on the remote node."
1506 "<li>If the remote room name is different, the remote "
1507 "node must also configure the name of the room here."
1514 /* Mailing list management */
1515 if (!strcmp(tab, "listserv")) {
1516 room_states RoomFlags;
1517 wprintf("<div class=\"tabcontent\">");
1519 wprintf("<br /><center>"
1520 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1521 "<tr><td VALIGN=TOP>");
1523 wprintf(_("<i>The contents of this room are being "
1524 "mailed <b>as individual messages</b> "
1525 "to the following list recipients:"
1526 "</i><br /><br />\n"));
1529 serv_getln(buf, sizeof buf);
1530 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1531 extract_token(cmd, buf, 0, '|', sizeof cmd);
1532 if (!strcasecmp(cmd, "listrecp")) {
1533 extract_token(recp, buf, 1, '|', sizeof recp);
1536 wprintf(" <a href=\"netedit?cmd=remove&tab=listserv&line=listrecp|");
1539 wprintf(_("(remove)"));
1540 wprintf("</A><br />");
1543 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1544 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1545 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1546 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1547 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1548 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1549 wprintf("</form>\n");
1551 wprintf("</td><td VALIGN=TOP>\n");
1553 wprintf(_("<i>The contents of this room are being "
1554 "mailed <b>in digest form</b> "
1555 "to the following list recipients:"
1556 "</i><br /><br />\n"));
1559 serv_getln(buf, sizeof buf);
1560 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1561 extract_token(cmd, buf, 0, '|', sizeof cmd);
1562 if (!strcasecmp(cmd, "digestrecp")) {
1563 extract_token(recp, buf, 1, '|', sizeof recp);
1566 wprintf(" <a href=\"netedit?cmd=remove&tab=listserv&line="
1570 wprintf(_("(remove)"));
1571 wprintf("</A><br />");
1574 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1575 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1576 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1577 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1578 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1579 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1580 wprintf("</form>\n");
1582 wprintf("</td></tr></table>\n");
1584 /** Pop open an address book -- begin **/
1585 wprintf("<div align=right>"
1586 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1588 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1593 _("Add recipients from Contacts or other address books"),
1594 _("Add recipients from Contacts or other address books")
1596 /* Pop open an address book -- end **/
1598 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1600 get_roomflags (&RoomFlags);
1602 /* Self Service subscription? */
1603 wprintf("<table><tr><td>\n");
1604 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1605 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1606 " <tr><td colspan=\"2\">\n",
1607 (is_selflist(&RoomFlags))?"checked":"");
1608 wprintf(_("The URL for subscribe/unsubscribe is: "));
1609 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1610 (is_https ? "https" : "http"),
1611 ChrPtr(WC->Hdr->HR.http_host));
1612 /* Public posting? */
1613 wprintf("<tr><td>");
1614 wprintf(_("Allow non-subscribers to mail to this room."));
1615 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1616 (is_publiclist(&RoomFlags))?"checked":"");
1618 /* Moderated List? */
1619 wprintf("<tr><td>");
1620 wprintf(_("Room post publication needs Aide permission."));
1621 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1622 (is_moderatedlist(&RoomFlags))?"checked":"");
1625 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1626 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1627 wprintf("</table></form>");
1630 wprintf("</CENTER>\n");
1635 /* Configuration of The Dreaded Auto-Purger */
1636 if (!strcmp(tab, "expire")) {
1637 wprintf("<div class=\"tabcontent\">");
1639 serv_puts("GPEX room");
1640 serv_getln(buf, sizeof buf);
1641 if (!strncmp(buf, "550", 3)) {
1642 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1643 _("Higher access is required to access this function.")
1646 else if (buf[0] != '2') {
1647 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1650 roompolicy = extract_int(&buf[4], 0);
1651 roomvalue = extract_int(&buf[4], 1);
1653 serv_puts("GPEX floor");
1654 serv_getln(buf, sizeof buf);
1655 if (buf[0] == '2') {
1656 floorpolicy = extract_int(&buf[4], 0);
1657 floorvalue = extract_int(&buf[4], 1);
1660 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1661 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1662 wprintf("<table border=0 cellspacing=5>\n");
1663 wprintf("<tr><td>");
1664 wprintf(_("Message expire policy for this room"));
1666 escputs(ChrPtr(WC->wc_roomname));
1667 wprintf(")</td><td>");
1668 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1669 ((roompolicy == 0) ? "CHECKED" : "") );
1670 wprintf(_("Use the default policy for this floor"));
1671 wprintf("<br />\n");
1672 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1673 ((roompolicy == 1) ? "CHECKED" : "") );
1674 wprintf(_("Never automatically expire messages"));
1675 wprintf("<br />\n");
1676 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1677 ((roompolicy == 2) ? "CHECKED" : "") );
1678 wprintf(_("Expire by message count"));
1679 wprintf("<br />\n");
1680 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1681 ((roompolicy == 3) ? "CHECKED" : "") );
1682 wprintf(_("Expire by message age"));
1684 wprintf(_("Number of messages or days: "));
1685 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1686 wprintf("</td></tr>\n");
1688 if (WC->axlevel >= 6) {
1689 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1690 wprintf("<tr><td>");
1691 wprintf(_("Message expire policy for this floor"));
1693 escputs(floorlist[WC->wc_floor]);
1694 wprintf(")</td><td>");
1695 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1696 ((floorpolicy == 0) ? "CHECKED" : "") );
1697 wprintf(_("Use the system default"));
1698 wprintf("<br />\n");
1699 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1700 ((floorpolicy == 1) ? "CHECKED" : "") );
1701 wprintf(_("Never automatically expire messages"));
1702 wprintf("<br />\n");
1703 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1704 ((floorpolicy == 2) ? "CHECKED" : "") );
1705 wprintf(_("Expire by message count"));
1706 wprintf("<br />\n");
1707 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1708 ((floorpolicy == 3) ? "CHECKED" : "") );
1709 wprintf(_("Expire by message age"));
1711 wprintf(_("Number of messages or days: "));
1712 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1716 wprintf("<CENTER>\n");
1717 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1718 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1720 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1721 wprintf("</CENTER></td><tr>\n");
1723 wprintf("</table>\n"
1724 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1732 /* Access controls */
1733 if (!strcmp(tab, "access")) {
1734 wprintf("<div class=\"tabcontent\">");
1739 /* Fetch messages from remote locations */
1740 if (!strcmp(tab, "feeds")) {
1741 wprintf("<div class=\"tabcontent\">");
1744 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1745 wprintf("</i><br />\n");
1747 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1748 "<tr class=\"even\"><th>");
1749 wprintf(_("Remote host"));
1750 wprintf("</th><th>");
1751 wprintf(_("User name"));
1752 wprintf("</th><th>");
1753 wprintf(_("Password"));
1754 wprintf("</th><th>");
1755 wprintf(_("Keep messages on server?"));
1756 wprintf("</th><th>");
1757 wprintf(_("Interval"));
1758 wprintf("</th><th> </th></tr>");
1761 serv_getln(buf, sizeof buf);
1763 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1764 extract_token(cmd, buf, 0, '|', sizeof cmd);
1765 if (!strcasecmp(cmd, "pop3client")) {
1766 safestrncpy(recp, &buf[11], sizeof recp);
1769 wprintf("<tr class=\"%s\">",
1770 (bg ? "even" : "odd")
1774 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1779 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1783 wprintf("<td>*****</td>"); /* Don't show the password */
1785 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1787 wprintf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
1789 wprintf("<td class=\"button_link\">");
1790 wprintf(" <a href=\"netedit?cmd=remove&tab=feeds&line=pop3client|");
1793 wprintf(_("(remove)"));
1794 wprintf("</a></td>");
1800 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1802 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1803 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1804 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1806 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1809 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1812 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1815 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1818 wprintf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
1821 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1822 wprintf("</td></tr>");
1823 wprintf("</form></table>\n");
1828 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1829 wprintf("</i><br />\n");
1831 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1832 "<tr class=\"even\"><th>");
1833 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1834 wprintf(_("Feed URL"));
1835 wprintf("</th><th>");
1836 wprintf("</th></tr>");
1839 serv_getln(buf, sizeof buf);
1841 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1842 extract_token(cmd, buf, 0, '|', sizeof cmd);
1843 if (!strcasecmp(cmd, "rssclient")) {
1844 safestrncpy(recp, &buf[10], sizeof recp);
1847 wprintf("<tr class=\"%s\">",
1848 (bg ? "even" : "odd")
1852 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1856 wprintf("<td class=\"button_link\">");
1857 wprintf(" <a href=\"netedit?cmd=remove&tab=feeds&line=rssclient|");
1860 wprintf(_("(remove)"));
1861 wprintf("</a></td>");
1867 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1869 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1870 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
1871 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1873 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
1874 "maxlength=\"256\" name=\"line_pop3host\">\n");
1877 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
1878 wprintf("</td></tr>");
1879 wprintf("</form></table>\n");
1885 /* end content of whatever tab is open now */
1886 wprintf("</div>\n");
1888 address_book_popup();
1894 * Toggle self-service list subscription
1896 void toggle_self_service(void) {
1897 room_states RoomFlags;
1899 get_roomflags (&RoomFlags);
1901 if (yesbstr("QR2_SelfList"))
1902 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
1904 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
1906 if (yesbstr("QR2_SMTP_PUBLIC"))
1907 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
1909 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
1911 if (yesbstr("QR2_Moderated"))
1912 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
1914 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
1915 if (yesbstr("QR2_SubsOnly"))
1916 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
1918 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
1920 set_roomflags (&RoomFlags);
1928 * save new parameters for a room
1935 StrBuf *er_password;
1937 StrBuf *er_roomaide;
1940 int er_listingorder;
1946 if (!havebstr("ok_button")) {
1947 strcpy(WC->ImportantMessage,
1948 _("Cancelled. Changes were not saved."));
1954 StrBuf_ServGetln(Buf);
1955 if (GetServerStatus(Buf, NULL) != 2) {
1956 StrBufCutLeft(Buf, 4);
1957 strcpy(WC->ImportantMessage, ChrPtr(Buf));
1963 er_name = NewStrBuf();
1964 er_password = NewStrBuf();
1965 er_dirname = NewStrBuf();
1966 er_roomaide = NewStrBuf();
1968 StrBufCutLeft(Buf, 4);
1969 StrBufExtract_token(er_name, Buf, 0, '|');
1970 StrBufExtract_token(er_password, Buf, 1, '|');
1971 StrBufExtract_token(er_dirname, Buf, 2, '|');
1972 er_flags = StrBufExtract_int(Buf, 3, '|');
1973 er_listingorder = StrBufExtract_int(Buf, 5, '|');
1974 er_defaultview = StrBufExtract_int(Buf, 6, '|');
1975 er_flags2 = StrBufExtract_int(Buf, 7, '|');
1977 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
1978 if (StrLength(er_roomaide) == 0) {
1980 StrBuf_ServGetln(Buf);
1981 if (GetServerStatus(Buf, NULL) != 2) {
1982 FlushStrBuf(er_roomaide);
1984 StrBufCutLeft(Buf, 4);
1985 StrBufExtract_token(er_roomaide, Buf, 0, '|');
1988 Ptr = sbstr("er_name");
1989 if (StrLength(Ptr) > 0) {
1990 FlushStrBuf(er_name);
1991 StrBufAppendBuf(er_name, Ptr, 0);
1994 Ptr = sbstr("er_password");
1995 if (StrLength(Ptr) > 0) {
1996 FlushStrBuf(er_password);
1997 StrBufAppendBuf(er_password, Ptr, 0);
2001 Ptr = sbstr("er_dirname");
2002 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2003 FlushStrBuf(er_dirname);
2004 StrBufAppendBuf(er_dirname, Ptr, 0);
2008 Ptr = sbstr("type");
2009 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2011 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2012 er_flags |= (QR_PRIVATE);
2014 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2015 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2017 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2018 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2020 if (!strcmp(ChrPtr(Ptr), "personal")) {
2021 er_flags |= QR_MAILBOX;
2023 er_flags &= ~QR_MAILBOX;
2026 if (yesbstr("prefonly")) {
2027 er_flags |= QR_PREFONLY;
2029 er_flags &= ~QR_PREFONLY;
2032 if (yesbstr("readonly")) {
2033 er_flags |= QR_READONLY;
2035 er_flags &= ~QR_READONLY;
2039 if (yesbstr("collabdel")) {
2040 er_flags2 |= QR2_COLLABDEL;
2042 er_flags2 &= ~QR2_COLLABDEL;
2045 if (yesbstr("permanent")) {
2046 er_flags |= QR_PERMANENT;
2048 er_flags &= ~QR_PERMANENT;
2051 if (yesbstr("subjectreq")) {
2052 er_flags2 |= QR2_SUBJECTREQ;
2054 er_flags2 &= ~QR2_SUBJECTREQ;
2057 if (yesbstr("network")) {
2058 er_flags |= QR_NETWORK;
2060 er_flags &= ~QR_NETWORK;
2063 if (yesbstr("directory")) {
2064 er_flags |= QR_DIRECTORY;
2066 er_flags &= ~QR_DIRECTORY;
2069 if (yesbstr("ulallowed")) {
2070 er_flags |= QR_UPLOAD;
2072 er_flags &= ~QR_UPLOAD;
2075 if (yesbstr("dlallowed")) {
2076 er_flags |= QR_DOWNLOAD;
2078 er_flags &= ~QR_DOWNLOAD;
2081 if (yesbstr("visdir")) {
2082 er_flags |= QR_VISDIR;
2084 er_flags &= ~QR_VISDIR;
2087 Ptr = sbstr("anon");
2089 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2090 if (!strcmp(ChrPtr(Ptr), "anononly"))
2091 er_flags |= QR_ANONONLY;
2092 if (!strcmp(ChrPtr(Ptr), "anon2"))
2093 er_flags |= QR_ANONOPT;
2095 bump = yesbstr("bump");
2097 er_floor = ibstr("er_floor");
2099 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2101 ChrPtr(er_password),
2110 StrBuf_ServGetln(Buf);
2111 if (GetServerStatus(Buf, NULL) != 2) {
2112 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2115 FreeStrBuf(&er_name);
2116 FreeStrBuf(&er_password);
2117 FreeStrBuf(&er_dirname);
2118 FreeStrBuf(&er_roomaide);
2123 if (StrLength(er_roomaide) > 0) {
2124 serv_printf("SETA %s", ChrPtr(er_roomaide));
2125 StrBuf_ServGetln(Buf);
2126 if (GetServerStatus(Buf, NULL) != 2) {
2127 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2128 display_main_menu();
2130 FreeStrBuf(&er_name);
2131 FreeStrBuf(&er_password);
2132 FreeStrBuf(&er_dirname);
2133 FreeStrBuf(&er_roomaide);
2138 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2141 FreeStrBuf(&er_name);
2142 FreeStrBuf(&er_password);
2143 FreeStrBuf(&er_dirname);
2144 FreeStrBuf(&er_roomaide);
2150 * Display form for Invite, Kick, and show Who Knows a room
2152 void do_invt_kick(void) {
2153 char buf[SIZ], room[SIZ], username[SIZ];
2156 serv_getln(buf, sizeof buf);
2158 if (buf[0] != '2') {
2162 extract_token(room, &buf[4], 0, '|', sizeof room);
2164 strcpy(username, bstr("username"));
2166 if (havebstr("kick_button")) {
2167 sprintf(buf, "KICK %s", username);
2169 serv_getln(buf, sizeof buf);
2171 if (buf[0] != '2') {
2172 strcpy(WC->ImportantMessage, &buf[4]);
2174 sprintf(WC->ImportantMessage,
2175 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2180 if (havebstr("invite_button")) {
2181 sprintf(buf, "INVT %s", username);
2183 serv_getln(buf, sizeof buf);
2185 if (buf[0] != '2') {
2186 strcpy(WC->ImportantMessage, &buf[4]);
2188 sprintf(WC->ImportantMessage,
2189 _("<B><I>User %s invited to room %s.</I></B>\n"),
2200 * Display form for Invite, Kick, and show Who Knows a room
2202 void display_whok(void)
2204 char buf[SIZ], room[SIZ], username[SIZ];
2207 serv_getln(buf, sizeof buf);
2209 if (buf[0] != '2') {
2213 extract_token(room, &buf[4], 0, '|', sizeof room);
2216 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2217 wprintf(_("The users listed below have access to this room. "
2218 "To remove a user from the access list, select the user "
2219 "name from the list and click 'Kick'."));
2220 wprintf("<br /><br />");
2222 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2223 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2224 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2225 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2227 serv_getln(buf, sizeof buf);
2228 if (buf[0] == '1') {
2229 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2230 extract_token(username, buf, 0, '|', sizeof username);
2231 wprintf("<OPTION>");
2236 wprintf("</select><br />\n");
2238 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2239 wprintf("</form></CENTER>\n");
2241 wprintf("</td><td>");
2242 wprintf(_("To grant another user access to this room, enter the "
2243 "user name in the box below and click 'Invite'."));
2244 wprintf("<br /><br />");
2246 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2247 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2248 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2249 wprintf(_("Invite:"));
2251 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2252 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2253 "<input type=\"submit\" value=\"%s\">"
2254 "</form></CENTER>\n", _("Invite"));
2255 /* Pop open an address book -- begin **/
2257 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2259 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2262 _("Users"), _("Users")
2264 /* Pop open an address book -- end **/
2266 wprintf("</td></tr></table>\n");
2267 address_book_popup();
2274 * display the form for entering a new room
2276 void display_entroom(void)
2283 serv_puts("CRE8 0");
2284 serv_getln(buf, sizeof buf);
2286 if (buf[0] != '2') {
2287 strcpy(WC->ImportantMessage, &buf[4]);
2288 display_main_menu();
2293 output_headers(1, 1, 1, 0, 0, 0);
2295 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2296 do_template("beginbox", NULL);
2298 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2299 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2301 wprintf("<table class=\"altern\"> ");
2303 wprintf("<tr class=\"even\"><td>");
2304 wprintf(_("Name of room: "));
2305 wprintf("</td><td>");
2306 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2307 wprintf("</td></tr>");
2309 wprintf("<tr class=\"odd\"><td>");
2310 wprintf(_("Resides on floor: "));
2311 wprintf("</td><td>");
2312 load_floorlist(Buf);
2313 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2314 for (i = 0; i < 128; ++i)
2315 if (!IsEmptyStr(floorlist[i])) {
2316 wprintf("<option ");
2317 wprintf("value=\"%d\">", i);
2318 escputs(floorlist[i]);
2319 wprintf("</option>\n");
2321 wprintf("</select>\n");
2322 wprintf("</td></tr>");
2325 * Our clever little snippet of JavaScript automatically selects
2326 * a public room if the view is set to Bulletin Board or wiki, and
2327 * it selects a mailbox room otherwise. The user can override this,
2328 * of course. We also disable the floor selector for mailboxes.
2330 wprintf("<tr class=\"even\"><td>");
2331 wprintf(_("Default view for room: "));
2332 wprintf("</td><td>");
2333 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2334 " if ( (this.form.er_view.value == 0) "
2335 " || (this.form.er_view.value == 6) ) { "
2336 " this.form.type[0].checked=true; "
2337 " this.form.er_floor.disabled = false; "
2340 " this.form.type[4].checked=true; "
2341 " this.form.er_floor.disabled = true; "
2344 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2345 if (is_view_allowed_as_default(i)) {
2346 wprintf("<option %s value=\"%d\">",
2347 ((i == 0) ? "selected" : ""), i );
2348 escputs(viewdefs[i]);
2349 wprintf("</option>\n");
2352 wprintf("</select>\n");
2353 wprintf("</td></tr>");
2355 wprintf("<tr class=\"even\"><td>");
2356 wprintf(_("Type of room:"));
2357 wprintf("</td><td>");
2358 wprintf("<ul class=\"adminlist\">\n");
2360 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2361 wprintf("CHECKED OnChange=\""
2362 " if (this.form.type[0].checked == true) { "
2363 " this.form.er_floor.disabled = false; "
2366 wprintf(_("Public (automatically appears to everyone)"));
2369 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2370 " if (this.form.type[1].checked == true) { "
2371 " this.form.er_floor.disabled = false; "
2374 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2377 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2378 " if (this.form.type[2].checked == true) { "
2379 " this.form.er_floor.disabled = false; "
2382 wprintf(_("Private - require password: "));
2383 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2386 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2387 " if (this.form.type[3].checked == true) { "
2388 " this.form.er_floor.disabled = false; "
2391 wprintf(_("Private - invitation only"));
2394 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2396 " if (this.form.type[4].checked == true) { "
2397 " this.form.er_floor.disabled = true; "
2400 wprintf(_("Personal (mailbox for you only)"));
2403 wprintf("\n</ul>\n");
2404 wprintf("</td></tr></table>\n");
2406 wprintf("<div class=\"buttons\">\n");
2407 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2409 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2410 wprintf("</div>\n");
2411 wprintf("</form>\n<hr />");
2412 serv_printf("MESG roomaccess");
2413 serv_getln(buf, sizeof buf);
2414 if (buf[0] == '1') {
2418 do_template("endbox", NULL);
2428 * support function for entroom() -- sets the default view
2430 void er_set_default_view(int newview) {
2443 serv_getln(buf, sizeof buf);
2444 if (buf[0] != '2') return;
2446 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2447 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2448 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2449 rm_bits1 = extract_int(&buf[4], 3);
2450 rm_floor = extract_int(&buf[4], 4);
2451 rm_listorder = extract_int(&buf[4], 5);
2452 rm_bits2 = extract_int(&buf[4], 7);
2454 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2455 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2456 rm_listorder, newview, rm_bits2
2458 serv_getln(buf, sizeof buf);
2469 const StrBuf *er_name;
2470 const StrBuf *er_type;
2471 const StrBuf *er_password;
2476 if (!havebstr("ok_button")) {
2477 strcpy(WC->ImportantMessage,
2478 _("Cancelled. No new room was created."));
2479 display_main_menu();
2482 er_name = sbstr("er_name");
2483 er_type = sbstr("type");
2484 er_password = sbstr("er_password");
2485 er_floor = ibstr("er_floor");
2486 er_view = ibstr("er_view");
2489 if (!strcmp(ChrPtr(er_type), "hidden"))
2491 else if (!strcmp(ChrPtr(er_type), "passworded"))
2493 else if (!strcmp(ChrPtr(er_type), "invonly"))
2495 else if (!strcmp(ChrPtr(er_type), "personal"))
2498 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2501 ChrPtr(er_password),
2506 serv_getln(buf, sizeof buf);
2507 if (buf[0] != '2') {
2508 strcpy(WC->ImportantMessage, &buf[4]);
2509 display_main_menu();
2512 /** TODO: Room created, now udate the left hand icon bar for this user */
2513 burn_folder_cache(0); /* burn the old folder cache */
2517 do_change_view(er_view); /* Now go there */
2522 * \brief display the screen to enter a private room
2524 void display_private(char *rname, int req_pass)
2526 WCTemplputParams SubTP;
2528 output_headers(1, 1, 1, 0, 0, 0);
2530 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2531 memset(&SubTP, 0, sizeof(WCTemplputParams));
2532 SubTP.Filter.ContextType = CTX_STRBUF;
2533 SubTP.Context = Buf;
2534 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2539 wprintf(_("If you know the name of a hidden (guess-name) or "
2540 "passworded room, you can enter that room by typing "
2541 "its name below. Once you gain access to a private "
2542 "room, it will appear in your regular room listings "
2543 "so you don't have to keep returning here."));
2546 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2547 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2549 wprintf("<table class=\"altern\"> "
2550 "<tr class=\"even\"><td>");
2551 wprintf(_("Enter room name:"));
2553 "<input type=\"text\" name=\"gr_name\" "
2554 "value=\"%s\" maxlength=\"128\">\n", rname);
2557 wprintf("</td></tr><tr class=\"odd\"><td>");
2558 wprintf(_("Enter room password:"));
2559 wprintf("</td><td>");
2560 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2562 wprintf("</td></tr></table>\n");
2564 wprintf("<div class=\"buttons\">\n");
2565 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2567 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2571 wprintf("</div></form>\n");
2573 do_template("endbox", NULL);
2579 * \brief goto a private room
2581 void goto_private(void)
2586 if (!havebstr("ok_button")) {
2587 display_main_menu();
2590 strcpy(hold_rm, ChrPtr(WC->wc_roomname));
2591 serv_printf("GOTO %s|%s",
2594 serv_getln(buf, sizeof buf);
2596 if (buf[0] == '2') {
2597 smart_goto(sbstr("gr_name"));
2600 if (!strncmp(buf, "540", 3)) {
2601 display_private(bstr("gr_name"), 1);
2604 output_headers(1, 1, 1, 0, 0, 0);
2605 wprintf("%s\n", &buf[4]);
2612 * \brief display the screen to zap a room
2614 void display_zap(void)
2616 output_headers(1, 1, 2, 0, 0, 0);
2618 wprintf("<div id=\"banner\">\n");
2620 wprintf(_("Zap (forget/unsubscribe) the current room"));
2622 wprintf("</div>\n");
2624 wprintf("<div id=\"content\" class=\"service\">\n");
2626 wprintf(_("If you select this option, <em>%s</em> will "
2627 "disappear from your room list. Is this what you wish "
2628 "to do?<br />\n"), ChrPtr(WC->wc_roomname));
2630 wprintf("<form method=\"POST\" action=\"zap\">\n");
2631 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2632 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2634 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2635 wprintf("</form>\n");
2646 StrBuf *final_destination;
2649 * If the forget-room routine fails for any reason, we fall back
2650 * to the current room; otherwise, we go to the Lobby
2652 final_destination = NewStrBufDup(WC->wc_roomname);
2654 if (havebstr("ok_button")) {
2655 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
2656 serv_getln(buf, sizeof buf);
2657 if (buf[0] == '2') {
2659 serv_getln(buf, sizeof buf);
2660 if (buf[0] == '2') {
2661 FlushStrBuf(final_destination);
2662 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2666 smart_goto(final_destination);
2667 FreeStrBuf(&final_destination);
2673 * \brief Delete the current room
2675 void delete_room(void)
2680 serv_puts("KILL 1");
2681 serv_getln(buf, sizeof buf);
2682 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2683 if (buf[0] != '2') {
2684 strcpy(WC->ImportantMessage, &buf[4]);
2685 display_main_menu();
2690 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2699 * \brief Perform changes to a room's network configuration
2701 void netedit(void) {
2710 /*/ TODO: do line dynamic! */
2711 if (havebstr("line_pop3host")) {
2712 strcpy(line, bstr("prefix"));
2713 strcat(line, bstr("line_pop3host"));
2715 strcat(line, bstr("line_pop3user"));
2717 strcat(line, bstr("line_pop3pass"));
2719 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2721 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2722 strcat(line, bstr("suffix"));
2724 else if (havebstr("line")) {
2725 strcpy(line, bstr("prefix"));
2726 strcat(line, bstr("line"));
2727 strcat(line, bstr("suffix"));
2742 serv_getln(buf, sizeof buf);
2743 if (buf[0] != '1') {
2749 /** This loop works for add *or* remove. Spiffy, eh? */
2750 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2751 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2752 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2753 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2754 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2755 if ( (strcasecmp(cmpa0, cmpb0))
2756 || (strcasecmp(cmpa1, cmpb1)) ) {
2757 fprintf(fp, "%s\n", buf);
2763 serv_getln(buf, sizeof buf);
2764 if (buf[0] != '4') {
2770 while (fgets(buf, sizeof buf, fp) != NULL) {
2771 buf[strlen(buf)-1] = 0;
2775 if (havebstr("add_button")) {
2776 num_addrs = num_tokens(bstr("line"), ',');
2777 if (num_addrs < 2) {
2778 /* just adding one node or address */
2782 /* adding multiple addresses separated by commas */
2783 for (i=0; i<num_addrs; ++i) {
2784 strcpy(line, bstr("prefix"));
2785 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2788 strcat(line, bstr("suffix"));
2802 * \brief Convert a room name to a folder-ish-looking name.
2803 * \param folder the folderish name
2804 * \param room the room name
2805 * \param floor the floor name
2806 * \param is_mailbox is it a mailbox?
2808 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2813 * For mailboxes, just do it straight...
2816 sprintf(folder, "My folders|%s", room);
2820 * Otherwise, prefix the floor name as a "public folders" moniker
2823 if (floor > MAX_FLOORS) {
2825 sprintf(folder, "%%%%%%|%s", room);
2828 sprintf(folder, "%s|%s", floorlist[floor], room);
2833 * Replace "\" characters with "|" for pseudo-folder-delimiting
2835 len = strlen (folder);
2836 for (i=0; i<len; ++i) {
2837 if (folder[i] == '\\') folder[i] = '|';
2845 * \brief Back end for change_view()
2846 * \param newview set newview???
2848 void do_change_view(int newview) {
2851 serv_printf("VIEW %d", newview);
2852 serv_getln(buf, sizeof buf);
2853 WC->wc_view = newview;
2854 smart_goto(WC->wc_roomname);
2860 * \brief Change the view for this room
2862 void change_view(void) {
2865 view = lbstr("view");
2866 do_change_view(view);
2871 * \brief One big expanded tree list view --- like a folder list
2872 * \param fold the folder to view
2873 * \param max_folders how many folders???
2874 * \param num_floors hom many floors???
2876 void do_folder_view(struct __ofolder *fold, int max_folders, int num_floors) {
2880 int has_subfolders = 0;
2883 parents = malloc(max_folders * sizeof(int));
2885 /** BEGIN TREE MENU */
2886 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2888 /** include NanoTree */
2889 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2891 /** initialize NanoTree */
2892 wprintf("<script type=\"text/javascript\"> \n"
2893 " showRootNode = false; \n"
2894 " sortNodes = false; \n"
2895 " dragable = false; \n"
2897 " function standardClick(treeNode) { \n"
2900 " var closedGif = 'static/folder_closed.gif'; \n"
2901 " var openGif = 'static/folder_open.gif'; \n"
2903 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2907 for (i=0; i<max_folders; ++i) {
2910 if ((i+1) < max_folders) {
2912 len = strlen(fold[i].name);
2913 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
2914 && (fold[i+1].name[len] == '|') ) {
2919 levels = num_tokens(fold[i].name, '|');
2920 parents[levels] = i;
2922 wprintf("var node%d = new TreeNode(%d, '", i, i);
2924 if (fold[i].selectable) {
2925 wprintf("<a href=\"dotgoto?room=");
2926 urlescputs(fold[i].room);
2931 wprintf("<span class=\"roomlist_floor\">");
2933 else if (fold[i].hasnewmsgs) {
2934 wprintf("<span class=\"roomlist_new\">");
2937 wprintf("<span class=\"roomlist_old\">");
2939 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2944 if (has_subfolders) {
2945 wprintf("new Array(closedGif, openGif)");
2947 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2948 wprintf("'static/viewcontacts_16x.gif'");
2950 else if (fold[i].view == VIEW_CALENDAR) {
2951 wprintf("'static/calarea_16x.gif'");
2953 else if (fold[i].view == VIEW_CALBRIEF) {
2954 wprintf("'static/calarea_16x.gif'");
2956 else if (fold[i].view == VIEW_TASKS) {
2957 wprintf("'static/taskmanag_16x.gif'");
2959 else if (fold[i].view == VIEW_NOTES) {
2960 wprintf("'static/storenotes_16x.gif'");
2962 else if (fold[i].view == VIEW_MAILBOX) {
2963 wprintf("'static/privatemess_16x.gif'");
2966 wprintf("'static/chatrooms_16x.gif'");
2969 urlescputs(fold[i].name);
2973 wprintf("rootNode.addChild(node%d);\n", i);
2976 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2980 wprintf("container = document.getElementById('roomlist_div'); \n"
2986 /** END TREE MENU */
2990 * \brief Boxes and rooms and lists ... oh my!
2991 * \param fold the folder to view
2992 * \param max_folders how many folders???
2993 * \param num_floors hom many floors???
2995 void do_rooms_view(struct __ofolder *fold, int max_folders, int num_floors) {
2997 char floor_name[256];
2998 char old_floor_name[256];
2999 int levels, oldlevels;
3002 static int columns = 3;
3003 int boxes_per_column = 0;
3004 int current_column = 0;
3007 strcpy(floor_name, "");
3008 strcpy(old_floor_name, "");
3011 while (nf % columns != 0) ++nf;
3012 boxes_per_column = (nf / columns);
3013 if (boxes_per_column < 1) boxes_per_column = 1;
3015 /** Outer table (for columnization) */
3016 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3017 "<tr><td valign=top>");
3021 for (i=0; i<max_folders; ++i) {
3023 levels = num_tokens(fold[i].name, '|');
3024 extract_token(floor_name, fold[i].name, 0,
3025 '|', sizeof floor_name);
3027 if ( (strcasecmp(floor_name, old_floor_name))
3028 && (!IsEmptyStr(old_floor_name)) ) {
3030 do_template("endbox", NULL);
3034 if ((num_boxes % boxes_per_column) == 0) {
3036 if (current_column < columns) {
3037 wprintf("</td><td valign=top>\n");
3041 strcpy(old_floor_name, floor_name);
3045 WCTemplputParams SubTP;
3047 Buf = NewStrBufPlain(floor_name, -1);
3048 memset(&SubTP, 0, sizeof(WCTemplputParams));
3049 SubTP.Filter.ContextType = CTX_STRBUF;
3050 SubTP.Context = Buf;
3051 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
3060 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3061 if (fold[i].selectable) {
3062 wprintf("<a href=\"dotgoto?room=");
3063 urlescputs(fold[i].room);
3069 if (fold[i].hasnewmsgs) {
3070 wprintf("<span class=\"roomlist_new\">");
3073 wprintf("<span class=\"roomlist_old\">");
3075 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3078 if (fold[i].selectable) {
3084 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3085 wprintf(" (INBOX)");
3087 wprintf("<br />\n");
3090 /** End the final inner box */
3091 do_template("endbox", NULL);
3093 wprintf("</td></tr></table>\n");
3097 * \brief print a floor div???
3098 * \param which_floordiv name of the floordiv???
3100 void set_floordiv_expanded(void) {
3101 wcsession *WCC = WC;
3104 FloorDiv = NewStrBuf();
3105 StrBufExtract_token(FloorDiv, WCC->Hdr->HR.ReqLine, 0, '/');
3106 set_preference("floordiv_expanded", FloorDiv, 1);
3107 WCC->floordiv_expanded = FloorDiv;
3111 * \brief view the iconbar
3112 * \param fold the folder to view
3113 * \param max_folders how many folders???
3114 * \param num_floors hom many floors???
3116 void do_iconbar_view(struct __ofolder *fold, int max_folders, int num_floors) {
3118 char floor_name[256];
3119 char old_floor_name[256];
3120 char floordivtitle[256];
3121 char floordiv_id[32];
3122 int levels, oldlevels;
3126 strcpy(floor_name, "");
3127 strcpy(old_floor_name, "");
3131 for (i=0; i<max_folders; ++i) {
3133 levels = num_tokens(fold[i].name, '|');
3134 extract_token(floor_name, fold[i].name, 0,
3135 '|', sizeof floor_name);
3137 if ( (strcasecmp(floor_name, old_floor_name))
3138 && (!IsEmptyStr(old_floor_name)) ) {
3139 /** End inner box */
3141 wprintf("</div>\n"); /** floordiv */
3143 strcpy(old_floor_name, floor_name);
3147 stresc(floordivtitle, 256, floor_name, 0, 0);
3148 sprintf(floordiv_id, "floordiv%d", i);
3149 wprintf("<span class=\"ib_roomlist_floor\" "
3150 "onClick=\"expand_floor('%s')\">"
3151 "%s</span><br>\n", floordiv_id, floordivtitle);
3152 wprintf("<div id=\"%s\" style=\"display:%s\">",
3154 (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
3161 wprintf("<div id=\"roomdiv%d\">", i);
3163 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3165 /** choose the icon */
3166 if (fold[i].view == VIEW_ADDRESSBOOK) {
3167 icon = "viewcontacts_16x.gif" ;
3169 else if (fold[i].view == VIEW_CALENDAR) {
3170 icon = "calarea_16x.gif" ;
3172 else if (fold[i].view == VIEW_CALBRIEF) {
3173 icon = "calarea_16x.gif" ;
3175 else if (fold[i].view == VIEW_TASKS) {
3176 icon = "taskmanag_16x.gif" ;
3178 else if (fold[i].view == VIEW_NOTES) {
3179 icon = "storenotes_16x.gif" ;
3181 else if (fold[i].view == VIEW_MAILBOX) {
3182 icon = "privatemess_16x.gif" ;
3185 icon = "chatrooms_16x.gif" ;
3188 if (fold[i].selectable) {
3189 wprintf("<a href=\"dotgoto?room=");
3190 urlescputs(fold[i].room);
3192 wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
3197 if (fold[i].hasnewmsgs) {
3198 wprintf("<span class=\"ib_roomlist_new\">");
3201 wprintf("<span class=\"ib_roomlist_old\">");
3203 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3205 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3206 wprintf(" (INBOX)");
3209 if (fold[i].selectable) {
3216 wprintf("</div>\n"); /** roomdiv */
3219 wprintf("</div>\n"); /** floordiv */
3227 * \brief Burn the cached folder list.
3228 * \param age How old the cahce needs to be before we burn it.
3231 void burn_folder_cache(time_t age)
3233 /** If our cached folder list is very old, burn it. */
3234 if (WC->cache_fold != NULL) {
3235 if ((time(NULL) - WC->cache_timestamp) > age) {
3236 free(WC->cache_fold);
3237 WC->cache_fold = NULL;
3246 * \brief Show the room list.
3247 * (only should get called by
3248 * knrooms() because that's where output_headers() is called from)
3249 * \param viewpref the view preferences???
3252 void list_all_rooms_by_floor(const char *viewpref) {
3256 struct __ofolder *fold = NULL;
3257 struct __ofolder ftmp;
3258 int max_folders = 0;
3259 int alloc_folders = 0;
3263 int ShowEmptyFloors;
3266 int num_floors = 1; /** add an extra one for private folders */
3269 /** If our cached folder list is very old, burn it. */
3270 burn_folder_cache(300);
3272 /** Can we do the iconbar roomlist from cache? */
3273 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3274 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3279 /** Grab the floor table so we know how to build the list... */
3280 load_floorlist(Buf);
3282 /** Start with the mailboxes */
3285 fold = malloc(sizeof(struct __ofolder));
3286 memset(fold, 0, sizeof(struct __ofolder));
3287 strcpy(fold[0].name, "My folders");
3288 fold[0].is_mailbox = 1;
3290 /** Then add floors */
3292 serv_getln(buf, sizeof buf);
3293 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3294 if (max_folders >= alloc_folders) {
3295 alloc_folders = max_folders + 100;
3296 fold = realloc(fold,
3297 alloc_folders * sizeof(struct __ofolder));
3299 memset(&fold[max_folders], 0, sizeof(struct __ofolder));
3300 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3301 extract_token(buf3, buf, 0, '|', SIZ);
3302 fold[max_folders].floor = atol (buf3);
3307 for (i=0; i<num_floors; i++)
3308 if (IDMax < fold[i].floor)
3309 IDMax = fold[i].floor;
3310 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3311 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3312 for (i=0; i<num_floors; i++)
3313 floor_mapping[fold[i].floor]=i;
3315 /** refresh the messages index for this room */
3316 /* TODO serv_puts("GOTO ");
3317 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")); */
3318 /** Now add rooms */
3320 serv_getln(buf, sizeof buf);
3321 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3322 if (max_folders >= alloc_folders) {
3323 alloc_folders = max_folders + 100;
3324 fold = realloc(fold,
3325 alloc_folders * sizeof(struct __ofolder));
3327 memset(&fold[max_folders], 0, sizeof(struct __ofolder));
3328 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3329 ra_flags = extract_int(buf, 5);
3330 flags = extract_int(buf, 1);
3331 fold[max_folders].floor = extract_int(buf, 2);
3332 fold[max_folders].hasnewmsgs =
3333 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3334 if (flags & QR_MAILBOX) {
3335 fold[max_folders].is_mailbox = 1;
3337 fold[max_folders].view = extract_int(buf, 6);
3338 room_to_folder(fold[max_folders].name,
3339 fold[max_folders].room,
3340 fold[max_folders].floor,
3341 fold[max_folders].is_mailbox);
3342 fold[max_folders].selectable = 1;
3343 /* Increase the room count for the associtaed floor */
3344 if (fold[max_folders].is_mailbox) {
3345 fold[0].num_rooms++;
3348 i = floor_mapping[fold[max_folders].floor];
3349 fold[i].num_rooms++;
3355 * Remove any floors that don't have rooms
3357 get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
3358 if (ShowEmptyFloors)
3360 for (i=0; i<num_floors; i++)
3362 if (fold[i].num_rooms == 0) {
3363 for (j=i; j<max_folders; j++) {
3364 memcpy(&fold[j], &fold[j+1], sizeof(struct __ofolder));
3373 /** Bubble-sort the folder list */
3374 for (i=0; i<max_folders; ++i) {
3375 for (j=0; j<(max_folders-1)-i; ++j) {
3376 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3377 swap = strcasecmp(fold[j].name, fold[j+1].name);
3380 if ( (fold[j+1].is_mailbox)
3381 && (!fold[j].is_mailbox)) {
3389 memcpy(&ftmp, &fold[j], sizeof(struct __ofolder));
3390 memcpy(&fold[j], &fold[j+1],
3391 sizeof(struct __ofolder));
3392 memcpy(&fold[j+1], &ftmp,
3393 sizeof(struct __ofolder));
3399 if (!strcasecmp(viewpref, "folders")) {
3400 do_folder_view(fold, max_folders, num_floors);
3402 else if (!strcasecmp(viewpref, "hackish_view")) {
3403 for (i=0; i<max_folders; ++i) {
3404 escputs(fold[i].name);
3405 wprintf("<br />\n");
3408 else if (!strcasecmp(viewpref, "iconbar")) {
3409 do_iconbar_view(fold, max_folders, num_floors);
3412 do_rooms_view(fold, max_folders, num_floors);
3415 /* Don't free the folder list ... cache it for future use! */
3416 if (WC->cache_fold != NULL) {
3417 free(WC->cache_fold);
3419 WC->cache_fold = fold;
3420 WC->cache_max_folders = max_folders;
3421 WC->cache_num_floors = num_floors;
3422 WC->cache_timestamp = time(NULL);
3423 free(floor_mapping);
3428 * \brief Do either a known rooms list or a folders list, depending on the
3433 StrBuf *ListView = NULL;
3435 output_headers(1, 1, 2, 0, 0, 0);
3437 /** Determine whether the user is trying to change views */
3438 if (havebstr("view")) {
3439 ListView = NewStrBufPlain(bstr("view"), -1);
3440 set_preference("roomlistview", ListView, 1);
3442 /** Sanitize the input so its safe */
3443 if(!get_preference("roomlistview", &ListView) ||
3444 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3445 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3447 if (ListView == NULL) {
3448 ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1);
3449 set_preference("roomlistview", ListView, 0);
3452 StrBufPrintf(ListView, "rooms");
3458 wprintf("<div id=\"banner\">\n");
3459 wprintf("<div class=\"room_banner\" id=\"room_banner\">");
3461 if (!strcasecmp(ChrPtr(ListView), "rooms")) {
3462 wprintf(_("Room list"));
3464 else if (!strcasecmp(ChrPtr(ListView), "folders")) {
3465 wprintf(_("Folder list"));
3467 else if (!strcasecmp(ChrPtr(ListView), "table")) {
3468 wprintf(_("Room list"));
3470 wprintf("</h1></div>\n");
3472 /** offer the ability to switch views */
3473 wprintf("<div id=\"actiondiv\">");
3474 wprintf("<ul class=\"room_actions\">\n");
3475 wprintf("<li class=\"start_page\">");
3476 offer_start_page(NULL, &NoCtx);
3478 wprintf("<li><form name=\"roomlistomatic\">\n"
3479 "<select name=\"newview\" size=\"1\" "
3480 "OnChange=\"location.href=roomlistomatic.newview.options"
3481 "[selectedIndex].value\">\n");
3483 wprintf("<option %s value=\"knrooms?view=rooms\">"
3486 ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" )
3489 wprintf("<option %s value=\"knrooms?view=folders\">"
3490 "View as folder list"
3492 ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" )
3495 wprintf("</select>");
3496 wprintf("</form></li>");
3497 wprintf("</ul></div></div>\n");
3499 wprintf("<div id=\"content\" class=\"service\">\n");
3501 /** Display the room list in the user's preferred format */
3502 list_all_rooms_by_floor(ChrPtr(ListView));
3509 * \brief Set the message expire policy for this room and/or floor
3511 void set_room_policy(void) {
3514 if (!havebstr("ok_button")) {
3515 strcpy(WC->ImportantMessage,
3516 _("Cancelled. Changes were not saved."));
3521 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3522 serv_getln(buf, sizeof buf);
3523 strcpy(WC->ImportantMessage, &buf[4]);
3525 if (WC->axlevel >= 6) {
3526 strcat(WC->ImportantMessage, "<br />\n");
3527 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3528 serv_getln(buf, sizeof buf);
3529 strcat(WC->ImportantMessage, &buf[4]);
3535 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3537 StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0);
3541 void _display_private(void) {
3542 display_private("", 0);
3545 void dotgoto(void) {
3546 if (!havebstr("room")) {
3550 if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3553 smart_goto(sbstr("room"));
3556 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3558 wprintf("<div id=\"banner\">\n");
3559 embed_room_banner(NULL, navbar_default);
3560 wprintf("</div>\n");
3564 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3566 wcsession *WCC = WC;
3569 (!IsEmptyStr(WCC->ugname)))
3570 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3574 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3576 wcsession *WCC = WC;
3578 return ((WCC!=NULL) &&
3579 (!IsEmptyStr(WCC->ugname)) &&
3580 (strcasecmp(WCC->ugname, ChrPtr(WCC->wc_roomname)) == 0));
3583 int ConditionalRoomHas_QR_PERMANENT(StrBuf *Target, WCTemplputParams *TP)
3585 wcsession *WCC = WC;
3587 return ((WCC!=NULL) &&
3588 ((WCC->room_flags & QR_PERMANENT) != 0));
3591 int ConditionalRoomHas_QR_INUSE(StrBuf *Target, WCTemplputParams *TP)
3593 wcsession *WCC = WC;
3595 return ((WCC!=NULL) &&
3596 ((WCC->room_flags & QR_INUSE) != 0));
3599 int ConditionalRoomHas_QR_PRIVATE(StrBuf *Target, WCTemplputParams *TP)
3601 wcsession *WCC = WC;
3603 return ((WCC!=NULL) &&
3604 ((WCC->room_flags & QR_PRIVATE) != 0));
3607 int ConditionalRoomHas_QR_PASSWORDED(StrBuf *Target, WCTemplputParams *TP)
3609 wcsession *WCC = WC;
3611 return ((WCC!=NULL) &&
3612 ((WCC->room_flags & QR_PASSWORDED) != 0));
3615 int ConditionalRoomHas_QR_GUESSNAME(StrBuf *Target, WCTemplputParams *TP)
3617 wcsession *WCC = WC;
3619 return ((WCC!=NULL) &&
3620 ((WCC->room_flags & QR_GUESSNAME) != 0));
3623 int ConditionalRoomHas_QR_DIRECTORY(StrBuf *Target, WCTemplputParams *TP)
3625 wcsession *WCC = WC;
3627 return ((WCC!=NULL) &&
3628 ((WCC->room_flags & QR_DIRECTORY) != 0));
3631 int ConditionalRoomHas_QR_UPLOAD(StrBuf *Target, WCTemplputParams *TP)
3633 wcsession *WCC = WC;
3635 return ((WCC!=NULL) &&
3636 ((WCC->room_flags & QR_UPLOAD) != 0));
3639 int ConditionalRoomHas_QR_DOWNLOAD(StrBuf *Target, WCTemplputParams *TP)
3641 wcsession *WCC = WC;
3643 return ((WCC!=NULL) &&
3644 ((WCC->room_flags & QR_DOWNLOAD) != 0));
3647 int ConditionalRoomHas_QR_VISDIR(StrBuf *Target, WCTemplputParams *TP)
3649 wcsession *WCC = WC;
3651 return ((WCC!=NULL) &&
3652 ((WCC->room_flags & QR_VISDIR) != 0));
3655 int ConditionalRoomHas_QR_ANONONLY(StrBuf *Target, WCTemplputParams *TP)
3657 wcsession *WCC = WC;
3659 return ((WCC!=NULL) &&
3660 ((WCC->room_flags & QR_ANONONLY) != 0));
3663 int ConditionalRoomHas_QR_ANONOPT(StrBuf *Target, WCTemplputParams *TP)
3665 wcsession *WCC = WC;
3667 return ((WCC!=NULL) &&
3668 ((WCC->room_flags & QR_ANONOPT) != 0));
3671 int ConditionalRoomHas_QR_NETWORK(StrBuf *Target, WCTemplputParams *TP)
3673 wcsession *WCC = WC;
3675 return ((WCC!=NULL) &&
3676 ((WCC->room_flags & QR_NETWORK) != 0));
3679 int ConditionalRoomHas_QR_PREFONLY(StrBuf *Target, WCTemplputParams *TP)
3681 wcsession *WCC = WC;
3683 return ((WCC!=NULL) &&
3684 ((WCC->room_flags & QR_PREFONLY) != 0));
3687 int ConditionalRoomHas_QR_READONLY(StrBuf *Target, WCTemplputParams *TP)
3689 wcsession *WCC = WC;
3691 return ((WCC!=NULL) &&
3692 ((WCC->room_flags & QR_READONLY) != 0));
3695 int ConditionalRoomHas_QR_MAILBOX(StrBuf *Target, WCTemplputParams *TP)
3697 wcsession *WCC = WC;
3699 return ((WCC!=NULL) &&
3700 ((WCC->room_flags & QR_MAILBOX) != 0));
3707 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3709 wcsession *WCC = WC;
3711 return ( (WCC!= NULL) &&
3712 ((WCC->axlevel >= 6) ||
3713 (WCC->is_room_aide) ||
3714 (WCC->is_mailbox) ));
3717 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3719 wcsession *WCC = WC;
3721 if ((WCC == NULL) ||
3722 (TP->Tokens->nParameters < 3) ||
3723 (TP->Tokens->Params[2]->Type != TYPE_STR)||
3724 (TP->Tokens->Params[2]->len < 7))
3727 switch(WCC->wc_view) {
3729 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_BBS"));
3731 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_MAILBOX"));
3732 case VIEW_ADDRESSBOOK:
3733 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_ADDRESSBOOK"));
3735 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_TASKS"));
3737 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_NOTES"));
3739 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_WIKI"));
3741 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_JOURNAL"));
3743 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_CALENDAR"));
3745 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_CALBRIEF"));
3755 RegisterPreference("roomlistview",
3756 _("Room list view"),
3759 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3761 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, 0);
3763 WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0);
3764 WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, NEED_URL);
3765 WebcitAddUrlHandler(HKEY("dotskip"), dotskip, NEED_URL);
3766 WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0);
3767 WebcitAddUrlHandler(HKEY("goto_private"), goto_private, NEED_URL);
3768 WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0);
3769 WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0);
3770 WebcitAddUrlHandler(HKEY("zap"), zap, 0);
3771 WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0);
3772 WebcitAddUrlHandler(HKEY("entroom"), entroom, 0);
3773 WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0);
3774 WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0);
3775 WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0);
3776 WebcitAddUrlHandler(HKEY("netedit"), netedit, 0);
3777 WebcitAddUrlHandler(HKEY("editroom"), editroom, 0);
3778 WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0);
3779 WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0);
3780 WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX);
3781 WebcitAddUrlHandler(HKEY("changeview"), change_view, 0);
3782 WebcitAddUrlHandler(HKEY("toggle_self_service"), toggle_self_service, 0);
3783 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, 0);
3785 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3786 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PERMANENT"), 0, ConditionalRoomHas_QR_PERMANENT, CTX_NONE);
3787 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_INUSE"), 0, ConditionalRoomHas_QR_INUSE, CTX_NONE);
3788 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PRIVATE"), 0, ConditionalRoomHas_QR_PRIVATE, CTX_NONE);
3789 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PASSWORDED"), 0, ConditionalRoomHas_QR_PASSWORDED, CTX_NONE);
3790 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_GUESSNAME"), 0, ConditionalRoomHas_QR_GUESSNAME, CTX_NONE);
3791 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DIRECTORY"), 0, ConditionalRoomHas_QR_DIRECTORY, CTX_NONE);
3792 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_UPLOAD"), 0, ConditionalRoomHas_QR_UPLOAD, CTX_NONE);
3793 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DOWNLOAD"), 0, ConditionalRoomHas_QR_DOWNLOAD, CTX_NONE);
3794 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_VISIDIR"), 0, ConditionalRoomHas_QR_VISDIR, CTX_NONE);
3795 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONONLY"), 0, ConditionalRoomHas_QR_ANONONLY, CTX_NONE);
3796 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONOPT"), 0, ConditionalRoomHas_QR_ANONOPT, CTX_NONE);
3797 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_NETWORK"), 0, ConditionalRoomHas_QR_NETWORK, CTX_NONE);
3798 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PREFONLY"), 0, ConditionalRoomHas_QR_PREFONLY, CTX_NONE);
3799 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_READONLY"), 0, ConditionalRoomHas_QR_READONLY, CTX_NONE);
3800 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_MAILBOX"), 0, ConditionalRoomHas_QR_MAILBOX, CTX_NONE);
3802 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3803 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3805 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, 0);
3806 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3813 SessionDestroyModule_ROOMOPS
3816 if (sess->cache_fold != NULL) {
3817 free(sess->cache_fold);
3820 free_march_list(sess);
3821 DeleteHash(&sess->Floors);