* add a Display name to our handlers; this will be used by DAV handlers.
[citadel.git] / webcit / listsub.c
index bd2dcc1e9317c4acbd76fb5e6b91db9abe75eec4..f6ed32f2d6ba4b12c52d48b4e6291a72a03b5f1a 100644 (file)
@@ -1,18 +1,13 @@
 /*
  * $Id$
- */
-/**
- * \defgroup ListSubForms Web forms for handling mailing list subscribe/unsubscribe requests.
  *
+ * Web forms for handling mailing list subscribe/unsubscribe requests.
  */
 
-/*@{*/
 #include "webcit.h"
 
-
-
-/**
- * \brief List subscription handling
+/*
+ * List subscription handling
  */
 void do_listsub(void)
 {
@@ -28,10 +23,10 @@ void do_listsub(void)
        int self;
        char sroom[SIZ];
 
-       strcpy(WC->wc_fullname, "");
-       strcpy(WC->wc_username, "");
-       strcpy(WC->wc_password, "");
-       strcpy(WC->wc_roomname, "");
+       FlushStrBuf(WC->wc_fullname);
+       FlushStrBuf(WC->wc_username);
+       FlushStrBuf(WC->wc_password);
+       FlushStrBuf(WC->wc_roomname);
 
        output_headers(1, 0, 0, 1, 1, 0);
        begin_burst();
@@ -50,13 +45,14 @@ void do_listsub(void)
        strcpy(email, bstr("email"));
        strcpy(subtype, bstr("subtype"));
 
-       wprintf("<CENTER>"
-               "<TABLE WIDTH=100%% BORDER=0 BGCOLOR=\"#444455\"><TR><TD>"
-               "<SPAN CLASS=\"titlebar\">");
-       wprintf(_("List subscribe/unsubscribe"));
-       wprintf("</SPAN></TD></TR></TABLE><br />\n");
+       wprintf("<div align=center>");
+       wprintf("<table border=0 width=75%%><tr><td>");
 
-       /**
+       svput("BOXTITLE", WCS_STRING, _("List subscribe/unsubscribe"));
+       do_template("beginboxx", NULL);
+       wprintf("<div align=center><br>");
+
+       /*
         * Subscribe command
         */
        if (!strcasecmp(cmd, "subscribe")) {
@@ -65,12 +61,12 @@ void do_listsub(void)
                        email,
                        subtype,
                        (is_https ? "https" : "http"),
-                       WC->http_host
+                           ChrPtr(WC->Hdr->HR.http_host)
                );
                serv_getln(buf, sizeof buf);
                if (buf[0] == '2') {
-                       stresc(escaped_email, email, 0, 0);
-                       stresc(escaped_room, room, 0, 0);
+                       stresc(escaped_email, 256, email, 0, 0);
+                       stresc(escaped_room, 256, room, 0, 0);
 
                        wprintf("<CENTER><H1>");
                        wprintf(_("Confirmation request sent"));
@@ -98,15 +94,15 @@ void do_listsub(void)
                }
        }
 
-       /**
+       /*
         * Unsubscribe command
         */
        else if (!strcasecmp(cmd, "unsubscribe")) {
                serv_printf("SUBS unsubscribe|%s|%s|%s://%s/listsub",
-                       room,
-                       email,
-                       (is_https ? "https" : "http"),
-                       WC->http_host
+                           room,
+                           email,
+                           (is_https ? "https" : "http"),
+                           ChrPtr(WC->Hdr->HR.http_host)
                );
                serv_getln(buf, sizeof buf);
                if (buf[0] == '2') {
@@ -136,7 +132,7 @@ void do_listsub(void)
                }
        }
 
-       /**
+       /*
         * Confirm command
         */
        else if (!strcasecmp(cmd, "confirm")) {
@@ -164,16 +160,14 @@ void do_listsub(void)
                wprintf("%s</CENTER><br />\n", &buf[4]);
        }
 
