diff options
author | Marcel Korpel <marcel.korpel@gmail.com> | 2015-07-10 18:47:32 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2015-08-08 12:59:24 +0200 |
commit | e331ce273cab901726983e18249e0bb3455fc463 (patch) | |
tree | 8004583c0b468f1fb5163ae33a23b9f50427ce7b /web/lib/pkgfuncs.inc.php | |
parent | 92e19e95f3c07745e7ba7c6e358921b7789f8abe (diff) | |
download | aur-e331ce273cab901726983e18249e0bb3455fc463.tar.gz aur-e331ce273cab901726983e18249e0bb3455fc463.tar.xz |
Support comment editing in the backend
Create two new actions, do_AddComment and do_EditComment. When editing
or deleting a comment, a timestamp is added.
Signed-off-by: Marcel Korpel <marcel.korpel@gmail.com>
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'web/lib/pkgfuncs.inc.php')
-rw-r--r-- | web/lib/pkgfuncs.inc.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/web/lib/pkgfuncs.inc.php b/web/lib/pkgfuncs.inc.php index 7cb2ffcf..de57c3e0 100644 --- a/web/lib/pkgfuncs.inc.php +++ b/web/lib/pkgfuncs.inc.php @@ -43,6 +43,32 @@ function can_delete_comment_array($comment) { } /** + * Determine if the user can edit a specific package comment + * + * Only the comment submitter, Trusted Users, and Developers can edit + * comments. This function is used for the backend side of comment editing. + * + * @param string $comment_id The comment ID in the database + * + * @return bool True if the user can edit the comment, otherwise false + */ +function can_edit_comment($comment_id=0) { + $dbh = DB::connect(); + + $q = "SELECT UsersID FROM PackageComments "; + $q.= "WHERE ID = " . intval($comment_id); + $result = $dbh->query($q); + + if (!$result) { + return false; + } + + $uid = $result->fetch(PDO::FETCH_COLUMN, 0); + + return has_credential(CRED_COMMENT_EDIT, array($uid)); +} + +/** * Determine if the user can edit a specific package comment using an array * * Only the comment submitter, Trusted Users, and Developers can edit |