]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/dbObjects/User.java
add: send mail notification to support after support action
[gigi.git] / src / org / cacert / gigi / dbObjects / User.java
index 8e9bc762b227d88844edf05c0028b41df1488224..c0b0128bdd37e28040605d141a80dd3fcad24b49 100644 (file)
@@ -11,6 +11,7 @@ import java.util.Set;
 import org.cacert.gigi.GigiApiException;
 import org.cacert.gigi.database.GigiPreparedStatement;
 import org.cacert.gigi.database.GigiResultSet;
+import org.cacert.gigi.dbObjects.Assurance.AssuranceType;
 import org.cacert.gigi.dbObjects.CATS.CATSType;
 import org.cacert.gigi.localisation.Language;
 import org.cacert.gigi.output.DateSelector;
@@ -179,7 +180,7 @@ public class User extends CertificateOwner {
     }
 
     public int getAssurancePoints() {
-        try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT sum(points) FROM `notary` where `to`=? AND `deleted` is NULL AND (`expire` IS NULL OR `expire` > CURRENT_TIMESTAMP)")) {
+        try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT SUM(lastpoints) FROM ( SELECT DISTINCT ON (`from`) `from`, `to`, `points` as lastpoints, `method` FROM `notary` WHERE `deleted` is NULL AND (`expire` IS NULL OR `expire` > CURRENT_TIMESTAMP) AND `to` = ? ORDER BY  `from`, `when` DESC) as p")) {
             query.setInt(1, getId());
 
             GigiResultSet rs = query.executeQuery();
@@ -194,8 +195,9 @@ public class User extends CertificateOwner {
     }
 
     public int getExperiencePoints() {
-        try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT count(*) FROM `notary` where `from`=? AND `deleted` is NULL")) {
+        try (GigiPreparedStatement query = new GigiPreparedStatement("SELECT count(*) FROM ( SELECT `to` FROM `notary` WHERE `from`=? AND `deleted` IS NULL AND `method` = ? ::`notaryType` GROUP BY `to`) as p")) {
             query.setInt(1, getId());
+            query.setString(2, AssuranceType.FACE_TO_FACE.getDescription());
 
             GigiResultSet rs = query.executeQuery();
             int points = 0;
@@ -360,40 +362,6 @@ public class User extends CertificateOwner {
 
     }
 
-    public boolean wantsDirectoryListing() {
-        try (GigiPreparedStatement get = new GigiPreparedStatement("SELECT listme FROM users WHERE id=?")) {
-            get.setInt(1, getId());
-            GigiResultSet exec = get.executeQuery();
-            return exec.next() && exec.getBoolean("listme");
-        }
-    }
-
-    public String getContactInformation() {
-        try (GigiPreparedStatement get = new GigiPreparedStatement("SELECT contactinfo FROM users WHERE id=?")) {
-            get.setInt(1, getId());
-
-            GigiResultSet exec = get.executeQuery();
-            exec.next();
-            return exec.getString("contactinfo");
-        }
-    }
-
-    public void setDirectoryListing(boolean on) {
-        try (GigiPreparedStatement update = new GigiPreparedStatement("UPDATE users SET listme = ? WHERE id = ?")) {
-            update.setBoolean(1, on);
-            update.setInt(2, getId());
-            update.executeUpdate();
-        }
-    }
-
-    public void setContactInformation(String contactInfo) {
-        try (GigiPreparedStatement update = new GigiPreparedStatement("UPDATE users SET contactinfo = ? WHERE id = ?")) {
-            update.setString(1, contactInfo);
-            update.setInt(2, getId());
-            update.executeUpdate();
-        }
-    }
-
     public boolean isInGroup(Group g) {
         return groups.contains(g);
     }