From 4645bcbacbc4fd2fba2a3f28d6cd23bdfb184a9d Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Fri, 4 Jul 2014 11:00:07 +0200 Subject: Allow for adding a comment when closing a request This allows Trusted Users to optionally add a comment when closing a request. The comment is included in the notification email that is sent to the requests mailing list. Signed-off-by: Lukas Fleischer --- web/html/pkgbase.php | 2 +- web/lib/pkgbasefuncs.inc.php | 4 ++-- web/lib/pkgreqfuncs.inc.php | 12 +++++++++--- web/template/pkgreq_close_form.php | 8 ++++++++ 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/web/html/pkgbase.php b/web/html/pkgbase.php index 6202180..9725db7 100644 --- a/web/html/pkgbase.php +++ b/web/html/pkgbase.php @@ -105,7 +105,7 @@ if (check_token()) { $ret = false; } } elseif (current_action("do_CloseRequest")) { - list($ret, $output) = pkgreq_close($_POST['reqid'], $_POST['reason']); + list($ret, $output) = pkgreq_close($_POST['reqid'], $_POST['reason'], $_POST['comments']); } if (isset($_REQUEST['comment'])) { diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index 4c1f452..fed46c8 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -540,7 +540,7 @@ function pkgbase_delete ($atype, $base_ids, $merge_base_id, $via) { $dbh->exec($q); if ($via) { - pkgreq_close(intval($via), 'accepted'); + pkgreq_close(intval($via), 'accepted', ''); } return array(true, __("The selected packages have been deleted.")); @@ -598,7 +598,7 @@ function pkgbase_adopt ($atype, $base_ids, $action=true, $via) { $dbh->exec($q); if ($via) { - pkgreq_close(intval($via), 'accepted'); + pkgreq_close(intval($via), 'accepted', ''); } if ($action) { diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php index 0309bc3..fccf0b2 100644 --- a/web/lib/pkgreqfuncs.inc.php +++ b/web/lib/pkgreqfuncs.inc.php @@ -156,10 +156,11 @@ function pkgreq_file($ids, $type, $merge_into, $comments) { * @global string $AUR_REQUEST_ML The request notification mailing list * @param int $id The package request to close * @param string $reason Whether the request was accepted or rejected + * @param string $comments Comments to be added to the notification email * * @return array Tuple of success/failure indicator and error message */ -function pkgreq_close($id, $reason) { +function pkgreq_close($id, $reason, $comments) { global $AUR_LOCATION; global $AUR_REQUEST_ML; @@ -202,8 +203,13 @@ function pkgreq_close($id, $reason) { */ $username = username_from_sid($_COOKIE['AURSID']); $body = "Request #" . intval($id) . " has been " . $reason . " by " . - $username . " [1].\n\n" . - "[1] " . $AUR_LOCATION . get_user_uri($username) . "\n"; + $username . " [1]"; + if (!empty(trim($comments))) { + $body .= ":\n\n" . $comments . "\n\n"; + } else { + $body .= ".\n\n"; + } + $body .= "[1] " . $AUR_LOCATION . get_user_uri($username) . "\n"; $body = wordwrap($body, 70); $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/plain; charset=UTF-8\r\n"; diff --git a/web/template/pkgreq_close_form.php b/web/template/pkgreq_close_form.php index be36aef..00efafe 100644 --- a/web/template/pkgreq_close_form.php +++ b/web/template/pkgreq_close_form.php @@ -4,6 +4,10 @@ ', htmlspecialchars($pkgbase_name), ''); ?>

+

+ : + +

@@ -15,6 +19,10 @@

+

+ + +

" />

-- cgit v1.2.3-70-g09d2