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);
19 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP);
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(1);
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 wc_printf("<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 wc_printf("</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) wc_printf(" ");
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 wc_printf("<br /><br />\n");
229 wc_printf(_("Click on any room to un-zap it and goto that room.\n"));
230 do_template("endbox", NULL);
235 * Display the current view and offer an option to change it
237 void embed_view_o_matic(StrBuf *Target, WCTemplputParams *TP)
241 wc_printf("<form name=\"viewomatic\" action=\"changeview\">\n");
242 wc_printf("\t<div style=\"display: inline;\">\n\t<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
243 wc_printf("<label for=\"view_name\">");
244 wc_printf(_("View as:"));
245 wc_printf("</label> "
246 "<select name=\"newview\" size=\"1\" "
247 "id=\"view_name\" class=\"selectbox\" "
248 "OnChange=\"location.href=viewomatic.newview.options"
249 "[selectedIndex].value\">\n");
251 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
253 * Only offer the views that make sense, given the default
254 * view for the room. For example, don't offer a Calendar
255 * view in a non-Calendar room.
258 (i == WC->CurRoom.view)
259 || (i == WC->CurRoom.defview) /* default */
260 || ( (i == 0) && (WC->CurRoom.defview == 1) ) /* mail or bulletin */
261 || ( (i == 1) && (WC->CurRoom.defview == 0) ) /* mail or bulletin */
262 /* || ( (i == 7) && (WC->CurRoom.defview == 3) ) (calendar list temporarily disabled) */
265 wc_printf("<option %s value=\"changeview?view=%d\">",
266 ((i == WC->CurRoom.view) ? "selected" : ""),
268 escputs(viewdefs[i]);
269 wc_printf("</option>\n");
272 wc_printf("</select></div></form>\n");
278 * Embed the room banner
280 * got The information returned from a GOTO server command
281 * navbar_style Determines which navigation buttons to display
285 void embed_room_banner(char *got, int navbar_style) {
289 char with_files[256];
293 * We need to have the information returned by a GOTO server command.
294 * If it isn't supplied, we fake it by issuing our own GOTO.
297 memset(buf, '0', 20);
299 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
300 serv_getln(buf, sizeof buf);
304 /* The browser needs some information for its own use */
305 wc_printf("<script type=\"text/javascript\"> \n"
306 " room_is_trash = %d; \n"
308 ((WC->CurRoom.RAFlags & UA_ISTRASH) != 0)
312 * If the user happens to select the "make this my start page" link,
313 * we want it to remember the URL as a "/dotskip" one instead of
314 * a "skip" or "gotonext" or something like that.
316 if (WCC->Hdr->this_page == NULL) {
317 WCC->Hdr->this_page = NewStrBuf();
319 StrBufPrintf(WCC->Hdr->this_page,
321 ChrPtr(WC->CurRoom.name)
324 /* Check for new mail. */
325 WC->new_mail = extract_int(&got[4], 9);
326 WC->CurRoom.view = extract_int(&got[4], 11);
328 /* Is this a directory room and does it contain files and how many? */
329 if ((WC->CurRoom.QRFlags & QR_DIRECTORY) && (WC->CurRoom.QRFlags & QR_VISDIR))
332 serv_getln(buf2, sizeof buf2);
333 if (buf2[0] == '1') while (serv_getln(buf2, sizeof buf2), strcmp(buf2, "000"))
335 snprintf (with_files, sizeof with_files,
336 "; <a href=\"do_template?template=files\"> %d %s </a>",
338 ((file_count>1) || (file_count == 0) ? _("files") : _("file")));
341 strcpy (with_files, "");
343 svprintf(HKEY("NUMMSGS"), WCS_STRING,
344 _("%d new of %d messages%s"),
345 extract_int(&got[4], 1),
346 extract_int(&got[4], 2),
349 svcallback("VIEWOMATIC", embed_view_o_matic);
351 do_template("roombanner", NULL);
352 /* roombanner contains this for mobile */
353 if (navbar_style != navbar_none && (WC->is_mobile < 1)) {
355 wc_printf("<div id=\"navbar\"><ul>");
357 if (navbar_style == navbar_default) wc_printf(
358 "<li class=\"ungoto\">"
359 "<a href=\"ungoto\">"
360 "<img src=\"static/ungoto2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
361 "<span class=\"navbar_link\">%s</span></A>"
362 "</li>\n", _("Ungoto")
365 if ( (navbar_style == navbar_default) && (WC->CurRoom.view == VIEW_BBS) ) {
367 "<li class=\"newmess\">"
368 "<a href=\"readnew\">"
369 "<img src=\"static/newmess2_24x.gif\" alt=\"\" width=\"24\" height=\"24\">"
370 "<span class=\"navbar_link\">%s</span></A>"
371 "</li>\n", _("Read new messages")
375 if (navbar_style == navbar_default) {
376 switch(WC->CurRoom.view) {
377 case VIEW_ADDRESSBOOK:
379 "<li class=\"viewcontacts\">"
380 "<a href=\"readfwd\">"
381 "<img src=\"static/viewcontacts_24x.gif\" "
382 "alt=\"\" width=\"24\" height=\"24\">"
383 "<span class=\"navbar_link\">"
385 "</span></a></li>\n", _("View contacts")
390 "<li class=\"staskday\">"
391 "<a href=\"readfwd?calview=day\">"
392 "<img src=\"static/taskday2_24x.gif\" "
393 "alt=\"\" width=\"24\" height=\"24\">"
394 "<span class=\"navbar_link\">"
396 "</span></a></li>\n", _("Day view")
399 "<li class=\"monthview\">"
400 "<a href=\"readfwd?calview=month\">"
401 "<img src=\"static/monthview2_24x.gif\" "
402 "alt=\"\" width=\"24\" height=\"24\">"
403 "<span class=\"navbar_link\">"
405 "</span></a></li>\n", _("Month view")
410 "<li class=\"monthview\">"
411 "<a href=\"readfwd?calview=month\">"
412 "<img src=\"static/monthview2_24x.gif\" "
413 "alt=\"\" width=\"24\" height=\"24\">"
414 "<span class=\"navbar_link\">"
416 "</span></a></li>\n", _("Calendar list")
421 "<li class=\"taskmanag\">"
422 "<a href=\"readfwd\">"
423 "<img src=\"static/taskmanag_24x.gif\" "
424 "alt=\"\" width=\"24\" height=\"24\">"
425 "<span class=\"navbar_link\">"
427 "</span></a></li>\n", _("View tasks")
432 "<li class=\"viewnotes\">"
433 "<a href=\"readfwd\">"
434 "<img src=\"static/viewnotes_24x.gif\" "
435 "alt=\"\" width=\"24\" height=\"24\">"
436 "<span class=\"navbar_link\">"
438 "</span></a></li>\n", _("View notes")
443 "<li class=\"readallmess\">"
444 "<a id=\"m_refresh\" href=\"readfwd\">"
445 "<img src=\"static/readallmess3_24x.gif\" "
446 "alt=\"\" width=\"24\" height=\"24\">"
447 "<span class=\"navbar_link\">"
449 "</span></a></li>\n", _("Refresh message list")
454 "<li class=\"readallmess\">"
455 "<a href=\"wiki?page=home\">"
456 "<img src=\"static/readallmess3_24x.gif\" "
457 "alt=\"\" width=\"24\" height=\"24\">"
458 "<span class=\"navbar_link\">"
460 "</span></a></li>\n", _("Wiki home")
465 "<li class=\"readallmess\">"
466 "<a href=\"readfwd\">"
467 "<img src=\"static/readallmess3_24x.gif\" "
468 "alt=\"\" width=\"24\" height=\"24\">"
469 "<span class=\"navbar_link\">"
471 "</span></a></li>\n", _("Read all messages")
477 if (navbar_style == navbar_default) {
478 switch(WC->CurRoom.view) {
479 case VIEW_ADDRESSBOOK:
481 "<li class=\"addnewcontact\">"
482 "<a href=\"display_enter\">"
483 "<img src=\"static/addnewcontact_24x.gif\" "
484 "alt=\"\" width=\"24\" height=\"24\">"
485 "<span class=\"navbar_link\">"
487 "</span></a></li>\n", _("Add new contact")
492 wc_printf("<li class=\"addevent\"><a href=\"display_enter");
493 if (havebstr("year" )) wc_printf("?year=%s", bstr("year"));
494 if (havebstr("month")) wc_printf("?month=%s", bstr("month"));
495 if (havebstr("day" )) wc_printf("?day=%s", bstr("day"));
497 "<img src=\"static/addevent_24x.gif\" "
498 "alt=\"\" width=\"24\" height=\"24\">"
499 "<span class=\"navbar_link\">"
501 "</span></a></li>\n", _("Add new event")
506 "<li class=\"newmess\">"
507 "<a href=\"display_enter\">"
508 "<img src=\"static/newmess3_24x.gif\" "
509 "alt=\"\" width=\"24\" height=\"24\">"
510 "<span class=\"navbar_link\">"
512 "</span></a></li>\n", _("Add new task")
517 "<li class=\"enternewnote\">"
518 "<a href=\"add_new_note\">"
519 "<img src=\"static/enternewnote_24x.gif\" "
520 "alt=\"\" width=\"24\" height=\"24\">"
521 "<span class=\"navbar_link\">"
523 "</span></a></li>\n", _("Add new note")
527 safestrncpy(buf, bstr("page"), sizeof buf);
528 if (IsEmptyStr(buf)) {
529 safestrncpy(buf, "home", sizeof buf);
533 "<li class=\"newmess\">"
534 "<a href=\"display_enter?page=%s\">"
535 "<img src=\"static/newmess3_24x.gif\" "
536 "alt=\"\" width=\"24\" height=\"24\">"
537 "<span class=\"navbar_link\">"
539 "</span></a></li>\n", buf, _("Edit this page")
542 if (bmstrcasestr((char *)ChrPtr(WCC->Hdr->HR.ReqLine), "wiki_history")) {
543 /* already viewing history; display a link to the current page */
545 "<li class=\"newmess\">"
546 "<a href=\"wiki?page=%s\">"
547 "<img src=\"static/newmess3_24x.gif\" "
548 "alt=\"\" width=\"24\" height=\"24\">"
549 "<span class=\"navbar_link\">"
551 "</span></a></li>\n", buf, _("Current version")
555 /* display a link to the history */
557 "<li class=\"newmess\">"
558 "<a href=\"wiki_history?page=%s\">"
559 "<img src=\"static/newmess3_24x.gif\" "
560 "alt=\"\" width=\"24\" height=\"24\">"
561 "<span class=\"navbar_link\">"
563 "</span></a></li>\n", buf, _("History")
569 "<li class=\"newmess\">"
570 "<a href=\"display_enter\">"
571 "<img src=\"static/newmess3_24x.gif\" "
572 "alt=\"\" width=\"24\" height=\"24\">"
573 "<span class=\"navbar_link\">"
575 "</span></a></li>\n", _("Write mail")
578 "<li class=\"newmess\">"
579 "<a href=\"javascript:deleteAllSelectedMessages();\">"
580 "<img src=\"static/delete.gif\" "
581 "alt=\"\" width=\"24\" height=\"24\"><span class=\"navbar_link\">"
583 "</span></a></li>\n", _("Delete")
588 "<li class=\"newmess\">"
589 "<a href=\"display_enter\">"
590 "<img src=\"static/newmess3_24x.gif\" "
591 "alt=\"\" width=\"24\" height=\"24\">"
592 "<span class=\"navbar_link\">"
594 "</span></a></li>\n", _("Enter a message")
600 if (navbar_style == navbar_default) wc_printf(
601 "<li class=\"skipthisroom\">"
604 "<img src=\"static/skipthisroom_24x.gif\" alt=\"\" "
605 "width=\"24\" height=\"24\">"
606 "<span class=\"navbar_link\">%s</span></a>"
608 _("Leave all messages marked as unread, go to next room with unread messages"),
612 if (navbar_style == navbar_default) wc_printf(
613 "<li class=\"markngo\">"
614 "<a href=\"gotonext\" "
616 "<img src=\"static/markngo_24x.gif\" alt=\"\" "
617 "width=\"24\" height=\"24\">"
618 "<span class=\"navbar_link\">%s</span></a>"
620 _("Mark all messages as read, go to next room with unread messages"),
624 wc_printf("</ul></div>\n");
631 * back end routine to take the session to a new room
633 long gotoroom(const StrBuf *gname)
637 static long ls = (-1L);
640 /* store ungoto information */
641 strcpy(WCC->ugname, ChrPtr(WCC->CurRoom.name));
645 /* move to the new room */
646 serv_printf("GOTO %s", ChrPtr(gname));
647 StrBuf_ServGetln(Buf);
648 if (GetServerStatus(Buf, &err) != 2) {
649 serv_puts("GOTO _BASEROOM_");
650 StrBuf_ServGetln(Buf);
652 * well, we know that this is the fallback case,
653 * but we're interested that the first command
654 * didn't work out in first place.
656 if (GetServerStatus(Buf, NULL) != 2) {
661 ParseGoto(&WCC->CurRoom, Buf);
663 remove_march(WCC->CurRoom.name);
664 if (!strcasecmp(ChrPtr(gname), "_BASEROOM_"))
672 void ParseGoto(folder *room, StrBuf *Line)
680 if (StrLength(Line) < 4) {
684 /* ignore the commandstate... */
685 Pos = ChrPtr(Line) + 4;
687 if (room->RoomNameParts != NULL)
690 for (i=0; i < room->nRoomNameParts; i++)
691 FreeStrBuf(&room->RoomNameParts[i]);
692 free(room->RoomNameParts);
693 room->RoomNameParts = NULL;
698 pBuf = NewStrBufPlain(NULL, StrLength(Line));
701 memset(room, 0, sizeof(folder));
704 StrBufExtract_NextToken(room->name, Line, &Pos, '|'); // WC->CurRoom->name
706 room->nNewMessages = StrBufExtractNext_long(Line, &Pos, '|');
707 if (room->nNewMessages > 0)
708 room->RAFlags |= UA_HASNEWMSGS;
710 room->nTotalMessages = StrBufExtractNext_long(Line, &Pos, '|');
712 room->ShowInfo = StrBufExtractNext_long(Line, &Pos, '|');
714 room->QRFlags = StrBufExtractNext_long(Line, &Pos, '|'); //CurRoom->QRFlags
716 room->HighestRead = StrBufExtractNext_long(Line, &Pos, '|');
717 room->LastMessageRead = StrBufExtractNext_long(Line, &Pos, '|');
719 room->is_inbox = StrBufExtractNext_long(Line, &Pos, '|'); // is_mailbox
721 flag = StrBufExtractNext_long(Line, &Pos, '|');
722 if (WCC->is_aide || flag) {
723 room->RAFlags |= UA_ADMINALLOWED;
726 room->UsersNewMAilboxMessages = StrBufExtractNext_long(Line, &Pos, '|');
728 room->floorid = StrBufExtractNext_int(Line, &Pos, '|'); // wc_floor
730 room->view = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->view
732 room->defview = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->defview
734 flag = StrBufExtractNext_long(Line, &Pos, '|');
736 room->RAFlags |= UA_ISTRASH; // wc_is_trash
738 room->QRFlags2 = StrBufExtractNext_long(Line, &Pos, '|'); // CurRoom->QRFlags2
740 /* find out, whether we are in a sub-room */
741 room->nRoomNameParts = StrBufNum_tokens(room->name, '\\');
742 if (room->nRoomNameParts > 1)
747 room->RoomNameParts = malloc(sizeof(StrBuf*) * (room->nRoomNameParts + 1));
748 memset(room->RoomNameParts, 0, sizeof(StrBuf*) * (room->nRoomNameParts + 1));
749 for (i=0; i < room->nRoomNameParts; i++)
751 room->RoomNameParts[i] = NewStrBuf();
752 StrBufExtract_NextToken(room->RoomNameParts[i],
753 room->name, &Pos, '\\');
757 /* Private mailboxes on the main floor get remapped to the personal folder */
758 if ((room->QRFlags & QR_MAILBOX) &&
759 (room->floorid == 0))
761 room->floorid = VIRTUAL_MY_FLOOR;
762 if ((room->nRoomNameParts == 1) &&
763 (StrLength(room->name) == 4) &&
764 (strcmp(ChrPtr(room->name), "Mail") == 0))
770 /* get a pointer to the floor we're on: */
771 if (WCC->Floors == NULL)
772 GetFloorListHash(NULL, NULL);
774 GetHash(WCC->Floors, IKEY(room->floorid), &vFloor);
775 room->Floor = (const Floor*) vFloor;
778 void LoadRoomAide(void)
783 if (WCC->CurRoom.RoomAideLoaded)
786 WCC->CurRoom.RoomAideLoaded = 1;
789 StrBuf_ServGetln(Buf);
790 if (GetServerStatus(Buf, NULL) != 2) {
791 FlushStrBuf(WCC->CurRoom.RoomAide);
792 AppendImportantMessage (ChrPtr(Buf) + 4,
797 Pos = ChrPtr(Buf) + 4;
799 FreeStrBuf(&WCC->CurRoom.RoomAide);
800 WCC->CurRoom.RoomAide = NewStrBufPlain (NULL, StrLength (Buf));
802 StrBufExtract_NextToken(WCC->CurRoom.RoomAide, Buf, &Pos, '|');
806 void tmplput_CurrentRoomFloorName(StrBuf *Target, WCTemplputParams *TP)
809 folder *Folder = &WCC->CurRoom;
810 const Floor *pFloor = Folder->Floor;
815 StrBufAppendTemplate(Target, TP, pFloor->Name, 0);
818 void tmplput_CurrentRoomAide(StrBuf *Target, WCTemplputParams *TP)
824 StrBufAppendTemplate(Target, TP, WCC->CurRoom.RoomAide, 0);
828 void LoadRoomXA (void)
833 if (WCC->CurRoom.XALoaded)
836 WCC->CurRoom.XALoaded = 1;
839 StrBuf_ServGetln(Buf);
840 if (GetServerStatus(Buf, NULL) != 2) {
841 FlushStrBuf(WCC->CurRoom.XAPass);
842 FlushStrBuf(WCC->CurRoom.Directory);
844 AppendImportantMessage (ChrPtr(Buf) + 4,
849 Pos = ChrPtr(Buf) + 4;
851 FreeStrBuf(&WCC->CurRoom.XAPass);
852 FreeStrBuf(&WCC->CurRoom.Directory);
854 WCC->CurRoom.XAPass = NewStrBufPlain (NULL, StrLength (Buf));
855 WCC->CurRoom.Directory = NewStrBufPlain (NULL, StrLength (Buf));
857 StrBufSkip_NTokenS(Buf, &Pos, '|', 1); /* The Name, we already know... */
858 StrBufExtract_NextToken(WCC->CurRoom.XAPass, Buf, &Pos, '|');
859 StrBufExtract_NextToken(WCC->CurRoom.Directory, Buf, &Pos, '|');
860 StrBufSkip_NTokenS(Buf, &Pos, '|', 2); /* QRFlags, FloorNum we already know... */
861 WCC->CurRoom.Order = StrBufExtractNext_long(Buf, &Pos, '|');
862 WCC->CurRoom.DefView = StrBufExtractNext_long(Buf, &Pos, '|');
863 /* QR2Flags, we already know them... */
870 void LoadXRoomPic(void)
875 if (WCC->CurRoom.XHaveRoomPicLoaded)
878 WCC->CurRoom.XHaveRoomPicLoaded = 1;
880 serv_puts("OIMG _roompic_");
881 StrBuf_ServGetln(Buf);
882 if (GetServerStatus(Buf, NULL) != 2) {
883 WCC->CurRoom.XHaveRoomPic = 0;
885 WCC->CurRoom.XHaveRoomPic = 1;
888 StrBuf_ServGetln(Buf);
889 GetServerStatus(Buf, NULL);
893 int ConditionalThisRoomXHavePic(StrBuf *Target, WCTemplputParams *TP)
901 return WCC->CurRoom.XHaveRoomPic == 1;
904 void LoadXRoomInfoText(void)
910 if (WCC->CurRoom.XHaveInfoTextLoaded)
913 WCC->CurRoom.XHaveInfoTextLoaded = 1;
918 StrBuf_ServGetln(Buf);
919 if (GetServerStatus(Buf, NULL) == 1) {
920 WCC->CurRoom.XInfoText = NewStrBuf ();
922 while (!Done && StrBuf_ServGetln(Buf)>=0) {
923 if ( (StrLength(Buf)==3) &&
924 !strcmp(ChrPtr(Buf), "000"))
927 StrBufAppendBuf(WCC->CurRoom.XInfoText, Buf, 0);
934 int ConditionalThisRoomXHaveInfoText(StrBuf *Target, WCTemplputParams *TP)
942 return (StrLength(WCC->CurRoom.XInfoText)>0);
945 void tmplput_CurrentRoomInfoText(StrBuf *Target, WCTemplputParams *TP)
951 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 1);
954 void tmplput_CurrentRoomPass(StrBuf *Target, WCTemplputParams *TP)
960 StrBufAppendTemplate(Target, TP, WCC->CurRoom.XAPass, 0);
962 void tmplput_CurrentRoomDirectory(StrBuf *Target, WCTemplputParams *TP)
968 StrBufAppendTemplate(Target, TP, WCC->CurRoom.Directory, 0);
970 void tmplput_CurrentRoomOrder(StrBuf *Target, WCTemplputParams *TP)
976 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.Order);
978 void tmplput_CurrentRoomDefView(StrBuf *Target, WCTemplputParams *TP)
984 StrBufAppendPrintf(Target, "%d", WCC->CurRoom.DefView);
988 int ConditionalThisRoomOrder(StrBuf *Target, WCTemplputParams *TP)
998 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
999 return CheckThis == WCC->CurRoom.Order;
1002 int ConditionalThisRoomDefView(StrBuf *Target, WCTemplputParams *TP)
1004 wcsession *WCC = WC;
1012 CheckThis = GetTemplateTokenNumber(Target, TP, 2, 0);
1013 return CheckThis == WCC->CurRoom.DefView;
1023 void smart_goto(const StrBuf *next_room) {
1024 gotoroom(next_room);
1025 readloop(readnew, eUseDefault);
1031 * mark all messages in current room as having been read
1033 void slrp_highest(void)
1037 serv_puts("SLRP HIGHEST");
1038 serv_getln(buf, sizeof buf);
1042 typedef struct __room_states {
1057 * Set/clear/read the "self-service list subscribe" flag for a room
1059 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1060 * returns the new value.
1063 int self_service(int newval) {
1064 int current_value = 0;
1070 int flags, floor, order, view, flags2;
1073 serv_getln(buf, sizeof buf);
1074 if (buf[0] != '2') return(0);
1076 extract_token(name, &buf[4], 0, '|', sizeof name);
1077 extract_token(password, &buf[4], 1, '|', sizeof password);
1078 extract_token(dirname, &buf[4], 2, '|', sizeof dirname);
1079 flags = extract_int(&buf[4], 3);
1080 floor = extract_int(&buf[4], 4);
1081 order = extract_int(&buf[4], 5);
1082 view = extract_int(&buf[4], 6);
1083 flags2 = extract_int(&buf[4], 7);
1085 if (flags2 & QR2_SELFLIST) {
1093 flags2 = flags2 | QR2_SELFLIST;
1095 else if (newval == 0) {
1096 flags2 = flags2 & ~QR2_SELFLIST;
1099 return(current_value);
1102 if (newval != current_value) {
1103 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1104 name, password, dirname, flags,
1105 floor, order, view, flags2);
1106 serv_getln(buf, sizeof buf);
1113 int is_selflist(room_states *RoomFlags)
1115 return ((RoomFlags->flags2 & QR2_SELFLIST) != 0);
1118 int is_publiclist(room_states *RoomFlags)
1120 return ((RoomFlags->flags2 & QR2_SMTP_PUBLIC) != 0);
1123 int is_moderatedlist(room_states *RoomFlags)
1125 return ((RoomFlags->flags2 & QR2_MODERATED) != 0);
1129 * Set/clear/read the "self-service list subscribe" flag for a room
1131 * set newval to 0 to clear, 1 to set, any other value to leave unchanged.
1132 * returns the new value.
1135 int get_roomflags(room_states *RoomOps)
1140 serv_getln(buf, sizeof buf);
1141 if (buf[0] != '2') return(0);
1143 extract_token(RoomOps->name, &buf[4], 0, '|', sizeof RoomOps->name);
1144 extract_token(RoomOps->password, &buf[4], 1, '|', sizeof RoomOps->password);
1145 extract_token(RoomOps->dirname, &buf[4], 2, '|', sizeof RoomOps->dirname);
1146 RoomOps->flags = extract_int(&buf[4], 3);
1147 RoomOps->floor = extract_int(&buf[4], 4);
1148 RoomOps->order = extract_int(&buf[4], 5);
1149 RoomOps->view = extract_int(&buf[4], 6);
1150 RoomOps->flags2 = extract_int(&buf[4], 7);
1154 int set_roomflags(room_states *RoomOps)
1158 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
1167 serv_getln(buf, sizeof buf);
1177 * display the form for editing a room
1179 void display_editroom(void)
1185 char remote_room[128];
1188 char er_password[10];
1189 char er_dirname[15];
1190 char er_roomaide[26];
1197 char *not_shared_with = NULL;
1200 int floorpolicy = 0;
1202 char pop3_host[128];
1207 if (IsEmptyStr(tab)) tab = "admin";
1210 load_floorlist(Buf);
1212 output_headers(1, 1, 1, 0, 0, 0);
1214 wc_printf("<div class=\"fix_scrollbar_bug\">");
1216 wc_printf("<br />\n");
1218 /* print the tabbed dialog */
1219 wc_printf("<div align=\"center\">");
1220 wc_printf("<table id=\"AdminTabs\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"
1221 "<tr align=\"center\" style=\"cursor:pointer\"><td> </td>"
1224 wc_printf("<td class=\"");
1225 if (!strcmp(tab, "admin")) {
1226 wc_printf(" tab_cell_label\">");
1227 wc_printf(_("Administration"));
1230 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=admin\">");
1231 wc_printf(_("Administration"));
1234 wc_printf("</td>\n");
1235 wc_printf("<td> </td>\n");
1237 if ( ConditionalHaveRoomeditRights(NULL, NULL)) {
1239 wc_printf("<td class=\"");
1240 if (!strcmp(tab, "config")) {
1241 wc_printf(" tab_cell_label\">");
1242 wc_printf(_("Configuration"));
1245 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=config\">");
1246 wc_printf(_("Configuration"));
1249 wc_printf("</td>\n");
1250 wc_printf("<td> </td>\n");
1252 wc_printf("<td class=\"");
1253 if (!strcmp(tab, "expire")) {
1254 wc_printf(" tab_cell_label\">");
1255 wc_printf(_("Message expire policy"));
1258 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=expire\">");
1259 wc_printf(_("Message expire policy"));
1262 wc_printf("</td>\n");
1263 wc_printf("<td> </td>\n");
1265 wc_printf("<td class=\"");
1266 if (!strcmp(tab, "access")) {
1267 wc_printf(" tab_cell_label\">");
1268 wc_printf(_("Access controls"));
1271 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=access\">");
1272 wc_printf(_("Access controls"));
1275 wc_printf("</td>\n");
1276 wc_printf("<td> </td>\n");
1278 wc_printf("<td class=\"");
1279 if (!strcmp(tab, "sharing")) {
1280 wc_printf(" tab_cell_label\">");
1281 wc_printf(_("Sharing"));
1284 wc_printf(" tab_cell_edit\"><a href=\"display_editroom?tab=sharing\">");
1285 wc_printf(_("Sharing"));
1288 wc_printf("</td>\n");
1289 wc_printf("<td> </td>\n");
1291 wc_printf("<td class=\"");
1292 if (!strcmp(tab, "listserv")) {
1293 wc_printf(" tab_cell_label\">");
1294 wc_printf(_("Mailing list service"));
1297 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=listserv\">");
1298 wc_printf(_("Mailing list service"));
1301 wc_printf("</td>\n");
1302 wc_printf("<td> </td>\n");
1306 wc_printf("<td class=\"");
1307 if (!strcmp(tab, "feeds")) {
1308 wc_printf(" tab_cell_label\">");
1309 wc_printf(_("Remote retrieval"));
1312 wc_printf("< tab_cell_edit\"><a href=\"display_editroom?tab=feeds\">");
1313 wc_printf(_("Remote retrieval"));
1316 wc_printf("</td>\n");
1317 wc_printf("<td> </td>\n");
1319 wc_printf("</tr></table>\n");
1320 wc_printf("</div>\n");
1321 /* end tabbed dialog */
1323 wc_printf("<script type=\"text/javascript\">"
1324 " Nifty(\"table#AdminTabs td\", \"small transparent top\");"
1328 /* begin content of whatever tab is open now */
1330 if (!strcmp(tab, "admin")) {
1331 wc_printf("<div class=\"tabcontent\">");
1333 "<li><a href=\"delete_room\" "
1334 "onClick=\"return confirm('");
1335 wc_printf(_("Are you sure you want to delete this room?"));
1336 wc_printf("');\">\n");
1337 wc_printf(_("Delete this room"));
1339 "<li><a href=\"display_editroompic?which_room=");
1340 urlescputs(ChrPtr(WC->CurRoom.name));
1342 wc_printf(_("Set or change the icon for this room's banner"));
1344 "<li><a href=\"display_editinfo\">\n");
1345 wc_printf(_("Edit this room's Info file"));
1348 wc_printf("</div>");
1351 if (!strcmp(tab, "config")) {
1352 wc_printf("<div class=\"tabcontent\">");
1354 serv_getln(buf, sizeof buf);
1356 if (!strncmp(buf, "550", 3)) {
1357 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1358 _("Higher access is required to access this function.")
1361 else if (buf[0] != '2') {
1362 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1365 extract_token(er_name, &buf[4], 0, '|', sizeof er_name);
1366 extract_token(er_password, &buf[4], 1, '|', sizeof er_password);
1367 extract_token(er_dirname, &buf[4], 2, '|', sizeof er_dirname);
1368 er_flags = extract_int(&buf[4], 3);
1369 er_floor = extract_int(&buf[4], 4);
1370 er_flags2 = extract_int(&buf[4], 7);
1372 wc_printf("<form method=\"POST\" action=\"editroom\">\n");
1373 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1375 wc_printf("<ul><li>");
1376 wc_printf(_("Name of room: "));
1377 wc_printf("<input type=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\""ULONG_FMT"\">\n",
1383 wc_printf(_("Resides on floor: "));
1384 wc_printf("<select NAME=\"er_floor\" SIZE=\"1\"");
1385 if (er_flags & QR_MAILBOX)
1386 wc_printf("disabled >\n");
1387 for (i = 0; i < 128; ++i)
1388 if (!IsEmptyStr(floorlist[i])) {
1389 wc_printf("<OPTION ");
1391 wc_printf("SELECTED ");
1392 wc_printf("VALUE=\"%d\">", i);
1393 escputs(floorlist[i]);
1394 wc_printf("</OPTION>\n");
1396 wc_printf("</select>\n");
1399 wc_printf(_("Type of room:"));
1400 wc_printf("<ul>\n");
1402 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
1403 if ((er_flags & (QR_PRIVATE + QR_MAILBOX)) == 0)
1404 wc_printf("CHECKED ");
1405 wc_printf("OnChange=\""
1406 " if (this.form.type[0].checked == true) { "
1407 " this.form.er_floor.disabled = false; "
1410 wc_printf(_("Public (automatically appears to everyone)"));
1413 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" ");
1414 if ((er_flags & QR_PRIVATE) &&
1415 (er_flags & QR_GUESSNAME))
1416 wc_printf("CHECKED ");
1417 wc_printf(" OnChange=\""
1418 " if (this.form.type[1].checked == true) { "
1419 " this.form.er_floor.disabled = false; "
1422 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
1424 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" ");
1425 if ((er_flags & QR_PRIVATE) &&
1426 (er_flags & QR_PASSWORDED))
1427 wc_printf("CHECKED ");
1428 wc_printf(" OnChange=\""
1429 " if (this.form.type[2].checked == true) { "
1430 " this.form.er_floor.disabled = false; "
1433 wc_printf(_("Private - require password: "));
1434 wc_printf("\n<input type=\"text\" NAME=\"er_password\" VALUE=\"%s\" MAXLENGTH=\"9\">\n",
1437 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
1438 if ((er_flags & QR_PRIVATE)
1439 && ((er_flags & QR_GUESSNAME) == 0)
1440 && ((er_flags & QR_PASSWORDED) == 0))
1441 wc_printf("CHECKED ");
1442 wc_printf(" OnChange=\""
1443 " if (this.form.type[3].checked == true) { "
1444 " this.form.er_floor.disabled = false; "
1447 wc_printf(_("Private - invitation only"));
1449 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
1450 if (er_flags & QR_MAILBOX)
1451 wc_printf("CHECKED ");
1452 wc_printf (" OnChange=\""
1453 " if (this.form.type[4].checked == true) { "
1454 " this.form.er_floor.disabled = true; "
1457 wc_printf(_("Personal (mailbox for you only)"));
1459 wc_printf("\n<li><input type=\"checkbox\" NAME=\"bump\" VALUE=\"yes\" ");
1461 wc_printf(_("If private, cause current users to forget room"));
1463 wc_printf("\n</ul>\n");
1465 wc_printf("<li><input type=\"checkbox\" NAME=\"prefonly\" VALUE=\"yes\" ");
1466 if (er_flags & QR_PREFONLY)
1467 wc_printf("CHECKED ");
1469 wc_printf(_("Preferred users only"));
1471 wc_printf("\n<li><input type=\"checkbox\" NAME=\"readonly\" VALUE=\"yes\" ");
1472 if (er_flags & QR_READONLY)
1473 wc_printf("CHECKED ");
1475 wc_printf(_("Read-only room"));
1477 wc_printf("\n<li><input type=\"checkbox\" NAME=\"collabdel\" VALUE=\"yes\" ");
1478 if (er_flags2 & QR2_COLLABDEL)
1479 wc_printf("CHECKED ");
1481 wc_printf(_("All users allowed to post may also delete messages"));
1483 /** directory stuff */
1484 wc_printf("\n<li><input type=\"checkbox\" NAME=\"directory\" VALUE=\"yes\" ");
1485 if (er_flags & QR_DIRECTORY)
1486 wc_printf("CHECKED ");
1488 wc_printf(_("File directory room"));
1490 wc_printf("\n<ul><li>");
1491 wc_printf(_("Directory name: "));
1492 wc_printf("<input type=\"text\" NAME=\"er_dirname\" VALUE=\"%s\" MAXLENGTH=\"14\">\n",
1495 wc_printf("<li><input type=\"checkbox\" NAME=\"ulallowed\" VALUE=\"yes\" ");
1496 if (er_flags & QR_UPLOAD)
1497 wc_printf("CHECKED ");
1499 wc_printf(_("Uploading allowed"));
1501 wc_printf("\n<li><input type=\"checkbox\" NAME=\"dlallowed\" VALUE=\"yes\" ");
1502 if (er_flags & QR_DOWNLOAD)
1503 wc_printf("CHECKED ");
1505 wc_printf(_("Downloading allowed"));
1507 wc_printf("\n<li><input type=\"checkbox\" NAME=\"visdir\" VALUE=\"yes\" ");
1508 if (er_flags & QR_VISDIR)
1509 wc_printf("CHECKED ");
1511 wc_printf(_("Visible directory"));
1512 wc_printf("</ul>\n");
1514 /** end of directory stuff */
1516 wc_printf("<li><input type=\"checkbox\" NAME=\"network\" VALUE=\"yes\" ");
1517 if (er_flags & QR_NETWORK)
1518 wc_printf("CHECKED ");
1520 wc_printf(_("Network shared room"));
1522 wc_printf("\n<li><input type=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
1523 if (er_flags & QR_PERMANENT)
1524 wc_printf("CHECKED ");
1526 wc_printf(_("Permanent (does not auto-purge)"));
1528 wc_printf("\n<li><input type=\"checkbox\" NAME=\"subjectreq\" VALUE=\"yes\" ");
1529 if (er_flags2 & QR2_SUBJECTREQ)
1530 wc_printf("CHECKED ");
1532 wc_printf(_("Subject Required (Force users to specify a message subject)"));
1534 /** start of anon options */
1536 wc_printf("\n<li>");
1537 wc_printf(_("Anonymous messages"));
1538 wc_printf("<ul>\n");
1540 wc_printf("<li><input type=\"radio\" NAME=\"anon\" VALUE=\"no\" ");
1541 if (((er_flags & QR_ANONONLY) == 0)
1542 && ((er_flags & QR_ANONOPT) == 0))
1543 wc_printf("CHECKED ");
1545 wc_printf(_("No anonymous messages"));
1547 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anononly\" ");
1548 if (er_flags & QR_ANONONLY)
1549 wc_printf("CHECKED ");
1551 wc_printf(_("All messages are anonymous"));
1553 wc_printf("\n<li><input type=\"radio\" NAME=\"anon\" VALUE=\"anon2\" ");
1554 if (er_flags & QR_ANONOPT)
1555 wc_printf("CHECKED ");
1557 wc_printf(_("Prompt user when entering messages"));
1558 wc_printf("</ul>\n");
1560 /* end of anon options */
1563 wc_printf(_("Room aide: "));
1565 serv_getln(buf, sizeof buf);
1566 if (buf[0] != '2') {
1567 wc_printf("<em>%s</em>\n", &buf[4]);
1569 extract_token(er_roomaide, &buf[4], 0, '|', sizeof er_roomaide);
1570 wc_printf("<input type=\"text\" NAME=\"er_roomaide\" VALUE=\"%s\" MAXLENGTH=\"25\">\n", er_roomaide);
1573 wc_printf("</ul><CENTER>\n");
1574 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
1575 "<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">"
1577 "<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">"
1583 wc_printf("</div>");
1587 /* Sharing the room with other Citadel nodes... */
1588 if (!strcmp(tab, "sharing")) {
1589 wc_printf("<div class=\"tabcontent\">");
1591 shared_with = strdup("");
1592 not_shared_with = strdup("");
1594 /** Learn the current configuration */
1595 serv_puts("CONF getsys|application/x-citadel-ignet-config");
1596 serv_getln(buf, sizeof buf);
1597 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1598 extract_token(node, buf, 0, '|', sizeof node);
1599 not_shared_with = realloc(not_shared_with,
1600 strlen(not_shared_with) + 32);
1601 strcat(not_shared_with, node);
1602 strcat(not_shared_with, "\n");
1606 serv_getln(buf, sizeof buf);
1607 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1608 extract_token(cmd, buf, 0, '|', sizeof cmd);
1609 extract_token(node, buf, 1, '|', sizeof node);
1610 extract_token(remote_room, buf, 2, '|', sizeof remote_room);
1611 if (!strcasecmp(cmd, "ignet_push_share")) {
1612 shared_with = realloc(shared_with,
1613 strlen(shared_with) + 32);
1614 strcat(shared_with, node);
1615 if (!IsEmptyStr(remote_room)) {
1616 strcat(shared_with, "|");
1617 strcat(shared_with, remote_room);
1619 strcat(shared_with, "\n");
1623 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1624 extract_token(buf, shared_with, i, '\n', sizeof buf);
1625 extract_token(node, buf, 0, '|', sizeof node);
1626 for (j=0; j<num_tokens(not_shared_with, '\n'); ++j) {
1627 extract_token(cmd, not_shared_with, j, '\n', sizeof cmd);
1628 if (!strcasecmp(node, cmd)) {
1629 remove_token(not_shared_with, j, '\n');
1634 /* Display the stuff */
1635 wc_printf("<CENTER><br />"
1636 "<table border=1 cellpadding=5><tr>"
1638 wc_printf(_("Shared with"));
1639 wc_printf("</I></B></td>"
1641 wc_printf(_("Not shared with"));
1642 wc_printf("</I></B></td></tr>\n"
1643 "<tr><td VALIGN=TOP>\n");
1645 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1646 wc_printf(_("Remote node name"));
1647 wc_printf("</td><td>");
1648 wc_printf(_("Remote room name"));
1649 wc_printf("</td><td>");
1650 wc_printf(_("Actions"));
1651 wc_printf("</td></tr>\n");
1653 for (i=0; i<num_tokens(shared_with, '\n'); ++i) {
1654 extract_token(buf, shared_with, i, '\n', sizeof buf);
1655 extract_token(node, buf, 0, '|', sizeof node);
1656 extract_token(remote_room, buf, 1, '|', sizeof remote_room);
1657 if (!IsEmptyStr(node)) {
1658 wc_printf("<form method=\"POST\" action=\"netedit\">");
1659 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1660 wc_printf("<tr><td>%s</td>\n", node);
1663 if (!IsEmptyStr(remote_room)) {
1664 escputs(remote_room);
1670 wc_printf("<input type=\"hidden\" NAME=\"line\" "
1671 "VALUE=\"ignet_push_share|");
1673 if (!IsEmptyStr(remote_room)) {
1675 urlescputs(remote_room);
1678 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"sharing\">\n");
1679 wc_printf("<input type=\"hidden\" NAME=\"cmd\" VALUE=\"remove\">\n");
1680 wc_printf("<input type=\"submit\" "
1681 "NAME=\"unshare_button\" VALUE=\"%s\">", _("Unshare"));
1682 wc_printf("</td></tr></form>\n");
1686 wc_printf("</table>\n");
1687 wc_printf("</td><td VALIGN=TOP>\n");
1688 wc_printf("<table border=0 cellpadding=5><tr class=\"tab_cell\"><td>");
1689 wc_printf(_("Remote node name"));
1690 wc_printf("</td><td>");
1691 wc_printf(_("Remote room name"));
1692 wc_printf("</td><td>");
1693 wc_printf(_("Actions"));
1694 wc_printf("</td></tr>\n");
1696 for (i=0; i<num_tokens(not_shared_with, '\n'); ++i) {
1697 extract_token(node, not_shared_with, i, '\n', sizeof node);
1698 if (!IsEmptyStr(node)) {
1699 wc_printf("<form method=\"POST\" action=\"netedit\">");
1700 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1701 wc_printf("<tr><td>");
1703 wc_printf("</td><td>"
1704 "<input type=\"INPUT\" "
1708 wc_printf("<input type=\"hidden\" "
1710 "VALUE=\"ignet_push_share|");
1713 wc_printf("<input type=\"hidden\" NAME=\"tab\" "
1714 "VALUE=\"sharing\">\n");
1715 wc_printf("<input type=\"hidden\" NAME=\"cmd\" "
1716 "VALUE=\"add\">\n");
1717 wc_printf("<input type=\"submit\" "
1718 "NAME=\"add_button\" VALUE=\"%s\">", _("Share"));
1719 wc_printf("</td></tr></form>\n");
1723 wc_printf("</table>\n");
1724 wc_printf("</td></tr>"
1725 "</table></CENTER><br />\n"
1726 "<I><B>%s</B><ul><li>", _("Notes:"));
1727 wc_printf(_("When sharing a room, "
1728 "it must be shared from both ends. Adding a node to "
1729 "the 'shared' list sends messages out, but in order to"
1730 " receive messages, the other nodes must be configured"
1731 " to send messages out to your system as well. "
1732 "<li>If the remote room name is blank, it is assumed "
1733 "that the room name is identical on the remote node."
1734 "<li>If the remote room name is different, the remote "
1735 "node must also configure the name of the room here."
1739 wc_printf("</div>");
1742 if (not_shared_with != NULL)
1743 free (not_shared_with);
1745 /* Mailing list management */
1746 if (!strcmp(tab, "listserv")) {
1747 room_states RoomFlags;
1748 wc_printf("<div class=\"tabcontent\">");
1750 wc_printf("<br /><center>"
1751 "<table BORDER=0 WIDTH=100%% CELLPADDING=5>"
1752 "<tr><td VALIGN=TOP>");
1754 wc_printf(_("<i>The contents of this room are being "
1755 "mailed <b>as individual messages</b> "
1756 "to the following list recipients:"
1757 "</i><br /><br />\n"));
1760 serv_getln(buf, sizeof buf);
1761 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1762 extract_token(cmd, buf, 0, '|', sizeof cmd);
1763 if (!strcasecmp(cmd, "listrecp")) {
1764 extract_token(recp, buf, 1, '|', sizeof recp);
1767 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line=listrecp|");
1770 wc_printf(_("(remove)"));
1771 wc_printf("</A><br />");
1774 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1775 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1776 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
1777 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1778 wc_printf("<input type=\"text\" id=\"add_as_listrecp\" NAME=\"line\">\n");
1779 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1780 wc_printf("</form>\n");
1782 wc_printf("</td><td VALIGN=TOP>\n");
1784 wc_printf(_("<i>The contents of this room are being "
1785 "mailed <b>in digest form</b> "
1786 "to the following list recipients:"
1787 "</i><br /><br />\n"));
1790 serv_getln(buf, sizeof buf);
1791 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1792 extract_token(cmd, buf, 0, '|', sizeof cmd);
1793 if (!strcasecmp(cmd, "digestrecp")) {
1794 extract_token(recp, buf, 1, '|', sizeof recp);
1797 wc_printf(" <a href=\"netedit?cmd=remove?tab=listserv?line="
1801 wc_printf(_("(remove)"));
1802 wc_printf("</A><br />");
1805 wc_printf("<br /><form method=\"POST\" action=\"netedit\">\n"
1806 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
1807 "<input type=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
1808 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1809 wc_printf("<input type=\"text\" id=\"add_as_digestrecp\" NAME=\"line\">\n");
1810 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
1811 wc_printf("</form>\n");
1813 wc_printf("</td></tr></table>\n");
1815 /** Pop open an address book -- begin **/
1816 wc_printf("<div align=right>"
1817 "<a href=\"javascript:PopOpenAddressBook('add_as_listrecp|%s|add_as_digestrecp|%s');\" "
1819 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
1824 _("Add recipients from Contacts or other address books"),
1825 _("Add recipients from Contacts or other address books")
1827 /* Pop open an address book -- end **/
1829 wc_printf("<br />\n<form method=\"GET\" action=\"toggle_self_service\">\n");
1831 get_roomflags (&RoomFlags);
1833 /* Self Service subscription? */
1834 wc_printf("<table><tr><td>\n");
1835 wc_printf(_("Allow self-service subscribe/unsubscribe requests."));
1836 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SelfList\" value=\"yes\" %s></td></tr>\n"
1837 " <tr><td colspan=\"2\">\n",
1838 (is_selflist(&RoomFlags))?"checked":"");
1839 wc_printf(_("The URL for subscribe/unsubscribe is: "));
1840 wc_printf("<TT>%s://%s/listsub</TT></td></tr>\n",
1841 (is_https ? "https" : "http"),
1842 ChrPtr(WC->Hdr->HR.http_host));
1843 /* Public posting? */
1844 wc_printf("<tr><td>");
1845 wc_printf(_("Allow non-subscribers to mail to this room."));
1846 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_SubsOnly\" value=\"yes\" %s></td></tr>\n",
1847 (is_publiclist(&RoomFlags))?"checked":"");
1849 /* Moderated List? */
1850 wc_printf("<tr><td>");
1851 wc_printf(_("Room post publication needs Aide permission."));
1852 wc_printf("</td><td><input type=\"checkbox\" name=\"QR2_Moderated\" value=\"yes\" %s></td></tr>\n",
1853 (is_moderatedlist(&RoomFlags))?"checked":"");
1856 wc_printf("<tr><td colspan=\"2\" align=\"center\">"
1857 "<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\"></td></tr>", _("Save changes"));
1858 wc_printf("</table></form>");
1861 wc_printf("</CENTER>\n");
1862 wc_printf("</div>");
1866 /* Configuration of The Dreaded Auto-Purger */
1867 if (!strcmp(tab, "expire")) {
1868 wc_printf("<div class=\"tabcontent\">");
1870 serv_puts("GPEX room");
1871 serv_getln(buf, sizeof buf);
1872 if (!strncmp(buf, "550", 3)) {
1873 wc_printf("<br><br><div align=center>%s</div><br><br>\n",
1874 _("Higher access is required to access this function.")
1877 else if (buf[0] != '2') {
1878 wc_printf("<br><br><div align=center>%s</div><br><br>\n", &buf[4]);
1881 roompolicy = extract_int(&buf[4], 0);
1882 roomvalue = extract_int(&buf[4], 1);
1884 serv_puts("GPEX floor");
1885 serv_getln(buf, sizeof buf);
1886 if (buf[0] == '2') {
1887 floorpolicy = extract_int(&buf[4], 0);
1888 floorvalue = extract_int(&buf[4], 1);
1891 wc_printf("<br /><form method=\"POST\" action=\"set_room_policy\">\n");
1892 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
1893 wc_printf("<table border=0 cellspacing=5>\n");
1894 wc_printf("<tr><td>");
1895 wc_printf(_("Message expire policy for this room"));
1896 wc_printf("<br />(");
1897 escputs(ChrPtr(WC->CurRoom.name));
1898 wc_printf(")</td><td>");
1899 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
1900 ((roompolicy == 0) ? "CHECKED" : "") );
1901 wc_printf(_("Use the default policy for this floor"));
1902 wc_printf("<br />\n");
1903 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
1904 ((roompolicy == 1) ? "CHECKED" : "") );
1905 wc_printf(_("Never automatically expire messages"));
1906 wc_printf("<br />\n");
1907 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
1908 ((roompolicy == 2) ? "CHECKED" : "") );
1909 wc_printf(_("Expire by message count"));
1910 wc_printf("<br />\n");
1911 wc_printf("<input type=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
1912 ((roompolicy == 3) ? "CHECKED" : "") );
1913 wc_printf(_("Expire by message age"));
1914 wc_printf("<br />");
1915 wc_printf(_("Number of messages or days: "));
1916 wc_printf("<input type=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
1917 wc_printf("</td></tr>\n");
1919 if (WC->axlevel >= 6) {
1920 wc_printf("<tr><td COLSPAN=2><hr /></td></tr>\n");
1921 wc_printf("<tr><td>");
1922 wc_printf(_("Message expire policy for this floor"));
1923 wc_printf("<br />(");
1924 escputs(floorlist[WC->CurRoom.floorid]);
1925 wc_printf(")</td><td>");
1926 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
1927 ((floorpolicy == 0) ? "CHECKED" : "") );
1928 wc_printf(_("Use the system default"));
1929 wc_printf("<br />\n");
1930 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
1931 ((floorpolicy == 1) ? "CHECKED" : "") );
1932 wc_printf(_("Never automatically expire messages"));
1933 wc_printf("<br />\n");
1934 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
1935 ((floorpolicy == 2) ? "CHECKED" : "") );
1936 wc_printf(_("Expire by message count"));
1937 wc_printf("<br />\n");
1938 wc_printf("<input type=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
1939 ((floorpolicy == 3) ? "CHECKED" : "") );
1940 wc_printf(_("Expire by message age"));
1941 wc_printf("<br />");
1942 wc_printf(_("Number of messages or days: "));
1943 wc_printf("<input type=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
1947 wc_printf("<CENTER>\n");
1948 wc_printf("<tr><td COLSPAN=2><hr /><CENTER>\n");
1949 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Save changes"));
1950 wc_printf(" ");
1951 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
1952 wc_printf("</CENTER></td><tr>\n");
1954 wc_printf("</table>\n"
1955 "<input type=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
1960 wc_printf("</div>");
1963 /* Access controls */
1964 if (!strcmp(tab, "access")) {
1965 wc_printf("<div class=\"tabcontent\">");
1967 wc_printf("</div>");
1970 /* Fetch messages from remote locations */
1971 if (!strcmp(tab, "feeds")) {
1972 wc_printf("<div class=\"tabcontent\">");
1975 wc_printf(_("Retrieve messages from these remote POP3 accounts and store them in this room:"));
1976 wc_printf("</i><br />\n");
1978 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
1979 "<tr class=\"even\"><th>");
1980 wc_printf(_("Remote host"));
1981 wc_printf("</th><th>");
1982 wc_printf(_("User name"));
1983 wc_printf("</th><th>");
1984 wc_printf(_("Password"));
1985 wc_printf("</th><th>");
1986 wc_printf(_("Keep messages on server?"));
1987 wc_printf("</th><th>");
1988 wc_printf(_("Interval"));
1989 wc_printf("</th><th> </th></tr>");
1992 serv_getln(buf, sizeof buf);
1994 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
1995 extract_token(cmd, buf, 0, '|', sizeof cmd);
1996 if (!strcasecmp(cmd, "pop3client")) {
1997 safestrncpy(recp, &buf[11], sizeof recp);
2000 wc_printf("<tr class=\"%s\">",
2001 (bg ? "even" : "odd")
2005 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2010 extract_token(pop3_user, buf, 2, '|', sizeof pop3_user);
2014 wc_printf("<td>*****</td>"); /* Don't show the password */
2016 wc_printf("<td>%s</td>", extract_int(buf, 4) ? _("Yes") : _("No"));
2018 wc_printf("<td>%ld</td>", extract_long(buf, 5)); /* Fetching interval */
2020 wc_printf("<td class=\"button_link\">");
2021 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=pop3client|");
2024 wc_printf(_("(remove)"));
2025 wc_printf("</a></td>");
2031 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2033 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2034 "<input type=\"hidden\" name=\"prefix\" value=\"pop3client|\">\n");
2035 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2037 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" NAME=\"line_pop3host\">\n");
2040 wc_printf("<input type=\"text\" id=\"add_as_pop3user\" NAME=\"line_pop3user\">\n");
2043 wc_printf("<input type=\"password\" id=\"add_as_pop3pass\" NAME=\"line_pop3pass\">\n");
2046 wc_printf("<input type=\"checkbox\" id=\"add_as_pop3keep\" NAME=\"line_pop3keep\" VALUE=\"1\">");
2049 wc_printf("<input type=\"text\" id=\"add_as_pop3int\" NAME=\"line_pop3int\" MAXLENGTH=\"5\">");
2052 wc_printf("<input type=\"submit\" NAME=\"add_button\" VALUE=\"%s\">", _("Add"));
2053 wc_printf("</td></tr>");
2054 wc_printf("</form></table>\n");
2056 wc_printf("<hr>\n");
2059 wc_printf(_("Fetch the following RSS feeds and store them in this room:"));
2060 wc_printf("</i><br />\n");
2062 wc_printf("<table class=\"altern\" border=0 cellpadding=5>"
2063 "<tr class=\"even\"><th>");
2064 wc_printf("<img src=\"static/rss_16x.png\" width=\"16\" height=\"16\" alt=\" \"> ");
2065 wc_printf(_("Feed URL"));
2066 wc_printf("</th><th>");
2067 wc_printf("</th></tr>");
2070 serv_getln(buf, sizeof buf);
2072 if (buf[0]=='1') while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2073 extract_token(cmd, buf, 0, '|', sizeof cmd);
2074 if (!strcasecmp(cmd, "rssclient")) {
2075 safestrncpy(recp, &buf[10], sizeof recp);
2078 wc_printf("<tr class=\"%s\">",
2079 (bg ? "even" : "odd")
2083 extract_token(pop3_host, buf, 1, '|', sizeof pop3_host);
2087 wc_printf("<td class=\"button_link\">");
2088 wc_printf(" <a href=\"netedit?cmd=remove?tab=feeds?line=rssclient|");
2091 wc_printf(_("(remove)"));
2092 wc_printf("</a></td>");
2098 wc_printf("<form method=\"POST\" action=\"netedit\">\n"
2100 "<input type=\"hidden\" name=\"tab\" value=\"feeds\">"
2101 "<input type=\"hidden\" name=\"prefix\" value=\"rssclient|\">\n");
2102 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2104 wc_printf("<input type=\"text\" id=\"add_as_pop3host\" size=\"72\" "
2105 "maxlength=\"256\" name=\"line_pop3host\">\n");
2108 wc_printf("<input type=\"submit\" name=\"add_button\" value=\"%s\">", _("Add"));
2109 wc_printf("</td></tr>");
2110 wc_printf("</form></table>\n");
2112 wc_printf("</div>");
2116 /* end content of whatever tab is open now */
2117 wc_printf("</div>\n");
2119 address_book_popup();
2125 * Toggle self-service list subscription
2127 void toggle_self_service(void) {
2128 room_states RoomFlags;
2130 get_roomflags (&RoomFlags);
2132 if (yesbstr("QR2_SelfList"))
2133 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SELFLIST;
2135 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SELFLIST;
2137 if (yesbstr("QR2_SMTP_PUBLIC"))
2138 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2140 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2142 if (yesbstr("QR2_Moderated"))
2143 RoomFlags.flags2 = RoomFlags.flags2 | QR2_MODERATED;
2145 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_MODERATED;
2146 if (yesbstr("QR2_SubsOnly"))
2147 RoomFlags.flags2 = RoomFlags.flags2 | QR2_SMTP_PUBLIC;
2149 RoomFlags.flags2 = RoomFlags.flags2 & ~QR2_SMTP_PUBLIC;
2151 set_roomflags (&RoomFlags);
2159 * save new parameters for a room
2166 StrBuf *er_password;
2168 StrBuf *er_roomaide;
2171 int er_listingorder;
2177 if (!havebstr("ok_button")) {
2178 strcpy(WC->ImportantMessage,
2179 _("Cancelled. Changes were not saved."));
2185 StrBuf_ServGetln(Buf);
2186 if (GetServerStatus(Buf, NULL) != 2) {
2187 StrBufCutLeft(Buf, 4);
2188 strcpy(WC->ImportantMessage, ChrPtr(Buf));
2194 er_name = NewStrBuf();
2195 er_password = NewStrBuf();
2196 er_dirname = NewStrBuf();
2197 er_roomaide = NewStrBuf();
2199 StrBufCutLeft(Buf, 4);
2200 StrBufExtract_token(er_name, Buf, 0, '|');
2201 StrBufExtract_token(er_password, Buf, 1, '|');
2202 StrBufExtract_token(er_dirname, Buf, 2, '|');
2203 er_flags = StrBufExtract_int(Buf, 3, '|');
2204 er_listingorder = StrBufExtract_int(Buf, 5, '|');
2205 er_defaultview = StrBufExtract_int(Buf, 6, '|');
2206 er_flags2 = StrBufExtract_int(Buf, 7, '|');
2208 er_roomaide = NewStrBufDup(sbstr("er_roomaide"));
2209 if (StrLength(er_roomaide) == 0) {
2211 StrBuf_ServGetln(Buf);
2212 if (GetServerStatus(Buf, NULL) != 2) {
2213 FlushStrBuf(er_roomaide);
2215 StrBufCutLeft(Buf, 4);
2216 StrBufExtract_token(er_roomaide, Buf, 0, '|');
2219 Ptr = sbstr("er_name");
2220 if (StrLength(Ptr) > 0) {
2221 FlushStrBuf(er_name);
2222 StrBufAppendBuf(er_name, Ptr, 0);
2225 Ptr = sbstr("er_password");
2226 if (StrLength(Ptr) > 0) {
2227 FlushStrBuf(er_password);
2228 StrBufAppendBuf(er_password, Ptr, 0);
2232 Ptr = sbstr("er_dirname");
2233 if (StrLength(Ptr) > 0) { /* todo: cut 15 */
2234 FlushStrBuf(er_dirname);
2235 StrBufAppendBuf(er_dirname, Ptr, 0);
2239 Ptr = sbstr("type");
2240 er_flags &= !(QR_PRIVATE | QR_PASSWORDED | QR_GUESSNAME);
2242 if (!strcmp(ChrPtr(Ptr), "invonly")) {
2243 er_flags |= (QR_PRIVATE);
2245 if (!strcmp(ChrPtr(Ptr), "hidden")) {
2246 er_flags |= (QR_PRIVATE | QR_GUESSNAME);
2248 if (!strcmp(ChrPtr(Ptr), "passworded")) {
2249 er_flags |= (QR_PRIVATE | QR_PASSWORDED);
2251 if (!strcmp(ChrPtr(Ptr), "personal")) {
2252 er_flags |= QR_MAILBOX;
2254 er_flags &= ~QR_MAILBOX;
2257 if (yesbstr("prefonly")) {
2258 er_flags |= QR_PREFONLY;
2260 er_flags &= ~QR_PREFONLY;
2263 if (yesbstr("readonly")) {
2264 er_flags |= QR_READONLY;
2266 er_flags &= ~QR_READONLY;
2270 if (yesbstr("collabdel")) {
2271 er_flags2 |= QR2_COLLABDEL;
2273 er_flags2 &= ~QR2_COLLABDEL;
2276 if (yesbstr("permanent")) {
2277 er_flags |= QR_PERMANENT;
2279 er_flags &= ~QR_PERMANENT;
2282 if (yesbstr("subjectreq")) {
2283 er_flags2 |= QR2_SUBJECTREQ;
2285 er_flags2 &= ~QR2_SUBJECTREQ;
2288 if (yesbstr("network")) {
2289 er_flags |= QR_NETWORK;
2291 er_flags &= ~QR_NETWORK;
2294 if (yesbstr("directory")) {
2295 er_flags |= QR_DIRECTORY;
2297 er_flags &= ~QR_DIRECTORY;
2300 if (yesbstr("ulallowed")) {
2301 er_flags |= QR_UPLOAD;
2303 er_flags &= ~QR_UPLOAD;
2306 if (yesbstr("dlallowed")) {
2307 er_flags |= QR_DOWNLOAD;
2309 er_flags &= ~QR_DOWNLOAD;
2312 if (yesbstr("visdir")) {
2313 er_flags |= QR_VISDIR;
2315 er_flags &= ~QR_VISDIR;
2318 Ptr = sbstr("anon");
2320 er_flags &= ~(QR_ANONONLY | QR_ANONOPT);
2321 if (!strcmp(ChrPtr(Ptr), "anononly"))
2322 er_flags |= QR_ANONONLY;
2323 if (!strcmp(ChrPtr(Ptr), "anon2"))
2324 er_flags |= QR_ANONOPT;
2326 bump = yesbstr("bump");
2328 er_floor = ibstr("er_floor");
2330 StrBufPrintf(Buf, "SETR %s|%s|%s|%u|%d|%d|%d|%d|%u",
2332 ChrPtr(er_password),
2341 StrBuf_ServGetln(Buf);
2342 if (GetServerStatus(Buf, NULL) != 2) {
2343 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2346 FreeStrBuf(&er_name);
2347 FreeStrBuf(&er_password);
2348 FreeStrBuf(&er_dirname);
2349 FreeStrBuf(&er_roomaide);
2354 if (StrLength(er_roomaide) > 0) {
2355 serv_printf("SETA %s", ChrPtr(er_roomaide));
2356 StrBuf_ServGetln(Buf);
2357 if (GetServerStatus(Buf, NULL) != 2) {
2358 strcpy(WC->ImportantMessage, &ChrPtr(Buf)[4]);
2359 display_main_menu();
2361 FreeStrBuf(&er_name);
2362 FreeStrBuf(&er_password);
2363 FreeStrBuf(&er_dirname);
2364 FreeStrBuf(&er_roomaide);
2369 strcpy(WC->ImportantMessage, _("Your changes have been saved."));
2372 FreeStrBuf(&er_name);
2373 FreeStrBuf(&er_password);
2374 FreeStrBuf(&er_dirname);
2375 FreeStrBuf(&er_roomaide);
2381 * Display form for Invite, Kick, and show Who Knows a room
2383 void do_invt_kick(void) {
2384 char buf[SIZ], room[SIZ], username[SIZ];
2387 serv_getln(buf, sizeof buf);
2389 if (buf[0] != '2') {
2393 extract_token(room, &buf[4], 0, '|', sizeof room);
2395 strcpy(username, bstr("username"));
2397 if (havebstr("kick_button")) {
2398 sprintf(buf, "KICK %s", username);
2400 serv_getln(buf, sizeof buf);
2402 if (buf[0] != '2') {
2403 strcpy(WC->ImportantMessage, &buf[4]);
2405 sprintf(WC->ImportantMessage,
2406 _("<B><I>User %s kicked out of room %s.</I></B>\n"),
2411 if (havebstr("invite_button")) {
2412 sprintf(buf, "INVT %s", username);
2414 serv_getln(buf, sizeof buf);
2416 if (buf[0] != '2') {
2417 strcpy(WC->ImportantMessage, &buf[4]);
2419 sprintf(WC->ImportantMessage,
2420 _("<B><I>User %s invited to room %s.</I></B>\n"),
2431 * Display form for Invite, Kick, and show Who Knows a room
2433 void display_whok(void)
2435 char buf[SIZ], room[SIZ], username[SIZ];
2438 serv_getln(buf, sizeof buf);
2440 if (buf[0] != '2') {
2444 extract_token(room, &buf[4], 0, '|', sizeof room);
2447 wc_printf("<table border=0 CELLSPACING=10><tr VALIGN=TOP><td>");
2448 wc_printf(_("The users listed below have access to this room. "
2449 "To remove a user from the access list, select the user "
2450 "name from the list and click 'Kick'."));
2451 wc_printf("<br /><br />");
2453 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2454 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2455 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2456 wc_printf("<select NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
2458 serv_getln(buf, sizeof buf);
2459 if (buf[0] == '1') {
2460 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2461 extract_token(username, buf, 0, '|', sizeof username);
2462 wc_printf("<OPTION>");
2467 wc_printf("</select><br />\n");
2469 wc_printf("<input type=\"submit\" name=\"kick_button\" value=\"%s\">", _("Kick"));
2470 wc_printf("</form></CENTER>\n");
2472 wc_printf("</td><td>");
2473 wc_printf(_("To grant another user access to this room, enter the "
2474 "user name in the box below and click 'Invite'."));
2475 wc_printf("<br /><br />");
2477 wc_printf("<CENTER><form method=\"POST\" action=\"do_invt_kick\">\n");
2478 wc_printf("<input type=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
2479 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2480 wc_printf(_("Invite:"));
2482 wc_printf("<input type=\"text\" name=\"username\" id=\"username_id\" style=\"width:100%%\"><br />\n"
2483 "<input type=\"hidden\" name=\"invite_button\" value=\"Invite\">"
2484 "<input type=\"submit\" value=\"%s\">"
2485 "</form></CENTER>\n", _("Invite"));
2486 /* Pop open an address book -- begin **/
2488 "<a href=\"javascript:PopOpenAddressBook('username_id|%s');\" "
2490 "<img align=middle border=0 width=24 height=24 src=\"static/viewcontacts_24x.gif\">"
2493 _("Users"), _("Users")
2495 /* Pop open an address book -- end **/
2497 wc_printf("</td></tr></table>\n");
2498 address_book_popup();
2505 * display the form for entering a new room
2507 void display_entroom(void)
2514 serv_puts("CRE8 0");
2515 serv_getln(buf, sizeof buf);
2517 if (buf[0] != '2') {
2518 strcpy(WC->ImportantMessage, &buf[4]);
2519 display_main_menu();
2524 output_headers(1, 1, 1, 0, 0, 0);
2526 svprintf(HKEY("BOXTITLE"), WCS_STRING, _("Create a new room"));
2527 do_template("beginbox", NULL);
2529 wc_printf("<form name=\"create_room_form\" method=\"POST\" action=\"entroom\">\n");
2530 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2532 wc_printf("<table class=\"altern\"> ");
2534 wc_printf("<tr class=\"even\"><td>");
2535 wc_printf(_("Name of room: "));
2536 wc_printf("</td><td>");
2537 wc_printf("<input type=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
2538 wc_printf("</td></tr>");
2540 wc_printf("<tr class=\"odd\"><td>");
2541 wc_printf(_("Resides on floor: "));
2542 wc_printf("</td><td>");
2543 load_floorlist(Buf);
2544 wc_printf("<select name=\"er_floor\" size=\"1\">\n");
2545 for (i = 0; i < 128; ++i)
2546 if (!IsEmptyStr(floorlist[i])) {
2547 wc_printf("<option ");
2548 wc_printf("value=\"%d\">", i);
2549 escputs(floorlist[i]);
2550 wc_printf("</option>\n");
2552 wc_printf("</select>\n");
2553 wc_printf("</td></tr>");
2556 * Our clever little snippet of JavaScript automatically selects
2557 * a public room if the view is set to Bulletin Board or wiki, and
2558 * it selects a mailbox room otherwise. The user can override this,
2559 * of course. We also disable the floor selector for mailboxes.
2561 wc_printf("<tr class=\"even\"><td>");
2562 wc_printf(_("Default view for room: "));
2563 wc_printf("</td><td>");
2564 wc_printf("<select name=\"er_view\" size=\"1\" OnChange=\""
2565 " if ( (this.form.er_view.value == 0) "
2566 " || (this.form.er_view.value == 6) ) { "
2567 " this.form.type[0].checked=true; "
2568 " this.form.er_floor.disabled = false; "
2571 " this.form.type[4].checked=true; "
2572 " this.form.er_floor.disabled = true; "
2575 for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
2576 if (is_view_allowed_as_default(i)) {
2577 wc_printf("<option %s value=\"%d\">",
2578 ((i == 0) ? "selected" : ""), i );
2579 escputs(viewdefs[i]);
2580 wc_printf("</option>\n");
2583 wc_printf("</select>\n");
2584 wc_printf("</td></tr>");
2586 wc_printf("<tr class=\"even\"><td>");
2587 wc_printf(_("Type of room:"));
2588 wc_printf("</td><td>");
2589 wc_printf("<ul class=\"adminlist\">\n");
2591 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"public\" ");
2592 wc_printf("CHECKED OnChange=\""
2593 " if (this.form.type[0].checked == true) { "
2594 " this.form.er_floor.disabled = false; "
2597 wc_printf(_("Public (automatically appears to everyone)"));
2600 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"hidden\" OnChange=\""
2601 " if (this.form.type[1].checked == true) { "
2602 " this.form.er_floor.disabled = false; "
2605 wc_printf(_("Private - hidden (accessible to anyone who knows its name)"));
2608 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"passworded\" OnChange=\""
2609 " if (this.form.type[2].checked == true) { "
2610 " this.form.er_floor.disabled = false; "
2613 wc_printf(_("Private - require password: "));
2614 wc_printf("<input type=\"text\" NAME=\"er_password\" MAXLENGTH=\"9\">\n");
2617 wc_printf("<li><input type=\"radio\" NAME=\"type\" VALUE=\"invonly\" OnChange=\""
2618 " if (this.form.type[3].checked == true) { "
2619 " this.form.er_floor.disabled = false; "
2622 wc_printf(_("Private - invitation only"));
2625 wc_printf("\n<li><input type=\"radio\" NAME=\"type\" VALUE=\"personal\" "
2627 " if (this.form.type[4].checked == true) { "
2628 " this.form.er_floor.disabled = true; "
2631 wc_printf(_("Personal (mailbox for you only)"));
2634 wc_printf("\n</ul>\n");
2635 wc_printf("</td></tr></table>\n");
2637 wc_printf("<div class=\"buttons\">\n");
2638 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">", _("Create new room"));
2639 wc_printf(" ");
2640 wc_printf("<input type=\"submit\" name=\"cancel_button\" value=\"%s\">", _("Cancel"));
2641 wc_printf("</div>\n");
2642 wc_printf("</form>\n<hr />");
2643 serv_printf("MESG roomaccess");
2644 serv_getln(buf, sizeof buf);
2645 if (buf[0] == '1') {
2649 do_template("endbox", NULL);
2659 * support function for entroom() -- sets the default view
2661 void er_set_default_view(int newview) {
2674 serv_getln(buf, sizeof buf);
2675 if (buf[0] != '2') return;
2677 extract_token(rm_name, &buf[4], 0, '|', sizeof rm_name);
2678 extract_token(rm_pass, &buf[4], 1, '|', sizeof rm_pass);
2679 extract_token(rm_dir, &buf[4], 2, '|', sizeof rm_dir);
2680 rm_bits1 = extract_int(&buf[4], 3);
2681 rm_floor = extract_int(&buf[4], 4);
2682 rm_listorder = extract_int(&buf[4], 5);
2683 rm_bits2 = extract_int(&buf[4], 7);
2685 serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
2686 rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
2687 rm_listorder, newview, rm_bits2
2689 serv_getln(buf, sizeof buf);
2700 const StrBuf *er_name;
2701 const StrBuf *er_type;
2702 const StrBuf *er_password;
2706 wcsession *WCC = WC;
2708 if (!havebstr("ok_button")) {
2709 strcpy(WC->ImportantMessage,
2710 _("Cancelled. No new room was created."));
2711 display_main_menu();
2714 er_name = sbstr("er_name");
2715 er_type = sbstr("type");
2716 er_password = sbstr("er_password");
2717 er_floor = ibstr("er_floor");
2718 er_view = ibstr("er_view");
2721 if (!strcmp(ChrPtr(er_type), "hidden"))
2723 else if (!strcmp(ChrPtr(er_type), "passworded"))
2725 else if (!strcmp(ChrPtr(er_type), "invonly"))
2727 else if (!strcmp(ChrPtr(er_type), "personal"))
2730 serv_printf("CRE8 1|%s|%d|%s|%d|%d|%d",
2733 ChrPtr(er_password),
2738 serv_getln(buf, sizeof buf);
2739 if (buf[0] != '2') {
2740 strcpy(WCC->ImportantMessage, &buf[4]);
2741 display_main_menu();
2744 /** TODO: Room created, now update the left hand icon bar for this user */
2745 burn_folder_cache(0); /* burn the old folder cache */
2749 serv_printf("VIEW %d", er_view);
2750 serv_getln(buf, sizeof buf);
2751 WCC->CurRoom.view = er_view;
2753 if ( (WCC != NULL) && ( (WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ) {
2754 display_editroom ();
2756 do_change_view(er_view); /* Now go there */
2763 * \brief display the screen to enter a private room
2765 void display_private(char *rname, int req_pass)
2767 WCTemplputParams SubTP;
2769 output_headers(1, 1, 1, 0, 0, 0);
2771 Buf = NewStrBufPlain(_("Go to a hidden room"), -1);
2772 memset(&SubTP, 0, sizeof(WCTemplputParams));
2773 SubTP.Filter.ContextType = CTX_STRBUF;
2774 SubTP.Context = Buf;
2775 DoTemplate(HKEY("beginbox"), NULL, &SubTP);
2780 wc_printf(_("If you know the name of a hidden (guess-name) or "
2781 "passworded room, you can enter that room by typing "
2782 "its name below. Once you gain access to a private "
2783 "room, it will appear in your regular room listings "
2784 "so you don't have to keep returning here."));
2787 wc_printf("<form method=\"post\" action=\"goto_private\">\n");
2788 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2790 wc_printf("<table class=\"altern\"> "
2791 "<tr class=\"even\"><td>");
2792 wc_printf(_("Enter room name:"));
2793 wc_printf("</td><td>"
2794 "<input type=\"text\" name=\"gr_name\" "
2795 "value=\"%s\" maxlength=\"128\">\n", rname);
2798 wc_printf("</td></tr><tr class=\"odd\"><td>");
2799 wc_printf(_("Enter room password:"));
2800 wc_printf("</td><td>");
2801 wc_printf("<input type=\"password\" name=\"gr_pass\" maxlength=\"9\">\n");
2803 wc_printf("</td></tr></table>\n");
2805 wc_printf("<div class=\"buttons\">\n");
2806 wc_printf("<input type=\"submit\" name=\"ok_button\" value=\"%s\">"
2808 "<input type=\"submit\" name=\"cancel_button\" value=\"%s\">",
2812 wc_printf("</div></form>\n");
2814 do_template("endbox", NULL);
2820 * \brief goto a private room
2822 void goto_private(void)
2827 if (!havebstr("ok_button")) {
2828 display_main_menu();
2831 strcpy(hold_rm, ChrPtr(WC->CurRoom.name));
2832 serv_printf("GOTO %s|%s",
2835 serv_getln(buf, sizeof buf);
2837 if (buf[0] == '2') {
2838 smart_goto(sbstr("gr_name"));
2841 if (!strncmp(buf, "540", 3)) {
2842 display_private(bstr("gr_name"), 1);
2845 output_headers(1, 1, 1, 0, 0, 0);
2846 wc_printf("%s\n", &buf[4]);
2853 * \brief display the screen to zap a room
2855 void display_zap(void)
2857 output_headers(1, 1, 2, 0, 0, 0);
2859 wc_printf("<div id=\"banner\">\n");
2861 wc_printf(_("Zap (forget/unsubscribe) the current room"));
2862 wc_printf("</h1>\n");
2863 wc_printf("</div>\n");
2865 wc_printf("<div id=\"content\" class=\"service\">\n");
2867 wc_printf(_("If you select this option, <em>%s</em> will "
2868 "disappear from your room list. Is this what you wish "
2869 "to do?<br />\n"), ChrPtr(WC->CurRoom.name));
2871 wc_printf("<form method=\"POST\" action=\"zap\">\n");
2872 wc_printf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
2873 wc_printf("<input type=\"submit\" NAME=\"ok_button\" VALUE=\"%s\">", _("Zap this room"));
2874 wc_printf(" ");
2875 wc_printf("<input type=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">", _("Cancel"));
2876 wc_printf("</form>\n");
2887 StrBuf *final_destination;
2890 * If the forget-room routine fails for any reason, we fall back
2891 * to the current room; otherwise, we go to the Lobby
2893 final_destination = NewStrBufDup(WC->CurRoom.name);
2895 if (havebstr("ok_button")) {
2896 serv_printf("GOTO %s", ChrPtr(WC->CurRoom.name));
2897 serv_getln(buf, sizeof buf);
2898 if (buf[0] == '2') {
2900 serv_getln(buf, sizeof buf);
2901 if (buf[0] == '2') {
2902 FlushStrBuf(final_destination);
2903 StrBufAppendBufPlain(final_destination, HKEY("_BASEROOM_"), 0);
2907 smart_goto(final_destination);
2908 FreeStrBuf(&final_destination);
2914 * \brief Delete the current room
2916 void delete_room(void)
2921 serv_puts("KILL 1");
2922 serv_getln(buf, sizeof buf);
2923 burn_folder_cache(0); /* Burn the cahce of known rooms to update the icon bar */
2924 if (buf[0] != '2') {
2925 strcpy(WC->ImportantMessage, &buf[4]);
2926 display_main_menu();
2931 Buf = NewStrBufPlain(HKEY("_BASEROOM_"));
2940 * \brief Perform changes to a room's network configuration
2942 void netedit(void) {
2951 /*/ TODO: do line dynamic! */
2952 if (havebstr("line_pop3host")) {
2953 strcpy(line, bstr("prefix"));
2954 strcat(line, bstr("line_pop3host"));
2956 strcat(line, bstr("line_pop3user"));
2958 strcat(line, bstr("line_pop3pass"));
2960 strcat(line, ibstr("line_pop3keep") ? "1" : "0" );
2962 sprintf(&line[strlen(line)],"%ld", lbstr("line_pop3int"));
2963 strcat(line, bstr("suffix"));
2965 else if (havebstr("line")) {
2966 strcpy(line, bstr("prefix"));
2967 strcat(line, bstr("line"));
2968 strcat(line, bstr("suffix"));
2983 serv_getln(buf, sizeof buf);
2984 if (buf[0] != '1') {
2990 /** This loop works for add *or* remove. Spiffy, eh? */
2991 while (serv_getln(buf, sizeof buf), strcmp(buf, "000")) {
2992 extract_token(cmpa0, buf, 0, '|', sizeof cmpa0);
2993 extract_token(cmpa1, buf, 1, '|', sizeof cmpa1);
2994 extract_token(cmpb0, line, 0, '|', sizeof cmpb0);
2995 extract_token(cmpb1, line, 1, '|', sizeof cmpb1);
2996 if ( (strcasecmp(cmpa0, cmpb0))
2997 || (strcasecmp(cmpa1, cmpb1)) ) {
2998 fprintf(fp, "%s\n", buf);
3004 serv_getln(buf, sizeof buf);
3005 if (buf[0] != '4') {
3011 while (fgets(buf, sizeof buf, fp) != NULL) {
3012 buf[strlen(buf)-1] = 0;
3016 if (havebstr("add_button")) {
3017 num_addrs = num_tokens(bstr("line"), ',');
3018 if (num_addrs < 2) {
3019 /* just adding one node or address */
3023 /* adding multiple addresses separated by commas */
3024 for (i=0; i<num_addrs; ++i) {
3025 strcpy(line, bstr("prefix"));
3026 extract_token(buf, bstr("line"), i, ',', sizeof buf);
3029 strcat(line, bstr("suffix"));
3043 * \brief Convert a room name to a folder-ish-looking name.
3044 * \param folder the folderish name
3045 * \param room the room name
3046 * \param floor the floor name
3047 * \param is_mailbox is it a mailbox?
3049 void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
3054 * For mailboxes, just do it straight...
3057 sprintf(folder, "My folders|%s", room);
3061 * Otherwise, prefix the floor name as a "public folders" moniker
3064 if (floor > MAX_FLOORS) {
3066 sprintf(folder, "%%%%%%|%s", room);
3069 sprintf(folder, "%s|%s", floorlist[floor], room);
3074 * Replace "\" characters with "|" for pseudo-folder-delimiting
3076 len = strlen (folder);
3077 for (i=0; i<len; ++i) {
3078 if (folder[i] == '\\') folder[i] = '|';
3086 * \brief Back end for change_view()
3087 * \param newview set newview???
3089 void do_change_view(int newview) {
3092 serv_printf("VIEW %d", newview);
3093 serv_getln(buf, sizeof buf);
3094 WC->CurRoom.view = newview;
3095 smart_goto(WC->CurRoom.name);
3101 * \brief Change the view for this room
3103 void change_view(void) {
3106 view = lbstr("view");
3107 do_change_view(view);
3111 * \brief Burn the cached folder list.
3112 * \param age How old the cahce needs to be before we burn it.
3115 void burn_folder_cache(time_t age)
3117 /** If our cached folder list is very old, burn it. */
3118 if (WC->cache_fold != NULL) {
3119 if ((time(NULL) - WC->cache_timestamp) > age) {
3120 free(WC->cache_fold);
3121 WC->cache_fold = NULL;
3129 * \brief Do either a known rooms list or a folders list, depending on the
3134 StrBuf *ListView = NULL;
3136 /** Determine whether the user is trying to change views */
3137 if (havebstr("view")) {
3138 ListView = NewStrBufDup(SBSTR("view"));
3139 set_preference("roomlistview", ListView, 1);
3141 /** Sanitize the input so its safe */
3142 if((get_preference("roomlistview", &ListView) != 0)||
3143 ((strcasecmp(ChrPtr(ListView), "folders") != 0) &&
3144 (strcasecmp(ChrPtr(ListView), "table") != 0)))
3146 if (ListView == NULL) {
3147 ListView = NewStrBufPlain(HKEY("rooms"));
3148 set_preference("roomlistview", ListView, 0);
3152 ListView = NewStrBufPlain(HKEY("rooms"));
3153 set_preference("roomlistview", ListView, 0);
3157 FreeStrBuf(&ListView);
3164 * \brief Set the message expire policy for this room and/or floor
3166 void set_room_policy(void) {
3169 if (!havebstr("ok_button")) {
3170 strcpy(WC->ImportantMessage,
3171 _("Cancelled. Changes were not saved."));
3176 serv_printf("SPEX room|%d|%d", ibstr("roompolicy"), ibstr("roomvalue"));
3177 serv_getln(buf, sizeof buf);
3178 strcpy(WC->ImportantMessage, &buf[4]);
3180 if (WC->axlevel >= 6) {
3181 strcat(WC->ImportantMessage, "<br />\n");
3182 serv_printf("SPEX floor|%d|%d", ibstr("floorpolicy"), ibstr("floorvalue"));
3183 serv_getln(buf, sizeof buf);
3184 strcat(WC->ImportantMessage, &buf[4]);
3190 void tmplput_RoomName(StrBuf *Target, WCTemplputParams *TP)
3192 StrBufAppendTemplate(Target, TP, WC->CurRoom.name, 0);
3196 void _display_private(void) {
3197 display_private("", 0);
3200 void dotgoto(void) {
3201 if (!havebstr("room")) {
3202 readloop(readnew, eUseDefault);
3205 if (WC->CurRoom.view != VIEW_MAILBOX) { /* dotgoto acts like dotskip when we're in a mailbox view */
3208 smart_goto(sbstr("room"));
3213 void tmplput_current_room(StrBuf *Target, WCTemplputParams *TP)
3215 wcsession *WCC = WC;
3218 StrBufAppendTemplate(Target, TP,
3223 void tmplput_roombanner(StrBuf *Target, WCTemplputParams *TP)
3225 wc_printf("<div id=\"banner\">\n");
3226 embed_room_banner(NULL, navbar_default);
3227 wc_printf("</div>\n");
3231 void tmplput_ungoto(StrBuf *Target, WCTemplputParams *TP)
3233 wcsession *WCC = WC;
3236 (!IsEmptyStr(WCC->ugname)))
3237 StrBufAppendBufPlain(Target, WCC->ugname, -1, 0);
3240 int ConditionalRoomAide(StrBuf *Target, WCTemplputParams *TP)
3242 wcsession *WCC = WC;
3243 return (WCC != NULL)?
3244 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) : 0;
3247 int ConditionalRoomAcessDelete(StrBuf *Target, WCTemplputParams *TP)
3249 wcsession *WCC = WC;
3250 return (WCC == NULL)? 0 :
3251 ( ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3252 (WCC->CurRoom.is_inbox) ||
3253 (WCC->CurRoom.QRFlags2 & QR2_COLLABDEL) );
3256 int ConditionalHaveUngoto(StrBuf *Target, WCTemplputParams *TP)
3258 wcsession *WCC = WC;
3260 return ((WCC!=NULL) &&
3261 (!IsEmptyStr(WCC->ugname)) &&
3262 (strcasecmp(WCC->ugname, ChrPtr(WCC->CurRoom.name)) == 0));
3266 int ConditionalRoomHas_UAFlag(StrBuf *Target, WCTemplputParams *TP)
3268 folder *Folder = (folder *)(TP->Context);
3271 UA_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3272 if (UA_CheckFlag == 0)
3273 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3274 "requires one of the #\"UA_*\"- defines or an integer flag 0 is invalid!");
3276 return ((Folder->RAFlags & UA_CheckFlag) != 0);
3281 int ConditionalCurrentRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3284 wcsession *WCC = WC;
3286 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3287 if (QR_CheckFlag == 0)
3288 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3289 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3291 return ((WCC!=NULL) &&
3292 ((WCC->CurRoom.QRFlags & QR_CheckFlag) != 0));
3295 int ConditionalRoomHas_QRFlag(StrBuf *Target, WCTemplputParams *TP)
3298 folder *Folder = (folder *)(TP->Context);
3300 QR_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3301 if (QR_CheckFlag == 0)
3302 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3303 "requires one of the #\"QR*\"- defines or an integer flag 0 is invalid!");
3304 return ((Folder->QRFlags & QR_CheckFlag) != 0);
3308 int ConditionalCurrentRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3311 wcsession *WCC = WC;
3313 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3314 if (QR2_CheckFlag == 0)
3315 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3316 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3318 return ((WCC!=NULL) &&
3319 ((WCC->CurRoom.QRFlags2 & QR2_CheckFlag) != 0));
3322 int ConditionalRoomHas_QRFlag2(StrBuf *Target, WCTemplputParams *TP)
3325 folder *Folder = (folder *)(TP->Context);
3327 QR2_CheckFlag = GetTemplateTokenNumber(Target, TP, 2, 0);
3328 if (QR2_CheckFlag == 0)
3329 LogTemplateError(Target, "Conditional", ERR_PARM1, TP,
3330 "requires one of the #\"QR2*\"- defines or an integer flag 0 is invalid!");
3331 return ((Folder->QRFlags2 & QR2_CheckFlag) != 0);
3335 int ConditionalHaveRoomeditRights(StrBuf *Target, WCTemplputParams *TP)
3337 wcsession *WCC = WC;
3339 return ( (WCC!= NULL) &&
3340 ((WCC->axlevel >= 6) ||
3341 ((WCC->CurRoom.RAFlags & UA_ADMINALLOWED) != 0) ||
3342 (WCC->CurRoom.is_inbox) ));
3345 int ConditionalIsRoomtype(StrBuf *Target, WCTemplputParams *TP)
3347 wcsession *WCC = WC;
3349 if ((WCC == NULL) ||
3350 (TP->Tokens->nParameters < 3))
3352 return ((WCC->CurRoom.view < VIEW_BBS) ||
3353 (WCC->CurRoom.view > VIEW_MAX));
3356 return WCC->CurRoom.view == GetTemplateTokenNumber(Target, TP, 2, VIEW_BBS);
3360 HashList *GetWhoKnowsHash(StrBuf *Target, WCTemplputParams *TP)
3362 wcsession *WCC = WC;
3366 HashList *Whok = NULL;
3372 Token = NewStrBuf();
3373 StrBuf_ServGetln(Line);
3374 if (GetServerStatus(Line, &State) == 1)
3376 Whok = NewHash(1, Flathash);
3377 while(!Done && StrBuf_ServGetln(Line))
3378 if ( (StrLength(Line)==3) &&
3379 !strcmp(ChrPtr(Line), "000"))
3386 const char *Pos = NULL;
3387 Token = NewStrBufPlain (NULL, StrLength(Line));
3388 StrBufExtract_NextToken(Token, Line, &Pos, '|');
3396 else if (State == 550)
3397 StrBufAppendBufPlain(WCC->ImportantMsg,
3398 _("Higher access is required to access this function."), -1, 0);
3408 initialize_viewdefs();
3409 RegisterPreference("roomlistview",
3410 _("Room list view"),
3413 RegisterPreference("emptyfloors", _("Show empty floors"), PRF_YESNO, NULL);
3415 RegisterNamespace("ROOMNAME", 0, 1, tmplput_RoomName, NULL, CTX_NONE);
3418 WebcitAddUrlHandler(HKEY("knrooms"), "", 0, knrooms, 0);
3419 WebcitAddUrlHandler(HKEY("dotgoto"), "", 0, dotgoto, NEED_URL);
3420 WebcitAddUrlHandler(HKEY("dotskip"), "", 0, dotskip, NEED_URL);
3421 WebcitAddUrlHandler(HKEY("display_private"), "", 0, _display_private, 0);
3422 WebcitAddUrlHandler(HKEY("goto_private"), "", 0, goto_private, NEED_URL);
3423 WebcitAddUrlHandler(HKEY("zapped_list"), "", 0, zapped_list, 0);
3424 WebcitAddUrlHandler(HKEY("display_zap"), "", 0, display_zap, 0);
3425 WebcitAddUrlHandler(HKEY("zap"), "", 0, zap, 0);
3426 WebcitAddUrlHandler(HKEY("display_entroom"), "", 0, display_entroom, 0);
3427 WebcitAddUrlHandler(HKEY("entroom"), "", 0, entroom, 0);
3428 WebcitAddUrlHandler(HKEY("display_whok"), "", 0, display_whok, 0);
3429 WebcitAddUrlHandler(HKEY("do_invt_kick"), "", 0, do_invt_kick, 0);
3430 WebcitAddUrlHandler(HKEY("display_editroom"), "", 0, display_editroom, 0);
3431 WebcitAddUrlHandler(HKEY("netedit"), "", 0, netedit, 0);
3432 WebcitAddUrlHandler(HKEY("editroom"), "", 0, editroom, 0);
3433 WebcitAddUrlHandler(HKEY("delete_room"), "", 0, delete_room, 0);
3434 WebcitAddUrlHandler(HKEY("set_room_policy"), "", 0, set_room_policy, 0);
3435 WebcitAddUrlHandler(HKEY("changeview"), "", 0, change_view, 0);
3436 WebcitAddUrlHandler(HKEY("toggle_self_service"), "", 0, toggle_self_service, 0);
3437 RegisterNamespace("ROOMBANNER", 0, 1, tmplput_roombanner, NULL, CTX_NONE);
3439 RegisterConditional(HKEY("COND:ROOM:TYPE_IS"), 0, ConditionalIsRoomtype, CTX_NONE);
3440 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR"), 0, ConditionalCurrentRoomHas_QRFlag, CTX_NONE);
3441 RegisterConditional(HKEY("COND:ROOM:FLAG:QR"), 0, ConditionalRoomHas_QRFlag, CTX_ROOMS);
3443 RegisterConditional(HKEY("COND:THISROOM:FLAG:QR2"), 0, ConditionalCurrentRoomHas_QRFlag2, CTX_NONE);
3444 RegisterConditional(HKEY("COND:ROOM:FLAG:QR2"), 0, ConditionalRoomHas_QRFlag2, CTX_ROOMS);
3445 RegisterConditional(HKEY("COND:ROOM:FLAG:UA"), 0, ConditionalRoomHas_UAFlag, CTX_ROOMS);
3447 RegisterIterator("ITERATE:THISROOM:WHO_KNOWS", 0, NULL, GetWhoKnowsHash, NULL, DeleteHash, CTX_STRBUF, CTX_NONE, IT_NOFLAG);
3448 RegisterNamespace("THISROOM:FLOOR:NAME", 0, 1, tmplput_CurrentRoomFloorName, NULL, CTX_NONE);
3449 RegisterNamespace("THISROOM:AIDE", 0, 1, tmplput_CurrentRoomAide, NULL, CTX_NONE);
3450 RegisterNamespace("THISROOM:PASS", 0, 1, tmplput_CurrentRoomPass, NULL, CTX_NONE);
3451 RegisterNamespace("THISROOM:DIRECTORY", 0, 1, tmplput_CurrentRoomDirectory, NULL, CTX_NONE);
3452 RegisterNamespace("THISROOM:ORDER", 0, 0, tmplput_CurrentRoomOrder, NULL, CTX_NONE);
3453 RegisterNamespace("THISROOM:DEFAULT_VIEW", 0, 0, tmplput_CurrentRoomDefView, NULL, CTX_NONE);
3454 RegisterNamespace("THISROOM:INFOTEXT", 1, 2, tmplput_CurrentRoomInfoText, NULL, CTX_NONE);
3455 RegisterConditional(HKEY("COND:THISROOM:ORDER"), 0, ConditionalThisRoomOrder, CTX_NONE);
3456 RegisterConditional(HKEY("COND:THISROOM:DEFAULT_VIEW"), 0, ConditionalThisRoomDefView, CTX_NONE);
3457 RegisterConditional(HKEY("COND:THISROOM:HAVE_PIC"), 0, ConditionalThisRoomXHavePic, CTX_NONE);
3458 RegisterConditional(HKEY("COND:THISROOM:HAVE_INFOTEXT"), 0, ConditionalThisRoomXHaveInfoText, CTX_NONE);
3461 REGISTERTokenParamDefine(QR_PERMANENT);
3462 REGISTERTokenParamDefine(QR_INUSE);
3463 REGISTERTokenParamDefine(QR_PRIVATE);
3464 REGISTERTokenParamDefine(QR_PASSWORDED);
3465 REGISTERTokenParamDefine(QR_GUESSNAME);
3466 REGISTERTokenParamDefine(QR_DIRECTORY);
3467 REGISTERTokenParamDefine(QR_UPLOAD);
3468 REGISTERTokenParamDefine(QR_DOWNLOAD);
3469 REGISTERTokenParamDefine(QR_VISDIR);
3470 REGISTERTokenParamDefine(QR_ANONONLY);
3471 REGISTERTokenParamDefine(QR_ANONOPT);
3472 REGISTERTokenParamDefine(QR_NETWORK);
3473 REGISTERTokenParamDefine(QR_PREFONLY);
3474 REGISTERTokenParamDefine(QR_READONLY);
3475 REGISTERTokenParamDefine(QR_MAILBOX);
3476 REGISTERTokenParamDefine(QR2_SYSTEM);
3477 REGISTERTokenParamDefine(QR2_SELFLIST);
3478 REGISTERTokenParamDefine(QR2_COLLABDEL);
3479 REGISTERTokenParamDefine(QR2_SUBJECTREQ);
3480 REGISTERTokenParamDefine(QR2_SMTP_PUBLIC);
3481 REGISTERTokenParamDefine(QR2_MODERATED);
3483 REGISTERTokenParamDefine(UA_KNOWN);
3484 REGISTERTokenParamDefine(UA_GOTOALLOWED);
3485 REGISTERTokenParamDefine(UA_HASNEWMSGS);
3486 REGISTERTokenParamDefine(UA_ZAPPED);
3487 REGISTERTokenParamDefine(UA_POSTALLOWED);
3488 REGISTERTokenParamDefine(UA_ADMINALLOWED);
3489 REGISTERTokenParamDefine(UA_DELETEALLOWED);
3490 REGISTERTokenParamDefine(UA_ISTRASH);
3492 REGISTERTokenParamDefine(US_NEEDVALID);
3493 REGISTERTokenParamDefine(US_PERM);
3494 REGISTERTokenParamDefine(US_LASTOLD);
3495 REGISTERTokenParamDefine(US_EXPERT);
3496 REGISTERTokenParamDefine(US_UNLISTED);
3497 REGISTERTokenParamDefine(US_NOPROMPT);
3498 REGISTERTokenParamDefine(US_PROMPTCTL);
3499 REGISTERTokenParamDefine(US_DISAPPEAR);
3500 REGISTERTokenParamDefine(US_REGIS);
3501 REGISTERTokenParamDefine(US_PAGINATOR);
3502 REGISTERTokenParamDefine(US_INTERNET);
3503 REGISTERTokenParamDefine(US_FLOORS);
3504 REGISTERTokenParamDefine(US_COLOR);
3505 REGISTERTokenParamDefine(US_USER_SET);
3507 REGISTERTokenParamDefine(VIEW_BBS);
3508 REGISTERTokenParamDefine(VIEW_MAILBOX);
3509 REGISTERTokenParamDefine(VIEW_ADDRESSBOOK);
3510 REGISTERTokenParamDefine(VIEW_CALENDAR);
3511 REGISTERTokenParamDefine(VIEW_TASKS);
3512 REGISTERTokenParamDefine(VIEW_NOTES);
3513 REGISTERTokenParamDefine(VIEW_WIKI);
3514 REGISTERTokenParamDefine(VIEW_CALBRIEF);
3515 REGISTERTokenParamDefine(VIEW_JOURNAL);
3516 REGISTERTokenParamDefine(VIEW_BLOG);
3519 REGISTERTokenParamDefine(ignet_push_share);
3520 { /* these are the parts of an IGNET push config */
3521 REGISTERTokenParamDefine(GNET_IGNET_NODE);
3522 REGISTERTokenParamDefine(GNET_IGNET_ROOM);
3524 REGISTERTokenParamDefine(listrecp);
3525 REGISTERTokenParamDefine(digestrecp);
3526 REGISTERTokenParamDefine(pop3client);
3527 { /* These are the parts of a pop3 client line... */
3528 REGISTERTokenParamDefine(GNET_POP3_HOST);
3529 REGISTERTokenParamDefine(GNET_POP3_USER);
3530 REGISTERTokenParamDefine(GNET_POP3_DONT_DELETE_REMOTE);
3531 REGISTERTokenParamDefine(GNET_POP3_INTERVAL);
3533 REGISTERTokenParamDefine(rssclient);
3534 REGISTERTokenParamDefine(participate);
3536 RegisterConditional(HKEY("COND:ROOMAIDE"), 2, ConditionalRoomAide, CTX_NONE);
3537 RegisterConditional(HKEY("COND:ACCESS:DELETE"), 2, ConditionalRoomAcessDelete, CTX_NONE);
3539 RegisterConditional(HKEY("COND:UNGOTO"), 0, ConditionalHaveUngoto, CTX_NONE);
3540 RegisterConditional(HKEY("COND:ROOM:EDITACCESS"), 0, ConditionalHaveRoomeditRights, CTX_NONE);
3542 RegisterNamespace("CURRENT_ROOM", 0, 1, tmplput_current_room, NULL, CTX_NONE);
3543 RegisterNamespace("ROOM:UNGOTO", 0, 0, tmplput_ungoto, NULL, CTX_NONE);
3544 RegisterIterator("FLOORS", 0, NULL, GetFloorListHash, NULL, NULL, CTX_FLOORS, CTX_NONE, IT_NOFLAG);
3551 SessionDestroyModule_ROOMOPS
3554 FlushFolder(&sess->CurRoom);
3555 if (sess->cache_fold != NULL) {
3556 free(sess->cache_fold);
3559 free_march_list(sess);
3560 DeleteHash(&sess->Floors);
3561 DeleteHash(&sess->Rooms);
3562 DeleteHash(&sess->FloorsByName);