]> WPIA git - gigi.git/commitdiff
upd: history also for organisations.
authorFelix Dörre <felix@dogcraft.de>
Wed, 11 Nov 2015 09:15:03 +0000 (10:15 +0100)
committerFelix Dörre <felix@dogcraft.de>
Wed, 11 Nov 2015 10:02:07 +0000 (11:02 +0100)
src/org/cacert/gigi/Gigi.java
src/org/cacert/gigi/dbObjects/CertificateOwner.java
src/org/cacert/gigi/dbObjects/User.java
src/org/cacert/gigi/pages/account/History.java [moved from src/org/cacert/gigi/pages/account/UserHistory.java with 82% similarity]
src/org/cacert/gigi/pages/account/History.templ [moved from src/org/cacert/gigi/pages/account/UserHistory.templ with 100% similarity]
tests/org/cacert/gigi/pages/admin/TestSEAdminPageDetails.java

index 9dde23a9aec0867686a492ea310a2f549ca05eb0..f558a6e44543a37fbdbb0374833a3f8bcd36e1df 100644 (file)
@@ -43,7 +43,7 @@ import org.cacert.gigi.pages.TestSecure;
 import org.cacert.gigi.pages.Verify;
 import org.cacert.gigi.pages.account.ChangePasswordPage;
 import org.cacert.gigi.pages.account.MyDetails;
 import org.cacert.gigi.pages.Verify;
 import org.cacert.gigi.pages.account.ChangePasswordPage;
 import org.cacert.gigi.pages.account.MyDetails;
-import org.cacert.gigi.pages.account.UserHistory;
+import org.cacert.gigi.pages.account.History;
 import org.cacert.gigi.pages.account.UserTrainings;
 import org.cacert.gigi.pages.account.certs.CertificateAdd;
 import org.cacert.gigi.pages.account.certs.Certificates;
 import org.cacert.gigi.pages.account.UserTrainings;
 import org.cacert.gigi.pages.account.certs.CertificateAdd;
 import org.cacert.gigi.pages.account.certs.Certificates;
@@ -149,8 +149,8 @@ public class Gigi extends HttpServlet {
             putPage(FindDomainPage.PATH, new FindDomainPage("Find Domain"), "Support Console");
 
             putPage(SupportUserDetailsPage.PATH + "*", new SupportUserDetailsPage("Support: User Details"), null);
             putPage(FindDomainPage.PATH, new FindDomainPage("Find Domain"), "Support Console");
 
             putPage(SupportUserDetailsPage.PATH + "*", new SupportUserDetailsPage("Support: User Details"), null);
-            putPage(UserHistory.PATH, new UserHistory(false), "My Account");
-            putPage(UserHistory.SUPPORT_PATH, new UserHistory(true), null);
+            putPage(History.PATH, new History(false), "My Account");
+            putPage(History.SUPPORT_PATH, new History(true), null);
             putPage(UserTrainings.PATH, new UserTrainings(false), "My Account");
             putPage(UserTrainings.SUPPORT_PATH, new UserTrainings(true), null);
             if (testing) {
             putPage(UserTrainings.PATH, new UserTrainings(false), "My Account");
             putPage(UserTrainings.SUPPORT_PATH, new UserTrainings(true), null);
             if (testing) {
index 661033fbf903996e43c8bdbe3826a0660de787d2..f9e9fbd57f0f721e9ac2c4cfc8a590968e727339 100644 (file)
@@ -1,6 +1,7 @@
 package org.cacert.gigi.dbObjects;
 
 import java.util.LinkedList;
 package org.cacert.gigi.dbObjects;
 
 import java.util.LinkedList;
+import java.util.List;
 
 import org.cacert.gigi.database.DatabaseConnection;
 import org.cacert.gigi.database.GigiPreparedStatement;
 
 import org.cacert.gigi.database.DatabaseConnection;
 import org.cacert.gigi.database.GigiPreparedStatement;
@@ -103,4 +104,17 @@ public abstract class CertificateOwner implements IdCachable {
         myCache.remove(this);
     }
 
         myCache.remove(this);
     }
 
+    public String[] getAdminLog() {
+        GigiPreparedStatement prep = DatabaseConnection.getInstance().prepare("SELECT `when`, type, information FROM `adminLog` WHERE uid=? ORDER BY `when` ASC");
+        prep.setInt(1, getId());
+        GigiResultSet res = prep.executeQuery();
+        List<String> entries = new LinkedList<String>();
+
+        while (res.next()) {
+            entries.add(res.getString(2) + " (" + res.getString(3) + ")");
+        }
+
+        return entries.toArray(new String[0]);
+    }
+
 }
 }
index f12002334566923764067289aa1f9cb39c281d12..72c26c237980006d8438382e0a8b5c430f11ba69 100644 (file)
@@ -469,19 +469,6 @@ public class User extends CertificateOwner {
         return false;
     }
 
         return false;
     }
 
