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
21 int Conditional_LISTSUB_EXECUTE_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
26 const StrBuf *Room, *Email, *SubType;
28 if (strcmp(bstr("cmd"), "subscribe")) {
35 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
36 AppendImportantMessage(ImpMsg, -1);
39 Email = sbstr("email");
42 ImpMsg = _("You need to specify the email address you'd like to subscribe with.");
43 AppendImportantMessage(ImpMsg, -1);
46 SubType = sbstr("subtype");
49 serv_printf("SUBS subscribe|%s|%s|%s|%s/listsub",
55 StrBuf_ServGetln(Line);
56 rc = GetServerStatusMsg(Line, NULL, 1, 2);
59 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
63 int Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
68 const StrBuf *Room, *Email;
70 if (strcmp(bstr("cmd"), "unsubscribe")) {
77 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
78 AppendImportantMessage(ImpMsg, -1);
81 Email = sbstr("email");
84 ImpMsg = _("You need to specify the email address you'd like to subscribe with.");
85 AppendImportantMessage(ImpMsg, -1);
89 serv_printf("SUBS unsubscribe|%s|%s|%s/listsub",
95 StrBuf_ServGetln(Line);
96 rc = GetServerStatusMsg(Line, NULL, 1, 2);
99 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
103 int Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP)
108 const StrBuf *Room, *Token;
110 if (strcmp(bstr("cmd"), "confirm")) {
114 Room = sbstr("room");
117 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
118 AppendImportantMessage(ImpMsg, -1);
121 Token = sbstr("token");
124 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
125 AppendImportantMessage(ImpMsg, -1);
130 serv_printf("SUBS confirm|%s|%s",
134 StrBuf_ServGetln(Line);
135 rc = GetServerStatusMsg(Line, NULL, 1, 2);
138 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
142 void do_listsub(void)
144 if (!havebstr("cmd"))
146 putbstr("cmd", NewStrBufPlain(HKEY("choose")));
148 output_headers(1, 0, 0, 0, 1, 0);
149 do_template("listsub_display");
157 RegisterConditional("COND:LISTSUB:EXECUTE:SUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_SUBSCRIBE, CTX_NONE);
158 RegisterConditional("COND:LISTSUB:EXECUTE:UNSUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE, CTX_NONE);
159 RegisterConditional("COND:LISTSUB:EXECUTE:CONFIRM:SUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE, CTX_NONE);
161 WebcitAddUrlHandler(HKEY("listsub"), "", 0, do_listsub, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);