aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2012-11-02 18:32:24 +0700
committerGravatar Ugnich Anton2012-11-02 18:32:24 +0700
commit83a82852057e48ef595057987b057496d5b562c6 (patch)
treef643e55b47d222dbde2746fd644758383cc4192c /src
parent4c311735dcf5d6e54dfb1d2d751a2bd42193e168 (diff)
getReplies
isReadonly
Diffstat (limited to 'src')
-rw-r--r--src/com/juick/server/MessagesQueries.java58
1 files changed, 57 insertions, 1 deletions
diff --git a/src/com/juick/server/MessagesQueries.java b/src/com/juick/server/MessagesQueries.java
index abcdd285..f7625a19 100644
--- a/src/com/juick/server/MessagesQueries.java
+++ b/src/com/juick/server/MessagesQueries.java
@@ -53,6 +53,26 @@ public class MessagesQueries {
return privacy >= 0 || (privacy == -1 && uid > 0 && UserQueries.isInWL(sql, owner_uid, uid)) || (privacy == -2 && uid == owner_uid);
}
+ public static boolean isReadOnly(Connection sql, int mid) {
+ boolean ret = false;
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT readonly FROM messages WHERE message_id=?");
+ stmt.setInt(1, mid);
+ rs = stmt.executeQuery();
+ if (rs.first()) {
+ ret = rs.getInt(1) == 1;
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+ return ret;
+ }
+
public static boolean isSubscribed(Connection sql, int uid, int mid) {
boolean ret = false;
@@ -638,7 +658,9 @@ public class MessagesQueries {
msg.MID = rs.getInt(1);
msg.User.UID = rs.getInt(2);
msg.User.UName = rs.getString(3);
- msg.parseTags(rs.getString(4));
+ if (rs.getString(4) != null) {
+ msg.parseTags(rs.getString(4));
+ }
msg.ReadOnly = rs.getInt(5) == 1;
msg.Privacy = rs.getInt(6);
msg.Text = rs.getString(7);
@@ -665,4 +687,38 @@ public class MessagesQueries {
return msgs;
}
+
+ public static ArrayList<com.juick.Message> getReplies(Connection sql, int mid) {
+ ArrayList<com.juick.Message> replies = new ArrayList<com.juick.Message>();
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT replies.reply_id,replies.replyto,replies.user_id,users.nick,replies.txt,TIMESTAMPDIFF(MINUTE,replies.ts,NOW()),replies.ts,replies.attach FROM replies INNER JOIN users ON replies.user_id=users.id WHERE replies.message_id=? ORDER BY replies.reply_id ASC");
+ stmt.setInt(1, mid);
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ while (rs.next()) {
+ com.juick.Message msg = new com.juick.Message();
+ msg.MID = mid;
+ msg.RID = rs.getInt(1);
+ msg.ReplyTo = rs.getInt(2);
+ msg.User = new com.juick.User();
+ msg.User.UID = rs.getInt(3);
+ msg.User.UName = rs.getString(4);
+ msg.Text = rs.getString(5);
+ msg.TimeAgo = rs.getInt(6);
+ msg.TimestampString = rs.getString(7);
+ msg.AttachmentType = rs.getString(8);
+
+ replies.add(msg);
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+
+ return replies;
+ }
}