* self-service
authorArt Cancro <ajc@citadel.org>
Fri, 16 Aug 2002 22:06:51 +0000 (22:06 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 16 Aug 2002 22:06:51 +0000 (22:06 +0000)
webcit/ChangeLog
webcit/listsub.c
webcit/roomops.c
webcit/webcit.c
webcit/webcit.h

index 2593dc1ece39eb60f7defe07859ec685480297ea..66c2dfa0dcf0eca26767a9182b91d0a1d25b30c2 100644 (file)
@@ -1,4 +1,7 @@
 $Log$
+Revision 323.59  2002/08/16 22:06:51  ajc
+* self-service
+
 Revision 323.58  2002/08/16 03:51:12  ajc
 * I think I've finally nailed the 'no session' pages now...
 
@@ -900,3 +903,4 @@ Sun Dec  6 19:50:55 EST 1998 Art Cancro <ajc@uncnsrd.mt-kisco.ny.us>
 
 1998-12-03 Nathan Bryant <bryant@cs.usm.maine.edu>
        * webserver.c: warning fix
+
index c58a7bad199dbfc989219140620c0692f6c56989..78eb3eab4fe2d21dd17416079910aeef1af63b6c 100644 (file)
@@ -33,6 +33,8 @@ void do_listsub(void)
        char subtype[SIZ];
 
        char buf[SIZ];
+       int self;
+       char sroom[SIZ];
 
        strcpy(WC->wc_username, "");
        strcpy(WC->wc_password, "");
@@ -97,11 +99,25 @@ FORM:               wprintf("<FORM METHOD=\"POST\" ACTION=\"/listsub\">\n"
                );
 
                wprintf("<TR><TD>Name of list</TD><TD>"
-                       "<INPUT TYPE=\"text\" NAME=\"room\" "
-                       "VALUE=\""
-               );
-               escputs(room);
-               wprintf("\" MAXLENGTH=128></TD></TR>\n");
+                       "<SELECT NAME=\"room\" SIZE=1>\n");
+
+               serv_puts("LPRM");
+               serv_gets(buf);
+               if (buf[0] == '1') {
+                       while (serv_gets(buf), strcmp(buf, "000")) {
+                               extract(sroom, buf, 0);
+                               self = extract_int(buf, 4) & QR2_SELFLIST ;
+                               if (self) {
+                                       wprintf("<OPTION VALUE=\"");
+                                       urlescputs(sroom);
+                                       wprintf("\">");
+                                       escputs(sroom);
+                                       wprintf("</OPTION>\n");
+                               }
+                       }
+               }
+               wprintf("</SELECT>"
+                       "</TD></TR>\n");
 
                wprintf("<TR><TD>Your e-mail address</TD><TD>"
                        "<INPUT TYPE=\"text\" NAME=\"email\" "
index 874d2147af73472dabcca1e5cc86ad09c5be2550..ba36d87aaf14da1f0061536770b541548fc153ff 100644 (file)
@@ -624,6 +624,72 @@ void ungoto(void)
        smart_goto(buf);
 }
 
