From b74e6c267498e6fda56a5167346623bf55a8f01e Mon Sep 17 00:00:00 2001 From: Ugnich Anton Date: Mon, 31 Dec 2012 16:34:51 +0700 Subject: MessagesQueries privacy --- src/com/juick/server/MessagesQueries.java | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/com/juick') diff --git a/src/com/juick/server/MessagesQueries.java b/src/com/juick/server/MessagesQueries.java index b2251048..227b3fea 100644 --- a/src/com/juick/server/MessagesQueries.java +++ b/src/com/juick/server/MessagesQueries.java @@ -544,18 +544,18 @@ public class MessagesQueries { return mids; } - public static ArrayList getUserBlog(Connection sql, int UID, int before) { + public static ArrayList getUserBlog(Connection sql, int UID, int privacy, int before) { ArrayList mids = new ArrayList(20); PreparedStatement stmt = null; ResultSet rs = null; try { if (before > 0) { - stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE user_id=? AND message_id=0 ORDER BY message_id DESC LIMIT 20"); + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE user_id=? AND message_id=" + privacy + " ORDER BY message_id DESC LIMIT 20"); stmt.setInt(1, UID); stmt.setInt(2, before); } else { - stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE user_id=? AND privacy>=0 ORDER BY message_id DESC LIMIT 20"); + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE user_id=? AND privacy>=" + privacy + " ORDER BY message_id DESC LIMIT 20"); stmt.setInt(1, UID); } rs = stmt.executeQuery(); @@ -571,19 +571,19 @@ public class MessagesQueries { return mids; } - public static ArrayList getUserTag(Connection sql, int UID, int TID, int before) { + public static ArrayList getUserTag(Connection sql, int UID, int TID, int privacy, int before) { ArrayList mids = new ArrayList(20); PreparedStatement stmt = null; ResultSet rs = null; try { if (before > 0) { - stmt = sql.prepareStatement("SELECT messages.message_id FROM messages_tags INNER JOIN messages USING(message_id) WHERE messages.user_id=? AND messages_tags.tag_id=? AND messages.message_id0 ORDER BY messages.message_id DESC LIMIT 20"); + stmt = sql.prepareStatement("SELECT messages.message_id FROM messages_tags INNER JOIN messages USING(message_id) WHERE messages.user_id=? AND messages_tags.tag_id=? AND messages.message_id" + privacy + " ORDER BY messages.message_id DESC LIMIT 20"); stmt.setInt(1, UID); stmt.setInt(2, TID); stmt.setInt(3, before); } else { - stmt = sql.prepareStatement("SELECT messages.message_id FROM messages_tags INNER JOIN messages USING(message_id) WHERE messages.user_id=? AND messages_tags.tag_id=? AND messages.privacy>0 ORDER BY messages.message_id DESC LIMIT 20"); + stmt = sql.prepareStatement("SELECT messages.message_id FROM messages_tags INNER JOIN messages USING(message_id) WHERE messages.user_id=? AND messages_tags.tag_id=? AND messages.privacy>" + privacy + " ORDER BY messages.message_id DESC LIMIT 20"); stmt.setInt(1, UID); stmt.setInt(2, TID); } @@ -627,18 +627,18 @@ public class MessagesQueries { return mids; } - public static ArrayList getUserPhotos(Connection sql, int UID, int before) { + public static ArrayList getUserPhotos(Connection sql, int UID, int privacy, int before) { ArrayList mids = new ArrayList(20); PreparedStatement stmt = null; ResultSet rs = null; try { if (before > 0) { - stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE user_id=? AND message_id=0 AND attach IS NOT NULL ORDER BY message_id DESC LIMIT 20"); + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE user_id=? AND message_id=" + privacy + " AND attach IS NOT NULL ORDER BY message_id DESC LIMIT 20"); stmt.setInt(1, UID); stmt.setInt(2, before); } else { - stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE user_id=? AND privacy>=0 AND attach IS NOT NULL ORDER BY message_id DESC LIMIT 20"); + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE user_id=? AND privacy>=" + privacy + " AND attach IS NOT NULL ORDER BY message_id DESC LIMIT 20"); stmt.setInt(1, UID); } rs = stmt.executeQuery(); @@ -654,7 +654,7 @@ public class MessagesQueries { return mids; } - public static ArrayList getUserSearch(Connection sql, Connection sqlSearch, int UID, String search, int before) { + public static ArrayList getUserSearch(Connection sql, Connection sqlSearch, int UID, String search, int privacy, int before) { ArrayList mids0 = new ArrayList(20); PreparedStatement stmt = null; @@ -684,7 +684,7 @@ public class MessagesQueries { ArrayList mids = new ArrayList(20); if (mids0.size() > 0) { try { - stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE message_id IN (" + Utils.convertArray2String(mids0) + ") AND privacy>=0 ORDER BY message_id DESC"); + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE message_id IN (" + Utils.convertArray2String(mids0) + ") AND privacy>=" + privacy + " ORDER BY message_id DESC"); rs = stmt.executeQuery(); rs.beforeFirst(); while (rs.next()) { -- cgit v1.2.3