* Replaced all the "centered 99% tables" with 100% width tables wrapped
[citadel.git] / webcit / roomops.c
index dde608aa776316aa6cdb5bec64ccfe5fb6d547bc..62b0fbb124c843c4732116c914dd111189621fa0 100644 (file)
@@ -1,5 +1,8 @@
-/* $Id$ */
-
+/*
+ * $Id$
+ *
+ * Lots of different room-related operations.
+ */
 
 #include <ctype.h>
 #include <stdlib.h>
@@ -326,7 +329,7 @@ void embed_view_o_matic(void) {
 
 
 
-void embed_room_banner(char *got) {
+void embed_room_banner(char *got, int navbar_style) {
        char fakegot[SIZ];
 
        /* We need to have the information returned by a GOTO server command.
@@ -357,7 +360,154 @@ void embed_room_banner(char *got) {
        svcallback("YOUHAVEMAIL", embed_newmail_button);
        svcallback("VIEWOMATIC", embed_view_o_matic);
        svcallback("START", offer_start_page);
+
        do_template("roombanner");
+       if (navbar_style != navbar_none) {
+
+               wprintf("<div style=\"position:absolute; bottom:0px; left:0px\">\n"
+                       "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%%\"><tr>\n");
+
+
+               if (navbar_style == navbar_default) wprintf(
+                       "<td>"
+                       "<a href=\"/ungoto\">"
+                       "<img align=\"middle\" src=\"/static/back.gif\" border=\"0\">"
+                       "<span class=\"navbar_link\">Ungoto</span></A>"
+                       "</td>\n"
+               );
+
+               if ( (navbar_style == navbar_default)
+                  && (WC->wc_view != VIEW_CALENDAR) 
+                  && (WC->wc_view != VIEW_ADDRESSBOOK) 
+                  && (WC->wc_view != VIEW_NOTES) 
+                  && (WC->wc_view != VIEW_TASKS) 
+                  ) {
+                       wprintf(
+                               "<td>"
+                               "<A HREF=\"/readnew\">"
+                               "<img align=\"middle\" src=\"/static/readmsgs.gif\" border=\"0\">"
+                               "<span class=\"navbar_link\">Read new messages</span></A>"
+                               "</td>\n"
+                       );
+               }
+
+               if (navbar_style == navbar_default) {
+                       switch(WC->wc_view) {
+                               case VIEW_ADDRESSBOOK:
+                                       wprintf(
+                                               "<td>"
+                                               "<A HREF=\"/readfwd\">"
+                                               "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
+                                               "border=\"0\">"
+                                               "<span class=\"navbar_link\">"
+                                               "View contacts"
+                                               "</span></a></td>\n"
+                                       );
+                                       break;
+                               case VIEW_CALENDAR:
+                                       wprintf(
+                                               "<td>"
+                                               "<A HREF=\"/readfwd?calview=day\">"
+                                               "<img align=\"middle\" src=\"/static/day_view.gif\" "
+                                               "border=\"0\">"
+                                               "<span class=\"navbar_link\">"
+                                               "Day view"
+                                               "</span></a></td>\n"
+                                       );
+                                       wprintf(
+                                               "<td>"
+                                               "<A HREF=\"/readfwd?calview=month\">"
+                                               "<img align=\"middle\" src=\"/static/month_view.gif\" "
+                                               "border=\"0\">"
+                                               "<span class=\"navbar_link\">"
+                                               "Month view"
+                                               "</span></a></td>\n"
+                                       );
+                                       break;
+                               case VIEW_TASKS:
+                                       wprintf(
+                                               "<td>"
+                                               "<A HREF=\"/readfwd\">"
+                                               "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
+                                               "border=\"0\">"
+                                               "<span class=\"navbar_link\">"
+                                               "View tasks"
+                                               "</span></a></td>\n"
+                                       );
+                                       break;
+                               case VIEW_NOTES:
+                                       wprintf(
+                                               "<td>"
+                                               "<A HREF=\"/readfwd\">"
+                                               "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
+                                               "border=\"0\">"
+                                               "<span class=\"navbar_link\">"
+                                               "View notes"
+                                               "</span></a></td>\n"
+                                       );
+                                       break;
+                               default:
+                                       wprintf(
+                                               "<td>"
+                                               "<A HREF=\"/readfwd\">"
+                                               "<img align=\"middle\" src=\"/static/readmsgs.gif\" "
+                                               "border=\"0\">"
+                                               "<span class=\"navbar_link\">"
+                                               "Read all messages"
+                                               "</span></a></td>\n"
+                                       );
+                                       break;
+                       }
+               }
+
+               if (navbar_style == navbar_default) {
+                       wprintf(
+                               "<td>"
+                               "<A HREF=\"/display_enter\">"
+                               "<img align=\"middle\" src=\"/static/enter.gif\" border=\"0\">"
+                               "<span class=\"navbar_link\">"
+                       );
+                       switch(WC->wc_view) {
+                               case VIEW_ADDRESSBOOK:
+                                       wprintf("Add new contact");
+                                       break;
+                               case VIEW_CALENDAR:
+                                       wprintf("Add new event");
+                                       break;
+                               case VIEW_TASKS:
+                                       wprintf("Add new task");
+                                       break;
+                               case VIEW_NOTES:
+                                       wprintf("Add new note");
+                                       break;
+                               default:
+                                       wprintf("Enter a message");
+                                       break;
+                       }
+                       wprintf("</span></a></td>\n");
+               }
+
+               if (navbar_style == navbar_default) wprintf(
+                       "<td>"
+                       "<A HREF=\"/skip\" "
+                       "TITLE=\"Leave all messages marked as unread, go to next room with unread messages\">"
+                       "<span class=\"navbar_link\">Skip this room</span>"
+                       "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
+                       "</td>\n"
+               );
+
+               if (navbar_style == navbar_default) wprintf(
+                       "<td>"
+                       "<A HREF=\"/gotonext\" "
+                       "TITLE=\"Mark all messages as read, go to next room with unread messages\">"
+                       "<span class=\"navbar_link\">Goto next room</span>"
+                       "<img align=\"middle\" src=\"/static/forward.gif\" border=\"0\"></A>"
+                       "</td>\n"
+               );
+
+               wprintf("</tr></table></div>\n");
+       }
+
 }
 
 
@@ -676,7 +826,9 @@ void display_editroom(void)
        output_headers(1, 1, 1, 0, 0, 0, 0);
 
        /* print the tabbed dialog */
-       wprintf("<br /><TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
+       wprintf("<br />"
+               "<div style=\"margin-right:1px\">"
+               "<TABLE border=0 cellspacing=0 cellpadding=0 width=100%%>"
                "<TR ALIGN=CENTER>"
                "<TD>&nbsp;</TD>\n");
 
@@ -728,6 +880,22 @@ void display_editroom(void)
 
        wprintf("<TD>&nbsp;</TD>\n");
 
+       if (!strcmp(tab, "access")) {
+               wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
+       }
+       else {
+               wprintf("<TD BGCOLOR=\"#CCCCCC\"><A HREF=\"/display_editroom&tab=access\">");
+       }
+       wprintf("Access controls");
+       if (!strcmp(tab, "access")) {
+               wprintf("</SPAN></TD>\n");
+       }
+       else {
+               wprintf("</A></TD>\n");
+       }
+
+       wprintf("<TD>&nbsp;</TD>\n");
+
        if (!strcmp(tab, "sharing")) {
                wprintf("<TD BGCOLOR=\"#FFFFFF\"><SPAN CLASS=\"tablabel\">");
        }
@@ -760,11 +928,12 @@ void display_editroom(void)
 
        wprintf("<TD>&nbsp;</TD>\n");
 
-       wprintf("</TR></TABLE>\n");
+       wprintf("</TR></TABLE></div>\n");
        /* end tabbed dialog */ 
 
        /* begin content of whatever tab is open now */
-       wprintf("<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
+       wprintf("<div style=\"margin-right:1px\">"
+               "<TABLE border=0 width=100%% bgcolor=\"#FFFFFF\">\n"
                "<TR><TD>\n");
 
        if (!strcmp(tab, "admin")) {
@@ -1229,9 +1398,13 @@ void display_editroom(void)
 
        }
 
+       /* Mailing list management */
+       if (!strcmp(tab, "access")) {
+               display_whok();
+       }
 
        /* end content of whatever tab is open now */
-       wprintf("</TD></TR></TABLE>\n");
+       wprintf("</TD></TR></TABLE></div>\n");
 
        wDumpContent(1);
 }
@@ -1410,26 +1583,25 @@ void editroom(void)
        return;
 }
 
+
 /*
- * Invite, Kick, and show Who Knows a room
+ * Display form for Invite, Kick, and show Who Knows a room
  */
-void display_whok(void)
-{
+void do_invt_kick(void) {
         char buf[SIZ], room[SIZ], username[SIZ];
 
         serv_puts("GETR");
         serv_gets(buf);
 
         if (buf[0] != '2') {
-               strcpy(WC->ImportantMessage, &buf[4]);
-               display_main_menu();
+               escputs(&buf[4]);
                return;
         }
         extract(room, &buf[4], 0);
 
         strcpy(username, bstr("username"));
 
-        if(!strcmp(bstr("sc"), "Kick")) {
+        if (!strcmp(bstr("sc"), "Kick")) {
                 sprintf(buf, "KICK %s", username);
                 serv_puts(buf);
                 serv_gets(buf);
@@ -1441,7 +1613,9 @@ void display_whok(void)
                                "<B><I>User %s kicked out of room %s.</I></B>\n", 
                                 username, room);
                 }
-        } else if(!strcmp(bstr("sc"), "Invite")) {
+        }
+
+       if (!strcmp(bstr("sc"), "Invite")) {
                 sprintf(buf, "INVT %s", username);
                 serv_puts(buf);
                 serv_gets(buf);
@@ -1454,19 +1628,37 @@ void display_whok(void)
                                 username, room);
                 }
         }
-        
-        output_headers(1, 1, 1, 0, 0, 0, 0);
-       stresc(buf, WC->wc_roomname, 1, 1);
-       svprintf("BOXTITLE", WCS_STRING, "Access control list for %s", buf);
-       do_template("beginbox");
 
+       display_editroom();
+}
+
+
+
+/*
+ * Display form for Invite, Kick, and show Who Knows a room
+ */
+void display_whok(void)
+{
+        char buf[SIZ], room[SIZ], username[SIZ];
+
+        serv_puts("GETR");
+        serv_gets(buf);
+
+        if (buf[0] != '2') {
+               escputs(&buf[4]);
+               return;
+        }
+        extract(room, &buf[4], 0);
+
+        
        wprintf("<TABLE border=0 CELLSPACING=10><TR VALIGN=TOP>"
                "<TD>The users listed below have access to this room.  "
                "To remove a user from the access list, select the user "
                "name from the list and click 'Kick'.<br /><br />");
        
-        wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
-        wprintf("<SELECT NAME=\"username\" SIZE=10>\n");
+        wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
+       wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
+        wprintf("<SELECT NAME=\"username\" SIZE=\"10\" style=\"width:100%%\">\n");
         serv_puts("WHOK");
         serv_gets(buf);
         if (buf[0] == '1') {
@@ -1486,15 +1678,15 @@ void display_whok(void)
                "To grant another user access to this room, enter the "
                "user name in the box below and click 'Invite'.<br /><br />");
 
-        wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/display_whok\">\n");
+        wprintf("<CENTER><FORM METHOD=\"POST\" ACTION=\"/do_invt_kick\">\n");
+       wprintf("<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"access\">\n");
         wprintf("Invite: ");
-        wprintf("<input type=text name=username><br />\n"
-               "<input type=hidden name=sc value=\"Invite\">"
-               "<input type=submit value=\"Invite\">"
+        wprintf("<input type=\"text\" name=\"username\" style=\"width:100%%\"><br />\n"
+               "<input type=\"hidden\" name=\"sc\" value=\"Invite\">"
+               "<input type=\"submit\" value=\"Invite\">"
                "</FORM></CENTER>\n");
 
        wprintf("</TD></TR></TABLE>\n");
-       do_template("endbox");
         wDumpContent(1);
 }
 
@@ -1516,9 +1708,17 @@ void display_entroom(void)
                display_main_menu();
                return;
        }
