3 * Lots of different room-related operations.
10 char floorlist[MAX_FLOORS][SIZ]; /* list of our floor names */
12 char *viewdefs[9]; /* the different kinds of available views */
14 /* See GetFloorListHash and GetRoomListHash for info on these.
15 * Basically we pull LFLR/LKRA etc. and set up a room HashList with these keys.
18 void display_whok(void);
21 * Initialize the viewdefs with localized strings
23 void initialize_viewdefs(void) {
24 viewdefs[0] = _("Bulletin Board");
25 viewdefs[1] = _("Mail Folder");
26 viewdefs[2] = _("Address Book");
27 viewdefs[3] = _("Calendar");
28 viewdefs[4] = _("Task List");
29 viewdefs[5] = _("Notes List");
30 viewdefs[6] = _("Wiki");
31 viewdefs[7] = _("Calendar List");
32 viewdefs[8] = _("Journal");
36 * Determine which views are allowed as the default for creating a new room.
38 int is_view_allowed_as_default(int which_view)
41 case VIEW_BBS: return(1);
42 case VIEW_MAILBOX: return(1);
43 case VIEW_ADDRESSBOOK: return(1);
44 case VIEW_CALENDAR: return(1);
45 case VIEW_TASKS: return(1);
46 case VIEW_NOTES: return(1);
47 case VIEW_WIKI: return(0); /* because it isn't finished yet */
48 case VIEW_CALBRIEF: return(0);
49 case VIEW_JOURNAL: return(0);
50 default: return(0); /* should never get here */
56 * load the list of floors
58 void load_floorlist(StrBuf *Buf)
63 for (a = 0; a < MAX_FLOORS; ++a)
67 StrBuf_ServGetln(Buf);
68 if (GetServerStatus(Buf, NULL) != 1) {
69 strcpy(floorlist[0], "Main Floor");
72 while (!Done && (StrBuf_ServGetln(Buf)>=0)) {
73 if ( (StrLength(Buf)==3) &&
74 !strcmp(ChrPtr(Buf), "000")) {
78 extract_token(floorlist[StrBufExtract_int(Buf, 0, '|')], ChrPtr(Buf), 1, '|', sizeof floorlist[0]);
86 * display rooms in tree structure
88 void room_tree_list(struct roomlisting *rp)
97 room_tree_list(rp->lnext);
99 strcpy(rmname, rp->rlname);
102 wprintf("<a href=\"dotgoto?room=");
106 escputs1(rmname, 1, 1);
107 if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
109 else if (f & QR_DIRECTORY)
111 else if (f & QR_NETWORK)
115 wprintf("</a><tt> </tt>\n");
117 room_tree_list(rp->rnext);
123 * Room ordering stuff (compare first by floor, then by order)
125 int rordercmp(struct roomlisting *r1, struct roomlisting *r2)
127 if ((r1 == NULL) && (r2 == NULL))
133 if (r1->rlfloor < r2->rlfloor)
135 if (r1->rlfloor > r2->rlfloor)
137 if (r1->rlorder < r2->rlorder)
139 if (r1->rlorder > r2->rlorder)
146 * Common code for all room listings
148 void listrms(char *variety)
153 struct roomlisting *rl = NULL;
154 struct roomlisting *rp;
155 struct roomlisting *rs;
157 /* Ask the server for a room list */
159 serv_getln(buf, sizeof buf);
165 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
167 rp = malloc(sizeof(struct roomlisting));
168 extract_token(rp->rlname, buf, 0, '|', sizeof rp->rlname);
169 rp->rlflags = extract_int(buf, 1);
170 rp->rlfloor = extract_int(buf, 2);
171 rp->rlorder = extract_int(buf, 3);
180 if (rordercmp(rp, rs) < 0) {
181 if (rs->lnext == NULL) {
188 if (rs->rnext == NULL) {
201 * If no rooms were listed, print an nbsp to make the cell
202 * borders show up anyway.
204 if (num_rooms == 0) wprintf(" ");
209 * list all forgotten rooms
211 void zapped_list(void)
213 WCTemplputParams SubTP;
216 output_headers(1, 1, 1, 0, 0, 0);
217 memset(&SubTP, 0, sizeof(WCTemplputParams));
218 Buf = NewStrBufPlain(_("Zapped (forgotten) rooms"), -1);
219 SubTP.Filter.ContextType = CTX_STRBUF;
221 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
227 wprintf("<br /><br />\n");
228 wprintf(_("Click on any room to un-zap it and goto that room.\n"));
229 do_template("endbox", NULL);
235 * read this room's info file (set v to 1 for verbose mode)
237 void readinfo(StrBuf *Target, WCTemplputParams *TP)
242 int fullinfo_len = 0;
245 serv_getln(buf, sizeof buf);
248 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
249 if (fullinfo_len < (sizeof fullinfo - sizeof buf)) {
250 strcpy(&fullinfo[fullinfo_len], buf);
251 fullinfo_len += strlen(buf);
255 safestrncpy(briefinfo, fullinfo, sizeof briefinfo);
256 strcpy(&briefinfo[50], "...");
258 wprintf("<div class=\"infos\" "
259 "onclick=\"javascript:Effect.Appear('room_infos', { duration: 0.5 });\" "
263 wprintf("</div><div id=\"room_infos\" style=\"display:none;\">");
264 wprintf("<img class=\"close_infos\" "
265 "onclick=\"javascript:Effect.Fade('room_infos', { duration: 0.5 });\" "
266 "src=\"static/closewindow.gif\" alt=\"%s\" width=\"16\" height=\"16\">",
281 * Display room banner icon.
282 * The server doesn't actually need the room name, but we supply it in
283 * order to keep the browser from using a cached icon from another room.
285 void embed_room_graphic(StrBuf *Target, WCTemplputParams *TP)
289 serv_puts("OIMG _roompic_");
290 serv_getln(buf, sizeof buf);
292 wprintf("<img height=\"64px\" src=\"image?name=_roompic_&room=");
293 urlescputs(ChrPtr(WC->wc_roomname));
296 serv_getln(buf, sizeof buf);
298 else if (WC->wc_view == VIEW_ADDRESSBOOK) {
299 wprintf("<img class=\"roompic\" alt=\"\" src=\""
300 "static/viewcontacts_48x.gif"
304 else if ( (WC->wc_view == VIEW_CALENDAR) || (WC->wc_view == VIEW_CALBRIEF) ) {
305 wprintf("<img class=\"roompic\" alt=\"\" src=\""
306 "static/calarea_48x.gif"
307 "\" width=\"48\" height=\"48\">"
310 else if (WC->wc_view == VIEW_TASKS) {
311 wprintf("<img class=\"roompic\" alt=\"\" src=\""
312 "static/taskmanag_48x.gif"
313 "\" width=\"48\" height=\"48\">"
316 else if (WC->wc_view == VIEW_NOTES) {
317 wprintf("<img class=\"roompic\" alt=\"\" src=\""
318 "static/storenotes_48x.gif"
319 "\" width=\"48\" height=\"48\">"
322 else if (WC->wc_view == VIEW_MAILBOX) {
323 wprintf("<img class=\"roompic\" alt=\"\" src=\""
324 "static/privatemess_48x.gif"
325 "\" width=\"48\" height=\"48\">"
329 wprintf("<img class=\"roompic\" alt=\"\" src=\""
330 "static/chatrooms_48x.gif"
331 "\" width=\"48\" height=\"48\">"
340 * Display the current view and offer an option to change it
342 void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
346 wprintf("<form name=\"viewomatic\" action=\"changeview\">\n");
347 wprintf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
348 wprintf("<label for=\"view_name\">");
349 wprintf(_("View as:"));
351 "<select name=\"newview\" size=\"1\" "
352 "id=\"view_name\" class=\"selectbox\" "
353 "OnChange=\"location.href=viewomatic.newview.options"
354 "[selectedIndex].value\">\n");
356 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
358 * Only offer the views that make sense, given the default
359 * view for the room. For example, don't offer a Calendar
360 * view in a non-Calendar room.
364 || (i == WC->wc_default_view) /* default */
365 || ( (i == 0) && (WC->wc_default_view == 1) ) /* mail or bulletin */
366 || ( (i == 1) && (WC->wc_default_view == 0) ) /* mail or bulletin */
367 /* || ( (i == 7) && (WC->wc_default_view == 3) ) (calendar list temporarily disabled) */
370 wprintf("<option %s value=\"changeview?view=%d\">",
371 ((i == WC->wc_view) ? "selected" : ""),
373 escputs(viewdefs[i]);
374 wprintf("</option>\n");
377 wprintf("</select></div></form>\n");
382 * Display a search box
384 void embed_search_o_matic(StrBuf *Target, WCTemplputParams *TP)
386 wprintf("<form name=\"searchomatic\" action=\"do_search\">\n");
387 wprintf("<div style=\"display: inline;\"><input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
388 wprintf("<label for=\"srchquery\">");
389 wprintf(_("Search: "));
390 wprintf("</label><input ");
391 wprintf("%s", WC->serv_info->serv_fulltext_enabled ? "" : "disabled ");
392 wprintf("type=\"text\" name=\"query\" id=\"srchquery\" size=\"15\" maxlength=\"128\" class=\"inputbox\">\n"
394 wprintf("</div></form>\n");
399 * Embed the room banner
401 * got The information returned from a GOTO server command
402 * navbar_style Determines which navigation buttons to display
406 void embed_room_banner(char *got, int navbar_style) {
410 char with_files[256];
414 * We need to have the information returned by a GOTO server command.
415 * If it isn't supplied, we fake it by issuing our own GOTO.
418 memset(buf, '0', 20);
420 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
421 serv_getln(buf, sizeof buf);
425 /* The browser needs some information for its own use */
426 wprintf("<script type=\"text/javascript\"> \n"
427 " room_is_trash = %d; \n"
433 * If the user happens to select the "make this my start page" link,
434 * we want it to remember the URL as a "/dotskip" one instead of
435 * a "skip" or "gotonext" or something like that.
437 if (WCC->Hdr->this_page == NULL) {
438 WCC->Hdr->this_page = NewStrBuf();
440 StrBufPrintf(WCC->Hdr->this_page,
442 ChrPtr(WC->wc_roomname)
445 /* Check for new mail. */
446 WC->new_mail = extract_int(&got[4], 9);
447 WC->wc_view = extract_int(&got[4], 11);
449 /* Is this a directory room and does it contain files and how many? */
450 if ((WC->room_flags & QR_DIRECTORY) && (WC->room_flags & QR_VISDIR))
453 serv_getln(buf2, sizeof buf2);
454 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
456 snprintf (with_files, sizeof with_files,
457 "; <a href=\"do_template?template=files\"> %d %s </a>",
459 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
462 strcpy (with_files, "");
464 svprintf(HKEY("NUMMSGS"), WCS_STRING,
465 _("%d new of %d messages%s"),
466 extract_int(&got[4], 1),
467 extract_int(&got[4], 2),
470 svcallback("ROOMPIC", embed_room_graphic);
471 svcallback("ROOMINFO", readinfo);
472 svcallback("VIEWOMATIC", embed_view_o_matic);
473 svcallback("SEARCHOMATIC", embed_search_o_matic);
474 svcallback("START", offer_start_page);
476 do_template("roombanner", NULL);
477 /* roombanner contains this for mobile */
478 if (navbar_style != navbar_none && !WC->is_mobile) {
480 wprintf("<div id=\"navbar\"><ul>");
482 if (navbar_style == navbar_default) wprintf(
483 "<li class=\"ungoto\">"
484 "<a href=\"ungoto\">"
485 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
486 "<span class=\"navbar_link\">%s</span></A>"
487 "</li>\n", _("Ungoto")
490 if ( (navbar_style == navbar_default) && (WC->wc_view == VIEW_BBS) ) {
492 "<li class=\"newmess\">"
493 "<a href=\"readnew\">"
494 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
495 "<span class=\"navbar_link\">%s</span></A>"
496 "</li>\n", _("Read new messages")
500 if (navbar_style == navbar_default) {
501 switch(WC->wc_view) {
502 case VIEW_ADDRESSBOOK:
504 "<li class=\"viewcontacts\">"
505 "<a href=\"readfwd\">"
506 "<img src=\"static/viewcontacts_24x.gif\" "
507 "alt=\"\" width=\"24\" height=\"24\">"
508 "<span class=\"navbar_link\">"
510 "</span></a></li>\n", _("View contacts")
515 "<li class=\"staskday\">"
516 "<a href=\"readfwd?calview=day\">"
517 "<img src=\"static/taskday2_24x.gif\" "
518 "alt=\"\" width=\"24\" height=\"24\">"
519 "<span class=\"navbar_link\">"
521 "</span></a></li>\n", _("Day view")
524 "<li class=\"monthview\">"
525 "<a href=\"readfwd?calview=month\">"
526 "<img src=\"static/monthview2_24x.gif\" "
527 "alt=\"\" width=\"24\" height=\"24\">"
528 "<span class=\"navbar_link\">"
530 "</span></a></li>\n", _("Month view")
535 "<li class=\"monthview\">"
536 "<a href=\"readfwd?calview=month\">"
537 "<img src=\"static/monthview2_24x.gif\" "
538 "alt=\"\" width=\"24\" height=\"24\">"
539 "<span class=\"navbar_link\">"
541 "</span></a></li>\n", _("Calendar list")
546 "<li class=\"taskmanag\">"
547 "<a href=\"readfwd\">"
548 "<img src=\"static/taskmanag_24x.gif\" "
549 "alt=\"\" width=\"24\" height=\"24\">"
550 "<span class=\"navbar_link\">"
552 "</span></a></li>\n", _("View tasks")
557 "<li class=\"viewnotes\">"
558 "<a href=\"readfwd\">"
559 "<img src=\"static/viewnotes_24x.gif\" "
560 "alt=\"\" width=\"24\" height=\"24\">"
561 "<span class=\"navbar_link\">"
563 "</span></a></li>\n", _("View notes")
568 "<li class=\"readallmess\">"
569 "<a id=\"m_refresh\" href=\"readfwd\">"
570 "<img src=\"static/readallmess3_24x.gif\" "
571 "alt=\"\" width=\"24\" height=\"24\">"
572 "<span class=\"navbar_link\">"
574 "</span></a></li>\n", _("Refresh message list")
579 "<li class=\"readallmess\">"
580 "<a href=\"readfwd\">"
581 "<img src=\"static/readallmess3_24x.gif\" "
582 "alt=\"\" width=\"24\" height=\"24\">"
583 "<span class=\"navbar_link\">"
585 "</span></a></li>\n", _("Wiki home")
590 "<li class=\"readallmess\">"
591 "<a href=\"readfwd\">"
592 "<img src=\"static/readallmess3_24x.gif\" "
593 "alt=\"\" width=\"24\" height=\"24\">"
594 "<span class=\"navbar_link\">"
596 "</span></a></li>\n", _("Read all messages")
602 if (navbar_style == navbar_default) {
603 switch(WC->wc_view) {
604 case VIEW_ADDRESSBOOK:
606 "<li class=\"addnewcontact\">"
607 "<a href=\"display_enter\">"
608 "<img src=\"static/addnewcontact_24x.gif\" "
609 "alt=\"\" width=\"24\" height=\"24\">"
610 "<span class=\"navbar_link\">"
612 "</span></a></li>\n", _("Add new contact")
617 wprintf("<li class=\"addevent\"><a href=\"display_enter");
618 if (havebstr("year" )) wprintf("?year=%s", bstr("year"));
619 if (havebstr("month")) wprintf("?month=%s", bstr("month"));
620 if (havebstr("day" )) wprintf("?day=%s", bstr("day"));
622 "<img src=\"static/addevent_24x.gif\" "
623 "alt=\"\" width=\"24\" height=\"24\">"
624 "<span class=\"navbar_link\">"
626 "</span></a></li>\n", _("Add new event")
631 "<li class=\"newmess\">"
632 "<a href=\"display_enter\">"
633 "<img src=\"static/newmess3_24x.gif\" "
634 "alt=\"\" width=\"24\" height=\"24\">"
635 "<span class=\"navbar_link\">"
637 "</span></a></li>\n", _("Add new task")
642 "<li class=\"enternewnote\">"
643 "<a href=\"add_new_note\">"
644 "<img src=\"static/enternewnote_24x.gif\" "
645 "alt=\"\" width=\"24\" height=\"24\">"
646 "<span class=\"navbar_link\">"
648 "</span></a></li>\n", _("Add new note")
652 safestrncpy(buf, bstr("page"), sizeof buf);
655 "<li class=\"newmess\">"
656 "<a href=\"display_enter?wikipage=%s\">"
657 "<img src=\"static/newmess3_24x.gif\" "
658 "alt=\"\" width=\"24\" height=\"24\">"
659 "<span class=\"navbar_link\">"
661 "</span></a></li>\n", buf, _("Edit this page")
666 "<li class=\"newmess\">"
667 "<a href=\"display_enter\">"
668 "<img src=\"static/newmess3_24x.gif\" "
669 "alt=\"\" width=\"24\" height=\"24\">"
670 "<span class=\"navbar_link\">"
672 "</span></a></li>\n", _("Write mail")
675 "<li class=\"newmess\">"
676 "<a href=\"javascript:deleteAllSelectedMessages();\">"
677 "<img src=\"static/delete.gif\" "
678 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
680 "</span></a></li>\n", _("Delete")
685 "<li class=\"newmess\">"
686 "<a href=\"display_enter\">"
687 "<img src=\"static/newmess3_24x.gif\" "
688 "alt=\"\" width=\"24\" height=\"24\">"
689 "<span class=\"navbar_link\">"
691 "</span></a></li>\n", _("Enter a message")
697 if (navbar_style == navbar_default) wprintf(
698 "<li class=\"skipthisroom\">"
701 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
702 "width=\"24\" height=\"24\">"
703 "<span class=\"navbar_link\">%s</span></a>"
705 _("Leave all messages marked as unread, go to next room with unread messages"),
709 if (navbar_style == navbar_default) wprintf(
710 "<li class=\"markngo\">"
711 "<a href=\"gotonext\" "
713 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
714 "width=\"24\" height=\"24\">"
715 "<span class=\"navbar_link\">%s</span></a>"
717 _("Mark all messages as read, go to next room with unread messages"),
721 wprintf("</ul></div>\n");
728 * back end routine to take the session to a new room
730 long gotoroom(const StrBuf *gname)
733 static long ls = (-1L);
736 /* store ungoto information */
737 strcpy(WC->ugname, ChrPtr(WC->wc_roomname));
741 /* move to the new room */
742 serv_printf("GOTO %s", ChrPtr(gname));
743 StrBuf_ServGetln(Buf);
744 if (GetServerStatus(Buf, &err) != 2) {
745 serv_puts("GOTO _BASEROOM_");
746 StrBuf_ServGetln(Buf);
748 * well, we know that this is the fallback case,
749 * but we're interested that the first command
750 * didn't work out in first place.
752 if (GetServerStatus(Buf, NULL) != 2) {
758 if (WC->wc_roomname == NULL)
759 WC->wc_roomname = NewStrBuf();
761 FlushStrBuf(WC->wc_roomname);
763 StrBufExtract_token(WC->wc_roomname, Buf, 0, '|');
764 StrBufCutLeft(WC->wc_roomname, 4);
765 WC->room_flags = StrBufExtract_int(Buf, 4, '|');
766 /* highest_msg_read = extract_int(&buf[4],6);
767 maxmsgnum = extract_int(&buf[4],5);
769 WC->is_mailbox = StrBufExtract_int(Buf, 7, '|');
770 ls = StrBufExtract_long(Buf, 6, '|');
771 WC->wc_floor = StrBufExtract_int(Buf, 10, '|');
772 WC->wc_view = StrBufExtract_int(Buf, 11, '|');
773 WC->wc_default_view = StrBufExtract_int(Buf, 12, '|');
774 WC->wc_is_trash = StrBufExtract_int(Buf, 13, '|');
775 WC->room_flags2 = StrBufExtract_int(Buf, 14, '|');
778 WC->is_room_aide = WC->is_aide;
780 WC->is_room_aide = (char) StrBufExtract_int(Buf, 8, '|');
782 remove_march(WC->wc_roomname);
783 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
794 void smart_goto(const StrBuf *next_room) {
802 * mark all messages in current room as having been read
804 void slrp_highest(void)
808 serv_puts("SLRP HIGHEST");
809 serv_getln(buf, sizeof buf);
813 typedef struct __room_states {
828 * Set/clear/read the "self-service list subscribe" flag for a room
830 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
831 * returns the new value.
834 int self_service(int newval) {
835 int current_value = 0;
841 int flags, floor, order, view, flags2;
844 serv_getln(buf, sizeof buf);
845 if (buf[0] != '2') return(0);
847 extract_token(name, &buf[4], 0, '|', sizeof name);
848 extract_token(password, &buf[4], 1, '|', sizeof password);
849 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
850 flags = extract_int(&buf[4], 3);
851 floor = extract_int(&buf[4], 4);
852 order = extract_int(&buf[4], 5);
853 view = extract_int(&buf[4], 6);
854 flags2 = extract_int(&buf[4], 7);
856 if (flags2 & QR2_SELFLIST) {
864 flags2 = flags2 | QR2_SELFLIST;
866 else if (newval == 0) {
867 flags2 = flags2 & ~QR2_SELFLIST;
870 return(current_value);
873 if (newval != current_value) {
874 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
875 name, password, dirname, flags,
876 floor, order, view, flags2);
877 serv_getln(buf, sizeof buf);
884 int is_selflist(room_states *RoomFlags)
886 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
889 int is_publiclist(room_states *RoomFlags)
891 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
894 int is_moderatedlist(room_states *RoomFlags)
896 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
900 * Set/clear/read the "self-service list subscribe" flag for a room
902 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
903 * returns the new value.
906 int get_roomflags(room_states *RoomOps)
911 serv_getln(buf, sizeof buf);
912 if (buf[0] != '2') return(0);
914 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
915 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
916 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
917 RoomOps->flags = extract_int(&buf[4], 3);
918 RoomOps->floor = extract_int(&buf[4], 4);
919 RoomOps->order = extract_int(&buf[4], 5);
920 RoomOps->view = extract_int(&buf[4], 6);
921 RoomOps->flags2 = extract_int(&buf[4], 7);
925 int set_roomflags(room_states *RoomOps)
929 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
938 serv_getln(buf, sizeof buf);
948 * display the form for editing a room
950 void display_editroom(void)
956 char remote_room[128];
959 char er_password[10];
961 char er_roomaide[26];
968 char *not_shared_with;
978 if (IsEmptyStr(tab)) tab = "admin";
983 output_headers(1, 1, 1, 0, 0, 0);
985 wprintf("<div class=\"fix_scrollbar_bug\">");
989 /* print the tabbed dialog */
990 wprintf("<div align=\"center\">");
991 wprintf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
992 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
995 wprintf("<td class=\"");
996 if (!strcmp(tab, "admin")) {
997 wprintf(" tab_cell_label\">");
998 wprintf(_("Administration"));
1001 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1002 wprintf(_("Administration"));
1006 wprintf("<td> </td>\n");
1008 if ( (WC->axlevel >= 6) || (WC->is_room_aide) ) {
1010 wprintf("<td class=\"");
1011 if (!strcmp(tab, "config")) {
1012 wprintf(" tab_cell_label\">");
1013 wprintf(_("Configuration"));
1016 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1017 wprintf(_("Configuration"));
1021 wprintf("<td> </td>\n");
1023 wprintf("<td class=\"");
1024 if (!strcmp(tab, "expire")) {
1025 wprintf(" tab_cell_label\">");
1026 wprintf(_("Message expire policy"));
1029 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1030 wprintf(_("Message expire policy"));
1034 wprintf("<td> </td>\n");
1036 wprintf("<td class=\"");
1037 if (!strcmp(tab, "access")) {
1038 wprintf(" tab_cell_label\">");
1039 wprintf(_("Access controls"));
1042 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1043 wprintf(_("Access controls"));
1047 wprintf("<td> </td>\n");
1049 wprintf("<td class=\"");
1050 if (!strcmp(tab, "sharing")) {
1051 wprintf(" tab_cell_label\">");
1052 wprintf(_("Sharing"));
1055 wprintf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1056 wprintf(_("Sharing"));
1060 wprintf("<td> </td>\n");
1062 wprintf("<td class=\"");
1063 if (!strcmp(tab, "listserv")) {
1064 wprintf(" tab_cell_label\">");
1065 wprintf(_("Mailing list service"));
1068 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1069 wprintf(_("Mailing list service"));
1073 wprintf("<td> </td>\n");
1077 wprintf("<td class=\"");
1078 if (!strcmp(tab, "feeds")) {
1079 wprintf(" tab_cell_label\">");
1080 wprintf(_("Remote retrieval"));
1083 wprintf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1084 wprintf(_("Remote retrieval"));
1088 wprintf("<td> </td>\n");
1090 wprintf("</tr></table>\n");
1091 wprintf("</div>\n");
1092 /* end tabbed dialog */
1094 wprintf("<script type=\"text/javascript\">"
1095 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1099 /* begin content of whatever tab is open now */
1101 if (!strcmp(tab, "admin")) {
1102 wprintf("<div class=\"tabcontent\">");
1104 "<li><a href=\"delete_room\" "
1105 "onClick=\"return confirm('");
1106 wprintf(_("Are you sure you want to delete this room?"));
1107 wprintf("');\">\n");
1108 wprintf(_("Delete this room"));
1110 "<li><a href=\"display_editroompic?which_room=");
1111 urlescputs(ChrPtr(WC->wc_roomname));
1113 wprintf(_("Set or change the icon for this room's banner"));
1115 "<li><a href=\"display_editinfo\">\n");
1116 wprintf(_("Edit this room's Info file"));
1122 if (!strcmp(tab, "config")) {
1123 wprintf("<div class=\"tabcontent\">");
1125 serv_getln(buf, sizeof buf);
1127 if (!strncmp(buf, "550", 3)) {
1128 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1129 _("Higher access is required to access this function.")
1132 else if (buf[0] != '2') {
1133 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1136 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1137 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1138 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1139 er_flags = extract_int(&buf[4], 3);
1140 er_floor = extract_int(&buf[4], 4);
1141 er_flags2 = extract_int(&buf[4], 7);
1143 wprintf("<form method=\"POST\" action=\"editroom\">\n");
1144 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1146 wprintf("<ul><li>");
1147 wprintf(_("Name of room: "));
1148 wprintf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"%d\">\n",
1154 wprintf(_("Resides on floor: "));
1155 wprintf("<select NAME=\"er_floor\" SIZE=\"1\"");
1156 if (er_flags & QR_MAILBOX)
1157 wprintf("disabled >\n");
1158 for (i = 0; i < 128; ++i)
1159 if (!IsEmptyStr(floorlist[i])) {
1160 wprintf("<OPTION ");
1162 wprintf("SELECTED ");
1163 wprintf("VALUE=\"%d\">", i);
1164 escputs(floorlist[i]);
1165 wprintf("</OPTION>\n");
1167 wprintf("</select>\n");
1170 wprintf(_("Type of room:"));
1173 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1174 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1175 wprintf("CHECKED ");
1176 wprintf("OnChange=\""
1177 " if (this.form.type[0].checked == true) { "
1178 " this.form.er_floor.disabled = false; "
1181 wprintf(_("Public (automatically appears to everyone)"));
1184 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1185 if ((er_flags & QR_PRIVATE) &&
1186 (er_flags & QR_GUESSNAME))
1187 wprintf("CHECKED ");
1188 wprintf(" OnChange=\""
1189 " if (this.form.type[1].checked == true) { "
1190 " this.form.er_floor.disabled = false; "
1193 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
1195 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1196 if ((er_flags & QR_PRIVATE) &&
1197 (er_flags & QR_PASSWORDED))
1198 wprintf("CHECKED ");
1199 wprintf(" OnChange=\""
1200 " if (this.form.type[2].checked == true) { "
1201 " this.form.er_floor.disabled = false; "
1204 wprintf(_("Private - require password: "));
1205 wprintf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1208 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1209 if ((er_flags & QR_PRIVATE)
1210 && ((er_flags & QR_GUESSNAME) == 0)
1211 && ((er_flags & QR_PASSWORDED) == 0))
1212 wprintf("CHECKED ");
1213 wprintf(" OnChange=\""
1214 " if (this.form.type[3].checked == true) { "
1215 " this.form.er_floor.disabled = false; "
1218 wprintf(_("Private - invitation only"));
1220 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1221 if (er_flags & QR_MAILBOX)
1222 wprintf("CHECKED ");
1223 wprintf (" OnChange=\""
1224 " if (this.form.type[4].checked == true) { "
1225 " this.form.er_floor.disabled = true; "
1228 wprintf(_("Personal (mailbox for you only)"));
1230 wprintf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1232 wprintf(_("If private, cause current users to forget room"));
1234 wprintf("\n</ul>\n");
1236 wprintf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1237 if (er_flags & QR_PREFONLY)
1238 wprintf("CHECKED ");
1240 wprintf(_("Preferred users only"));
1242 wprintf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1243 if (er_flags & QR_READONLY)
1244 wprintf("CHECKED ");
1246 wprintf(_("Read-only room"));
1248 wprintf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1249 if (er_flags2 & QR2_COLLABDEL)
1250 wprintf("CHECKED ");
1252 wprintf(_("All users allowed to post may also delete messages"));
1254 /** directory stuff */
1255 wprintf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1256 if (er_flags & QR_DIRECTORY)
1257 wprintf("CHECKED ");
1259 wprintf(_("File directory room"));
1261 wprintf("\n<ul><li>");
1262 wprintf(_("Directory name: "));
1263 wprintf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1266 wprintf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1267 if (er_flags & QR_UPLOAD)
1268 wprintf("CHECKED ");
1270 wprintf(_("Uploading allowed"));
1272 wprintf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1273 if (er_flags & QR_DOWNLOAD)
1274 wprintf("CHECKED ");
1276 wprintf(_("Downloading allowed"));
1278 wprintf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1279 if (er_flags & QR_VISDIR)
1280 wprintf("CHECKED ");
1282 wprintf(_("Visible directory"));
1285 /** end of directory stuff */
1287 wprintf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1288 if (er_flags & QR_NETWORK)
1289 wprintf("CHECKED ");
1291 wprintf(_("Network shared room"));
1293 wprintf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1294 if (er_flags & QR_PERMANENT)
1295 wprintf("CHECKED ");
1297 wprintf(_("Permanent (does not auto-purge)"));
1299 wprintf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1300 if (er_flags2 & QR2_SUBJECTREQ)
1301 wprintf("CHECKED ");
1303 wprintf(_("Subject Required (Force users to specify a message subject)"));
1305 /** start of anon options */
1308 wprintf(_("Anonymous messages"));
1311 wprintf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1312 if (((er_flags & QR_ANONONLY) == 0)
1313 && ((er_flags & QR_ANONOPT) == 0))
1314 wprintf("CHECKED ");
1316 wprintf(_("No anonymous messages"));
1318 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1319 if (er_flags & QR_ANONONLY)
1320 wprintf("CHECKED ");
1322 wprintf(_("All messages are anonymous"));
1324 wprintf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1325 if (er_flags & QR_ANONOPT)
1326 wprintf("CHECKED ");
1328 wprintf(_("Prompt user when entering messages"));
1331 /* end of anon options */
1334 wprintf(_("Room aide: "));
1336 serv_getln(buf, sizeof buf);
1337 if (buf[0] != '2') {
1338 wprintf("<em>%s</em>\n", &buf[4]);
1340 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1341 wprintf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1344 wprintf("</ul><CENTER>\n");
1345 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1346 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1348 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1358 /* Sharing the room with other Citadel nodes... */
1359 if (!strcmp(tab, "sharing")) {
1360 wprintf("<div class=\"tabcontent\">");
1362 shared_with = strdup("");
1363 not_shared_with = strdup("");
1365 /** Learn the current configuration */
1366 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1367 serv_getln(buf, sizeof buf);
1368 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1369 extract_token(node, buf, 0, '|', sizeof node);
1370 not_shared_with = realloc(not_shared_with,
1371 strlen(not_shared_with) + 32);
1372 strcat(not_shared_with, node);
1373 strcat(not_shared_with, "\n");
1377 serv_getln(buf, sizeof buf);
1378 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1379 extract_token(cmd, buf, 0, '|', sizeof cmd);
1380 extract_token(node, buf, 1, '|', sizeof node);
1381 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1382 if (!strcasecmp(cmd, "ignet_push_share")) {
1383 shared_with = realloc(shared_with,
1384 strlen(shared_with) + 32);
1385 strcat(shared_with, node);
1386 if (!IsEmptyStr(remote_room)) {
1387 strcat(shared_with, "|");
1388 strcat(shared_with, remote_room);
1390 strcat(shared_with, "\n");
1394 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1395 extract_token(buf, shared_with, i, '\n', sizeof buf);
1396 extract_token(node, buf, 0, '|', sizeof node);
1397 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1398 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1399 if (!strcasecmp(node, cmd)) {
1400 remove_token(not_shared_with, j, '\n');
1405 /* Display the stuff */
1406 wprintf("<CENTER><br />"
1407 "<table border=1 cellpadding=5><tr>"
1409 wprintf(_("Shared with"));
1410 wprintf("</I></B></td>"
1412 wprintf(_("Not shared with"));
1413 wprintf("</I></B></td></tr>\n"
1414 "<tr><td VALIGN=TOP>\n");
1416 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1417 wprintf(_("Remote node name"));
1418 wprintf("</td><td>");
1419 wprintf(_("Remote room name"));
1420 wprintf("</td><td>");
1421 wprintf(_("Actions"));
1422 wprintf("</td></tr>\n");
1424 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1425 extract_token(buf, shared_with, i, '\n', sizeof buf);
1426 extract_token(node, buf, 0, '|', sizeof node);
1427 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1428 if (!IsEmptyStr(node)) {
1429 wprintf("<form method=\"POST\" action=\"netedit\">");
1430 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1431 wprintf("<tr><td>%s</td>\n", node);
1434 if (!IsEmptyStr(remote_room)) {
1435 escputs(remote_room);
1441 wprintf("<input type=\"hidden\" NAME=\"line\" "
1442 "VALUE=\"ignet_push_share|");
1444 if (!IsEmptyStr(remote_room)) {
1446 urlescputs(remote_room);
1449 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1450 wprintf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1451 wprintf("<input type=\"submit\" "
1452 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1453 wprintf("</td></tr></form>\n");
1457 wprintf("</table>\n");
1458 wprintf("</td><td VALIGN=TOP>\n");
1459 wprintf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1460 wprintf(_("Remote node name"));
1461 wprintf("</td><td>");
1462 wprintf(_("Remote room name"));
1463 wprintf("</td><td>");
1464 wprintf(_("Actions"));
1465 wprintf("</td></tr>\n");
1467 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1468 extract_token(node, not_shared_with, i, '\n', sizeof node);
1469 if (!IsEmptyStr(node)) {
1470 wprintf("<form method=\"POST\" action=\"netedit\">");
1471 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1472 wprintf("<tr><td>");
1475 "<input type=\"INPUT\" "
1479 wprintf("<input type=\"hidden\" "
1481 "VALUE=\"ignet_push_share|");
1484 wprintf("<input type=\"hidden\" NAME=\"tab\" "
1485 "VALUE=\"sharing\">\n");
1486 wprintf("<input type=\"hidden\" NAME=\"cmd\" "
1487 "VALUE=\"add\">\n");
1488 wprintf("<input type=\"submit\" "
1489 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1490 wprintf("</td></tr></form>\n");
1494 wprintf("</table>\n");
1495 wprintf("</td></tr>"
1496 "</table></CENTER><br />\n"
1497 "<I><B>%s</B><ul><li>", _("Notes:"));
1498 wprintf(_("When sharing a room, "
1499 "it must be shared from both ends. Adding a node to "
1500 "the 'shared' list sends messages out, but in order to"
1501 " receive messages, the other nodes must be configured"
1502 " to send messages out to your system as well. "
1503 "<li>If the remote room name is blank, it is assumed "
1504 "that the room name is identical on the remote node."
1505 "<li>If the remote room name is different, the remote "
1506 "node must also configure the name of the room here."
1513 /* Mailing list management */
1514 if (!strcmp(tab, "listserv")) {
1515 room_states RoomFlags;
1516 wprintf("<div class=\"tabcontent\">");
1518 wprintf("<br /><center>"
1519 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1520 "<tr><td VALIGN=TOP>");
1522 wprintf(_("<i>The contents of this room are being "
1523 "mailed <b>as individual messages</b> "
1524 "to the following list recipients:"
1525 "</i><br /><br />\n"));
1528 serv_getln(buf, sizeof buf);
1529 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1530 extract_token(cmd, buf, 0, '|', sizeof cmd);
1531 if (!strcasecmp(cmd, "listrecp")) {
1532 extract_token(recp, buf, 1, '|', sizeof recp);
1535 wprintf(" <a href=\"netedit?cmd=remove&tab=listserv&line=listrecp|");
1538 wprintf(_("(remove)"));
1539 wprintf("</A><br />");
1542 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1543 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1544 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1545 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1546 wprintf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1547 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1548 wprintf("</form>\n");
1550 wprintf("</td><td VALIGN=TOP>\n");
1552 wprintf(_("<i>The contents of this room are being "
1553 "mailed <b>in digest form</b> "
1554 "to the following list recipients:"
1555 "</i><br /><br />\n"));
1558 serv_getln(buf, sizeof buf);
1559 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1560 extract_token(cmd, buf, 0, '|', sizeof cmd);
1561 if (!strcasecmp(cmd, "digestrecp")) {
1562 extract_token(recp, buf, 1, '|', sizeof recp);
1565 wprintf(" <a href=\"netedit?cmd=remove&tab=listserv&line="
1569 wprintf(_("(remove)"));
1570 wprintf("</A><br />");
1573 wprintf("<br /><form method=\"POST\" action=\"netedit\">\n"
1574 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1575 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1576 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1577 wprintf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1578 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1579 wprintf("</form>\n");
1581 wprintf("</td></tr></table>\n");
1583 /** Pop open an address book -- begin **/
1584 wprintf("<div align=right>"
1585 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1587 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1592 _("Add recipients from Contacts or other address books"),
1593 _("Add recipients from Contacts or other address books")
1595 /* Pop open an address book -- end **/
1597 wprintf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1599 get_roomflags (&RoomFlags);
1601 /* Self Service subscription? */
1602 wprintf("<table><tr><td>\n");
1603 wprintf(_("Allow self-service subscribe/unsubscribe requests."));
1604 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1605 " <tr><td colspan=\"2\">\n",
1606 (is_selflist(&RoomFlags))?"checked":"");
1607 wprintf(_("The URL for subscribe/unsubscribe is: "));
1608 wprintf("<TT>%s://%s/listsub</TT></td></tr>\n",
1609 (is_https ? "https" : "http"),
1610 ChrPtr(WC->Hdr->HR.http_host));
1611 /* Public posting? */
1612 wprintf("<tr><td>");
1613 wprintf(_("Allow non-subscribers to mail to this room."));
1614 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1615 (is_publiclist(&RoomFlags))?"checked":"");
1617 /* Moderated List? */
1618 wprintf("<tr><td>");
1619 wprintf(_("Room post publication needs Aide permission."));
1620 wprintf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1621 (is_moderatedlist(&RoomFlags))?"checked":"");
1624 wprintf("<tr><td colspan=\"2\" align=\"center\">"
1625 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1626 wprintf("</table></form>");
1629 wprintf("</CENTER>\n");
1634 /* Configuration of The Dreaded Auto-Purger */
1635 if (!strcmp(tab, "expire")) {
1636 wprintf("<div class=\"tabcontent\">");
1638 serv_puts("GPEX room");
1639 serv_getln(buf, sizeof buf);
1640 if (!strncmp(buf, "550", 3)) {
1641 wprintf("<br><br><div align=center>%s</div><br><br>\n",
1642 _("Higher access is required to access this function.")
1645 else if (buf[0] != '2') {
1646 wprintf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1649 roompolicy = extract_int(&buf[4], 0);
1650 roomvalue = extract_int(&buf[4], 1);
1652 serv_puts("GPEX floor");
1653 serv_getln(buf, sizeof buf);
1654 if (buf[0] == '2') {
1655 floorpolicy = extract_int(&buf[4], 0);
1656 floorvalue = extract_int(&buf[4], 1);
1659 wprintf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1660 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1661 wprintf("<table border=0 cellspacing=5>\n");
1662 wprintf("<tr><td>");
1663 wprintf(_("Message expire policy for this room"));
1665 escputs(ChrPtr(WC->wc_roomname));
1666 wprintf(")</td><td>");
1667 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1668 ((roompolicy == 0) ? "CHECKED" : "") );
1669 wprintf(_("Use the default policy for this floor"));
1670 wprintf("<br />\n");
1671 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1672 ((roompolicy == 1) ? "CHECKED" : "") );
1673 wprintf(_("Never automatically expire messages"));
1674 wprintf("<br />\n");
1675 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1676 ((roompolicy == 2) ? "CHECKED" : "") );
1677 wprintf(_("Expire by message count"));
1678 wprintf("<br />\n");
1679 wprintf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1680 ((roompolicy == 3) ? "CHECKED" : "") );
1681 wprintf(_("Expire by message age"));
1683 wprintf(_("Number of messages or days: "));
1684 wprintf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1685 wprintf("</td></tr>\n");
1687 if (WC->axlevel >= 6) {
1688 wprintf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1689 wprintf("<tr><td>");
1690 wprintf(_("Message expire policy for this floor"));
1692 escputs(floorlist[WC->wc_floor]);
1693 wprintf(")</td><td>");
1694 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1695 ((floorpolicy == 0) ? "CHECKED" : "") );
1696 wprintf(_("Use the system default"));
1697 wprintf("<br />\n");
1698 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1699 ((floorpolicy == 1) ? "CHECKED" : "") );
1700 wprintf(_("Never automatically expire messages"));
1701 wprintf("<br />\n");
1702 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1703 ((floorpolicy == 2) ? "CHECKED" : "") );
1704 wprintf(_("Expire by message count"));
1705 wprintf("<br />\n");
1706 wprintf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1707 ((floorpolicy == 3) ? "CHECKED" : "") );
1708 wprintf(_("Expire by message age"));
1710 wprintf(_("Number of messages or days: "));
1711 wprintf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1715 wprintf("<CENTER>\n");
1716 wprintf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1717 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1719 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1720 wprintf("</CENTER></td><tr>\n");
1722 wprintf("</table>\n"
1723 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1731 /* Access controls */
1732 if (!strcmp(tab, "access")) {
1733 wprintf("<div class=\"tabcontent\">");
1738 /* Fetch messages from remote locations */
1739 if (!strcmp(tab, "feeds")) {
1740 wprintf("<div class=\"tabcontent\">");
1743 wprintf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1744 wprintf("</i><br />\n");
1746 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1747 "<tr class=\"even\"><th>");
1748 wprintf(_("Remote host"));
1749 wprintf("</th><th>");
1750 wprintf(_("User name"));
1751 wprintf("</th><th>");
1752 wprintf(_("Password"));
1753 wprintf("</th><th>");
1754 wprintf(_("Keep messages on server?"));
1755 wprintf("</th><th>");
1756 wprintf(_("Interval"));
1757 wprintf("</th><th> </th></tr>");
1760 serv_getln(buf, sizeof buf);
1762 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1763 extract_token(cmd, buf, 0, '|', sizeof cmd);
1764 if (!strcasecmp(cmd, "pop3client")) {
1765 safestrncpy(recp, &buf[11], sizeof recp);
1768 wprintf("<tr class=\"%s\">",
1769 (bg ? "even" : "odd")
1773 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1778 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
1782 wprintf("<td>*****</td>"); /* Don't show the password */
1784 wprintf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
1786 wprintf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
1788 wprintf("<td class=\"button_link\">");
1789 wprintf(" <a href=\"netedit?cmd=remove&tab=feeds&line=pop3client|");
1792 wprintf(_("(remove)"));
1793 wprintf("</a></td>");
1799 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1801 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1802 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
1803 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1805 wprintf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
1808 wprintf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
1811 wprintf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
1814 wprintf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
1817 wprintf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
1820 wprintf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1821 wprintf("</td></tr>");
1822 wprintf("</form></table>\n");
1827 wprintf(_("Fetch the following RSS feeds and store them in this room:"));
1828 wprintf("</i><br />\n");
1830 wprintf("<table class=\"altern\" border=0 cellpadding=5>"
1831 "<tr class=\"even\"><th>");
1832 wprintf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
1833 wprintf(_("Feed URL"));
1834 wprintf("</th><th>");
1835 wprintf("</th></tr>");
1838 serv_getln(buf, sizeof buf);
1840 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1841 extract_token(cmd, buf, 0, '|', sizeof cmd);
1842 if (!strcasecmp(cmd, "rssclient")) {
1843 safestrncpy(recp, &buf[10], sizeof recp);
1846 wprintf("<tr class=\"%s\">",
1847 (bg ? "even" : "odd")
1851 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
1855 wprintf("<td class=\"button_link\">");
1856 wprintf(" <a href=\"netedit?cmd=remove&tab=feeds&line=rssclient|");
1859 wprintf(_("(remove)"));
1860 wprintf("</a></td>");
1866 wprintf("<form method=\"POST\" action=\"netedit\">\n"
1868 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
1869 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
1870 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1872 wprintf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
1873 "maxlength=\"256\" name=\"line_pop3host\">\n");
1876 wprintf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
1877 wprintf("</td></tr>");
1878 wprintf("</form></table>\n");
1884 /* end content of whatever tab is open now */
1885 wprintf("</div>\n");
1887 address_book_popup();
1893 * Toggle self-service list subscription
1895 void toggle_self_service(void) {
1896 room_states RoomFlags;
1898 get_roomflags (&RoomFlags);
1900 if (yesbstr("QR2_SelfList"))
1901 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
1903 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
1905 if (yesbstr("QR2_SMTP_PUBLIC"))
1906 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
1908 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
1910 if (yesbstr("QR2_Moderated"))
1911 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
1913 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
1914 if (yesbstr("QR2_SubsOnly"))
1915 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
1917 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
1919 set_roomflags (&RoomFlags);
1927 * save new parameters for a room
1934 StrBuf *er_password;
1936 StrBuf *er_roomaide;
1939 int er_listingorder;
1945 if (!havebstr("ok_button")) {
1946 strcpy(WC->ImportantMessage,
1947 _("Cancelled. Changes were not saved."));
1953 StrBuf_ServGetln(Buf);
1954 if (GetServerStatus(Buf, NULL) != 2) {
1955 StrBufCutLeft(Buf, 4);
1956 strcpy(WC->ImportantMessage, ChrPtr(Buf));
1962 er_name = NewStrBuf();
1963 er_password = NewStrBuf();
1964 er_dirname = NewStrBuf();
1965 er_roomaide = NewStrBuf();
1967 StrBufCutLeft(Buf, 4);
1968 StrBufExtract_token(er_name, Buf, 0, '|');
1969 StrBufExtract_token(er_password, Buf, 1, '|');
1970 StrBufExtract_token(er_dirname, Buf, 2, '|');
1971 er_flags = StrBufExtract_int(Buf, 3, '|');
1972 er_listingorder = StrBufExtract_int(Buf, 5, '|');
1973 er_defaultview = StrBufExtract_int(Buf, 6, '|');
1974 er_flags2 = StrBufExtract_int(Buf, 7, '|');
1976 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
1977 if (StrLength(er_roomaide) == 0) {
1979 StrBuf_ServGetln(Buf);
1980 if (GetServerStatus(Buf, NULL) != 2) {
1981 FlushStrBuf(er_roomaide);
1983 StrBufCutLeft(Buf, 4);
1984 StrBufExtract_token(er_roomaide, Buf, 0, '|');
1987 Ptr = sbstr("er_name");
1988 if (StrLength(Ptr) > 0) {
1989 FlushStrBuf(er_name);
1990 StrBufAppendBuf(er_name, Ptr, 0);
1993 Ptr = sbstr("er_password");
1994 if (StrLength(Ptr) > 0) {
1995 FlushStrBuf(er_password);
1996 StrBufAppendBuf(er_password, Ptr, 0);
2000 Ptr = sbstr("er_dirname");
2001 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2002 FlushStrBuf(er_dirname);
2003 StrBufAppendBuf(er_dirname, Ptr, 0);
2007 Ptr = sbstr("type");
2008 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2010 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2011 er_flags |= (QR_PRIVATE);
2013 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2014 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2016 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2017 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2019 if (!strcmp(ChrPtr(Ptr), "personal")) {
2020 er_flags |= QR_MAILBOX;
2022 er_flags &= ~QR_MAILBOX;
2025 if (yesbstr("prefonly")) {
2026 er_flags |= QR_PREFONLY;
2028 er_flags &= ~QR_PREFONLY;
2031 if (yesbstr("readonly")) {
2032 er_flags |= QR_READONLY;
2034 er_flags &= ~QR_READONLY;
2038 if (yesbstr("collabdel")) {
2039 er_flags2 |= QR2_COLLABDEL;
2041 er_flags2 &= ~QR2_COLLABDEL;
2044 if (yesbstr("permanent")) {
2045 er_flags |= QR_PERMANENT;
2047 er_flags &= ~QR_PERMANENT;
2050 if (yesbstr("subjectreq")) {
2051 er_flags2 |= QR2_SUBJECTREQ;
2053 er_flags2 &= ~QR2_SUBJECTREQ;
2056 if (yesbstr("network")) {
2057 er_flags |= QR_NETWORK;
2059 er_flags &= ~QR_NETWORK;
2062 if (yesbstr("directory")) {
2063 er_flags |= QR_DIRECTORY;
2065 er_flags &= ~QR_DIRECTORY;
2068 if (yesbstr("ulallowed")) {
2069 er_flags |= QR_UPLOAD;
2071 er_flags &= ~QR_UPLOAD;
2074 if (yesbstr("dlallowed")) {
2075 er_flags |= QR_DOWNLOAD;
2077 er_flags &= ~QR_DOWNLOAD;
2080 if (yesbstr("visdir")) {
2081 er_flags |= QR_VISDIR;
2083 er_flags &= ~QR_VISDIR;
2086 Ptr = sbstr("anon");
2088 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2089 if (!strcmp(ChrPtr(Ptr), "anononly"))
2090 er_flags |= QR_ANONONLY;
2091 if (!strcmp(ChrPtr(Ptr), "anon2"))
2092 er_flags |= QR_ANONOPT;
2094 bump = yesbstr("bump");
2096 er_floor = ibstr("er_floor");
2098 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2100 ChrPtr(er_password),
2109 StrBuf_ServGetln(Buf);
2110 if (GetServerStatus(Buf, NULL) != 2) {
2111 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2114 FreeStrBuf(&er_name);
2115 FreeStrBuf(&er_password);
2116 FreeStrBuf(&er_dirname);
2117 FreeStrBuf(&er_roomaide);
2122 if (StrLength(er_roomaide) > 0) {
2123 serv_printf("SETA %s", ChrPtr(er_roomaide));
2124 StrBuf_ServGetln(Buf);
2125 if (GetServerStatus(Buf, NULL) != 2) {
2126 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2127 display_main_menu();
2129 FreeStrBuf(&er_name);
2130 FreeStrBuf(&er_password);
2131 FreeStrBuf(&er_dirname);
2132 FreeStrBuf(&er_roomaide);
2137 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2140 FreeStrBuf(&er_name);
2141 FreeStrBuf(&er_password);
2142 FreeStrBuf(&er_dirname);
2143 FreeStrBuf(&er_roomaide);
2149 * Display form for Invite, Kick, and show Who Knows a room
2151 void do_invt_kick(void) {
2152 char buf[SIZ], room[SIZ], username[SIZ];
2155 serv_getln(buf, sizeof buf);
2157 if (buf[0] != '2') {
2161 extract_token(room, &buf[4], 0, '|', sizeof room);
2163 strcpy(username, bstr("username"));
2165 if (havebstr("kick_button")) {
2166 sprintf(buf, "KICK %s", username);
2168 serv_getln(buf, sizeof buf);
2170 if (buf[0] != '2') {
2171 strcpy(WC->ImportantMessage, &buf[4]);
2173 sprintf(WC->ImportantMessage,
2174 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2179 if (havebstr("invite_button")) {
2180 sprintf(buf, "INVT %s", username);
2182 serv_getln(buf, sizeof buf);
2184 if (buf[0] != '2') {
2185 strcpy(WC->ImportantMessage, &buf[4]);
2187 sprintf(WC->ImportantMessage,
2188 _("<B><I>User %s invited to room %s.</I></B>\n"),
2199 * Display form for Invite, Kick, and show Who Knows a room
2201 void display_whok(void)
2203 char buf[SIZ], room[SIZ], username[SIZ];
2206 serv_getln(buf, sizeof buf);
2208 if (buf[0] != '2') {
2212 extract_token(room, &buf[4], 0, '|', sizeof room);
2215 wprintf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2216 wprintf(_("The users listed below have access to this room. "
2217 "To remove a user from the access list, select the user "
2218 "name from the list and click 'Kick'."));
2219 wprintf("<br /><br />");
2221 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2222 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2223 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2224 wprintf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2226 serv_getln(buf, sizeof buf);
2227 if (buf[0] == '1') {
2228 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2229 extract_token(username, buf, 0, '|', sizeof username);
2230 wprintf("<OPTION>");
2235 wprintf("</select><br />\n");
2237 wprintf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2238 wprintf("</form></CENTER>\n");
2240 wprintf("</td><td>");
2241 wprintf(_("To grant another user access to this room, enter the "
2242 "user name in the box below and click 'Invite'."));
2243 wprintf("<br /><br />");
2245 wprintf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2246 wprintf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2247 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2248 wprintf(_("Invite:"));
2250 wprintf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2251 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2252 "<input type=\"submit\" value=\"%s\">"
2253 "</form></CENTER>\n", _("Invite"));
2254 /* Pop open an address book -- begin **/
2256 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2258 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2261 _("Users"), _("Users")
2263 /* Pop open an address book -- end **/
2265 wprintf("</td></tr></table>\n");
2266 address_book_popup();
2273 * display the form for entering a new room
2275 void display_entroom(void)
2282 serv_puts("CRE8 0");
2283 serv_getln(buf, sizeof buf);
2285 if (buf[0] != '2') {
2286 strcpy(WC->ImportantMessage, &buf[4]);
2287 display_main_menu();
2292 output_headers(1, 1, 1, 0, 0, 0);
2294 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2295 do_template("beginbox", NULL);
2297 wprintf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2298 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2300 wprintf("<table class=\"altern\"> ");
2302 wprintf("<tr class=\"even\"><td>");
2303 wprintf(_("Name of room: "));
2304 wprintf("</td><td>");
2305 wprintf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2306 wprintf("</td></tr>");
2308 wprintf("<tr class=\"odd\"><td>");
2309 wprintf(_("Resides on floor: "));
2310 wprintf("</td><td>");
2311 load_floorlist(Buf);
2312 wprintf("<select name=\"er_floor\" size=\"1\">\n");
2313 for (i = 0; i < 128; ++i)
2314 if (!IsEmptyStr(floorlist[i])) {
2315 wprintf("<option ");
2316 wprintf("value=\"%d\">", i);
2317 escputs(floorlist[i]);
2318 wprintf("</option>\n");
2320 wprintf("</select>\n");
2321 wprintf("</td></tr>");
2324 * Our clever little snippet of JavaScript automatically selects
2325 * a public room if the view is set to Bulletin Board or wiki, and
2326 * it selects a mailbox room otherwise. The user can override this,
2327 * of course. We also disable the floor selector for mailboxes.
2329 wprintf("<tr class=\"even\"><td>");
2330 wprintf(_("Default view for room: "));
2331 wprintf("</td><td>");
2332 wprintf("<select name=\"er_view\" size=\"1\" OnChange=\""
2333 " if ( (this.form.er_view.value == 0) "
2334 " || (this.form.er_view.value == 6) ) { "
2335 " this.form.type[0].checked=true; "
2336 " this.form.er_floor.disabled = false; "
2339 " this.form.type[4].checked=true; "
2340 " this.form.er_floor.disabled = true; "
2343 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2344 if (is_view_allowed_as_default(i)) {
2345 wprintf("<option %s value=\"%d\">",
2346 ((i == 0) ? "selected" : ""), i );
2347 escputs(viewdefs[i]);
2348 wprintf("</option>\n");
2351 wprintf("</select>\n");
2352 wprintf("</td></tr>");
2354 wprintf("<tr class=\"even\"><td>");
2355 wprintf(_("Type of room:"));
2356 wprintf("</td><td>");
2357 wprintf("<ul class=\"adminlist\">\n");
2359 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2360 wprintf("CHECKED OnChange=\""
2361 " if (this.form.type[0].checked == true) { "
2362 " this.form.er_floor.disabled = false; "
2365 wprintf(_("Public (automatically appears to everyone)"));
2368 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2369 " if (this.form.type[1].checked == true) { "
2370 " this.form.er_floor.disabled = false; "
2373 wprintf(_("Private - hidden (accessible to anyone who knows its name)"));
2376 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2377 " if (this.form.type[2].checked == true) { "
2378 " this.form.er_floor.disabled = false; "
2381 wprintf(_("Private - require password: "));
2382 wprintf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2385 wprintf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2386 " if (this.form.type[3].checked == true) { "
2387 " this.form.er_floor.disabled = false; "
2390 wprintf(_("Private - invitation only"));
2393 wprintf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2395 " if (this.form.type[4].checked == true) { "
2396 " this.form.er_floor.disabled = true; "
2399 wprintf(_("Personal (mailbox for you only)"));
2402 wprintf("\n</ul>\n");
2403 wprintf("</td></tr></table>\n");
2405 wprintf("<div class=\"buttons\">\n");
2406 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2408 wprintf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2409 wprintf("</div>\n");
2410 wprintf("</form>\n<hr />");
2411 serv_printf("MESG roomaccess");
2412 serv_getln(buf, sizeof buf);
2413 if (buf[0] == '1') {
2417 do_template("endbox", NULL);
2427 * support function for entroom() -- sets the default view
2429 void er_set_default_view(int newview) {
2442 serv_getln(buf, sizeof buf);
2443 if (buf[0] != '2') return;
2445 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2446 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2447 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2448 rm_bits1 = extract_int(&buf[4], 3);
2449 rm_floor = extract_int(&buf[4], 4);
2450 rm_listorder = extract_int(&buf[4], 5);
2451 rm_bits2 = extract_int(&buf[4], 7);
2453 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2454 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2455 rm_listorder, newview, rm_bits2
2457 serv_getln(buf, sizeof buf);
2468 const StrBuf *er_name;
2469 const StrBuf *er_type;
2470 const StrBuf *er_password;
2475 if (!havebstr("ok_button")) {
2476 strcpy(WC->ImportantMessage,
2477 _("Cancelled. No new room was created."));
2478 display_main_menu();
2481 er_name = sbstr("er_name");
2482 er_type = sbstr("type");
2483 er_password = sbstr("er_password");
2484 er_floor = ibstr("er_floor");
2485 er_view = ibstr("er_view");
2488 if (!strcmp(ChrPtr(er_type), "hidden"))
2490 else if (!strcmp(ChrPtr(er_type), "passworded"))
2492 else if (!strcmp(ChrPtr(er_type), "invonly"))
2494 else if (!strcmp(ChrPtr(er_type), "personal"))
2497 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2500 ChrPtr(er_password),
2505 serv_getln(buf, sizeof buf);
2506 if (buf[0] != '2') {
2507 strcpy(WC->ImportantMessage, &buf[4]);
2508 display_main_menu();
2511 /** TODO: Room created, now udate the left hand icon bar for this user */
2512 burn_folder_cache(0); /* burn the old folder cache */
2516 do_change_view(er_view); /* Now go there */
2521 * \brief display the screen to enter a private room
2523 void display_private(char *rname, int req_pass)
2525 WCTemplputParams SubTP;
2527 output_headers(1, 1, 1, 0, 0, 0);
2529 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2530 memset(&SubTP, 0, sizeof(WCTemplputParams));
2531 SubTP.Filter.ContextType = CTX_STRBUF;
2532 SubTP.Context = Buf;
2533 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2538 wprintf(_("If you know the name of a hidden (guess-name) or "
2539 "passworded room, you can enter that room by typing "
2540 "its name below. Once you gain access to a private "
2541 "room, it will appear in your regular room listings "
2542 "so you don't have to keep returning here."));
2545 wprintf("<form method=\"post\" action=\"goto_private\">\n");
2546 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2548 wprintf("<table class=\"altern\"> "
2549 "<tr class=\"even\"><td>");
2550 wprintf(_("Enter room name:"));
2552 "<input type=\"text\" name=\"gr_name\" "
2553 "value=\"%s\" maxlength=\"128\">\n", rname);
2556 wprintf("</td></tr><tr class=\"odd\"><td>");
2557 wprintf(_("Enter room password:"));
2558 wprintf("</td><td>");
2559 wprintf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2561 wprintf("</td></tr></table>\n");
2563 wprintf("<div class=\"buttons\">\n");
2564 wprintf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2566 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2570 wprintf("</div></form>\n");
2572 do_template("endbox", NULL);
2578 * \brief goto a private room
2580 void goto_private(void)
2585 if (!havebstr("ok_button")) {
2586 display_main_menu();
2589 strcpy(hold_rm, ChrPtr(WC->wc_roomname));
2590 serv_printf("GOTO %s|%s",
2593 serv_getln(buf, sizeof buf);
2595 if (buf[0] == '2') {
2596 smart_goto(sbstr("gr_name"));
2599 if (!strncmp(buf, "540", 3)) {
2600 display_private(bstr("gr_name"), 1);
2603 output_headers(1, 1, 1, 0, 0, 0);
2604 wprintf("%s\n", &buf[4]);
2611 * \brief display the screen to zap a room
2613 void display_zap(void)
2615 output_headers(1, 1, 2, 0, 0, 0);
2617 wprintf("<div id=\"banner\">\n");
2619 wprintf(_("Zap (forget/unsubscribe) the current room"));
2621 wprintf("</div>\n");
2623 wprintf("<div id=\"content\" class=\"service\">\n");
2625 wprintf(_("If you select this option, <em>%s</em> will "
2626 "disappear from your room list. Is this what you wish "
2627 "to do?<br />\n"), ChrPtr(WC->wc_roomname));
2629 wprintf("<form method=\"POST\" action=\"zap\">\n");
2630 wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2631 wprintf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2633 wprintf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2634 wprintf("</form>\n");
2645 StrBuf *final_destination;
2648 * If the forget-room routine fails for any reason, we fall back
2649 * to the current room; otherwise, we go to the Lobby
2651 final_destination = NewStrBufDup(WC->wc_roomname);
2653 if (havebstr("ok_button")) {
2654 serv_printf("GOTO %s", ChrPtr(WC->wc_roomname));
2655 serv_getln(buf, sizeof buf);
2656 if (buf[0] == '2') {
2658 serv_getln(buf, sizeof buf);
2659 if (buf[0] == '2') {
2660 FlushStrBuf(final_destination);
2661 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2665 smart_goto(final_destination);
2666 FreeStrBuf(&final_destination);
2672 * \brief Delete the current room
2674 void delete_room(void)
2679 serv_puts("KILL 1");
2680 serv_getln(buf, sizeof buf);
2681 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2682 if (buf[0] != '2') {
2683 strcpy(WC->ImportantMessage, &buf[4]);
2684 display_main_menu();
2689 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2698 * \brief Perform changes to a room's network configuration
2700 void netedit(void) {
2709 /*/ TODO: do line dynamic! */
2710 if (havebstr("line_pop3host")) {
2711 strcpy(line, bstr("prefix"));
2712 strcat(line, bstr("line_pop3host"));
2714 strcat(line, bstr("line_pop3user"));
2716 strcat(line, bstr("line_pop3pass"));
2718 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2720 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2721 strcat(line, bstr("suffix"));
2723 else if (havebstr("line")) {
2724 strcpy(line, bstr("prefix"));
2725 strcat(line, bstr("line"));
2726 strcat(line, bstr("suffix"));
2741 serv_getln(buf, sizeof buf);
2742 if (buf[0] != '1') {
2748 /** This loop works for add *or* remove. Spiffy, eh? */
2749 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2750 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2751 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2752 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2753 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2754 if ( (strcasecmp(cmpa0, cmpb0))
2755 || (strcasecmp(cmpa1, cmpb1)) ) {
2756 fprintf(fp, "%s\n", buf);
2762 serv_getln(buf, sizeof buf);
2763 if (buf[0] != '4') {
2769 while (fgets(buf, sizeof buf, fp) != NULL) {
2770 buf[strlen(buf)-1] = 0;
2774 if (havebstr("add_button")) {
2775 num_addrs = num_tokens(bstr("line"), ',');
2776 if (num_addrs < 2) {
2777 /* just adding one node or address */
2781 /* adding multiple addresses separated by commas */
2782 for (i=0; i<num_addrs; ++i) {
2783 strcpy(line, bstr("prefix"));
2784 extract_token(buf, bstr("line"), i, ',', sizeof buf);
2787 strcat(line, bstr("suffix"));
2801 * \brief Convert a room name to a folder-ish-looking name.
2802 * \param folder the folderish name
2803 * \param room the room name
2804 * \param floor the floor name
2805 * \param is_mailbox is it a mailbox?
2807 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
2812 * For mailboxes, just do it straight...
2815 sprintf(folder, "My folders|%s", room);
2819 * Otherwise, prefix the floor name as a "public folders" moniker
2822 if (floor > MAX_FLOORS) {
2824 sprintf(folder, "%%%%%%|%s", room);
2827 sprintf(folder, "%s|%s", floorlist[floor], room);
2832 * Replace "\" characters with "|" for pseudo-folder-delimiting
2834 len = strlen (folder);
2835 for (i=0; i<len; ++i) {
2836 if (folder[i] == '\\') folder[i] = '|';
2844 * \brief Back end for change_view()
2845 * \param newview set newview???
2847 void do_change_view(int newview) {
2850 serv_printf("VIEW %d", newview);
2851 serv_getln(buf, sizeof buf);
2852 WC->wc_view = newview;
2853 smart_goto(WC->wc_roomname);
2859 * \brief Change the view for this room
2861 void change_view(void) {
2864 view = lbstr("view");
2865 do_change_view(view);
2870 * \brief One big expanded tree list view --- like a folder list
2871 * \param fold the folder to view
2872 * \param max_folders how many folders???
2873 * \param num_floors hom many floors???
2875 void do_folder_view(struct __ofolder *fold, int max_folders, int num_floors) {
2879 int has_subfolders = 0;
2882 parents = malloc(max_folders * sizeof(int));
2884 /** BEGIN TREE MENU */
2885 wprintf("<div id=\"roomlist_div\">Loading folder list...</div>\n");
2887 /** include NanoTree */
2888 wprintf("<script type=\"text/javascript\" src=\"static/nanotree.js\"></script>\n");
2890 /** initialize NanoTree */
2891 wprintf("<script type=\"text/javascript\"> \n"
2892 " showRootNode = false; \n"
2893 " sortNodes = false; \n"
2894 " dragable = false; \n"
2896 " function standardClick(treeNode) { \n"
2899 " var closedGif = 'static/folder_closed.gif'; \n"
2900 " var openGif = 'static/folder_open.gif'; \n"
2902 " rootNode = new TreeNode(1, 'root node - hide'); \n"
2906 for (i=0; i<max_folders; ++i) {
2909 if ((i+1) < max_folders) {
2911 len = strlen(fold[i].name);
2912 if ( (!strncasecmp(fold[i].name, fold[i+1].name, len))
2913 && (fold[i+1].name[len] == '|') ) {
2918 levels = num_tokens(fold[i].name, '|');
2919 parents[levels] = i;
2921 wprintf("var node%d = new TreeNode(%d, '", i, i);
2923 if (fold[i].selectable) {
2924 wprintf("<a href=\"dotgoto?room=");
2925 urlescputs(fold[i].room);
2930 wprintf("<span class=\"roomlist_floor\">");
2932 else if (fold[i].hasnewmsgs) {
2933 wprintf("<span class=\"roomlist_new\">");
2936 wprintf("<span class=\"roomlist_old\">");
2938 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
2943 if (has_subfolders) {
2944 wprintf("new Array(closedGif, openGif)");
2946 else if (fold[i].view == VIEW_ADDRESSBOOK) {
2947 wprintf("'static/viewcontacts_16x.gif'");
2949 else if (fold[i].view == VIEW_CALENDAR) {
2950 wprintf("'static/calarea_16x.gif'");
2952 else if (fold[i].view == VIEW_CALBRIEF) {
2953 wprintf("'static/calarea_16x.gif'");
2955 else if (fold[i].view == VIEW_TASKS) {
2956 wprintf("'static/taskmanag_16x.gif'");
2958 else if (fold[i].view == VIEW_NOTES) {
2959 wprintf("'static/storenotes_16x.gif'");
2961 else if (fold[i].view == VIEW_MAILBOX) {
2962 wprintf("'static/privatemess_16x.gif'");
2965 wprintf("'static/chatrooms_16x.gif'");
2968 urlescputs(fold[i].name);
2972 wprintf("rootNode.addChild(node%d);\n", i);
2975 wprintf("node%d.addChild(node%d);\n", parents[levels-1], i);
2979 wprintf("container = document.getElementById('roomlist_div'); \n"
2985 /** END TREE MENU */
2989 * \brief Boxes and rooms and lists ... oh my!
2990 * \param fold the folder to view
2991 * \param max_folders how many folders???
2992 * \param num_floors hom many floors???
2994 void do_rooms_view(struct __ofolder *fold, int max_folders, int num_floors) {
2996 char floor_name[256];
2997 char old_floor_name[256];
2998 int levels, oldlevels;
3001 static int columns = 3;
3002 int boxes_per_column = 0;
3003 int current_column = 0;
3006 strcpy(floor_name, "");
3007 strcpy(old_floor_name, "");
3010 while (nf % columns != 0) ++nf;
3011 boxes_per_column = (nf / columns);
3012 if (boxes_per_column < 1) boxes_per_column = 1;
3014 /** Outer table (for columnization) */
3015 wprintf("<table BORDER=0 WIDTH=96%% CELLPADDING=5>"
3016 "<tr><td valign=top>");
3020 for (i=0; i<max_folders; ++i) {
3022 levels = num_tokens(fold[i].name, '|');
3023 extract_token(floor_name, fold[i].name, 0,
3024 '|', sizeof floor_name);
3026 if ( (strcasecmp(floor_name, old_floor_name))
3027 && (!IsEmptyStr(old_floor_name)) ) {
3029 do_template("endbox", NULL);
3033 if ((num_boxes % boxes_per_column) == 0) {
3035 if (current_column < columns) {
3036 wprintf("</td><td valign=top>\n");
3040 strcpy(old_floor_name, floor_name);
3044 WCTemplputParams SubTP;
3046 Buf = NewStrBufPlain(floor_name, -1);
3047 memset(&SubTP, 0, sizeof(WCTemplputParams));
3048 SubTP.Filter.ContextType = CTX_STRBUF;
3049 SubTP.Context = Buf;
3050 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
3059 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3060 if (fold[i].selectable) {
3061 wprintf("<a href=\"dotgoto?room=");
3062 urlescputs(fold[i].room);
3068 if (fold[i].hasnewmsgs) {
3069 wprintf("<span class=\"roomlist_new\">");
3072 wprintf("<span class=\"roomlist_old\">");
3074 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3077 if (fold[i].selectable) {
3083 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3084 wprintf(" (INBOX)");
3086 wprintf("<br />\n");
3089 /** End the final inner box */
3090 do_template("endbox", NULL);
3092 wprintf("</td></tr></table>\n");
3096 * \brief print a floor div???
3097 * \param which_floordiv name of the floordiv???
3099 void set_floordiv_expanded(void) {
3100 wcsession *WCC = WC;
3103 FloorDiv = NewStrBuf();
3104 StrBufExtract_token(FloorDiv, WCC->Hdr->HR.ReqLine, 0, '/');
3105 set_preference("floordiv_expanded", FloorDiv, 1);
3106 WCC->floordiv_expanded = FloorDiv;
3110 * \brief view the iconbar
3111 * \param fold the folder to view
3112 * \param max_folders how many folders???
3113 * \param num_floors hom many floors???
3115 void do_iconbar_view(struct __ofolder *fold, int max_folders, int num_floors) {
3117 char floor_name[256];
3118 char old_floor_name[256];
3119 char floordivtitle[256];
3120 char floordiv_id[32];
3121 int levels, oldlevels;
3125 strcpy(floor_name, "");
3126 strcpy(old_floor_name, "");
3130 for (i=0; i<max_folders; ++i) {
3132 levels = num_tokens(fold[i].name, '|');
3133 extract_token(floor_name, fold[i].name, 0,
3134 '|', sizeof floor_name);
3136 if ( (strcasecmp(floor_name, old_floor_name))
3137 && (!IsEmptyStr(old_floor_name)) ) {
3138 /** End inner box */
3140 wprintf("</div>\n"); /** floordiv */
3142 strcpy(old_floor_name, floor_name);
3146 stresc(floordivtitle, 256, floor_name, 0, 0);
3147 sprintf(floordiv_id, "floordiv%d", i);
3148 wprintf("<span class=\"ib_roomlist_floor\" "
3149 "onClick=\"expand_floor('%s')\">"
3150 "%s</span><br>\n", floordiv_id, floordivtitle);
3151 wprintf("<div id=\"%s\" style=\"display:%s\">",
3153 (!strcasecmp(floordiv_id, ChrPtr(WC->floordiv_expanded)) ? "block" : "none")
3160 wprintf("<div id=\"roomdiv%d\">", i);
3162 if (levels>2) for (t=0; t<(levels-2); ++t) wprintf(" ");
3164 /** choose the icon */
3165 if (fold[i].view == VIEW_ADDRESSBOOK) {
3166 icon = "viewcontacts_16x.gif" ;
3168 else if (fold[i].view == VIEW_CALENDAR) {
3169 icon = "calarea_16x.gif" ;
3171 else if (fold[i].view == VIEW_CALBRIEF) {
3172 icon = "calarea_16x.gif" ;
3174 else if (fold[i].view == VIEW_TASKS) {
3175 icon = "taskmanag_16x.gif" ;
3177 else if (fold[i].view == VIEW_NOTES) {
3178 icon = "storenotes_16x.gif" ;
3180 else if (fold[i].view == VIEW_MAILBOX) {
3181 icon = "privatemess_16x.gif" ;
3184 icon = "chatrooms_16x.gif" ;
3187 if (fold[i].selectable) {
3188 wprintf("<a href=\"dotgoto?room=");
3189 urlescputs(fold[i].room);
3191 wprintf("<img border=0 src=\"static/%s\" alt=\"\"> ", icon);
3196 if (fold[i].hasnewmsgs) {
3197 wprintf("<span class=\"ib_roomlist_new\">");
3200 wprintf("<span class=\"ib_roomlist_old\">");
3202 extract_token(buf, fold[i].name, levels-1, '|', sizeof buf);
3204 if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
3205 wprintf(" (INBOX)");
3208 if (fold[i].selectable) {
3215 wprintf("</div>\n"); /** roomdiv */
3218 wprintf("</div>\n"); /** floordiv */
3226 * \brief Burn the cached folder list.
3227 * \param age How old the cahce needs to be before we burn it.
3230 void burn_folder_cache(time_t age)
3232 /** If our cached folder list is very old, burn it. */
3233 if (WC->cache_fold != NULL) {
3234 if ((time(NULL) - WC->cache_timestamp) > age) {
3235 free(WC->cache_fold);
3236 WC->cache_fold = NULL;
3245 * \brief Show the room list.
3246 * (only should get called by
3247 * knrooms() because that's where output_headers() is called from)
3248 * \param viewpref the view preferences???
3251 void list_all_rooms_by_floor(const char *viewpref) {
3255 struct __ofolder *fold = NULL;
3256 struct __ofolder ftmp;
3257 int max_folders = 0;
3258 int alloc_folders = 0;
3262 int ShowEmptyFloors;
3265 int num_floors = 1; /** add an extra one for private folders */
3268 /** If our cached folder list is very old, burn it. */
3269 burn_folder_cache(300);
3271 /** Can we do the iconbar roomlist from cache? */
3272 if ((WC->cache_fold != NULL) && (!strcasecmp(viewpref, "iconbar"))) {
3273 do_iconbar_view(WC->cache_fold, WC->cache_max_folders, WC->cache_num_floors);
3278 /** Grab the floor table so we know how to build the list... */
3279 load_floorlist(Buf);
3281 /** Start with the mailboxes */
3284 fold = malloc(sizeof(struct __ofolder));
3285 memset(fold, 0, sizeof(struct __ofolder));
3286 strcpy(fold[0].name, "My folders");
3287 fold[0].is_mailbox = 1;
3289 /** Then add floors */
3291 serv_getln(buf, sizeof buf);
3292 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3293 if (max_folders >= alloc_folders) {
3294 alloc_folders = max_folders + 100;
3295 fold = realloc(fold,
3296 alloc_folders * sizeof(struct __ofolder));
3298 memset(&fold[max_folders], 0, sizeof(struct __ofolder));
3299 extract_token(fold[max_folders].name, buf, 1, '|', sizeof fold[max_folders].name);
3300 extract_token(buf3, buf, 0, '|', SIZ);
3301 fold[max_folders].floor = atol (buf3);
3306 for (i=0; i<num_floors; i++)
3307 if (IDMax < fold[i].floor)
3308 IDMax = fold[i].floor;
3309 floor_mapping = malloc (sizeof (int) * (IDMax + 1));
3310 memset (floor_mapping, 0, sizeof (int) * (IDMax + 1));
3311 for (i=0; i<num_floors; i++)
3312 floor_mapping[fold[i].floor]=i;
3314 /** refresh the messages index for this room */
3315 /* TODO serv_puts("GOTO ");
3316 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")); */
3317 /** Now add rooms */
3319 serv_getln(buf, sizeof buf);
3320 if (buf[0]=='1') while(serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
3321 if (max_folders >= alloc_folders) {
3322 alloc_folders = max_folders + 100;
3323 fold = realloc(fold,
3324 alloc_folders * sizeof(struct __ofolder));
3326 memset(&fold[max_folders], 0, sizeof(struct __ofolder));
3327 extract_token(fold[max_folders].room, buf, 0, '|', sizeof fold[max_folders].room);
3328 ra_flags = extract_int(buf, 5);
3329 flags = extract_int(buf, 1);
3330 fold[max_folders].floor = extract_int(buf, 2);
3331 fold[max_folders].hasnewmsgs =
3332 ((ra_flags & UA_HASNEWMSGS) ? 1 : 0 );
3333 if (flags & QR_MAILBOX) {
3334 fold[max_folders].is_mailbox = 1;
3336 fold[max_folders].view = extract_int(buf, 6);
3337 room_to_folder(fold[max_folders].name,
3338 fold[max_folders].room,
3339 fold[max_folders].floor,
3340 fold[max_folders].is_mailbox);
3341 fold[max_folders].selectable = 1;
3342 /* Increase the room count for the associtaed floor */
3343 if (fold[max_folders].is_mailbox) {
3344 fold[0].num_rooms++;
3347 i = floor_mapping[fold[max_folders].floor];
3348 fold[i].num_rooms++;
3354 * Remove any floors that don't have rooms
3356 get_pref_yesno("emptyfloors", &ShowEmptyFloors, 0);
3357 if (ShowEmptyFloors)
3359 for (i=0; i<num_floors; i++)
3361 if (fold[i].num_rooms == 0) {
3362 for (j=i; j<max_folders; j++) {
3363 memcpy(&fold[j], &fold[j+1], sizeof(struct __ofolder));
3372 /** Bubble-sort the folder list */
3373 for (i=0; i<max_folders; ++i) {
3374 for (j=0; j<(max_folders-1)-i; ++j) {
3375 if (fold[j].is_mailbox == fold[j+1].is_mailbox) {
3376 swap = strcasecmp(fold[j].name, fold[j+1].name);
3379 if ( (fold[j+1].is_mailbox)
3380 && (!fold[j].is_mailbox)) {
3388 memcpy(&ftmp, &fold[j], sizeof(struct __ofolder));
3389 memcpy(&fold[j], &fold[j+1],
3390 sizeof(struct __ofolder));
3391 memcpy(&fold[j+1], &ftmp,
3392 sizeof(struct __ofolder));
3398 if (!strcasecmp(viewpref, "folders")) {
3399 do_folder_view(fold, max_folders, num_floors);
3401 else if (!strcasecmp(viewpref, "hackish_view")) {
3402 for (i=0; i<max_folders; ++i) {
3403 escputs(fold[i].name);
3404 wprintf("<br />\n");
3407 else if (!strcasecmp(viewpref, "iconbar")) {
3408 do_iconbar_view(fold, max_folders, num_floors);
3411 do_rooms_view(fold, max_folders, num_floors);
3414 /* Don't free the folder list ... cache it for future use! */
3415 if (WC->cache_fold != NULL) {
3416 free(WC->cache_fold);
3418 WC->cache_fold = fold;
3419 WC->cache_max_folders = max_folders;
3420 WC->cache_num_floors = num_floors;
3421 WC->cache_timestamp = time(NULL);
3422 free(floor_mapping);
3427 * \brief Do either a known rooms list or a folders list, depending on the
3432 StrBuf *ListView = NULL;
3434 output_headers(1, 1, 2, 0, 0, 0);
3436 /** Determine whether the user is trying to change views */
3437 if (havebstr("view")) {
3438 ListView = NewStrBufPlain(bstr("view"), -1);
3439 set_preference("roomlistview", ListView, 1);
3441 /** Sanitize the input so its safe */
3442 if(!get_preference("roomlistview", &ListView) ||
3443 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3444 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3446 if (ListView == NULL) {
3447 ListView = NewStrBufPlain("rooms", sizeof("rooms") - 1);
3448 set_preference("roomlistview", ListView, 0);
3451 StrBufPrintf(ListView, "rooms");
3457 wprintf("<div id=\"banner\">\n");
3458 wprintf("<div class=\"room_banner\" id=\"room_banner\">");
3460 if (!strcasecmp(ChrPtr(ListView), "rooms")) {
3461 wprintf(_("Room list"));
3463 else if (!strcasecmp(ChrPtr(ListView), "folders")) {
3464 wprintf(_("Folder list"));
3466 else if (!strcasecmp(ChrPtr(ListView), "table")) {
3467 wprintf(_("Room list"));
3469 wprintf("</h1></div>\n");
3471 /** offer the ability to switch views */
3472 wprintf("<div id=\"actiondiv\">");
3473 wprintf("<ul class=\"room_actions\">\n");
3474 wprintf("<li class=\"start_page\">");
3475 offer_start_page(NULL, &NoCtx);
3477 wprintf("<li><form name=\"roomlistomatic\">\n"
3478 "<select name=\"newview\" size=\"1\" "
3479 "OnChange=\"location.href=roomlistomatic.newview.options"
3480 "[selectedIndex].value\">\n");
3482 wprintf("<option %s value=\"knrooms?view=rooms\">"
3485 ( !strcasecmp(ChrPtr(ListView), "rooms") ? "SELECTED" : "" )
3488 wprintf("<option %s value=\"knrooms?view=folders\">"
3489 "View as folder list"
3491 ( !strcasecmp(ChrPtr(ListView), "folders") ? "SELECTED" : "" )
3494 wprintf("</select>");
3495 wprintf("</form></li>");
3496 wprintf("</ul></div></div>\n");
3498 wprintf("<div id=\"content\" class=\"service\">\n");
3500 /** Display the room list in the user's preferred format */
3501 list_all_rooms_by_floor(ChrPtr(ListView));
3508 * \brief Set the message expire policy for this room and/or floor
3510 void set_room_policy(void) {
3513 if (!havebstr("ok_button")) {
3514 strcpy(WC->ImportantMessage,
3515 _("Cancelled. Changes were not saved."));
3520 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3521 serv_getln(buf, sizeof buf);
3522 strcpy(WC->ImportantMessage, &buf[4]);
3524 if (WC->axlevel >= 6) {
3525 strcat(WC->ImportantMessage, "<br />\n");
3526 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3527 serv_getln(buf, sizeof buf);
3528 strcat(WC->ImportantMessage, &buf[4]);
3534 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3536 StrBufAppendTemplate(Target, TP, WC->wc_roomname, 0);
3540 void _display_private(void) {
3541 display_private("", 0);
3544 void dotgoto(void) {
3545 if (!havebstr("room")) {
3549 if (WC->wc_view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3552 smart_goto(sbstr("room"));
3555 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3557 wprintf("<div id=\"banner\">\n");
3558 embed_room_banner(NULL, navbar_default);
3559 wprintf("</div>\n");
3563 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3565 wcsession *WCC = WC;
3568 (!IsEmptyStr(WCC->ugname)))
3569 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3573 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3575 wcsession *WCC = WC;
3577 return ((WCC!=NULL) &&
3578 (!IsEmptyStr(WCC->ugname)) &&
3579 (strcasecmp(WCC->ugname, ChrPtr(WCC->wc_roomname)) == 0));
3582 int ConditionalRoomHas_QR_PERMANENT(StrBuf *Target, WCTemplputParams *TP)
3584 wcsession *WCC = WC;
3586 return ((WCC!=NULL) &&
3587 ((WCC->room_flags & QR_PERMANENT) != 0));
3590 int ConditionalRoomHas_QR_INUSE(StrBuf *Target, WCTemplputParams *TP)
3592 wcsession *WCC = WC;
3594 return ((WCC!=NULL) &&
3595 ((WCC->room_flags & QR_INUSE) != 0));
3598 int ConditionalRoomHas_QR_PRIVATE(StrBuf *Target, WCTemplputParams *TP)
3600 wcsession *WCC = WC;
3602 return ((WCC!=NULL) &&
3603 ((WCC->room_flags & QR_PRIVATE) != 0));
3606 int ConditionalRoomHas_QR_PASSWORDED(StrBuf *Target, WCTemplputParams *TP)
3608 wcsession *WCC = WC;
3610 return ((WCC!=NULL) &&
3611 ((WCC->room_flags & QR_PASSWORDED) != 0));
3614 int ConditionalRoomHas_QR_GUESSNAME(StrBuf *Target, WCTemplputParams *TP)
3616 wcsession *WCC = WC;
3618 return ((WCC!=NULL) &&
3619 ((WCC->room_flags & QR_GUESSNAME) != 0));
3622 int ConditionalRoomHas_QR_DIRECTORY(StrBuf *Target, WCTemplputParams *TP)
3624 wcsession *WCC = WC;
3626 return ((WCC!=NULL) &&
3627 ((WCC->room_flags & QR_DIRECTORY) != 0));
3630 int ConditionalRoomHas_QR_UPLOAD(StrBuf *Target, WCTemplputParams *TP)
3632 wcsession *WCC = WC;
3634 return ((WCC!=NULL) &&
3635 ((WCC->room_flags & QR_UPLOAD) != 0));
3638 int ConditionalRoomHas_QR_DOWNLOAD(StrBuf *Target, WCTemplputParams *TP)
3640 wcsession *WCC = WC;
3642 return ((WCC!=NULL) &&
3643 ((WCC->room_flags & QR_DOWNLOAD) != 0));
3646 int ConditionalRoomHas_QR_VISDIR(StrBuf *Target, WCTemplputParams *TP)
3648 wcsession *WCC = WC;
3650 return ((WCC!=NULL) &&
3651 ((WCC->room_flags & QR_VISDIR) != 0));
3654 int ConditionalRoomHas_QR_ANONONLY(StrBuf *Target, WCTemplputParams *TP)
3656 wcsession *WCC = WC;
3658 return ((WCC!=NULL) &&
3659 ((WCC->room_flags & QR_ANONONLY) != 0));
3662 int ConditionalRoomHas_QR_ANONOPT(StrBuf *Target, WCTemplputParams *TP)
3664 wcsession *WCC = WC;
3666 return ((WCC!=NULL) &&
3667 ((WCC->room_flags & QR_ANONOPT) != 0));
3670 int ConditionalRoomHas_QR_NETWORK(StrBuf *Target, WCTemplputParams *TP)
3672 wcsession *WCC = WC;
3674 return ((WCC!=NULL) &&
3675 ((WCC->room_flags & QR_NETWORK) != 0));
3678 int ConditionalRoomHas_QR_PREFONLY(StrBuf *Target, WCTemplputParams *TP)
3680 wcsession *WCC = WC;
3682 return ((WCC!=NULL) &&
3683 ((WCC->room_flags & QR_PREFONLY) != 0));
3686 int ConditionalRoomHas_QR_READONLY(StrBuf *Target, WCTemplputParams *TP)
3688 wcsession *WCC = WC;
3690 return ((WCC!=NULL) &&
3691 ((WCC->room_flags & QR_READONLY) != 0));
3694 int ConditionalRoomHas_QR_MAILBOX(StrBuf *Target, WCTemplputParams *TP)
3696 wcsession *WCC = WC;
3698 return ((WCC!=NULL) &&
3699 ((WCC->room_flags & QR_MAILBOX) != 0));
3706 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3708 wcsession *WCC = WC;
3710 return ( (WCC!= NULL) &&
3711 ((WCC->axlevel >= 6) ||
3712 (WCC->is_room_aide) ||
3713 (WCC->is_mailbox) ));
3716 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3718 wcsession *WCC = WC;
3720 if ((WCC == NULL) ||
3721 (TP->Tokens->nParameters < 3) ||
3722 (TP->Tokens->Params[2]->Type != TYPE_STR)||
3723 (TP->Tokens->Params[2]->len < 7))
3726 switch(WCC->wc_view) {
3728 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_BBS"));
3730 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_MAILBOX"));
3731 case VIEW_ADDRESSBOOK:
3732 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_ADDRESSBOOK"));
3734 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_TASKS"));
3736 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_NOTES"));
3738 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_WIKI"));
3740 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_JOURNAL"));
3742 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_CALENDAR"));
3744 return (!strcasecmp(TP->Tokens->Params[2]->Start, "VIEW_CALBRIEF"));
3754 RegisterPreference("roomlistview",
3755 _("Room list view"),
3758 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3760 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, 0);
3762 WebcitAddUrlHandler(HKEY("knrooms"), knrooms, 0);
3763 WebcitAddUrlHandler(HKEY("dotgoto"), dotgoto, NEED_URL);
3764 WebcitAddUrlHandler(HKEY("dotskip"), dotskip, NEED_URL);
3765 WebcitAddUrlHandler(HKEY("display_private"), _display_private, 0);
3766 WebcitAddUrlHandler(HKEY("goto_private"), goto_private, NEED_URL);
3767 WebcitAddUrlHandler(HKEY("zapped_list"), zapped_list, 0);
3768 WebcitAddUrlHandler(HKEY("display_zap"), display_zap, 0);
3769 WebcitAddUrlHandler(HKEY("zap"), zap, 0);
3770 WebcitAddUrlHandler(HKEY("display_entroom"), display_entroom, 0);
3771 WebcitAddUrlHandler(HKEY("entroom"), entroom, 0);
3772 WebcitAddUrlHandler(HKEY("display_whok"), display_whok, 0);
3773 WebcitAddUrlHandler(HKEY("do_invt_kick"), do_invt_kick, 0);
3774 WebcitAddUrlHandler(HKEY("display_editroom"), display_editroom, 0);
3775 WebcitAddUrlHandler(HKEY("netedit"), netedit, 0);
3776 WebcitAddUrlHandler(HKEY("editroom"), editroom, 0);
3777 WebcitAddUrlHandler(HKEY("delete_room"), delete_room, 0);
3778 WebcitAddUrlHandler(HKEY("set_room_policy"), set_room_policy, 0);
3779 WebcitAddUrlHandler(HKEY("set_floordiv_expanded"), set_floordiv_expanded, NEED_URL|AJAX);
3780 WebcitAddUrlHandler(HKEY("changeview"), change_view, 0);
3781 WebcitAddUrlHandler(HKEY("toggle_self_service"), toggle_self_service, 0);
3782 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, 0);
3784 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3785 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PERMANENT"), 0, ConditionalRoomHas_QR_PERMANENT, CTX_NONE);
3786 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_INUSE"), 0, ConditionalRoomHas_QR_INUSE, CTX_NONE);
3787 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PRIVATE"), 0, ConditionalRoomHas_QR_PRIVATE, CTX_NONE);
3788 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PASSWORDED"), 0, ConditionalRoomHas_QR_PASSWORDED, CTX_NONE);
3789 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_GUESSNAME"), 0, ConditionalRoomHas_QR_GUESSNAME, CTX_NONE);
3790 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DIRECTORY"), 0, ConditionalRoomHas_QR_DIRECTORY, CTX_NONE);
3791 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_UPLOAD"), 0, ConditionalRoomHas_QR_UPLOAD, CTX_NONE);
3792 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_DOWNLOAD"), 0, ConditionalRoomHas_QR_DOWNLOAD, CTX_NONE);
3793 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_VISIDIR"), 0, ConditionalRoomHas_QR_VISDIR, CTX_NONE);
3794 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONONLY"), 0, ConditionalRoomHas_QR_ANONONLY, CTX_NONE);
3795 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_ANONOPT"), 0, ConditionalRoomHas_QR_ANONOPT, CTX_NONE);
3796 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_NETWORK"), 0, ConditionalRoomHas_QR_NETWORK, CTX_NONE);
3797 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_PREFONLY"), 0, ConditionalRoomHas_QR_PREFONLY, CTX_NONE);
3798 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_READONLY"), 0, ConditionalRoomHas_QR_READONLY, CTX_NONE);
3799 RegisterConditional(HKEY("COND:ROOM:FLAGS:QR_MAILBOX"), 0, ConditionalRoomHas_QR_MAILBOX, CTX_NONE);
3801 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3802 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3804 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, 0);
3805 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3812 SessionDestroyModule_ROOMOPS
3815 if (sess->cache_fold != NULL) {
3816 free(sess->cache_fold);
3819 free_march_list(sess);
3820 DeleteHash(&sess->Floors);