aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/juick/server/TagQueries.java25
-rw-r--r--src/com/juick/server/UserQueries.java20
2 files changed, 45 insertions, 0 deletions
diff --git a/src/com/juick/server/TagQueries.java b/src/com/juick/server/TagQueries.java
index 8cb7ee1a..7d78e345 100644
--- a/src/com/juick/server/TagQueries.java
+++ b/src/com/juick/server/TagQueries.java
@@ -22,6 +22,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
+import java.util.ArrayList;
/**
*
@@ -65,4 +66,28 @@ public class TagQueries {
return tid;
}
+
+ public static ArrayList<com.juick.Tag> getUserTagsAll(Connection sql, int uid) {
+ ArrayList<com.juick.Tag> tags = new ArrayList<com.juick.Tag>();
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT tags.name,COUNT(messages.message_id) FROM (messages INNER JOIN messages_tags ON (messages.user_id=? AND messages.message_id=messages_tags.message_id)) INNER JOIN tags ON messages_tags.tag_id=tags.tag_id GROUP BY tags.tag_id ORDER BY tags.name ASC");
+ stmt.setInt(1, uid);
+ rs = stmt.executeQuery();
+ rs.beforeFirst();
+ while (rs.next()) {
+ com.juick.Tag t = new com.juick.Tag();
+ t.Name = rs.getString(1);
+ t.UsageCnt = rs.getInt(2);
+ tags.add(t);
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+ return tags;
+ }
}
diff --git a/src/com/juick/server/UserQueries.java b/src/com/juick/server/UserQueries.java
index 97cae91f..906f7742 100644
--- a/src/com/juick/server/UserQueries.java
+++ b/src/com/juick/server/UserQueries.java
@@ -215,4 +215,24 @@ public class UserQueries {
Utils.finishSQL(null, stmt);
}
}
+
+ public static boolean getCanMedia(Connection sql, int uid) {
+ boolean ret = false;
+
+ PreparedStatement stmt = null;
+ ResultSet rs = null;
+ try {
+ stmt = sql.prepareStatement("SELECT users.lastphoto-UNIX_TIMESTAMP() FROM users WHERE id=?");
+ stmt.setInt(1, uid);
+ rs = stmt.executeQuery();
+ if (rs.first()) {
+ ret = rs.getInt(1) < 3600;
+ }
+ } catch (SQLException e) {
+ System.err.println(e);
+ } finally {
+ Utils.finishSQL(rs, stmt);
+ }
+ return ret;
+ }
}