]> code.citadel.org Git - citadel.git/blobdiff - webcit/roomops.c
* Finally tracked down the WC->vars heap corruption issue (for real this
[citadel.git] / webcit / roomops.c
index bff0aec93bdba1fc93f1396308b0e045a01966e0..c10d9d655e95f4df4b2ff78199a106386e9668cf 100644 (file)
@@ -36,7 +36,8 @@ char *viewdefs[] = {
        "Summary",
        "Address Book",
        "Calendar",
-       "Tasks"
+       "Tasks",
+       "Notes"
 };
 
 char floorlist[128][SIZ];
@@ -114,7 +115,7 @@ void room_tree_list(struct roomlisting *rp)
        urlescputs(rmname);
        wprintf("\"");
        wprintf(">");
-       escputs1(rmname, 1);
+       escputs1(rmname, 1, 1);
        if ((f & QR_DIRECTORY) && (f & QR_NETWORK))
                wprintf("}");
        else if (f & QR_DIRECTORY)
@@ -215,75 +216,21 @@ void listrms(char *variety)
 }
 
 
-/*
- * list all rooms by floor (only should get called from knrooms() because
- * that's where output_headers() is called from)
- */
-void tabular_room_list(void)
-{
-       int a;
-       char buf[SIZ];
-
-       do_template("beginbox_nt");
-       wprintf("<TABLE width=100%% border><TR><TH>Floor</TH>");
-       wprintf("<TH>Rooms with new messages</TH>");
-       wprintf("<TH>Rooms with no new messages</TH></TR>\n");
-
-       for (a = 0; a < 128; ++a)
-               if (floorlist[a][0] != 0) {
-
-                       /* Floor name column */
-                       wprintf("<TR><TD>");
-
-                       serv_printf("OIMG _floorpic_|%d", a);
-                       serv_gets(buf);
-                       if (buf[0] == '2') {
-                               serv_puts("CLOS");
-                               serv_gets(buf);
-                               wprintf("<IMG SRC=\"/image&name=_floorpic_&parm=%d\" ALT=\"%s\">",
-                                       a, &floorlist[a][0]);
-                       } else {
-                               escputs(&floorlist[a][0]);
-                       }
-
-                       wprintf("</TD>");
-
-                       /* Rooms with new messages column */
-                       wprintf("<TD>");
-                       sprintf(buf, "LKRN %d", a);
-                       listrms(buf);
-                       wprintf("</TD>\n<TD>");
-
-                       /* Rooms with old messages column */
-                       sprintf(buf, "LKRO %d", a);
-                       listrms(buf);
-                       wprintf("</TD></TR>\n");
-               }
-       wprintf("</TABLE>\n");
-       do_template("endbox");
-       wDumpContent(1);
-}
-
-
-
-
-
-
-
-
-
 /*
  * list all forgotten rooms
  */
 void zapped_list(void)
 {
-       output_headers(1);
-       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
-       wprintf("<SPAN CLASS=\"titlebar\">Zapped (forgotten) rooms</SPAN>\n");
-       wprintf("</TD></TR></TABLE><BR>\n");
+       output_headers(3);
+
+       svprintf("BOXTITLE", WCS_STRING, "Zapped (forgotten) rooms");
+       do_template("beginbox");
+
        listrms("LZRM -1");
+
        wprintf("<BR><BR>\n");
        wprintf("Click on any room to un-zap it and goto that room.\n");
+       do_template("endbox");
        wDumpContent(1);
 }
 
@@ -298,7 +245,7 @@ void readinfo(void)
        serv_puts("RINF");
        serv_gets(buf);
        if (buf[0] == '1') {
-               fmout(NULL);
+               fmout(NULL, "CENTER");
        }
 }
 
