added List.jsp
authoradam <adam@megacz.com>
Fri, 3 Sep 2004 00:55:17 +0000 (00:55 +0000)
committeradam <adam@megacz.com>
Fri, 3 Sep 2004 00:55:17 +0000 (00:55 +0000)
darcs-hash:20040903005517-5007d-1cddd8d69f12580c19e30bb067e8b30f75aec9cb.gz

src/org/ibex/mail/List.jsp [new file with mode: 0644]

diff --git a/src/org/ibex/mail/List.jsp b/src/org/ibex/mail/List.jsp
new file mode 100644 (file)
index 0000000..dc8a62c
--- /dev/null
@@ -0,0 +1,78 @@
+<%@ page import = "java.util.*" %>
+<%@ page import = "javax.servlet.*" %>
+<%@ page import = "org.ibex.mail.*" %>
+<%@ page import = "org.prevayler.*" %>
+<%@ page import = "org.ibex.mail.target.*" %>
+<%@ page import = "org.ibex.mail.List" %>
+<html>
+    <title> Mailing Lists </title>
+    <body>
+    <form method=get>
+    <%
+          String action = request.getParameter("action");
+          boolean admin = "true".equals(request.getParameter("admin"));
+
+          // Display //////////////////////////////////////////////////////////////////////////////
+          if (action == null) {
+              %> <table border=1> <tr><td>List Address</td> <td>Description</td></tr> <%
+              List[] all = (List[])List.p.execute(List.all());
+              for(int i=0; i<all.length; i++) {
+                  %>
+                     <tr>
+                          <td> <a href="?action=List&list=<%=all[i].address%>"> <%= all[i].address %> </td>
+                          <td> <%= all[i].one_line_description %> </td>
+                          if (admin) {
+                              <td><input type=submit name=action
+                                         value="Delete <%=all[i].address.user+"@"+all[i].address.host%>"></td>
+                          }
+                     </tr>
+                  <%
+              }
+              if (admin) {
+                  %> <tr>
+                         <td> <input type=text size=20 name=name>        </td>
+                         <td> <input type=text size=40 name=description> </td>
+                         <td> <input type=submit name=action value=Add>  </td>
+                     </tr> </table> <%
+              }
+
+          // Add //////////////////////////////////////////////////////////////////////////////
+          } else if ("Add".equals(action)) {
+              Address a = new Address(request.getParameter("name"));
+              Transaction t =
+                    List.create(a,
+                      FileBasedMailbox.getFileBasedMailbox(List.ROOT + "/" + a.user + "@" + a.host + "/pending", true),
+                      FileBasedMailbox.getFileBasedMailbox(List.ROOT + "/" + a.user + "@" + a.host + "/archive", true));
+              List.p.execute((Transaction)t);
+          // Specific List ///////////////////////////////////////////////////////////////////////
+          } else if (action.startsWith("List")) {
+              List list = (List)List.p.execute(List.forAddress(Address.parse(request.getParameter("list"))));
+              %><table border=1>
+                    <tr><td>List:</td><td><%=list.address%></td></tr>
+                    <tr><td>Description:</td><td><%=list.one_line_description%></td></tr>
+                    </table>
+                <input type=hidden name=list value=<%=list.address%>>
+                <input type=text size=30 name=email>
+                <input type=submit name=action value=Subscribe>
+              <%
+
+          // Subscribe //////////////////////////////////////////////////////////////////////////////
+          } else if (action.startsWith("Subscribe")) {
+              List.p.execute(List.subscribeNewUser(Address.parse(request.getParameter("email")), request.getParameter("list")));
+              %><h3>Please check your email</h3>
+                A confirmation message has been sent to you.
+                response.sendRedirect("");
+              <%
+
+          // Delete //////////////////////////////////////////////////////////////////////////////
+          } else if (action.startsWith("Delete")) {
+              Transaction t = List.delete(new Address(action.substring(6).trim()));
+              List.p.execute((Transaction)t);
+              response.sendRedirect("");
+          }
+              %>         
+      </form>
+
+    </body>
+</html>
\ No newline at end of file