X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Faccount%2FMailOverview.java;h=6b9000c85d9977faa2b712986fd58e8082cf9f64;hp=f165cc10b09b1de21b259066883170824809f2e9;hb=e409ba881965634f63f0b67824bc93dda4ec4327;hpb=6dd543c2f2c7e585a1e97f9db6b933fac46406eb diff --git a/src/org/cacert/gigi/pages/account/MailOverview.java b/src/org/cacert/gigi/pages/account/MailOverview.java index f165cc10..6b9000c8 100644 --- a/src/org/cacert/gigi/pages/account/MailOverview.java +++ b/src/org/cacert/gigi/pages/account/MailOverview.java @@ -1,28 +1,50 @@ package org.cacert.gigi.pages.account; import java.io.IOException; +import java.io.PrintWriter; import java.util.HashMap; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.cacert.gigi.output.MailTable; +import org.cacert.gigi.dbObjects.User; +import org.cacert.gigi.localisation.Language; +import org.cacert.gigi.output.Form; import org.cacert.gigi.pages.Page; public class MailOverview extends Page { - public static final String DEFAULT_PATH = "/account/mails"; - public MailOverview(String title) { - super(title); - } - - @Override - public void doGet(HttpServletRequest req, HttpServletResponse resp) - throws IOException { - HashMap vars = new HashMap(); - - new MailTable().output(resp.getWriter(), getLanguage(req), vars); - - } + public static final String DEFAULT_PATH = "/account/mails"; + + public MailOverview(String title) { + super(title); + } + + @Override + public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { + final User us = getUser(req); + Language lang = Page.getLanguage(req); + HashMap vars = new HashMap<>(); + vars.put("addForm", new MailAddForm(req, us)); + vars.put("manForm", new MailManagementForm(req, us)); + getDefaultTemplate().output(resp.getWriter(), lang, vars); + } + + @Override + public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { + PrintWriter out = resp.getWriter(); + if (req.getParameter("addmail") != null) { + MailAddForm f = Form.getForm(req, MailAddForm.class); + if (f.submit(out, req)) { + resp.sendRedirect(MailOverview.DEFAULT_PATH); + } + } else if (req.getParameter("makedefault") != null || req.getParameter("delete") != null) { + MailManagementForm f = Form.getForm(req, MailManagementForm.class); + if (f.submit(out, req)) { + resp.sendRedirect(MailOverview.DEFAULT_PATH); + } + } + super.doPost(req, resp); + } }