]> WPIA git - gigi.git/blob - src/org/cacert/gigi/output/MailTable.java
Added mailOverview (form dummy)
[gigi.git] / src / org / cacert / gigi / output / MailTable.java
1 package org.cacert.gigi.output;
2
3 import java.io.PrintWriter;
4 import java.sql.ResultSet;
5 import java.sql.SQLException;
6 import java.util.LinkedList;
7 import java.util.Map;
8
9 import org.cacert.gigi.Language;
10 import org.cacert.gigi.output.DataTable.Cell;
11
12 public class MailTable implements Outputable {
13         private String resultSet, userMail;
14
15         public MailTable(String key, String userMail) {
16                 this.resultSet = key;
17                 this.userMail = userMail;
18         }
19
20         @Override
21         public void output(PrintWriter out, Language l, Map<String, Object> vars) {
22                 ResultSet rs = (ResultSet) vars.get(resultSet);
23                 String userMail = (String) vars.get(this.userMail);
24                 LinkedList<Cell> cells = new LinkedList<>();
25                 cells.add(new Cell("Email Accounts", true, 4, "class=\"title\""));
26                 cells.add(new Cell("Default", true));
27                 cells.add(new Cell("Status", true));
28                 cells.add(new Cell("Delete", true));
29                 cells.add(new Cell("Address", true));
30                 try {
31                         rs.beforeFirst();
32                         while (rs.next()) {
33                                 cells.add(new Cell());
34                                 cells.add(new Cell(
35                                                 rs.getString("hash").trim().isEmpty() ? "Verified"
36                                                                 : "Unverified", true));
37                                 if (rs.getString("email").equals(userMail)) {
38                                         cells.add(new Cell(
39                                                         "N/A"
40                                                                         , true));
41                                 } else {
42                                         cells.add(new Cell("<input type=\"checkbox\" name=\"delid[]\" value=\""
43                                                                                         + rs.getInt("id") + "\">", false));
44                                 }
45                                 cells.add(new Cell(rs.getString("email"), false));
46                         }
47                 } catch (SQLException e) {
48                         e.printStackTrace();
49                 }
50                 String trans = l.getTranslation("Make Default");
51                 cells.add(new Cell(
52                                 "<input type=\"submit\" name=\"makedefault\" value=\"" + trans
53                                                 + "\">", false, 2));
54                 trans = l.getTranslation("Delete");
55                 cells.add(new Cell("<input type=\"submit\" name=\"process\" value=\""
56                                 + trans + "\">", false, 2));
57                 DataTable t = new DataTable(4, cells);
58                 t.output(out, l, vars);
59         }
60
61 }