-       output_headers(1, 1, 0, 0, 0, 0, 0);
-       svprintf("BOXTITLE", WCS_STRING, "Create a new room");
-       do_template("beginbox");
+
+       output_headers(1, 1, 2, 0, 0, 0, 0);
+       wprintf("<div id=\"banner\">\n"
+               "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
+               "<SPAN CLASS=\"titlebar\">Create a new room</SPAN>"
+               "</TD></TR></TABLE>\n"
+               "</div>\n<div id=\"content\">\n"
+       );
+
+       wprintf("<div style=\"margin-right:1px\">"
+               "<table border=0 width=100%% bgcolor=\"#ffffff\"><tr><td>\n");
 
        wprintf("<FORM METHOD=\"POST\" ACTION=\"/entroom\">\n");
 
@@ -1537,6 +1737,16 @@ void display_entroom(void)
                 }
         wprintf("</SELECT>\n");
 
+       wprintf("<LI>Default view for room: ");
+        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("<LI>Type of room:<UL>\n");
 
        wprintf("<LI><INPUT TYPE=\"radio\" NAME=\"type\" VALUE=\"public\" ");
@@ -1556,16 +1766,6 @@ void display_entroom(void)
        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;");
@@ -1577,7 +1777,7 @@ void display_entroom(void)
        if (buf[0] == '1') {
                fmout(NULL, "CENTER");
        }