+
+
+
+
+/*
+ * Set/clear/read the "self-service list subscribe" flag for a room
+ * 
+ * Set 'newval' to 0 to clear, 1 to set, any other value to leave unchanged.
+ * Always returns the new value.
+ */
+
+int self_service(int newval) {
+       int current_value = 0;
+       char buf[SIZ];
+       
+       char name[SIZ];
+       char password[SIZ];
+       char dirname[SIZ];
+       int flags, floor, order, view, flags2;
+
+       serv_puts("GETR");
+       serv_gets(buf);
+       if (buf[0] != '2') return(0);
+
+       extract(name, &buf[4], 0);
+       extract(password, &buf[4], 1);
+       extract(dirname, &buf[4], 2);
+       flags = extract_int(&buf[4], 3);
+       floor = extract_int(&buf[4], 4);
+       order = extract_int(&buf[4], 5);
+       view = extract_int(&buf[4], 6);
+       flags2 = extract_int(&buf[4], 7);
+
+       if (flags2 & QR2_SELFLIST) {
+               current_value = 1;
+       }
+       else {
+               current_value = 0;
+       }
+
+       if (newval == 1) {
+               flags2 = flags2 | QR2_SELFLIST;
+       }
+       else if (newval == 0) {
+               flags2 = flags2 & ~QR2_SELFLIST;
+       }
+       else {
+               return(current_value);
+       }
+
+       if (newval != current_value) {
+               serv_printf("SETR %s|%s|%s|%d|0|%d|%d|%d|%d",
+                       name, password, dirname, flags,
+                       floor, order, view, flags2);
+               serv_gets(buf);
+       }
+
+       return(newval);
+
+}
+
+
+
+
+
+
 /*
  * display the form for editing a room
  */
@@ -964,8 +1030,13 @@ void display_editroom(void)
        /* Mailing list management */
        if (!strcmp(tab, "listserv")) {
 
-               wprintf("<BR><center><i>The contents of this room are being "
-                       "mailed to the following list recipients:"
+               wprintf("<BR><center>"
+                       "<TABLE BORDER=0 WIDTH=100%% CELLPADDING=5>"
+                       "<TR><TD VALIGN=TOP>");
+
+               wprintf("<i>The contents of this room are being "
+                       "mailed <b>as individual messages</b> "
+                       "to the following list recipients:"
                        "</i><br><br>\n");
 
                serv_puts("GNET");
@@ -988,13 +1059,77 @@ void display_editroom(void)
                        "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"listrecp|\">\n");
                wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
                wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
-               wprintf("</FORM><BR></CENTER>\n");
+               wprintf("</FORM>\n");
+
+               wprintf("</TD><TD VALIGN=TOP>\n");
+               
+               wprintf("<i>The contents of this room are being "
+                       "mailed <b>in digest form</b> "
+                       "to the following list recipients:"
+                       "</i><br><br>\n");
+
+               serv_puts("GNET");
+               serv_gets(buf);
+               if (buf[0]=='1') while (serv_gets(buf), strcmp(buf, "000")) {
+                       extract(cmd, buf, 0);
+                       if (!strcasecmp(cmd, "digestrecp")) {
+                               extract(recp, buf, 1);
+                       
+                               escputs(recp);
+                               wprintf(" <A HREF=\"/netedit&cmd=remove&line="
+                                       "digestrecp|");
+                               urlescputs(recp);
+                               wprintf("&tab=listserv\">(remove)</A><BR>");
+
+                       }
+               }
+               wprintf("<BR><FORM METHOD=\"POST\" ACTION=\"/netedit\">\n"
+                       "<INPUT TYPE=\"hidden\" NAME=\"tab\" VALUE=\"listserv\">\n"
+                       "<INPUT TYPE=\"hidden\" NAME=\"prefix\" VALUE=\"digestrecp|\">\n");
+               wprintf("<INPUT TYPE=\"text\" NAME=\"line\">\n");
+               wprintf("<INPUT TYPE=\"submit\" NAME=\"cmd\" VALUE=\"Add\">");
+               wprintf("</FORM>\n");
+               
+               wprintf("</TD></TR></TABLE><HR>\n");
+
+               if (self_service(999) == 1) {
+                       wprintf("This room is configured to allow "
+                               "self-service subscribe/unsubscribe requests."
+                               " <A HREF=\"/toggle_self_service?newval=0&"
+                               "tab=listserv\">"
+                               "Click to disable.</A><BR>\n"
+                       );
+               }
+               else {
+                       wprintf("This room is <i>not</i> configured to allow "
+                               "self-service subscribe/unsubscribe requests."
+                               " <A HREF=\"/toggle_self_service?newval=1&"
+                               "tab=listserv\">"
+                               "Click to enable.</A><BR>\n"
+                       );
+               }
+
+
+               wprintf("</CENTER>\n");
        }
 
        wDumpContent(1);
 }
 
 