@@ -317,7 +264,7 @@ void embed_room_graphic(void) {
        serv_gets(buf);
        if (buf[0] == '2') {
                wprintf("<TD BGCOLOR=\"#444455\">");
-               wprintf("<IMG SRC=\"/image&name=_roompic_&room=");
+               wprintf("<IMG HEIGHT=64 SRC=\"/image&name=_roompic_&room=");
                urlescputs(WC->wc_roomname);
                wprintf("\"></TD>");
                serv_puts("CLOS");
@@ -412,7 +359,6 @@ void embed_room_banner(char *got) {
        svcallback("START", offer_start_page);
 
        do_template("roombanner");
-       clear_local_substs();
 }
 
 
@@ -420,36 +366,18 @@ void embed_room_banner(char *got) {
 
 
 /*
- * generic routine to take the session to a new room
+ * back end routine to take the session to a new room
  *
- * display_name values:  0 = goto only
- *                       1 = goto and display
- *                       2 = display only
  */
-void gotoroom(char *gname, int display_name)
+void gotoroom(char *gname)
 {
        char buf[SIZ];
        static long ls = (-1L);
 
+       /* store ungoto information */
+       strcpy(WC->ugname, WC->wc_roomname);
+       WC->uglsn = ls;
 
-       if (display_name) {
-               output_headers(0);
-                wprintf("Pragma: no-cache\n");
-                wprintf("Cache-Control: no-store\n");
-
-               wprintf("<HTML><HEAD>\n"
-                       "<META HTTP-EQUIV=\"refresh\" CONTENT=\"500363689;\">\n"
-                       "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">\n"
-                       "<META HTTP-EQUIV=\"expired\" CONTENT=\"28-May-1971 18:10:00 GMT\">\n"
-                       "<meta name=\"MSSmartTagsPreventParsing\" content=\"TRUE\">\n"
-                       "</HEAD>\n");
-               do_template("background");
-       }
-       if (display_name != 2) {
-               /* store ungoto information */
-               strcpy(WC->ugname, WC->wc_roomname);
-               WC->uglsn = ls;
-       }
        /* move to the new room */
        serv_printf("GOTO %s", gname);
        serv_gets(buf);
@@ -458,10 +386,6 @@ void gotoroom(char *gname, int display_name)
                serv_gets(buf);
        }
        if (buf[0] != '2') {
-               if (display_name) {
-                       wprintf("<EM>%s</EM><BR>\n", &buf[4]);
-                       wDumpContent(1);
-               }
                return;
        }
        extract(WC->wc_roomname, &buf[4], 0);
@@ -470,6 +394,9 @@ void gotoroom(char *gname, int display_name)
           maxmsgnum = extract_int(&buf[4],5);
           is_mail = (char) extract_int(&buf[4],7); */
        ls = extract_long(&buf[4], 6);
+       WC->wc_floor = extract_int(&buf[4], 10);
+       WC->wc_view = extract_int(&buf[4], 11);
+       WC->wc_default_view = extract_int(&buf[4], 12);
 
        if (WC->is_aide)
                WC->is_room_aide = WC->is_aide;
@@ -479,15 +406,6 @@ void gotoroom(char *gname, int display_name)
        remove_march(WC->wc_roomname);
        if (!strcasecmp(gname, "_BASEROOM_"))
                remove_march(gname);
-
-       /* Display the room banner */
-       if (display_name) {
-               embed_room_banner(buf);
-               wDumpContent(1);
-       }
-       strcpy(WC->wc_roomname, WC->wc_roomname);
-       WC->wc_view = extract_int(&buf[4], 11);
-       WC->wc_default_view = extract_int(&buf[4], 12);
 }
 
 
@@ -598,7 +516,7 @@ void gotonext(void)
 
 
 void smart_goto(char *next_room) {
-       gotoroom(next_room, 0);
+       gotoroom(next_room);
        readloop("readnew");
 }
 
@@ -732,15 +650,21 @@ void display_editroom(void)
        char *tab;
        char *shared_with;
        char *not_shared_with;
+       int roompolicy = 0;
+       int roomvalue = 0;
+       int floorpolicy = 0;
+       int floorvalue = 0;
 
        tab = bstr("tab");
        if (strlen(tab) == 0) tab = "admin";
 
+       load_floorlist();
        serv_puts("GETR");
        serv_gets(buf);
 
        if (buf[0] != '2') {
-               display_error(&buf[4]);
+               strcpy(WC->ImportantMessage, &buf[4]);
+               display_main_menu();
                return;
        }
        extract(er_name, &buf[4], 0);
@@ -752,17 +676,17 @@ void display_editroom(void)
        output_headers(1);
 
        /* print the tabbed dialog */
-       wprintf("<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
-               "<TR ALIGN=CENTER BGCOLOR=\"#FFFFFF\">"
+       wprintf("<BR><TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
+               "<TR ALIGN=CENTER>"
                "<TD>&nbsp;</TD>\n");
 
        if (!strcmp(tab, "admin")) {
-               wprintf("<TD BGCOLOR=\"#000077\"><SPAN CLASS=\"tablabel\">");
+               wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
        }
        else {
-               wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=admin\">");
+               wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=admin\">");
        }
-       wprintf("Room administration");
+       wprintf("Administration");
        if (!strcmp(tab, "admin")) {
                wprintf("</SPAN></TD>\n");
        }
@@ -773,12 +697,12 @@ void display_editroom(void)
        wprintf("<TD>&nbsp;</TD>\n");
 
        if (!strcmp(tab, "config")) {
-               wprintf("<TD BGCOLOR=\"#000077\"><SPAN CLASS=\"tablabel\">");
+               wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
        }
        else {
-               wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=config\">");
+               wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=config\">");
        }
-       wprintf("Room configuration");
+       wprintf("Configuration");
        if (!strcmp(tab, "config")) {
                wprintf("</SPAN></TD>\n");
        }
@@ -788,11 +712,27 @@ void display_editroom(void)
 
        wprintf("<TD>&nbsp;</TD>\n");
 
