From 959c61a77dd6a41bf82cc12b5eb873c9cfb0ffb8 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Wed, 25 Jun 2014 10:43:41 +0200 Subject: Add an accept button to the package request list This button allows for accepting a request, disowning the affected package or redirecting to the package deletion page. The request is closed automatically when the action has been performed. Signed-off-by: Lukas Fleischer --- web/html/pkgbase.php | 10 ++++++---- web/html/pkgdel.php | 3 +++ web/lib/pkgbasefuncs.inc.php | 14 ++++++++++++-- web/template/pkgreq_results.php | 11 +++++++++++ 4 files changed, 32 insertions(+), 6 deletions(-) (limited to 'web') diff --git a/web/html/pkgbase.php b/web/html/pkgbase.php index 9047f5b..da88210 100644 --- a/web/html/pkgbase.php +++ b/web/html/pkgbase.php @@ -59,23 +59,25 @@ if (check_token()) { } elseif (current_action("do_UnFlag")) { list($ret, $output) = pkgbase_unflag($atype, $ids); } elseif (current_action("do_Adopt")) { - list($ret, $output) = pkgbase_adopt($atype, $ids, true); + list($ret, $output) = pkgbase_adopt($atype, $ids, true, NULL); } elseif (current_action("do_Disown")) { - list($ret, $output) = pkgbase_adopt($atype, $ids, false); + $via = isset($_POST['via']) ? $_POST['via'] : NULL; + list($ret, $output) = pkgbase_adopt($atype, $ids, false, $via); } elseif (current_action("do_Vote")) { list($ret, $output) = pkgbase_vote($atype, $ids, true); } elseif (current_action("do_UnVote")) { list($ret, $output) = pkgbase_vote($atype, $ids, false); } elseif (current_action("do_Delete")) { if (isset($_POST['confirm_Delete'])) { + $via = isset($_POST['via']) ? $_POST['via'] : NULL; if (!isset($_POST['merge_Into']) || empty($_POST['merge_Into'])) { - list($ret, $output) = pkgbase_delete($atype, $ids, NULL); + list($ret, $output) = pkgbase_delete($atype, $ids, NULL, $via); unset($_GET['ID']); } else { $merge_base_id = pkgbase_from_name($_POST['merge_Into']); if ($merge_base_id) { - list($ret, $output) = pkgbase_delete($atype, $ids, $merge_base_id); + list($ret, $output) = pkgbase_delete($atype, $ids, $merge_base_id, $via); unset($_GET['ID']); } else { diff --git a/web/html/pkgdel.php b/web/html/pkgdel.php index 39fe81a..621c3c9 100644 --- a/web/html/pkgdel.php +++ b/web/html/pkgdel.php @@ -37,6 +37,9 @@ if ($atype == "Trusted User" || $atype == "Developer"): ?> + + +

" />

diff --git a/web/lib/pkgbasefuncs.inc.php b/web/lib/pkgbasefuncs.inc.php index a039f83..2444674 100644 --- a/web/lib/pkgbasefuncs.inc.php +++ b/web/lib/pkgbasefuncs.inc.php @@ -438,10 +438,11 @@ function pkgbase_unflag($atype, $base_ids) { * @param string $atype Account type, output of account_from_sid * @param array $base_ids Array of package base IDs to delete * @param int $merge_base_id Package base to merge the deleted ones into + * @param int $via Package request to close upon deletion * * @return array Tuple of success/failure indicator and error message */ -function pkgbase_delete ($atype, $base_ids, $merge_base_id) { +function pkgbase_delete ($atype, $base_ids, $merge_base_id, $via) { if (!$atype) { return array(false, __("You must be logged in before you can delete packages.")); } @@ -537,6 +538,10 @@ function pkgbase_delete ($atype, $base_ids, $merge_base_id) { $q = "DELETE FROM PackageBases WHERE ID IN (" . implode(",", $base_ids) . ")"; $dbh->exec($q); + if ($via) { + pkgbase_close_request(intval($via)); + } + return array(true, __("The selected packages have been deleted.")); } @@ -546,10 +551,11 @@ function pkgbase_delete ($atype, $base_ids, $merge_base_id) { * @param string $atype Account type, output of account_from_sid * @param array $base_ids Array of package base IDs to adopt/disown * @param bool $action Adopts if true, disowns if false. Adopts by default + * @param int $via Package request to close upon adoption * * @return array Tuple of success/failure indicator and error message */ -function pkgbase_adopt ($atype, $base_ids, $action=true) { +function pkgbase_adopt ($atype, $base_ids, $action=true, $via) { if (!$atype) { if ($action) { return array(false, __("You must be logged in before you can adopt packages.")); @@ -590,6 +596,10 @@ function pkgbase_adopt ($atype, $base_ids, $action=true) { $dbh->exec($q); + if ($via) { + pkgbase_close_request(intval($via)); + } + if ($action) { pkgbase_notify(account_from_sid($_COOKIE["AURSID"]), $base_ids); return array(true, __("The selected packages have been adopted.")); diff --git a/web/template/pkgreq_results.php b/web/template/pkgreq_results.php index 213f180..8ab8351 100644 --- a/web/template/pkgreq_results.php +++ b/web/template/pkgreq_results.php @@ -44,6 +44,17 @@ $REQUEST_IDLE_TIME): ?> class="flagged"> + + + + +
+ + + +
+ +
-- cgit v1.2.3-70-g09d2