X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Fwot%2FMyPoints.java;fp=src%2Forg%2Fcacert%2Fgigi%2Fpages%2Fwot%2FMyPoints.java;h=9d8a3e3bc0565651b5990faa0f125ed7b86ac7a0;hb=796edd7987d09c70f0eed74ebd648fefa889e8a8;hp=69f5d7e6f9a3667eff71ffb508e29f1758042652;hpb=9a6015ecc14fd10aaad4f25a5646ce94334887ba;p=gigi.git diff --git a/src/org/cacert/gigi/pages/wot/MyPoints.java b/src/org/cacert/gigi/pages/wot/MyPoints.java index 69f5d7e6..9d8a3e3b 100644 --- a/src/org/cacert/gigi/pages/wot/MyPoints.java +++ b/src/org/cacert/gigi/pages/wot/MyPoints.java @@ -13,22 +13,45 @@ import org.cacert.gigi.util.AuthorizationContext; public class MyPoints extends Page { + public static final String SUPPORT_PATH = "/support/user/*/points"; + public static final String PATH = "/wot/mypoints"; - private AssurancesDisplay myDisplay = new AssurancesDisplay("asArr", false); + private static final int intStart = SUPPORT_PATH.indexOf('*'); + + private boolean support; - private AssurancesDisplay toOtherDisplay = new AssurancesDisplay("otherAsArr", true); + private AssurancesDisplay myDisplay; - public MyPoints() { - super("My Points"); + private AssurancesDisplay toOtherDisplay; + + public MyPoints(boolean support) { + super(support ? "Support User Points" : "My Points"); + this.support = support; + myDisplay = new AssurancesDisplay("asArr", false, support); + toOtherDisplay = new AssurancesDisplay("otherAsArr", true, support); } @Override public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException { + User user; + if (support) { + String info = req.getPathInfo(); + int id = Integer.parseInt(info.substring(intStart, info.length() - SUPPORT_PATH.length() + intStart + 1)); + user = User.getById(id); + if (user == null) { + resp.sendError(404); + return; + } + } else { + user = getUser(req); + } + HashMap vars = new HashMap(); + vars.put("support", support); + vars.put("username", user.getPreferredName().toString()); vars.put("pointlist", myDisplay); vars.put("madelist", toOtherDisplay); - User user = getUser(req); vars.put("asArr", user.getReceivedAssurances()); vars.put("otherAsArr", user.getMadeAssurances()); vars.put("assP", user.getAssurancePoints()); @@ -41,6 +64,14 @@ public class MyPoints extends Page { @Override public boolean isPermitted(AuthorizationContext ac) { - return ac != null && ac.getTarget() instanceof User; + if (ac == null) { + return false; + } + if (support) { + return ac.canSupport(); + } else { + return ac.getTarget() instanceof User; + } } + }