+       if (!strcmp(tab, "expire")) {
+               wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
+       }
+       else {
+               wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=expire\">");
+       }
+       wprintf("Message expire policy");
+       if (!strcmp(tab, "expire")) {
+               wprintf("</SPAN></TD>\n");
+       }
+       else {
+               wprintf("</A></TD>\n");
+       }
+
+       wprintf("<TD>&nbsp;</TD>\n");
+
        if (!strcmp(tab, "sharing")) {
-               wprintf("<TD BGCOLOR=\"#000077\"><SPAN CLASS=\"tablabel\">");
+               wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
        }
        else {
-               wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=sharing\">");
+               wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=sharing\">");
        }
        wprintf("Sharing");
        if (!strcmp(tab, "sharing")) {
@@ -805,10 +745,10 @@ void display_editroom(void)
        wprintf("<TD>&nbsp;</TD>\n");
 
        if (!strcmp(tab, "listserv")) {
-               wprintf("<TD BGCOLOR=\"#000077\"><SPAN CLASS=\"tablabel\">");
+               wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
        }
        else {
-               wprintf("<TD BGCOLOR=\"#AAAAAA\"><A HREF=\"/display_editroom&tab=listserv\">");
+               wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=listserv\">");
        }
        wprintf("Mailing list service");
        if (!strcmp(tab, "listserv")) {
@@ -818,12 +758,14 @@ void display_editroom(void)
                wprintf("</A></TD>\n");
        }
 
-       wprintf("<TD>&nbsp;</TD></TR>"
-               "<TR><TD BGCOLOR=\"#000077\" COLSPAN=9 HEIGHT=5> </TD></TR>"
-               "</TABLE>\n");
+       wprintf("<TD>&nbsp;</TD>\n");
 
+       wprintf("</TR></TABLE>\n");
        /* end tabbed dialog */ 
 
+       /* begin content of whatever tab is open now */
+       wprintf("<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
+               "<TR><TD>\n");
 
        if (!strcmp(tab, "admin")) {
                wprintf("<UL>"
@@ -843,7 +785,6 @@ void display_editroom(void)
                wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", er_name);
        
                wprintf("<LI>Resides on floor: ");
-               load_floorlist();
                wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
                for (i = 0; i < 128; ++i)
                        if (strlen(floorlist[i]) > 0) {
@@ -929,6 +870,11 @@ void display_editroom(void)
                        wprintf("CHECKED ");
                wprintf("> Network shared room\n");
 
+               wprintf("<LI><INPUT TYPE=\"checkbox\" NAME=\"permanent\" VALUE=\"yes\" ");
+               if (er_flags & QR_PERMANENT)
+                       wprintf("CHECKED ");
+               wprintf("> Permanent (does not auto-purge)\n");
+
        /* start of anon options */
        
                wprintf("<LI>Anonymous messages<UL>\n");
@@ -962,9 +908,12 @@ void display_editroom(void)
                }
        
                wprintf("</UL><CENTER>\n");
-               wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
-               wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
-               wprintf("</CENTER>\n");
+               wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"config\">\n"
+                       "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
+                       "&nbsp;"
+                       "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">"
+                       "</CENTER>\n"
+               );
        }
 
 
@@ -1139,6 +1088,85 @@ void display_editroom(void)
                wprintf("</CENTER>\n");
        }
 