-       /**
+       /*
         * Any other (invalid) command causes the form to be displayed
         */
        else {
-FORM:          wprintf("<FORM METHOD=\"POST\" action=\"listsub\">\n"
-                       "<TABLE BORDER=0>\n"
-               );
+FORM:          wprintf("<form method=\"POST\" action=\"listsub\">\n");
 
-               wprintf("<TR><TD>Name of list</TD><TD>"
-                       "<SELECT NAME=\"room\" SIZE=1>\n");
+               wprintf("Name of list: "
+                       "<select name=\"room\" size=1>\n");
 
                serv_puts("LPRM");
                serv_getln(buf, sizeof buf);
@@ -182,39 +176,37 @@ FORM:             wprintf("<FORM METHOD=\"POST\" action=\"listsub\">\n"
                                extract_token(sroom, buf, 0, '|', sizeof sroom);
                                self = extract_int(buf, 4) & QR2_SELFLIST ;
                                if (self) {
-                                       wprintf("<OPTION VALUE=\"");
+                                       wprintf("<option value=\"");
                                        escputs(sroom);
                                        wprintf("\">");
                                        escputs(sroom);
-                                       wprintf("</OPTION>\n");
+                                       wprintf("</option>\n");
                                }
                        }
                }
-               wprintf("</SELECT>"
-                       "</TD></TR>\n");
+               wprintf("</select><br><br>\n");
 
-               wprintf("<TR><TD>Your e-mail address</TD><TD>"
+               wprintf("Your e-mail address: "
                        "<INPUT TYPE=\"text\" NAME=\"email\" "
                        "VALUE=\""
                );
                escputs(email);
-               wprintf("\" MAXLENGTH=128></TD></TR>\n");
-
-               wprintf("</TABLE>"
-                       "(If subscribing) preferred format: "
-                       "<INPUT TYPE=\"radio\" NAME=\"subtype\""
-                       "VALUE=\"list\">One message at a time&nbsp; "
-                       "<INPUT TYPE=\"radio\" NAME=\"subtype\""
-                       "VALUE=\"digest\" CHECKED>Digest format&nbsp; "
-                       "<br />\n"
+               wprintf("\" maxlength=128 size=60><br><br>\n");
+
+               wprintf("(If subscribing) preferred format: "
+                       "<INPUT TYPE=\"radio\" NAME=\"subtype\" "
+                       "VALUE=\"list\" CHECKED>One message at a time&nbsp; "
+                       "<INPUT TYPE=\"radio\" NAME=\"subtype\" "
+                       "VALUE=\"digest\">Digest format&nbsp; "
+                       "<br><br>\n"
                        "<INPUT TYPE=\"submit\" NAME=\"cmd\""
                        " VALUE=\"subscribe\">\n"
                        "<INPUT TYPE=\"submit\" NAME=\"cmd\""
-                       " VALUE=\"unsubscribe\">\n"
+                       " VALUE=\"unsubscribe\"><br><br>\n"
                        "</FORM>\n"
                );
 
-               wprintf("<br />When you attempt to subscribe or unsubscribe to "
+               wprintf("<hr>When you attempt to subscribe or unsubscribe to "
                        "a mailing list, you will receive an e-mail containing"
                        " one additional web link to click on for final "
                        "confirmation.  This extra step is for your "
@@ -224,6 +216,10 @@ FORM:              wprintf("<FORM METHOD=\"POST\" action=\"listsub\">\n"
 
        }
 
+       wprintf("</div>");
+       do_template("endbox", NULL);
+       wprintf("</td></tr></table></div>");
+
        wprintf("</BODY></HTML>\n");
        wDumpContent(0);
        end_webcit_session();
@@ -231,4 +227,11 @@ FORM:              wprintf("<FORM METHOD=\"POST\" action=\"listsub\">\n"
 
 
 
-/*@}*/
+void 
+InitModule_LISTSUB
+(void)
+{
+       WebcitAddUrlHandler(HKEY("listsub"), "", 0, do_listsub, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
+
+
+}