aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2013-11-17 02:13:22 +0700
committerGravatar Ugnich Anton2013-11-17 02:13:22 +0700
commitc0ccfe940d00f4eeb888c5f721e8a63c415daeb3 (patch)
tree27df4972092199dc1ea091aa2f5d9978daaa224c /src
parent26a5fcecd4d71b58fa5d099a58007252e7b85c3c (diff)
SubscriptionsQueries.getJIDSubscribedToUser
Diffstat (limited to 'src')
-rw-r--r--src/com/juick/server/SubscriptionsQueries.java29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/com/juick/server/SubscriptionsQueries.java b/src/com/juick/server/SubscriptionsQueries.java
index d7b7fbc3..9f9468cd 100644
--- a/src/com/juick/server/SubscriptionsQueries.java
+++ b/src/com/juick/server/SubscriptionsQueries.java
@@ -16,13 +16,40 @@ import java.util.ArrayList;
*/
public class SubscriptionsQueries {
+ public static ArrayList<String> getJIDSubscribedToUser(Connection sql, int uid, boolean friendsonly) {
+ ArrayList<String> jids = new ArrayList<String>();
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ if (friendsonly == false) {
+ stmt = sql.prepareStatement("SELECT jids.jid FROM subscr_users INNER JOIN jids ON (subscr_users.user_id=? AND subscr_users.suser_id=jids.user_id) WHERE jids.active=1");
+ stmt.setInt(1, uid);
+ } else {
+ stmt = sql.prepareStatement("SELECT jids.jid FROM subscr_users INNER JOIN jids ON (subscr_users.user_id=? AND subscr_users.suser_id=jids.user_id) WHERE jids.active=1 AND jids.user_id IN (SELECT wl_user_id FROM wl_users WHERE user_id=?)");
+ stmt.setInt(1, uid);
+ stmt.setInt(2, uid);
+ }
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ while (rs.next()) {
+ jids.add(rs.getString(1));
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+ return jids;
+ }
+
public static ArrayList<String> getJIDSubscribedToComments(Connection sql, int mid, int ignore_uid) {
ArrayList<String> jids = new ArrayList<String>();
PreparedStatement stmt = null;
ResultSet rs = null;
try {
- stmt = sql.prepareStatement("SELECT jid FROM subscr_messages WHERE message_id=? AND active=b'1' AND suser_id!=? AND jid!=''");
+ stmt = sql.prepareStatement("SELECT jids.jid FROM subscr_messages INNER JOIN jids ON (subscr_messages.message_id=? AND subscr_messages.suser_id=jids.user_id) WHERE jids.user_id!=? AND jids.active=1");
stmt.setInt(1, mid);
stmt.setInt(2, ignore_uid);
rs = stmt.executeQuery();