+
+       /* Mailing list management */
+       if (!strcmp(tab, "expire")) {
+
+               serv_puts("GPEX room");
+               serv_gets(buf);
+               if (buf[0] == '2') {
+                       roompolicy = extract_int(&buf[4], 0);
+                       roomvalue = extract_int(&buf[4], 1);
+               }
+               
+               serv_puts("GPEX floor");
+               serv_gets(buf);
+               if (buf[0] == '2') {
+                       floorpolicy = extract_int(&buf[4], 0);
+                       floorvalue = extract_int(&buf[4], 1);
+               }
+               
+               wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/set_room_policy\">\n");
+               wprintf("<TABLE border=0 cellspacing=5>\n");
+               wprintf("<TR><TD>Message expire policy for this room<BR>(");
+               escputs(WC->wc_roomname);
+               wprintf(")</TD><TD>");
+               wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"0\" %s>",
+                       ((roompolicy == 0) ? "CHECKED" : "") );
+               wprintf("Use the default policy for this floor<BR>\n");
+               wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"1\" %s>",
+                       ((roompolicy == 1) ? "CHECKED" : "") );
+               wprintf("Never automatically expire messages<BR>\n");
+               wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"2\" %s>",
+                       ((roompolicy == 2) ? "CHECKED" : "") );
+               wprintf("Expire by message count<BR>\n");
+               wprintf("<INPUT TYPE=\"radio\" NAME=\"roompolicy\" VALUE=\"3\" %s>",
+                       ((roompolicy == 3) ? "CHECKED" : "") );
+               wprintf("Expire by message age<BR>");
+               wprintf("Number of messages or days: ");
+               wprintf("<INPUT TYPE=\"text\" NAME=\"roomvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">", roomvalue);
+               wprintf("</TD></TR>\n");
+
+               if (WC->axlevel >= 6) {
+                       wprintf("<TR><TD COLSPAN=2><HR></TD></TR>\n");
+                       wprintf("<TR><TD>Message expire policy for this floor<BR>(");
+                       escputs(floorlist[WC->wc_floor]);
+                       wprintf(")</TD><TD>");
+                       wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"0\" %s>",
+                               ((floorpolicy == 0) ? "CHECKED" : "") );
+                       wprintf("Use the system default<BR>\n");
+                       wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"1\" %s>",
+                               ((floorpolicy == 1) ? "CHECKED" : "") );
+                       wprintf("Never automatically expire messages<BR>\n");
+                       wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"2\" %s>",
+                               ((floorpolicy == 2) ? "CHECKED" : "") );
+                       wprintf("Expire by message count<BR>\n");
+                       wprintf("<INPUT TYPE=\"radio\" NAME=\"floorpolicy\" VALUE=\"3\" %s>",
+                               ((floorpolicy == 3) ? "CHECKED" : "") );
+                       wprintf("Expire by message age<BR>");
+                       wprintf("Number of messages or days: ");
+                       wprintf("<INPUT TYPE=\"text\" NAME=\"floorvalue\" MAXLENGTH=\"5\" VALUE=\"%d\">",
+                               floorvalue);
+               }
+
+               wprintf("<CENTER>\n");
+               wprintf("<TR><TD COLSPAN=2><HR><CENTER>\n");
+               wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
+               wprintf("&nbsp;");
+               wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
+               wprintf("</CENTER></TD><TR>\n");
+
+               wprintf("</TABLE>\n"
+                       "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"expire\">\n"
+                       "</FORM>\n"
+               );
+
+       }
+
+
+       /* end content of whatever tab is open now */
+       wprintf("</TD></TR></TABLE>\n");
+
        wDumpContent(1);
 }
 
@@ -1172,14 +1200,17 @@ void editroom(void)
 
 
        if (strcmp(bstr("sc"), "OK")) {
-               display_error("Cancelled.  Changes were not saved.");
+               strcpy(WC->ImportantMessage,
+                       "Cancelled.  Changes were not saved.");
+               display_editroom();
                return;
        }
        serv_puts("GETR");
        serv_gets(buf);
 
        if (buf[0] != '2') {
-               display_error(&buf[4]);
+               strcpy(WC->ImportantMessage, &buf[4]);
+               display_editroom();
                return;
        }
        extract(er_name, &buf[4], 0);
@@ -1236,6 +1267,12 @@ void editroom(void)
                er_flags &= ~QR_READONLY;
        }
 
+       if (!strcmp(bstr("permanent"), "yes")) {
+               er_flags |= QR_PERMANENT;
+       } else {
+               er_flags &= ~QR_PERMANENT;
+       }
+
        if (!strcmp(bstr("network"), "yes")) {
                er_flags |= QR_NETWORK;
        } else {
@@ -1285,21 +1322,26 @@ void editroom(void)
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0] != '2') {
-               display_error(&buf[4]);
+               strcpy(WC->ImportantMessage, &buf[4]);
+               display_editroom();
                return;
        }
-       gotoroom(er_name, 0);
+       gotoroom(er_name);
 
        if (strlen(er_roomaide) > 0) {
                sprintf(buf, "SETA %s", er_roomaide);
                serv_puts(buf);
                serv_gets(buf);
                if (buf[0] != '2') {
-                       display_error(&buf[4]);
+                       strcpy(WC->ImportantMessage, &buf[4]);
+                       display_main_menu();
                        return;
                }
        }
