]> WPIA git - gigi.git/commitdiff
UPD: Allow 2-level wildcard pages
authorJanis Streib <janis@dogcraft.de>
Thu, 4 Jun 2015 14:38:03 +0000 (16:38 +0200)
committerFelix Dörre <felix@dogcraft.de>
Thu, 4 Jun 2015 17:19:48 +0000 (19:19 +0200)
src/org/cacert/gigi/Gigi.java
src/org/cacert/gigi/pages/admin/support/SupportUserDetailsPage.java

index 6af640ead48ddf2b83a8a2905f8415ff46c6d85d..09daf6df3ccb4c3b4d9142075ca36e9a677250b5 100644 (file)
@@ -249,6 +249,17 @@ public class Gigi extends HttpServlet {
         int idx = pathInfo.lastIndexOf('/');
         pathInfo = pathInfo.substring(0, idx);
 
+        page = pages.get(pathInfo + "/*");
+        if (page != null) {
+            return page;
+        }
+
+        idx = pathInfo.lastIndexOf('/');
+        if (idx == -1) {
+            return null;
+        }
+        pathInfo = pathInfo.substring(0, idx);
+
         page = pages.get(pathInfo + "/*");
         if (page != null) {
             return page;
index 234448088d91f5bcaa82b1eb357f8f81c25995db..afacb56c86e3edbfda135e4aac6f2d746aace52a 100644 (file)
@@ -27,9 +27,17 @@ public class SupportUserDetailsPage extends Page {
 
     @Override
     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
-        int id;
+        int id = -1;
         String[] idP = req.getPathInfo().split("/");
-        id = Integer.parseInt(idP[idP.length - 1]);
+        try {
+            if (req.getPathInfo().endsWith("history") || req.getPathInfo().endsWith("trainings")) {
+                id = Integer.parseInt(idP[idP.length - 2]);
+            } else {
+                id = Integer.parseInt(idP[idP.length - 1]);
+            }
+        } catch (NumberFormatException e) {
+            resp.sendError(404);
+        }
         final User user = User.getById(id);
         String ticket = (String) req.getSession().getAttribute("ticketNo" + user.getId());
         SupportUserDetailsForm f = new SupportUserDetailsForm(req, new SupportedUser(user, getUser(req), ticket));