+/* 
+ * Toggle self-service list subscription
+ */
+void toggle_self_service(void) {
+       int newval = 0;
+
+       newval = atoi(bstr("newval"));
+       self_service(newval);
+       display_editroom();
+}
+
+
+
 /*
  * save new parameters for a room
  */
index 2700a6565a41a4859ff0fb35d422e695a55d0fcd..3a6f13ec919489d47f507934f1e0bc3aa521e823 100644 (file)
@@ -1151,6 +1151,8 @@ void session_loop(struct httprequest *req)
                change_start_page();
        } else if (!strcasecmp(action, "display_floorconfig")) {
                display_floorconfig(NULL);
+       } else if (!strcasecmp(action, "toggle_self_service")) {
+               toggle_self_service();
        } else if (!strcasecmp(action, "diagnostics")) {
                output_headers(1);
 
index 001fbafbad54020fe6db3c61dcc0a1bff9b7c496..62ed9e26e401e26bceb95c847c3e0fd9d64bc027 100644 (file)
 #define USERCONFIGROOM         "My Citadel Config"
 
 
-/* Room flags (from Citadel) */
-#define QR_PERMANENT   1       /* Room does not purge              */
-#define QR_INUSE       2       /* Set if in use, clear if avail    */
-#define QR_PRIVATE     4       /* Set for any type of private room */
-#define QR_PASSWORDED  8       /* Set if there's a password too    */
-#define QR_GUESSNAME   16      /* Set if it's a guessname room     */
-#define QR_DIRECTORY   32      /* Directory room                   */
-#define QR_UPLOAD      64      /* Allowed to upload                */
-#define QR_DOWNLOAD    128     /* Allowed to download              */
-#define QR_VISDIR      256     /* Visible directory                */
-#define QR_ANONONLY    512     /* Anonymous-Only room              */
-#define QR_ANONOPT     1024    /* Anonymous-Option room            */
-#define QR_NETWORK     2048    /* Shared network room              */
-#define QR_PREFONLY    4096    /* Preferred status needed to enter */
-#define QR_READONLY    8192    /* Aide status required to post     */
-#define QR_MAILBOX     16384   /* Set if this is a private mailbox */
+/*
+ * Room flags (from Citadel)
+ *
+ * bucket one...
+ */
+#define QR_PERMANENT   1               /* Room does not purge              */
+#define QR_INUSE       2               /* Set if in use, clear if avail    */
+#define QR_PRIVATE     4               /* Set for any type of private room */
+#define QR_PASSWORDED  8               /* Set if there's a password too    */
+#define QR_GUESSNAME   16              /* Set if it's a guessname room     */
+#define QR_DIRECTORY   32              /* Directory room                   */
+#define QR_UPLOAD      64              /* Allowed to upload                */
+#define QR_DOWNLOAD    128             /* Allowed to download              */
+#define QR_VISDIR      256             /* Visible directory                */
+#define QR_ANONONLY    512             /* Anonymous-Only room              */
+#define QR_ANONOPT     1024            /* Anonymous-Option room            */
+#define QR_NETWORK     2048            /* Shared network room              */
+#define QR_PREFONLY    4096            /* Preferred status needed to enter */
+#define QR_READONLY    8192            /* Aide status required to post     */
+#define QR_MAILBOX     16384           /* Set if this is a private mailbox */
+
+/*
+ * bucket two...
+ */
+#define QR2_SYSTEM     1               /* System room; hide by default     */
+#define QR2_SELFLIST   2               /* Self-service mailing list mgmt   */
 
 
 struct httprequest {
@@ -320,3 +330,4 @@ void delete_floor(void);
 void create_floor(void);
 void rename_floor(void);
 void do_listsub(void);
+void toggle_self_service(void);