aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-01-10 15:10:16 +0300
committerGravatar Vitaly Takmazov2016-01-10 15:10:32 +0300
commit98b91289a497989e2c776c7e4e333ce6df719211 (patch)
tree5ce5bf6fdefed9e51ff28aae671e03dc96cf9e35 /src
parent23666546ca2c0f1ee492b1bea8c0ea83c8c04a2b (diff)
ON/OFF
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/server/UserQueries.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/com/juick/server/UserQueries.java b/src/main/java/com/juick/server/UserQueries.java
index d1313715..9140e8ea 100644
--- a/src/main/java/com/juick/server/UserQueries.java
+++ b/src/main/java/com/juick/server/UserQueries.java
@@ -589,4 +589,29 @@ public class UserQueries {
public static int getStatsReplies(Connection sql, int uid) {
return SQLHelpers.getInt(sql, "SELECT COUNT(*) FROM replies WHERE user_id=?", uid, 0);
}
+
+ public enum ActiveStatus {
+ Inactive,
+ Active
+ }
+
+ public static boolean setActiveStatusForJID(Connection sql, String JID, ActiveStatus jidStatus) {
+ User user = getUserByJID(sql, JID);
+ if (user != null) {
+ PreparedStatement preparedStatement = null;
+ try {
+ preparedStatement = sql.prepareStatement(
+ "UPDATE jids SET active=? WHERE user_id=? AND jid=?");
+ int newStatus = jidStatus == ActiveStatus.Active ? 1 : 0;
+ preparedStatement.setInt(1, newStatus);
+ preparedStatement.setInt(2, user.UID);
+ preparedStatement.setString(3, JID);
+ return preparedStatement.executeUpdate() >= 0;
+ } catch (SQLException e) {
+ e.printStackTrace();
+ } finally {
+ Utils.finishSQL(null, preparedStatement);
+ }
+ }
+ }
}