-       smart_goto(er_name);
+       gotoroom(er_name);
+       strcpy(WC->ImportantMessage, "Your changes have been saved.");
+       display_editroom();
+       return;
 }
 
 /*
@@ -1313,30 +1355,24 @@ void display_whok(void)
         serv_gets(buf);
 
         if (buf[0] != '2') {
-                display_error(&buf[4]);
-                return;
+               strcpy(WC->ImportantMessage, &buf[4]);
+               display_main_menu();
+               return;
         }
         extract(room, &buf[4], 0);
 
         strcpy(username, bstr("username"));
 
-        output_headers(1);
-
-        wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#007700\"><TR><TD>");
-        wprintf("<SPAN CLASS=\"titlebar\">Access control list for ");
-       escputs(WC->wc_roomname);
-        wprintf("</SPAN></TD></TR></TABLE>\n");
-
         if(!strcmp(bstr("sc"), "Kick")) {
                 sprintf(buf, "KICK %s", username);
                 serv_puts(buf);
                 serv_gets(buf);
 
                 if (buf[0] != '2') {
-                        display_error(&buf[4]);
-                        return;
+                        strcpy(WC->ImportantMessage, &buf[4]);
                 } else {
-                        wprintf("<B><I>User %s kicked out of room %s.</I></B>\n", 
+                        sprintf(WC->ImportantMessage,
+                               "<B><I>User %s kicked out of room %s.</I></B>\n", 
                                 username, room);
                 }
         } else if(!strcmp(bstr("sc"), "Invite")) {
@@ -1345,15 +1381,18 @@ void display_whok(void)
                 serv_gets(buf);
 
                 if (buf[0] != '2') {
-                        display_error(&buf[4]);
-                        return;
+                        strcpy(WC->ImportantMessage, &buf[4]);
                 } else {
-                        wprintf("<B><I>User %s invited to room %s.</I></B>\n", 
+                        sprintf(WC->ImportantMessage,
+                               "<B><I>User %s invited to room %s.</I></B>\n", 
                                 username, room);
                 }
         }
         
-
+        output_headers(1);
+       stresc(buf, WC->wc_roomname, 1, 1);
+       svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
+       do_template("beginbox");
 
        wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
                "<TD>The users listed below have access to this room.  "
@@ -1389,6 +1428,7 @@ void display_whok(void)
                "</FORM></CENTER>\n");
 
        wprintf("</TD></TR></TABLE>\n");
+       do_template("endbox");
         wDumpContent(1);
 }
 
@@ -1406,19 +1446,30 @@ void display_entroom(void)
        serv_gets(buf);
 
        if (buf[0] != '2') {
-               display_error(&buf[4]);
+               strcpy(WC->ImportantMessage, &buf[4]);
+               display_main_menu();
                return;
        }
-       output_headers(1);
-
-       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#000077\"><TR><TD>");
-       wprintf("<SPAN CLASS=\"titlebar\">Enter (create) a new room</SPAN>\n");
-       wprintf("</TD></TR></TABLE>\n");
+       output_headers(3);
+       svprintf("BOXTITLE", WCS_STRING, "Create a new room");
+       do_template("beginbox");
 
        wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
 
        wprintf("<UL><LI>Name of room: ");
-       wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"19\">\n");
+       wprintf("<INPUT TYPE=\"text\" NAME=\"er_name\" MAXLENGTH=\"127\">\n");
+
+        wprintf("<LI>Resides on floor: ");
+        load_floorlist(); 
+        wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
+        for (i = 0; i < 128; ++i)
+                if (strlen(floorlist[i]) > 0) {
+                        wprintf("<OPTION ");
+                        wprintf("VALUE=\"%d\">", i);
+                        escputs(floorlist[i]);
+                        wprintf("</OPTION>\n");
+                }
+        wprintf("</SELECT>\n");
 
        wprintf("<LI>Type of room:<UL>\n");
 
@@ -1434,57 +1485,99 @@ void display_entroom(void)
 
        wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"invonly\" ");
        wprintf("> Private - invitation only\n");
-       wprintf("</UL>\n");
 
-        wprintf("<LI>Resides on floor: ");
-        load_floorlist(); 
-        wprintf("<SELECT NAME=\"er_floor\" SIZE=\"1\">\n");
-        for (i = 0; i < 128; ++i)
-                if (strlen(floorlist[i]) > 0) {
-                        wprintf("<OPTION ");
-                        wprintf("VALUE=\"%d\">", i);
-                        escputs(floorlist[i]);
-                        wprintf("</OPTION>\n");
-                }
-        wprintf("</SELECT>\n");                
+       wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"personal\" ");
+       wprintf("> Personal (mailbox for you only)\n");
        wprintf("</UL>\n");
 
+       wprintf("<LI>Default view for room: "); /* FOO */
+        wprintf("<SELECT NAME=\"er_view\" SIZE=\"1\">\n");
+       for (i=0; i<(sizeof viewdefs / sizeof (char *)); ++i) {
+               wprintf("<OPTION %s VALUE=\"%d\">",
+                       ((i == 0) ? "SELECTED" : ""), i );
+               escputs(viewdefs[i]);
+               wprintf("</OPTION>\n");
+       }
+       wprintf("</SELECT>\n");
 
        wprintf("<CENTER>\n");
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
+       wprintf("&nbsp;");
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
        wprintf("</CENTER>\n");
        wprintf("</FORM>\n<HR>");
        serv_printf("MESG roomaccess");
        serv_gets(buf);
        if (buf[0] == '1') {
-               fmout(NULL);
+               fmout(NULL, "CENTER");
        }
+       do_template("endbox");
        wDumpContent(1);
 }
 
 
 
