summaryrefslogtreecommitdiffstats
path: root/web/lib/pkgbasefuncs.inc.php
diff options
context:
space:
mode:
authorMarcel Korpel <marcel.korpel@gmail.com>2015-07-10 18:47:32 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-08-08 12:59:24 +0200
commite331ce273cab901726983e18249e0bb3455fc463 (patch)
tree8004583c0b468f1fb5163ae33a23b9f50427ce7b /web/lib/pkgbasefuncs.inc.php
parent92e19e95f3c07745e7ba7c6e358921b7789f8abe (diff)
downloadaurweb-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/pkgbasefuncs.inc.php')
-rw-r--r--web/lib/pkgbasefuncs.inc.php34
1 files changed, 33 insertions, 1 deletions
diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index 5d191eb..1ae3166 100644
--- a/web/lib/pkgbasefuncs.inc.php
+++ b/web/lib/pkgbasefuncs.inc.php
@@ -830,7 +830,8 @@ function pkgbase_delete_comment() {
$dbh = DB::connect();
if (can_delete_comment($comment_id)) {
$q = "UPDATE PackageComments ";
- $q.= "SET DelUsersID = ".$uid." ";
+ $q.= "SET DelUsersID = ".$uid.", ";
+ $q.= "EditedTS = UNIX_TIMESTAMP() ";
$q.= "WHERE ID = ".intval($comment_id);
$dbh->exec($q);
return array(true, __("Comment has been deleted."));
@@ -840,6 +841,37 @@ function pkgbase_delete_comment() {
}
/**
+ * Edit a package comment
+ *
+ * @return array Tuple of success/failure indicator and error message
+ */
+function pkgbase_edit_comment($comment) {
+ $uid = uid_from_sid($_COOKIE["AURSID"]);
+ if (!$uid) {
+ return array(false, __("You must be logged in before you can edit package information."));
+ }
+
+ if (isset($_POST["comment_id"])) {
+ $comment_id = $_POST["comment_id"];
+ } else {
+ return array(false, __("Missing comment ID."));
+ }
+
+ $dbh = DB::connect();
+ if (can_edit_comment($comment_id)) {
+ $q = "UPDATE PackageComments ";
+ $q.= "SET EditedUsersID = ".$uid.", ";
+ $q.= "Comments = ".$dbh->quote($comment).", ";
+ $q.= "EditedTS = UNIX_TIMESTAMP() ";
+ $q.= "WHERE ID = ".intval($comment_id);
+ $dbh->exec($q);
+ return array(true, __("Comment has been edited."));
+ } else {
+ return array(false, __("You are not allowed to edit this comment."));
+ }
+}
+
+/**
* Get a list of package base keywords
*
* @param int $base_id The package base ID to retrieve the keywords for