]> WPIA git - gigi.git/blobdiff - src/org/cacert/gigi/User.java
Move "About CAcert"-Menu to dynamic content.
[gigi.git] / src / org / cacert / gigi / User.java
index ca1c8ff8d6dddd721a5b1c7153433a6d8e2709ef..be8a6ec6202de813442dc7752dcc80405feeec59 100644 (file)
@@ -7,8 +7,8 @@ import java.sql.SQLException;
 import java.util.Calendar;
 
 import org.cacert.gigi.database.DatabaseConnection;
-import org.cacert.gigi.util.Notary;
 import org.cacert.gigi.localisation.Language;
+import org.cacert.gigi.util.Notary;
 import org.cacert.gigi.util.PasswordHash;
 import org.cacert.gigi.util.PasswordStrengthChecker;
 
@@ -450,4 +450,34 @@ public class User {
     public Language getPrefferedLanguage() {
         return Language.getInstance("de");
     }
+
+    public boolean wantsDirectoryListing() throws SQLException {
+        PreparedStatement get = DatabaseConnection.getInstance().prepare("SELECT listme FROM users WHERE id=?");
+        get.setInt(1, getId());
+        ResultSet exec = get.executeQuery();
+        exec.next();
+        return exec.getBoolean("listme");
+    }
+
+    public String getContactInformation() throws SQLException {
+        PreparedStatement get = DatabaseConnection.getInstance().prepare("SELECT contactinfo FROM users WHERE id=?");
+        get.setInt(1, getId());
+        ResultSet exec = get.executeQuery();
+        exec.next();
+        return exec.getString("contactinfo");
+    }
+
+    public void setDirectoryListing(boolean on) throws SQLException {
+        PreparedStatement update = DatabaseConnection.getInstance().prepare("UPDATE users SET listme = ? WHERE id = ?");
+        update.setBoolean(1, on);
+        update.setInt(2, getId());
+        update.executeUpdate();
+    }
+
+    public void setContactInformation(String contactInfo) throws SQLException {
+        PreparedStatement update = DatabaseConnection.getInstance().prepare("UPDATE users SET contactinfo = ? WHERE id = ?");
+        update.setString(1, contactInfo);
+        update.setInt(2, getId());
+        update.executeUpdate();
+    }
 }