+
+/*
+ * support function for entroom() -- sets the default view 
+ */
+void er_set_default_view(int newview) {
+
+       char buf[SIZ];
+
+       char rm_name[SIZ];
+       char rm_pass[SIZ];
+       char rm_dir[SIZ];
+       int rm_bits1;
+       int rm_floor;
+       int rm_listorder;
+       int rm_bits2;
+
+       serv_puts("GETR");
+       serv_gets(buf);
+       if (buf[0] != '2') return;
+
+       extract(rm_name, &buf[4], 0);
+       extract(rm_pass, &buf[4], 1);
+       extract(rm_dir, &buf[4], 2);
+       rm_bits1 = extract_int(&buf[4], 3);
+       rm_floor = extract_int(&buf[4], 4);
+       rm_listorder = extract_int(&buf[4], 5);
+       rm_bits2 = extract_int(&buf[4], 7);
+
+       serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
+               rm_name, rm_pass, rm_dir, rm_bits1, rm_floor,
+               rm_listorder, newview, rm_bits2
+       );
+       serv_gets(buf);
+}
+
+
+
 /*
  * enter a new room
  */
 void entroom(void)
 {
        char buf[SIZ];
-       char er_name[20];
-       char er_type[20];
-       char er_password[10];
+       char er_name[SIZ];
+       char er_type[SIZ];
+       char er_password[SIZ];
        int er_floor;
        int er_num_type;
+       int er_view;
 
        if (strcmp(bstr("sc"), "OK")) {
-               display_error("Cancelled.  No new room was created.");
+               strcpy(WC->ImportantMessage,
+                       "Cancelled.  No new room was created.");
+               display_main_menu();
                return;
        }
        strcpy(er_name, bstr("er_name"));
        strcpy(er_type, bstr("type"));
        strcpy(er_password, bstr("er_password"));
        er_floor = atoi(bstr("er_floor"));
+       er_view = atoi(bstr("er_view"));
 
        er_num_type = 0;
        if (!strcmp(er_type, "guessname"))
@@ -1493,16 +1586,20 @@ void entroom(void)
                er_num_type = 2;
        if (!strcmp(er_type, "invonly"))
                er_num_type = 3;
+       if (!strcmp(er_type, "personal"))
+               er_num_type = 4;
 
-       sprintf(buf, "CRE8 1|%s|%d|%s|%d", 
-               er_name, er_num_type, er_password, er_floor);
+       sprintf(buf, "CRE8 1|%s|%d|%s|%d|%d|%d", 
+               er_name, er_num_type, er_password, er_floor, 0, er_view);
        serv_puts(buf);
        serv_gets(buf);
        if (buf[0] != '2') {
-               display_error(&buf[4]);
+               strcpy(WC->ImportantMessage, &buf[4]);
+               display_main_menu();
                return;
        }
-       smart_goto(er_name);
+       gotoroom(er_name);
+       do_change_view(er_view);                /* Now go there */
 }
 
 
@@ -1512,14 +1609,13 @@ void entroom(void)
 void display_private(char *rname, int req_pass)
 {
 
-       output_headers(1);
+       output_headers(3);
 
-       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#770000\"><TR><TD>");
-       wprintf("<SPAN CLASS=\"titlebar\">Goto a private room</SPAN>\n");
-       wprintf("</TD></TR></TABLE>\n");
+       svprintf("BOXTITLE", WCS_STRING, "Go to a hidden room");
+       do_template("beginbox");
 
        wprintf("<CENTER>\n");
-       wprintf("If you know the name of a hidden (guess-name) or\n");
+       wprintf("<BR>If you know the name of a hidden (guess-name) or\n");
        wprintf("passworded room, you can enter that room by typing\n");
        wprintf("its name below.  Once you gain access to a private\n");
        wprintf("room, it will appear in your regular room listings\n");
@@ -1528,20 +1624,25 @@ void display_private(char *rname, int req_pass)
 
        wprintf("<FORM METHOD=\"GET\" ACTION=\"/goto_private\">\n");
 
-       wprintf("<TABLE border><TR><TD>");
-       wprintf("Enter room name:</TD><TD>");
-       wprintf("<INPUT TYPE=\"text\" NAME=\"gr_name\" VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
+       wprintf("<table border=\"0\" cellspacing=\"5\" "
+               "cellpadding=\"5\" BGCOLOR=\"#EEEEEE\">\n"
+               "<TR><TD>"
+               "Enter room name:</TD><TD>"
+               "<INPUT TYPE=\"text\" NAME=\"gr_name\" "
+               "VALUE=\"%s\" MAXLENGTH=\"19\">\n", rname);
 
        if (req_pass) {
                wprintf("</TD></TR><TR><TD>");
                wprintf("Enter room password:</TD><TD>");
                wprintf("<INPUT TYPE=\"password\" NAME=\"gr_pass\" MAXLENGTH=\"9\">\n");
        }
-       wprintf("</TD></TR></TABLE>\n");
+       wprintf("</TD></TR></TABLE><BR>\n");
 
-       wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
-       wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
+       wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">"
+               "&nbsp;"
+               "<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
        wprintf("</FORM>\n");
+       do_template("endbox");
        wDumpContent(1);
 }
 
@@ -1597,6 +1698,7 @@ void display_zap(void)
 
        wprintf("<FORM METHOD=\"GET\" ACTION=\"/zap\">\n");
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"OK\">");
+       wprintf("&nbsp;");
        wprintf("<INPUT TYPE=\"submit\" NAME=\"sc\" VALUE=\"Cancel\">");
        wprintf("</FORM>\n");
        wDumpContent(1);