-    public String[] getAdminLog() {
-        GigiPreparedStatement prep = DatabaseConnection.getInstance().prepare("SELECT `when`, type, information FROM `adminLog` WHERE uid=? ORDER BY `when` ASC");
-        prep.setInt(1, getId());
-        GigiResultSet res = prep.executeQuery();
-        List<String> entries = new LinkedList<String>();
-
-        while (res.next()) {
-            entries.add(res.getString(2) + " (" + res.getString(3) + ")");
-        }
-
-        return entries.toArray(new String[0]);
-    }
-
     public String[] getTrainings() {
         GigiPreparedStatement prep = DatabaseConnection.getInstance().prepare("SELECT `pass_date`, `type_text` FROM `cats_passed` LEFT JOIN `cats_type` ON `cats_type`.`id`=`cats_passed`.`variant_id`  WHERE `user_id`=? ORDER BY `pass_date` ASC");
         prep.setInt(1, getId());
     public String[] getTrainings() {
         GigiPreparedStatement prep = DatabaseConnection.getInstance().prepare("SELECT `pass_date`, `type_text` FROM `cats_passed` LEFT JOIN `cats_type` ON `cats_type`.`id`=`cats_passed`.`variant_id`  WHERE `user_id`=? ORDER BY `pass_date` ASC");
         prep.setInt(1, getId());
similarity index 82%
rename from src/org/cacert/gigi/pages/account/UserHistory.java
rename to src/org/cacert/gigi/pages/account/History.java
index 53e81a23c88cef1f3d5a817360c3d0e95010800c..520e3a549b3f7a73c453a51d4a9592da31e5ded8 100644 (file)
@@ -6,12 +6,14 @@ import java.util.HashMap;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.cacert.gigi.dbObjects.CertificateOwner;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.output.template.OutputableArrayIterable;
 import org.cacert.gigi.dbObjects.User;
 import org.cacert.gigi.output.template.OutputableArrayIterable;
+import org.cacert.gigi.pages.LoginPage;
 import org.cacert.gigi.pages.Page;
 import org.cacert.gigi.util.AuthorizationContext;
 
 import org.cacert.gigi.pages.Page;
 import org.cacert.gigi.util.AuthorizationContext;
 
-public class UserHistory extends Page {
+public class History extends Page {
 
     public static final String SUPPORT_PATH = "/support/user/*/history";
 
 
     public static final String SUPPORT_PATH = "/support/user/*/history";
 
@@ -21,14 +23,14 @@ public class UserHistory extends Page {
 
     private boolean support;
 
 
     private boolean support;
 
-    public UserHistory(boolean support) {
-        super(support ? "Support user history" : "History");
+    public History(boolean support) {
+        super(support ? "Support History" : "History");
         this.support = support;
     }
 
     @Override
     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
         this.support = support;
     }
 
     @Override
     public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
-        User u;
+        CertificateOwner u;
         if (support) {
             String info = req.getPathInfo();
             int id = Integer.parseInt(info.substring(intStart, info.length() - SUPPORT_PATH.length() + intStart + 1));
         if (support) {
             String info = req.getPathInfo();
             int id = Integer.parseInt(info.substring(intStart, info.length() - SUPPORT_PATH.length() + intStart + 1));
@@ -38,7 +40,7 @@ public class UserHistory extends Page {
                 return;
             }
         } else {
                 return;
             }
         } else {
-            u = getUser(req);
+            u = LoginPage.getAuthorizationContext(req).getTarget();
         }
         String[] adminLog = u.getAdminLog();
         HashMap<String, Object> vars = new HashMap<>();
         }
         String[] adminLog = u.getAdminLog();
         HashMap<String, Object> vars = new HashMap<>();
index b554a2c3390e1ff1782d586fe1dfdc2162d621e1..3cb78b9a10b232b91de888fc500739de040366b9 100644 (file)
@@ -12,7 +12,7 @@ import java.util.regex.Pattern;
 
 import org.cacert.gigi.dbObjects.Group;
 import org.cacert.gigi.pages.account.MyDetails;
 
 import org.cacert.gigi.dbObjects.Group;
 import org.cacert.gigi.pages.account.MyDetails;
-import org.cacert.gigi.pages.account.UserHistory;
+import org.cacert.gigi.pages.account.History;
 import org.cacert.gigi.pages.admin.support.SupportEnterTicketPage;
 import org.cacert.gigi.pages.admin.support.SupportUserDetailsPage;
 import org.cacert.gigi.testUtils.ClientTest;
 import org.cacert.gigi.pages.admin.support.SupportEnterTicketPage;
 import org.cacert.gigi.pages.admin.support.SupportUserDetailsPage;
 import org.cacert.gigi.testUtils.ClientTest;
@@ -104,11 +104,11 @@ public class TestSEAdminPageDetails extends ClientTest {
     }
 
     private int logCountAdmin(int id) throws IOException {
     }
 
     private int logCountAdmin(int id) throws IOException {
-        return getLogEntryCount(IOUtils.readURL(get(UserHistory.SUPPORT_PATH.replace("*", Integer.toString(id)))));
+        return getLogEntryCount(IOUtils.readURL(get(History.SUPPORT_PATH.replace("*", Integer.toString(id)))));
     }
 
     private int logCountUser(String cookie) throws IOException {
     }
 
     private int logCountUser(String cookie) throws IOException {
-        return getLogEntryCount(IOUtils.readURL(get(cookie, UserHistory.PATH)));
+        return getLogEntryCount(IOUtils.readURL(get(cookie, History.PATH)));
     }
 
     private int getLogEntryCount(String readURL) {
     }
 
     private int getLogEntryCount(String readURL) {