summaryrefslogtreecommitdiffstats
path: root/web/lib/acctfuncs.inc.php
diff options
context:
space:
mode:
authorJohannes Löthberg <johannes@kyriasis.com>2018-08-06 02:02:57 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2018-08-06 06:03:58 +0200
commit3578e77ad4e9258495eed7e786b7dc3aebcf1b63 (patch)
tree6261b4c66435d25ea10583c6a647d645e7182ed7 /web/lib/acctfuncs.inc.php
parenta7865ef5aa0309976b5dd2642210632babe106d9 (diff)
downloadaur-3578e77ad4e9258495eed7e786b7dc3aebcf1b63.tar.gz
aur-3578e77ad4e9258495eed7e786b7dc3aebcf1b63.tar.xz
Allow listing all comments from a user
Signed-off-by: Johannes Löthberg <johannes@kyriasis.com> Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib/acctfuncs.inc.php')
-rw-r--r--web/lib/acctfuncs.inc.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/web/lib/acctfuncs.inc.php b/web/lib/acctfuncs.inc.php
index df573755..dc444842 100644
--- a/web/lib/acctfuncs.inc.php
+++ b/web/lib/acctfuncs.inc.php
@@ -1403,3 +1403,45 @@ function accept_terms($uid, $termrev) {
$dbh->exec($q);
}
}
+
+function account_comments($uid, $limit, $offset=0) {
+ $dbh = DB::connect();
+ $q = "SELECT PackageComments.ID, Comments, UsersID, ";
+ $q.= "PackageBaseId, CommentTS, DelTS, EditedTS, B.UserName AS EditUserName, ";
+ $q.= "PinnedTS, ";
+ $q.= "C.UserName as DelUserName, RenderedComment, ";
+ $q.= "PB.ID as PackageBaseID, PB.Name as PackageBaseName ";
+ $q.= "FROM PackageComments ";
+ $q.= "LEFT JOIN PackageBases PB ON PackageComments.PackageBaseID = PB.ID ";
+ $q.= "LEFT JOIN Users A ON PackageComments.UsersID = A.ID ";
+ $q.= "LEFT JOIN Users B ON PackageComments.EditedUsersID = B.ID ";
+ $q.= "LEFT JOIN Users C ON PackageComments.DelUsersID = C.ID ";
+ $q.= "WHERE A.ID = " . $dbh->quote($uid) . " ";
+ $q.= "ORDER BY CommentTS DESC";
+
+ if ($limit > 0) {
+ $q.=" LIMIT " . intval($limit);
+ }
+
+ if ($offset > 0) {
+ $q.=" OFFSET " . intval($offset);
+ }
+
+ $result = $dbh->query($q);
+ if (!$result) {
+ return null;
+ }
+
+ return $result->fetchAll();
+}
+
+function account_comments_count($uid) {
+ $dbh = DB::connect();
+ $q = "SELECT COUNT(*) ";
+ $q.= "FROM PackageComments ";
+ $q.= "LEFT JOIN Users A ON PackageComments.UsersID = A.ID ";
+ $q.= "WHERE A.ID = " . $dbh->quote($uid);
+
+ $result = $dbh->query($q);
+ return $result->fetchColumn();
+}