@@ -1647,7 +1749,8 @@ void confirm_delete_room(void)
        serv_puts("KILL 0");
        serv_gets(buf);
        if (buf[0] != '2') {
-               display_error(&buf[4]);
+               strcpy(WC->ImportantMessage, &buf[4]);
+               display_main_menu();
                return;
        }
        output_headers(1);
@@ -1681,13 +1784,17 @@ void delete_room(void)
        strcpy(sc, bstr("sc"));
 
        if (strcasecmp(sc, "Delete")) {
-               display_error("Cancelled.  This room was not deleted.");
+               strcpy(WC->ImportantMessage,
+                       "Cancelled.  This room was not deleted.");
+               display_main_menu();
                return;
        }
        serv_puts("KILL 1");
        serv_gets(buf);
        if (buf[0] != '2') {
-               display_error(&buf[4]);
+               strcpy(WC->ImportantMessage, &buf[4]);
+               display_main_menu();
+               return;
        } else {
                smart_goto("_BASEROOM_");
        }
@@ -1790,6 +1897,17 @@ void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
 
 
 
+/*
+ * Back end for change_view()
+ */
+void do_change_view(int newview) {
+       char buf[SIZ];
+
+       serv_printf("VIEW %d", newview);
+       serv_gets(buf);
+       WC->wc_view = newview;
+       smart_goto(WC->wc_roomname);
+}
 
 
 
@@ -1798,13 +1916,9 @@ void room_to_folder(char *folder, char *room, int floor, int is_mailbox)
  */
 void change_view(void) {
        int view;
-       char buf[SIZ];
 
        view = atol(bstr("view"));
-
-       serv_printf("VIEW %d", view);
-       serv_gets(buf);
-       smart_goto(WC->wc_roomname);
+       do_change_view(view);
 }
 
 
@@ -1815,39 +1929,90 @@ void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
        char buf[SIZ];
        int levels, oldlevels;
        int i, t;
+       int actnum = 0;
+       int has_subfolders = 0;
+
+       /* Include the menu expanding/collapsing code */
+       wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
 
        do_template("beginbox_nt");
+       wprintf("<div id=\"mainMenu\">\n");
+       wprintf("<UL id=\"menuList\">\n");
        levels = 0;
        oldlevels = 0;
+
        for (i=0; i<max_folders; ++i) {
 
+               has_subfolders = 0;
+               if ((i+1) < max_folders) {
+                       if ( (!strncasecmp(fold[i].name, fold[i+1].name, strlen(fold[i].name)))
+                          && (fold[i+1].name[strlen(fold[i].name)] == '|') ) {
+                               has_subfolders = 1;
+                       }
+               }
+
                levels = num_tokens(fold[i].name, '|');
-               oldlevels = levels;
 
-               for (t=0; t<levels; ++t) wprintf("&nbsp;&nbsp;&nbsp;");
+               if ( (levels < oldlevels) || ((levels==1)&&(i!=0)) ) {
+                       for (t=0; t<(oldlevels-levels); ++t) {
+                               wprintf("</UL>\n");
+                       }
+               }
+
+               if (has_subfolders) {
+                       wprintf("<LI");
+                       if (levels == 1) wprintf(" class=\"menubar\"");
+                       wprintf(">");
+                       wprintf("<A href=\"#\" id=\"actuator%d\" class=\"actuator\"></a>\n", actnum);
+               }
+               else {
+                       wprintf("<LI>");
+               }
+
                if (fold[i].selectable) {
                        wprintf("<A HREF=\"/dotgoto?room=");
                        urlescputs(fold[i].room);
                        wprintf("\">");
                }
+
+               if (levels == 1) {
+                       wprintf("<SPAN CLASS=\"roomlist_floor\">");
+               }
+               else if (fold[i].hasnewmsgs) {
+                       wprintf("<SPAN CLASS=\"roomlist_new\">");
+               }
                else {
-                       wprintf("<i>");
+                       wprintf("<SPAN CLASS=\"roomlist_old\">");
                }
-               if (fold[i].hasnewmsgs) wprintf("<B>");
                extract(buf, fold[i].name, levels-1);
                escputs(buf);
-               if (fold[i].hasnewmsgs) wprintf("</B>");
+               wprintf("</SPAN>");
+
+               if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
+                       wprintf(" (INBOX)");
+               }
+
                if (fold[i].selectable) {
                        wprintf("</A>");
                }
-               else {
-                       wprintf("</i>");
-               }
-               if (!strcasecmp(fold[i].name, "My Folders|Mail")) {
-                       wprintf(" (INBOX)");
+               wprintf("\n");
+
+               if (has_subfolders) {
+                       wprintf("<UL id=\"menu%d\" class=\"%s\">\n",
+                               actnum++,
+                               ( (levels == 1) ? "menu" : "submenu")
+                       );
                }
-               wprintf("<BR>\n");
+
+               oldlevels = levels;
        }
