summaryrefslogtreecommitdiffstats
path: root/web/lib
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2014-07-04 10:40:29 +0200
committerLukas Fleischer <archlinux@cryptocrack.de>2014-07-04 11:10:37 +0200
commit8a465182babccec10b8e789dbc871db3beb9bec5 (patch)
tree135ca7f54ec901fc498c77dbfab9486df5080a9b /web/lib
parent61d70c1fa5f0ed9cfe4708a4630fbf959da2d781 (diff)
downloadaurweb-8a465182babccec10b8e789dbc871db3beb9bec5.tar.xz
Allow for selecting a reason when closing a request
When closing a package request, Trusted Users can now pick a reason ("Accepted" or "Rejected"). This allows for marking a request as accepted, even if the corresponding package base has already been deleted. Also, the notification email now always explicitly states whether a request has been accepted or closed in the message body. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'web/lib')
-rw-r--r--web/lib/pkgbasefuncs.inc.php4
-rw-r--r--web/lib/pkgreqfuncs.inc.php27
2 files changed, 25 insertions, 6 deletions
diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php
index 0ee2c31..4c1f452 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), true);
+ 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), true);
+ pkgreq_close(intval($via), 'accepted');
}
if ($action) {
diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php
index a79677e..0309bc3 100644
--- a/web/lib/pkgreqfuncs.inc.php
+++ b/web/lib/pkgreqfuncs.inc.php
@@ -41,6 +41,22 @@ function pkgreq_list($offset, $limit) {
}
/**
+ * Obtain the package base that belongs to a package request.
+ *
+ * @param int $id Package request ID to retrieve the package base for
+ *
+ * @return int The name of the corresponding package base
+ */
+function pkgreq_get_pkgbase_name($id) {
+ $dbh = DB::connect();
+
+ $q = "SELECT PackageBaseName FROM PackageRequests ";
+ $q.= "WHERE ID = " . intval($id);
+ $result = $dbh->query($q);
+ return $result->fetch(PDO::FETCH_COLUMN, 0);
+}
+
+/**
* File a deletion/orphan request against a package base
*
* @global string $AUR_LOCATION The AUR's URL used for notification e-mails
@@ -139,14 +155,18 @@ function pkgreq_file($ids, $type, $merge_into, $comments) {
* @global string $AUR_LOCATION The AUR's URL used for notification e-mails
* @global string $AUR_REQUEST_ML The request notification mailing list
* @param int $id The package request to close
- * @param bool $accepted True if the request has been accepted, false otherwise
+ * @param string $reason Whether the request was accepted or rejected
*
* @return array Tuple of success/failure indicator and error message
*/
-function pkgreq_close($id, $accepted) {
+function pkgreq_close($id, $reason) {
global $AUR_LOCATION;
global $AUR_REQUEST_ML;
+ if ($reason != 'accepted' && $reason != 'rejected') {
+ return array(false, __("Invalid reason."));
+ }
+
$dbh = DB::connect();
$id = intval($id);
@@ -181,8 +201,7 @@ function pkgreq_close($id, $accepted) {
* user who posted the comment was in.
*/
$username = username_from_sid($_COOKIE['AURSID']);
- $body = "Request #" . intval($id) . " has been " .
- ($accepted ? "accepted" : "closed") . " by " .
+ $body = "Request #" . intval($id) . " has been " . $reason . " by " .
$username . " [1].\n\n" .
"[1] " . $AUR_LOCATION . get_user_uri($username) . "\n";
$body = wordwrap($body, 70);