2 * Web forms for handling mailing list subscribe/unsubscribe requests.
4 * Copyright (c) 1996-2012 by the citadel.org team
6 * This program is open source software. You can redistribute it and/or
7 * modify it under the terms of the GNU General Public License, version 3.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
18 * List subscription handling
20 int Conditional_LISTSUB_EXECUTE_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP) {
24 const StrBuf *Room, *Email;
26 if (strcmp(bstr("cmd"), "subscribe")) {
33 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
34 AppendImportantMessage(ImpMsg, -1);
37 Email = sbstr("email");
40 ImpMsg = _("You need to specify the email address you'd like to subscribe with.");
41 AppendImportantMessage(ImpMsg, -1);
46 serv_printf("LSUB subscribe|%s|%s|%s/listsub", ChrPtr(Room), ChrPtr(Email), ChrPtr(site_prefix));
47 StrBuf_ServGetln(Line);
48 rc = GetServerStatusMsg(Line, NULL, 1, 2);
51 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
57 int Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP) {
61 const StrBuf *Room, *Email;
63 if (strcmp(bstr("cmd"), "unsubscribe")) {
70 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
71 AppendImportantMessage(ImpMsg, -1);
74 Email = sbstr("email");
77 ImpMsg = _("You need to specify the email address you'd like to subscribe with.");
78 AppendImportantMessage(ImpMsg, -1);
82 serv_printf("LSUB unsubscribe|%s|%s|%s/listsub", ChrPtr(Room), ChrPtr(Email), ChrPtr(site_prefix));
84 StrBuf_ServGetln(Line);
85 rc = GetServerStatusMsg(Line, NULL, 1, 2);
88 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
92 int Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
97 const StrBuf *Room, *Token;
99 if (strcmp(bstr("cmd"), "confirm")) {
103 Room = sbstr("room");
106 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
107 AppendImportantMessage(ImpMsg, -1);
110 Token = sbstr("token");
113 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
114 AppendImportantMessage(ImpMsg, -1);
119 serv_printf("LSUB confirm|%s|%s", ChrPtr(Room), ChrPtr(Token));
120 StrBuf_ServGetln(Line);
121 rc = GetServerStatusMsg(Line, NULL, 1, 2);
124 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
128 void do_listsub(void)
130 if (!havebstr("cmd"))
132 putbstr("cmd", NewStrBufPlain(HKEY("choose")));
134 output_headers(1, 0, 0, 0, 1, 0);
135 do_template("listsub_display");
143 RegisterConditional("COND:LISTSUB:EXECUTE:SUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_SUBSCRIBE, CTX_NONE);
144 RegisterConditional("COND:LISTSUB:EXECUTE:UNSUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE, CTX_NONE);
145 RegisterConditional("COND:LISTSUB:EXECUTE:CONFIRM:SUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE, CTX_NONE);
147 WebcitAddUrlHandler(HKEY("listsub"), "", 0, do_listsub, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);