diff options
author | Ugnich Anton | 2013-10-17 20:21:02 +0700 |
---|---|---|
committer | Ugnich Anton | 2013-10-17 20:21:02 +0700 |
commit | f5c7fe7a3f295f9b49bf19057b07b82d3e475223 (patch) | |
tree | 1026cea5d5858ebeb12daf7abdad54ce44af6882 /src/com/juick | |
parent | 102925eebf91f45f02824c597c8ec393017aa1cb (diff) |
Messages.getAll hack for uid=1
Diffstat (limited to 'src/com/juick')
-rw-r--r-- | src/com/juick/server/MessagesQueries.java | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/com/juick/server/MessagesQueries.java b/src/com/juick/server/MessagesQueries.java index 444cd13d..5e3cc238 100644 --- a/src/com/juick/server/MessagesQueries.java +++ b/src/com/juick/server/MessagesQueries.java @@ -286,13 +286,25 @@ public class MessagesQueries { PreparedStatement stmt = null; ResultSet rs = null; try { - if (before > 0) { - stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE message_id<? AND (privacy>0 OR user_id=?) AND lang='ru' ORDER BY message_id DESC LIMIT 20"); - stmt.setInt(1, before); - stmt.setInt(2, visitor_uid); + if (visitor_uid > 1) { + if (before > 0) { + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE message_id<? AND (privacy>0 OR user_id=?) AND lang='ru' AND user_id NOT IN (SELECT bl_user_id FROM bl_users WHERE user_id=?) ORDER BY message_id DESC LIMIT 20"); + stmt.setInt(1, before); + stmt.setInt(2, visitor_uid); + stmt.setInt(3, visitor_uid); + } else { + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE (privacy>0 OR user_id=?) AND lang='ru' AND user_id NOT IN (SELECT bl_user_id FROM bl_users WHERE user_id=?) ORDER BY message_id DESC LIMIT 20"); + stmt.setInt(1, visitor_uid); + stmt.setInt(2, visitor_uid); + } } else { - stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE (privacy>0 OR user_id=?) AND lang='ru' ORDER BY message_id DESC LIMIT 20"); - stmt.setInt(1, visitor_uid); + if (before > 0) { + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE message_id<? AND privacy>0 AND lang='ru' ORDER BY message_id DESC LIMIT 20"); + stmt.setInt(1, before); + } else { + stmt = sql.prepareStatement("SELECT message_id FROM messages WHERE privacy>0 AND lang='ru' ORDER BY message_id DESC LIMIT 20"); + } + } rs = stmt.executeQuery(); rs.beforeFirst(); |