1 package org.cacert.gigi.pages.account;
3 import java.io.IOException;
4 import java.util.HashMap;
6 import javax.servlet.http.HttpServletRequest;
7 import javax.servlet.http.HttpServletResponse;
9 import org.cacert.gigi.dbObjects.User;
10 import org.cacert.gigi.output.template.OutputableArrayIterable;
11 import org.cacert.gigi.pages.Page;
12 import org.cacert.gigi.util.AuthorizationContext;
14 public class UserHistory extends Page {
16 public static final String SUPPORT_PATH = "/support/user/*/history";
18 public static final String PATH = "/account/history";
20 private static final int intStart = SUPPORT_PATH.indexOf('*');
22 private boolean support;
24 public UserHistory(boolean support) {
25 super(support ? "Support user history" : "History");
26 this.support = support;
30 public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
33 String info = req.getPathInfo();
34 int id = Integer.parseInt(info.substring(intStart, info.length() - SUPPORT_PATH.length() + intStart + 1));
43 String[] adminLog = u.getAdminLog();
44 HashMap<String, Object> vars = new HashMap<>();
45 vars.put("entries", new OutputableArrayIterable(adminLog, "entry"));
46 getDefaultTemplate().output(resp.getWriter(), getLanguage(req), vars);
50 public boolean isPermitted(AuthorizationContext ac) {
51 return ac != null && ( !support || ac.canSupport());