BrightSide Workbench Full Report + Source Code
MailFormAction.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2011 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.mail.recipients;
19 
20 import java.util.Set;
21 import java.util.TreeSet;
22 import org.turro.action.MailSenders;
23 import org.turro.elephant.context.IAction;
24 import org.turro.elephant.impl.abstracts.AbstractAction;
25 import org.turro.elephant.impl.util.StringParser;
26 import org.turro.html.HTMLGenerator;
27 import org.turro.marker.FormTrick;
28 
33 public class MailFormAction extends AbstractAction implements IAction {
34 
36  public MailFormAction() {
37  }
38 
39  @Override
40  public int execute() throws Exception {
41  String ctx = getContextParameter(),
42  action = getActionParameter();
43 
44  boolean isAJAX = false;
45 
46  if("mailform-send".equals(action)) {
47  boolean proceed = true;
48  HTMLGenerator hg = new HTMLGenerator();
49  hg.startTable("width='100%' style='padding:5px;background-color:#fefefe;color:#444444;border: solid 1px #eeeeee;font-size:12px;font-family:verdana'");
50  hg.startTableCol("")
51  .startTag("div", " style='border-bottom: solid 1px #eeeeee;font-weight:bold'")
52  .write(ctx + " FORM")
53  .endTag()
54  .startTag("p");
55 
56  for(String name : new TreeSet<String>((Set<String>) constructor.getRequest().getParameterMap().keySet())) {
57  if(name.equals("formtrick")) {
59  } else if(!name.equals("context") && !name.equals("action") && !name.equals("email_to")) {
60  hg.write(name + ": ")
61  .startTag("b")
63  .endTag()
64  .writeNewLine();
65  }
66  }
67  hg.endAllTags();
68 
69  if(proceed) {
71  .addUser(null, constructor.getParameter("email_to"))
72  .send(ctx + " FORM", hg.toString());
73  }
74  }
75 
76  if(!isAJAX) constructor.redirect(ctx);
77 
78  return IAction.DONE;
79  }
80 
81 }
static IMailSender getPool()
static String toHTML(String value)
HTMLGenerator write(String value)
HTMLGenerator startTag(String tag)
HTMLGenerator startTableCol(String attributes)
HTMLGenerator startTable(String attributes)
static boolean checkTrick(String value)
Definition: FormTrick.java:39
T addUser(String name, String email)