]> WPIA git - gigi.git/commitdiff
Begin the assurance form
authorFelix Dörre <felix@dogcraft.de>
Thu, 26 Jun 2014 08:54:29 +0000 (10:54 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 26 Jun 2014 08:54:29 +0000 (10:54 +0200)
src/org/cacert/gigi/User.java
src/org/cacert/gigi/pages/wot/AssuranceForm.java
src/org/cacert/gigi/pages/wot/AssuranceForm.templ [new file with mode: 0644]
src/org/cacert/gigi/pages/wot/AssurePage.java

index bf47552ac56a7b3e7285eefe20588f895e8aa984..055ac8384fe376e65771e5aaff1a8d52459beec4 100644 (file)
@@ -22,12 +22,13 @@ public class User {
                this.id = id;
                try {
                        PreparedStatement ps = DatabaseConnection.getInstance().prepare(
-                                       "SELECT `fname`, `lname` FROM `users` WHERE id=?");
+                                       "SELECT `fname`, `lname`, `dob` FROM `users` WHERE id=?");
                        ps.setInt(1, id);
                        ResultSet rs = ps.executeQuery();
                        if (rs.next()) {
                                fname = rs.getString(1);
                                lname = rs.getString(2);
+                               dob = rs.getDate(3);
                        }
                        rs.close();
                } catch (SQLException e) {
index 28a1ddfbd0a3dc935fb79f571448d9c066bb7374..809743d61b5d7b38f392b2fa398fbb44a20f7060 100644 (file)
@@ -1,16 +1,40 @@
 package org.cacert.gigi.pages.wot;
 
+import java.io.InputStreamReader;
 import java.io.PrintWriter;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.cacert.gigi.Language;
+import org.cacert.gigi.User;
 import org.cacert.gigi.output.Outputable;
+import org.cacert.gigi.output.Template;
+import org.cacert.gigi.util.HTMLEncoder;
 
 public class AssuranceForm implements Outputable {
+       User assuree;
+       static final Template templ;
+       static {
+               templ = new Template(new InputStreamReader(
+                               AssuranceForm.class.getResourceAsStream("AssuranceForm.templ")));
+       }
+
+       public AssuranceForm(int assuree) {
+               this.assuree = new User(assuree);
+       }
 
        @Override
        public void output(PrintWriter out, Language l, Map<String, Object> vars) {
-
+               HashMap<String, Object> res = new HashMap<String, Object>();
+               res.putAll(vars);
+               res.put("fname", HTMLEncoder.encodeHTML(assuree.getFname()));
+               res.put("mname",
+                               assuree.getMname() == null ? "" : HTMLEncoder
+                                               .encodeHTML(assuree.getMname()));
+               res.put("lname", HTMLEncoder.encodeHTML(assuree.getLname()));
+               res.put("suffix",
+                               assuree.getSuffix() == null ? "" : HTMLEncoder
+                                               .encodeHTML(assuree.getSuffix()));
+               templ.output(out, l, res);
        }
-
 }
diff --git a/src/org/cacert/gigi/pages/wot/AssuranceForm.templ b/src/org/cacert/gigi/pages/wot/AssuranceForm.templ
new file mode 100644 (file)
index 0000000..e0c6ed4
--- /dev/null
@@ -0,0 +1,7 @@
+<form method="POST">\r
+<table class="wrapper" width="600">\r
+<tr><td colspan="2" class="title"><?=_Assurance Confirmation?></td></tr>\r
+<tr><td colspan="2" class="DataTD"><?=s,$fname,$mname,$lname,$suffix,Please check the following details match against what you witnessed when you met %s %s %s %s in person. You MUST NOT proceed unless you are sure the details are correct. You may be held responsible by the CAcert Arbitrator for any issues with this Assurance.?>\r
+</td></tr>\r
+</table>\r
+</form>
\ No newline at end of file
index 6c5622b7e612613719263cd262e8e5ce555263a9..5fae0f8cd042374e86ff5aabe3a9fd86fc0c90c3 100644 (file)
@@ -11,9 +11,11 @@ import java.util.HashMap;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.cacert.gigi.User;
 import org.cacert.gigi.database.DatabaseConnection;
 import org.cacert.gigi.output.DateSelector;
 import org.cacert.gigi.output.Template;
+import org.cacert.gigi.pages.LoginPage;
 import org.cacert.gigi.pages.Page;
 
 public class AssurePage extends Page {
@@ -36,6 +38,15 @@ public class AssurePage extends Page {
                if (pi.length() > 1) {
                        out.println("I am a Placeholder for the Assurance form # ");
                        out.println(pi.substring(1));
+                       User myself = LoginPage.getUser(req);
+                       int mid = Integer.parseInt(pi.substring(1));
+                       if (mid == myself.getId()) {
+                               out.println("Cannot assure myself.");
+                               return;
+                       }
+
+                       new AssuranceForm(mid).output(out, getLanguage(req),
+                                       new HashMap<String, Object>());;
                } else {
                        HashMap<String, Object> vars = new HashMap<String, Object>();
                        vars.put("DoB", ds);