-       do_template("endbox");
+       wprintf("</td></tr></table></div>\n");
        wDumpContent(1);
 }
 
@@ -1789,14 +1989,10 @@ void zap(void)
        if (!strcasecmp(bstr("sc"), "OK")) {
                serv_printf("GOTO %s", WC->wc_roomname);
                serv_gets(buf);
-               if (buf[0] != '2') {
-                       /* ExpressMessageCat(&buf[4]); */
-               } else {
+               if (buf[0] == '2') {
                        serv_puts("FORG");
                        serv_gets(buf);
-                       if (buf[0] != '2') {
-                               /* ExpressMessageCat(&buf[4]); */
-                       } else {
+                       if (buf[0] == '2') {
                                strcpy(final_destination, "_BASEROOM_");
                        }
                }
@@ -2015,6 +2211,7 @@ void do_folder_view(struct folder *fold, int max_folders, int num_floors) {
        wprintf("<script type=\"text/javascript\" src=\"/static/menuExpandable3.js\"></script>\n");
 
        /* BEGIN TREE MENU */
+       wprintf("<div style=\"background: white\">\n");
        wprintf("<div id=\"mainMenu\">\n");
        wprintf("<UL id=\"menuList\">\n");
        levels = 0;
@@ -2362,6 +2559,7 @@ void knrooms() {
        offer_start_page();
        wprintf("</FORM></TD></TR></TABLE>\n");
        wprintf("</div>\n"
+               "</div>\n"
                "<div id=\"content\">\n");
 
        /* Display the room list in the user's preferred format */