diff src/nabble/view/web/mailing_list/UnsubscribeFromMailingList.jtp @ 0:7ecd1a4ef557

add content
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 Mar 2019 19:15:52 -0600
parents
children 18cf4872fd7f
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/nabble/view/web/mailing_list/UnsubscribeFromMailingList.jtp	Thu Mar 21 19:15:52 2019 -0600
@@ -0,0 +1,134 @@
+<%
+package nabble.view.web.mailing_list;
+
+import fschmidt.util.servlet.AuthorizingServlet;
+import nabble.model.MailingList;
+import nabble.model.ModelHome;
+import nabble.model.Node;
+import nabble.model.User;
+import nabble.view.lib.Jtp;
+import nabble.view.lib.Shared;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+
+public final class UnsubscribeFromMailingList extends HttpServlet implements AuthorizingServlet {
+
+	public String getAuthorizationKey(HttpServletRequest request) throws ServletException {
+		return Jtp.getReadAuthorizationKey( Jtp.getSiteNotNull(request).getNode(Jtp.getLong(request,"node")) );
+	}
+
+	public boolean authorize(String key,HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
+		return Jtp.authorizeForRead(key,request,response);
+	}
+
+    protected void service(HttpServletRequest request,HttpServletResponse response)
+		throws ServletException, IOException
+	{
+		User user = Jtp.getUser(request,response);
+
+		if (user == null) {
+			Jtp.login("You must login to unsubscribe from a mailing list.", request, response);
+			return;
+		}
+
+		Node forum = Jtp.getSiteNotNull(request).getNode(Jtp.getLong(request, "node"));
+		boolean allowed = Jtp.canBeEditedBy(forum,user);
+		if (!allowed) {
+			Jtp.login("Only administrators can proceed in this area.", request, response);
+			return;
+		}
+
+		String errorMsg = null;
+		boolean isSendEmail = "SendEmail".equals(request.getParameter("action"));
+
+		MailingList mailingList = forum.getMailingList();
+		String subscriptionAddress = mailingList.getSubscriberAddress().getAddrSpec();
+		PrintWriter out = response.getWriter();
+		char c = 'A';
+		%>
+		<html>
+			<head>
+				<META NAME="robots" CONTENT="noindex,nofollow">
+				<% Shared.title(request,response,"How to Unsubscribe this Forum"); %>
+				<style type="text/css">
+					div.field-title {
+						margin-top: 0;
+					}
+					td.number {
+						width: 3em;
+						padding-bottom: .2em;
+					}
+					span.number {
+						font-size: 200%;
+						padding: 0 .3em .03em;
+						border-width:1px;
+						border-style:solid;
+					}
+				</style>
+			</head>
+			<body>
+				<% Shared.minHeader(request, response, forum);%>
+				<% Shared.editHeader(forum.getSubjectHtml(), "How to Unsubscribe this Forum", out); %>
+				<% Shared.errorMessage(request,response,errorMsg, "Please fix the error and try again." ); %>
+				<%
+				if (isSendEmail && "POST".equals(request.getMethod())) {
+					errorMsg = SubscribeToMailingList.sendRequest(forum, request, out);
+					Shared.errorMessage(request, response, errorMsg, "Failed to send the request." );
+				}
+				%>
+
+				<div class="field-box light-border-color">
+					<div class="second-font field-title">General Instructions</div>
+					<div style="margin-left:1.5em">
+						If you want to unsubscribe this forum from a mailing list, you have to remove the following email address from the mailing list subscriber's list:
+						<div class="info-message" style="margin:.2em;padding:.2em;font-weight:bold"><%=subscriptionAddress%></div>
+						This can be done in several ways. Below you can find the most common ones.
+					</div>
+				</div>
+
+				<div class="second-font field-title" style="margin-top:1em">Unsubscription Options</div>
+				<div class="weak-color">Choose the best option for this mailing list.</div>
+
+				<div class="field-box light-border-color">
+					<table style="margin-left:1.3em">
+						<tr valign="top">
+							<td class="number"><span class="number shaded-bg-color medium-border-color"><%=c++%></span></td>
+							<td>
+								<div class="second-font field-title">Remove from subscriber's list</div>
+								Mailing list administrators usually can remove email addresses from the subscribers' list directly.
+								If you can do this, remove <b><%=subscriptionAddress%></b> from that list.
+							</td>
+						</tr>
+					</table>
+				</div>
+
+				<div class="field-box light-border-color">
+					<table style="margin-left:1.3em">
+						<tr valign="top">
+							<td class="number"><span class="number shaded-bg-color medium-border-color"><%=c++%></span></td>
+							<td>
+								<div class="second-font field-title">Go to mailing list website</div>
+								You can go to the mailing list homepage (<a href="<%=mailingList.getUrl()%>"><%=mailingList.getUrl()%></a>)
+								and unsubscribe <b><%=subscriptionAddress%></b> from the list.
+								The confirmation email will be forwarded to your email address as soon as it is received by Nabble.com.
+								You will have to follow the instructions in that email to confirm this request.
+							</td>
+						</tr>
+					</table>
+				</div>
+				<% SubscribeToMailingList.emailForm(forum, false, "Unsubscribe by email", "Send Unsubscription Request", c, request, out); %>
+				<% Shared.footer(request,response); %>
+				<% Shared.analytics(request,response); %>
+			</body>
+		</html>
+		<%
+	}
+
+}
+%>