]> WPIA git - gigi.git/blob - src/org/cacert/gigi/pages/wot/MyListingForm.java
add: handling of multiple verifications by the same RA Agent
[gigi.git] / src / org / cacert / gigi / pages / wot / MyListingForm.java
1 package org.cacert.gigi.pages.wot;
2
3 import java.io.PrintWriter;
4 import java.util.Map;
5
6 import javax.servlet.http.HttpServletRequest;
7
8 import org.cacert.gigi.dbObjects.User;
9 import org.cacert.gigi.localisation.Language;
10 import org.cacert.gigi.output.template.Form;
11 import org.cacert.gigi.output.template.Template;
12
13 public class MyListingForm extends Form {
14
15     private static Template template;
16
17     static {
18         template = new Template(MyListingForm.class.getResource("MyListingForm.templ"));
19     }
20
21     private User target;
22
23     public MyListingForm(HttpServletRequest hsr, User target) {
24         super(hsr);
25         this.target = target;
26     }
27
28     @Override
29     public boolean submit(PrintWriter out, HttpServletRequest req) {
30         if (req.getParameter("listme") != null && req.getParameter("contactinfo") != null) {
31             boolean on = !req.getParameter("listme").equals("0");
32             target.setDirectoryListing(on);
33             if (on) {
34                 target.setContactInformation(req.getParameter("contactinfo"));
35             } else {
36                 target.setContactInformation("");
37             }
38             return true;
39         }
40         return false;
41     }
42
43     @Override
44     protected void outputContent(PrintWriter out, Language l, Map<String, Object> vars) {
45         if (target.wantsDirectoryListing()) {
46             vars.put("selected", "selected");
47             vars.put("notSelected", "");
48             vars.put("activeInfo", target.getContactInformation());
49         } else {
50             vars.put("selected", "");
51             vars.put("notSelected", "selected");
52             vars.put("activeInfo", target.getContactInformation());
53         }
54         template.output(out, l, vars);
55     }
56
57 }