summaryrefslogtreecommitdiffstats
path: root/web/lib/pkgfuncs.inc.php
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2017-11-06 16:57:12 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2017-11-06 17:03:37 +0100
commit8c98db0b82cc85a4498589e5d60299fefd93b421 (patch)
tree6b1910a5c1c41b79cd8a179f6b28c045be0068e6 /web/lib/pkgfuncs.inc.php
parente2fa5ea6fa0bf90043e041c7cfc6fa036834758c (diff)
downloadaur-8c98db0b82cc85a4498589e5d60299fefd93b421.tar.gz
aur-8c98db0b82cc85a4498589e5d60299fefd93b421.tar.xz
Allow package co-maintainers to pin comments
Implements FS#56255. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib/pkgfuncs.inc.php')
-rw-r--r--web/lib/pkgfuncs.inc.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php
index 5c48a8ea..dbcf63e8 100644
--- a/web/lib/pkgfuncs.inc.php
+++ b/web/lib/pkgfuncs.inc.php
@@ -85,8 +85,9 @@ function can_edit_comment_array($comment) {
/**
* Determine if the user can pin a specific package comment
*
- * Only the Package Maintainer, Trusted Users, and Developers can pin
- * comments. This function is used for the backend side of comment pinning.
+ * Only the Package Maintainer, Package Co-maintainers, Trusted Users, and
+ * Developers can pin comments. This function is used for the backend side of
+ * comment pinning.
*
* @param string $comment_id The comment ID in the database
*
@@ -97,6 +98,11 @@ function can_pin_comment($comment_id=0) {
$q = "SELECT MaintainerUID FROM PackageBases AS pb ";
$q.= "LEFT JOIN PackageComments AS pc ON pb.ID = pc.PackageBaseID ";
+ $q.= "WHERE pc.ID = " . intval($comment_id) . " ";
+ $q.= "UNION ";
+ $q = "SELECT pcm.UsersID FROM PackageComaintainers AS pcm ";
+ $q.= "LEFT JOIN PackageComments AS pc ";
+ $q.= "ON pcm.PackageBaseID = pc.PackageBaseID ";
$q.= "WHERE pc.ID = " . intval($comment_id);
$result = $dbh->query($q);
@@ -104,16 +110,17 @@ function can_pin_comment($comment_id=0) {
return false;
}
- $uid = $result->fetch(PDO::FETCH_COLUMN, 0);
+ $uids = $result->fetchAll(PDO::FETCH_COLUMN, 0);
- return has_credential(CRED_COMMENT_PIN, array($uid));
+ return has_credential(CRED_COMMENT_PIN, $uids);
}
/**
* Determine if the user can edit a specific package comment using an array
*
- * Only the Package Maintainer, Trusted Users, and Developers can pin
- * comments. This function is used for the frontend side of comment pinning.
+ * Only the Package Maintainer, Package Co-maintainers, Trusted Users, and
+ * Developers can pin comments. This function is used for the frontend side of
+ * comment pinning.
*
* @param array $comment All database information relating a specific comment
*