+       wprintf("</UL></UL>\n");
+       wprintf("<img src=\"/static/blank.gif\" onLoad = ' \n");
+       for (i=0; i<actnum; ++i) {
+               wprintf(" initializeMenu(\"menu%d\", \"actuator%d\");\n", i, i);
+       }
+       wprintf(" ' > \n");
+       wprintf("</DIV>\n");
        do_template("endbox");
 }
 
@@ -1863,8 +2028,11 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
        static int columns = 3;
        int boxes_per_column = 0;
        int current_column = 0;
+       int nf;
 
-       boxes_per_column = (num_floors / columns);
+       nf = num_floors;
+       while (nf % columns != 0) ++nf;
+       boxes_per_column = (nf / columns);
        if (boxes_per_column < 1) boxes_per_column = 1;
 
        /* Outer table (for columnization) */
@@ -1877,7 +2045,7 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
 
                levels = num_tokens(fold[i].name, '|');
 
-               if ((levels == 1) && (oldlevels == 2)) {
+               if ((levels == 1) && (oldlevels > 1)) {
 
                        /* End inner box */
                        do_template("endbox");
@@ -1895,7 +2063,7 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
 
                        /* Begin inner box */
                        extract(buf, fold[i].name, levels-1);
-                       stresc(boxtitle, buf, 1);
+                       stresc(boxtitle, buf, 1, 0);
                        svprintf("BOXTITLE", WCS_STRING, boxtitle);
                        do_template("beginbox");
 
@@ -1914,10 +2082,15 @@ void do_rooms_view(struct folder *fold, int max_folders, int num_floors) {
                        else {
                                wprintf("<i>");
                        }
-                       if (fold[i].hasnewmsgs) wprintf("<B>");
+                       if (fold[i].hasnewmsgs) {
+                               wprintf("<SPAN CLASS=\"roomlist_new\">");
+                       }
+                       else {
+                               wprintf("<SPAN CLASS=\"roomlist_old\">");
+                       }
                        extract(buf, fold[i].name, levels-1);
                        escputs(buf);
-                       if (fold[i].hasnewmsgs) wprintf("</B>");
+                       wprintf("</SPAN>");
                        if (fold[i].selectable) {
                                wprintf("</A>");
                        }
@@ -2065,7 +2238,7 @@ void knrooms() {
        }
 
        /* title bar */
-       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#000077\"><TR><TD>"
+       wprintf("<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
                "<SPAN CLASS=\"titlebar\">"
        );
        if (!strcasecmp(listviewpref, "rooms")) {
@@ -2081,7 +2254,7 @@ void knrooms() {
 
 
        /* offer the ability to switch views */
-       wprintf("<TD><FORM NAME=\"roomlistomatic\">\n"
+       wprintf("<TD ALIGN=RIGHT><FORM NAME=\"roomlistomatic\">\n"
                "<SELECT NAME=\"newview\" SIZE=\"1\" "
                "OnChange=\"location.href=roomlistomatic.newview.options"
                "[selectedIndex].value\">\n");
@@ -2098,21 +2271,39 @@ void knrooms() {
                ( !strcasecmp(listviewpref, "folders") ? "SELECTED" : "" )
        );
 
-       wprintf("<OPTION %s VALUE=\"/knrooms&view=table\">"
-               "Classic table view"
-               "</OPTION>\n",
-               ( !strcasecmp(listviewpref, "table") ? "SELECTED" : "" )
-       );
-
-       wprintf("</SELECT></FORM></TD><TD>\n");
+       wprintf("</SELECT><BR>");
        offer_start_page();
-       wprintf("</TD></TR></TABLE><BR>\n");
+       wprintf("</FORM></TD></TR></TABLE>\n");
 
        /* Display the room list in the user's preferred format */
-       if (!strcasecmp(listviewpref, "table")) {
-               tabular_room_list();
+       list_all_rooms_by_floor(listviewpref);
+}
+
+
+
+/* 
+ * Set the message expire policy for this room and/or floor
+ */
+void set_room_policy(void) {
+       char buf[SIZ];
+
+       if (strcmp(bstr("sc"), "OK")) {
+               strcpy(WC->ImportantMessage,
+                       "Cancelled.  Changes were not saved.");
+               display_editroom();
+               return;
        }
-       else {
-               list_all_rooms_by_floor(listviewpref);
+
+       serv_printf("SPEX room|%d|%d", atoi(bstr("roompolicy")), atoi(bstr("roomvalue")));
+       serv_gets(buf);
+       strcpy(WC->ImportantMessage, &buf[4]);
+
+       if (WC->axlevel >= 6) {
+               strcat(WC->ImportantMessage, "<BR>\n");
+               serv_printf("SPEX floor|%d|%d", atoi(bstr("floorpolicy")), atoi(bstr("floorvalue")));
+               serv_gets(buf);
+               strcat(WC->ImportantMessage, &buf[4]);
        }
+
+       display_editroom();
 }