1 // Web forms for handling mailing list subscribe/unsubscribe requests.
3 // Copyright (c) 1996-2022 by the citadel.org team
5 // This program is open source software. You can redistribute it and/or
6 // modify it under the terms of the GNU General Public License, version 3.
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
15 // List subscription handling
16 int Conditional_LISTSUB_EXECUTE_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP) {
20 const StrBuf *Room, *Email;
22 if (strcmp(bstr("cmd"), "subscribe")) {
28 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
29 AppendImportantMessage(ImpMsg, -1);
32 Email = sbstr("email");
34 ImpMsg = _("You need to specify the email address you'd like to subscribe with.");
35 AppendImportantMessage(ImpMsg, -1);
40 serv_printf("LSUB subscribe|%s|%s|%s/listsub", ChrPtr(Room), ChrPtr(Email), ChrPtr(site_prefix));
41 StrBuf_ServGetln(Line);
42 rc = GetServerStatusMsg(Line, NULL, 1, 2);
45 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
51 int Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE(StrBuf *Target, WCTemplputParams *TP) {
55 const StrBuf *Room, *Email;
57 if (strcmp(bstr("cmd"), "unsubscribe")) {
63 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
64 AppendImportantMessage(ImpMsg, -1);
67 Email = sbstr("email");
69 ImpMsg = _("You need to specify the email address you'd like to subscribe with.");
70 AppendImportantMessage(ImpMsg, -1);
74 serv_printf("LSUB unsubscribe|%s|%s|%s/listsub", ChrPtr(Room), ChrPtr(Email), ChrPtr(site_prefix));
76 StrBuf_ServGetln(Line);
77 rc = GetServerStatusMsg(Line, NULL, 1, 2);
80 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
86 int Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE(StrBuf *Target, WCTemplputParams *TP) {
90 const StrBuf *Room, *Token;
92 if (strcmp(bstr("cmd"), "confirm")) {
98 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
99 AppendImportantMessage(ImpMsg, -1);
102 Token = sbstr("token");
104 ImpMsg = _("You need to specify the mailinglist to subscribe to.");
105 AppendImportantMessage(ImpMsg, -1);
110 serv_printf("LSUB confirm|%s|%s", ChrPtr(Room), ChrPtr(Token));
111 StrBuf_ServGetln(Line);
112 rc = GetServerStatusMsg(Line, NULL, 1, 2);
115 putbstr("__FAIL", NewStrBufPlain(HKEY("1")));
121 void do_listsub(void) {
122 if (!havebstr("cmd")) {
123 putbstr("cmd", NewStrBufPlain(HKEY("choose")));
125 output_headers(1, 0, 0, 0, 1, 0);
126 do_template("listsub_display");
135 RegisterConditional("COND:LISTSUB:EXECUTE:SUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_SUBSCRIBE, CTX_NONE);
136 RegisterConditional("COND:LISTSUB:EXECUTE:UNSUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_UNSUBSCRIBE, CTX_NONE);
137 RegisterConditional("COND:LISTSUB:EXECUTE:CONFIRM:SUBSCRIBE", 0, Conditional_LISTSUB_EXECUTE_CONFIRM_SUBSCRIBE, CTX_NONE);
138 WebcitAddUrlHandler(HKEY("listsub"), "", 0, do_listsub, ANONYMOUS|COOKIEUNNEEDED|FORCE_SESSIONCLOSE);