diff options
author | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-07-25 10:12:31 +0200 |
---|---|---|
committer | Lukas Fleischer <archlinux@cryptocrack.de> | 2014-07-25 11:30:32 +0200 |
commit | daceef50ebb33a477795a0d790f17fc8770dc45d (patch) | |
tree | f3fc88d45881d8553db7d10594eae286c9a8ff7b /web/lib | |
parent | 16e4708f1e85ee657a3de3e8ad9831e714344004 (diff) | |
download | aur-daceef50ebb33a477795a0d790f17fc8770dc45d.tar.gz aur-daceef50ebb33a477795a0d790f17fc8770dc45d.tar.xz |
Make deleted comments visible to Trusted Users
This allows Trusted Users to check whether a user posted a politically
incorrect comment, even if he already deleted it.
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/credentials.inc.php | 2 | ||||
-rw-r--r-- | web/lib/pkgbasefuncs.inc.php | 20 | ||||
-rw-r--r-- | web/lib/pkgfuncs.inc.php | 3 |
3 files changed, 18 insertions, 7 deletions
diff --git a/web/lib/credentials.inc.php b/web/lib/credentials.inc.php index 47dd3fdd..efc203d3 100644 --- a/web/lib/credentials.inc.php +++ b/web/lib/credentials.inc.php @@ -7,6 +7,7 @@ define("CRED_ACCOUNT_EDIT_DEV", 3); define("CRED_ACCOUNT_LAST_LOGIN", 4); define("CRED_ACCOUNT_SEARCH", 5); define("CRED_COMMENT_DELETE", 6); +define("CRED_COMMENT_VIEW_DELETED", 22); define("CRED_PKGBASE_ADOPT", 7); define("CRED_PKGBASE_CHANGE_CATEGORY", 8); define("CRED_PKGBASE_DELETE", 9); @@ -55,6 +56,7 @@ function has_credential($credential, $approved_users=array()) { case CRED_ACCOUNT_LAST_LOGIN: case CRED_ACCOUNT_SEARCH: case CRED_COMMENT_DELETE: + case CRED_COMMENT_VIEW_DELETED: case CRED_PKGBASE_ADOPT: case CRED_PKGBASE_CHANGE_CATEGORY: case CRED_PKGBASE_DELETE: diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index 0d6b22bf..cf0b09b7 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -25,10 +25,11 @@ function pkgbase_categories() { * Get the number of non-deleted comments for a specific package base * * @param string $base_id The package base ID to get comment count for + * @param bool $include_deleted True if deleted comments should be included * * @return string The number of comments left for a specific package */ -function pkgbase_comments_count($base_id) { +function pkgbase_comments_count($base_id, $include_deleted) { $base_id = intval($base_id); if (!$base_id) { return null; @@ -37,7 +38,9 @@ function pkgbase_comments_count($base_id) { $dbh = DB::connect(); $q = "SELECT COUNT(*) FROM PackageComments "; $q.= "WHERE PackageBaseID = " . $base_id . " "; - $q.= "AND DelUsersID IS NULL"; + if (!$include_deleted) { + $q.= "AND DelUsersID IS NULL"; + } $result = $dbh->query($q); if (!$result) { return null; @@ -51,10 +54,11 @@ function pkgbase_comments_count($base_id) { * * @param int $base_id The package base ID to get comments for * @param int $limit Maximum number of comments to return (0 means unlimited) + * @param bool $include_deleted True if deleted comments should be included * * @return array All package comment information for a specific package base */ -function pkgbase_comments($base_id, $limit) { +function pkgbase_comments($base_id, $limit, $include_deleted) { $base_id = intval($base_id); $limit = intval($limit); if (!$base_id) { @@ -63,10 +67,13 @@ function pkgbase_comments($base_id, $limit) { $dbh = DB::connect(); $q = "SELECT PackageComments.ID, UserName, UsersID, Comments, "; - $q.= "CommentTS FROM PackageComments LEFT JOIN Users "; + $q.= "CommentTS, DelUsersID FROM PackageComments LEFT JOIN Users "; $q.= "ON PackageComments.UsersID = Users.ID "; $q.= "WHERE PackageBaseID = " . $base_id . " "; - $q.= "AND DelUsersID IS NULL ORDER BY CommentTS DESC"; + if (!$include_deleted) { + $q.= "AND DelUsersID IS NULL "; + } + $q.= "ORDER BY CommentTS DESC"; if ($limit > 0) { $q.=" LIMIT " . $limit; } @@ -242,7 +249,8 @@ function pkgbase_display_details($base_id, $row, $SID="") { } $limit = isset($_GET['comments']) ? 0 : 10; - $comments = pkgbase_comments($base_id, $limit); + $include_deleted = has_credential(CRED_COMMENT_VIEW_DELETED); + $comments = pkgbase_comments($base_id, $limit, $include_deleted); if (!empty($comments)) { include('pkg_comments.php'); } diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index 8c2a67de..69b1c94c 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -436,7 +436,8 @@ function pkg_display_details($id=0, $row, $SID="") { } $limit = isset($_GET['comments']) ? 0 : 10; - $comments = pkgbase_comments($base_id, $limit); + $include_deleted = has_credential(CRED_COMMENT_VIEW_DELETED); + $comments = pkgbase_comments($base_id, $limit, $include_deleted); if (!empty($comments)) { include('pkg_comments.php'); } |