Add templatization for the Listsubscriber Interface; the old interface remains intact.
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 28 Aug 2011 07:48:34 +0000 (07:48 +0000)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 28 Aug 2011 07:48:34 +0000 (07:48 +0000)
webcit/listsub.c
webcit/static/t/listsub/display.html [new file with mode: 0644]
webcit/static/t/listsub/subscribeable_rooms.html [new file with mode: 0644]

index 2bb9cbb3a49053656351762d3dd773beaa9b1ee9..d4de61bb227897868d0538d07d9972146cd5c33e 100644 (file)
@@ -23,6 +23,7 @@
 /*
  * List subscription handling
  */
+#ifndef EXPERIMENTAL_LISTSUB
 void do_listsub(void)
 {
        char cmd[256];
@@ -237,13 +238,138 @@ FORM:            wc_printf("<form method=\"POST\" action=\"listsub\">\n");
        wDumpContent(0);
        end_webcit_session();
 }
+#endif
 
+int Conditional_LISTSUB_EXECUTE_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
+{
+       int rc;
+       StrBuf *Line;
+       const char *ImpMsg;
+       const StrBuf *Room, *Email, *SubType;
+       
+       Room = sbstr("room");
+       if (Room == NULL)
+       {
+               ImpMsg = _("You need to specify the mailinglist to subscribe to.");
+               AppendImportantMessage(ImpMsg, -1);
+               return 0;
+       }
+       Email = sbstr("email");
+       if (Email == NULL)
+       {
+               ImpMsg = _("You need to specify the email address you'd like to subscribe with.");
+               AppendImportantMessage(ImpMsg, -1);
+               return 0;
+       }
+       SubType = sbstr("subtype");
 
+       Line = NewStrBuf();
+       serv_printf("SUBS subscribe|%s|%s|%s|%s/listsub",
+                   ChrPtr(Room),
+                   ChrPtr(Email),
+                   ChrPtr(SubType),
+                   ChrPtr(site_prefix)
+               );
+       StrBuf_ServGetln(Line);
+       rc = GetServerStatusMsg(Line, NULL, 1, 2);
+       FreeStrBuf(&Line);
+       if (rc == 2)
+               putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
+       return rc == 2;
+}
+
+int Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
+{
+       int rc;
+       StrBuf *Line;
+       const char *ImpMsg;
+       const StrBuf *Room, *Email;
+       
+       Room = sbstr("room");
+       if (Room == NULL)
+       {
+               ImpMsg = _("You need to specify the mailinglist to subscribe to.");
+               AppendImportantMessage(ImpMsg, -1);
+               return 0;
+       }
+       Email = sbstr("email");
+       if (Email == NULL)
+       {
+               ImpMsg = _("You need to specify the email address you'd like to subscribe with.");
+               AppendImportantMessage(ImpMsg, -1);
+               return 0;
+       }
+
+       serv_printf("SUBS unsubscribe|%s|%s|%s/listsub",
+                   ChrPtr(Room),
+                   ChrPtr(Email),
+                   ChrPtr(site_prefix)
+               );
+       Line = NewStrBuf();
+       StrBuf_ServGetln(Line);
+       rc = GetServerStatusMsg(Line, NULL, 1, 2);
+       FreeStrBuf(&Line);
+       if (rc == 2)
+               putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
+       return rc == 2;
+}
+
+int Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
+{
+       int rc;
+       StrBuf *Line;
+       const char *ImpMsg;
+       const StrBuf *Room, *Token;
+       
+       Room = sbstr("room");
+       if (Room == NULL)
+       {
+               ImpMsg = _("You need to specify the mailinglist to subscribe to.");
+               AppendImportantMessage(ImpMsg, -1);
+               return 0;
+       }
+       Token = sbstr("token");
+       if (Room == NULL)
+       {
+               ImpMsg = _("You need to specify the mailinglist to subscribe to.");
+               AppendImportantMessage(ImpMsg, -1);
+               return 0;
+       }
+
+       Line = NewStrBuf();
+       serv_printf("SUBS confirm|%s|%s",
+                   ChrPtr(Room),
+                   ChrPtr(Token)
+               );
+       StrBuf_ServGetln(Line);
+       rc = GetServerStatusMsg(Line, NULL, 1, 2);
+       FreeStrBuf(&Line);
+       if (rc == 2)
+               putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
+       return rc == 2;
+}
+
+#ifdef EXPERIMENTAL_LISTSUB
+void do_listsub(void)
+{
+       if (!havebstr("cmd"))
+       {
+               putbstr("cmd", NewStrBufPlain(HKEY("")));
+       }
+       output_headers(1, 0, 0, 0, 1, 0);
+       do_template("listsub_display");
+       end_burst();
+}
+#endif
 
 void 
 InitModule_LISTSUB
 (void)
 {
+       RegisterConditional(HKEY("COND:LISTSUB:EXECUTE:SUBSCRIBE"), 0, Conditional_LISTSUB_EXECUTE_SUBSCRIBE,  CTX_NONE);
+       RegisterConditional(HKEY("COND:LISTSUB:EXECUTE:UNSUBSCRIBE"), 0, Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE,  CTX_NONE);
+       RegisterConditional(HKEY("COND:LISTSUB:EXECUTE:CONFIRM:SUBSCRIBE"), 0, Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE,  CTX_NONE);
+
        WebcitAddUrlHandler(HKEY("listsub"), "", 0, do_listsub, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);
 
 
diff --git a/webcit/static/t/listsub/display.html b/webcit/static/t/listsub/display.html
new file mode 100644 (file)
index 0000000..5473bc8
--- /dev/null
@@ -0,0 +1,97 @@
+<HTML><HEAD>
+<meta name="MSSmartTagsPreventParsing" content="TRUE" />
+<link href="static/styles/webcit.css" rel="stylesheet" type="text/css">
+<TITLE>
+<?_("List subscription")>
+</TITLE></HEAD><BODY>
+<div align=center>
+<table border=0 width=75%><tr><td>
+<?=("box_begin_1")><?_("List subscribe/unsubscribe")><?=("box_begin_2")>
+<div align=center><br>
+
+<??("COND:BSTR", 10, "cmd", "subscribe")>
+<?!("COND:LISTSUB:EXECUTE:SUBSCRIBE", 11)>
+<CENTER>
+<H1><?_("Confirmation request sent")></H1>
+<?_("You are subscribing ")><TT><?BSTR("email", "X")></TT>
+<?_(" to the ")><b><?BSTR("room", "X")></b>
+<?_(" mailing list.")> 
+<?_("The listserver has sent you an e-mail with one additional Web link for you to click on to confirm your subscription.")>  
+<?_("This extra step is for your protection, as it prevents others from being able to subscribe you to lists without your consent.")>
+<br><br>
+<?_("Please click on the link which is being e-mailed to you and your subscription will be confirmed.")>
+<br>
+<a href="listsub"><?_("Go back...")></a>
+</CENTER>
+<?!("X", 11)><??("COND:BSTR", 12, "__FAIL")>
+<FONT SIZE=+1><B><?_("ERROR")>: <?IMPORTANTMESSAGE></B></FONT><br><br>
+<??("X", 12)>
+<??("X", 10)>
+
+<??("COND:BSTR", 20, "cmd", "unsubscribe")>
+<?!("COND:LISTSUB:EXECUTE:UNSUBSCRIBE", 21)>
+<CENTER>
+<H1><?_("Confirmation request sent")></H1>
+<?_("You are unsubscribing")> 
+<TT><?BSTR("email", "X")></TT> 
+<?_("from the")> 
+&quot;<?BSTR("room", "X")>&quot; 
+<?_("mailing list.")>
+<?_("The listserver has sent you an e-mail with one additional Web link for you to click on to confirm your unsubscription.")>
+<?_("This extra step is for your protection, as it prevents others from being able to unsubscribe you from lists without your consent.")> 
+<br><br>
+<?_("Please click on the link which is being e-mailed to you and your unsubscription will be confirmed.")><br>
+<a href="listsub"><?_("Back...")></a>
+</CENTER>
+<?!("X", 21)><??("COND:BSTR", 22, "__FAIL")>
+<FONT SIZE=+1><B><?_("ERROR")>: <?IMPORTANTMESSAGE></B></FONT>
+<br><br>
+<?!("X", 22)>
+<??("X", 20)>
+
+<??("COND:BSTR", 30, "cmd", "confirm")>
+<?!("COND:LISTSUB:EXECUTE:CONFIRM:SUBSCRIBE", 31)>
+<CENTER><H1><?_("Confirmation successful!")></H1>
+<?!("X", 31)><??("COND:BSTR", 32, "__FAIL")>
+<CENTER><H1><?_("Confirmation failed.")></H1>
+<?_("This could mean one of two things:")>
+<UL>
+<LI><?_("You waited too long to confirm your subscribe/unsubscribe request (the confirmation link is only valid for three days)")></LI>
+<LI><?_("You have <i>already</i> successfully confirmed your subscribe/unsubscribe request and are attempting to do it again.")></li>
+</UL>
+<?_("The error returned by the server was: ")><?IMPORTANTMESSAGE>
+<??("X", 32)>
+<??("X", 30)>
+
+<??("COND:BSTR", 40, "cmd", "choose")>
+
+<form method="POST" action="listsub">
+
+<?_("Name of list:")>
+<select name="room" size=1>
+<?ITERATE("LPRM", ="listsub_subscribeable_rooms")>
+</select><br><br>
+
+<?_("Your e-mail address:")> 
+<INPUT TYPE="text" NAME="email" VALUE="<?BSTR('email', 'X')>" maxlength="128" size="60">
+<br><br>
+
+<?_("(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>
+<INPUT TYPE="submit" NAME="cmd" VALUE="subscribe">
+<INPUT TYPE="submit" NAME="cmd" VALUE="unsubscribe">
+<br><br>
+</FORM>
+
+<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 protection, as it prevents others from being able to subscribe or unsubscribe you to lists.")>
+<br>
+<??("X", 40)>
+</div>
+<?=("box_end")>
+</td></tr></table></div>
+
+</BODY></HTML>
diff --git a/webcit/static/t/listsub/subscribeable_rooms.html b/webcit/static/t/listsub/subscribeable_rooms.html
new file mode 100644 (file)
index 0000000..3a757e3
--- /dev/null
@@ -0,0 +1 @@
+<?!("COND:ROOM:FLAG:QR2", 1, #"QR2_SELFLIST")><option value="<?ROOM:INFO:NAME('X')>"><?ROOM:INFO:NAME("X")></option><?!("X", 1)>