Commit 959c61a7 authored by Lukas Fleischer's avatar Lukas Fleischer
Browse files

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: default avatarLukas Fleischer <archlinux@cryptocrack.de>
parent d8dbad0c
...@@ -59,23 +59,25 @@ if (check_token()) { ...@@ -59,23 +59,25 @@ if (check_token()) {
} elseif (current_action("do_UnFlag")) { } elseif (current_action("do_UnFlag")) {
list($ret, $output) = pkgbase_unflag($atype, $ids); list($ret, $output) = pkgbase_unflag($atype, $ids);
} elseif (current_action("do_Adopt")) { } 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")) { } 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")) { } elseif (current_action("do_Vote")) {
list($ret, $output) = pkgbase_vote($atype, $ids, true); list($ret, $output) = pkgbase_vote($atype, $ids, true);
} elseif (current_action("do_UnVote")) { } elseif (current_action("do_UnVote")) {
list($ret, $output) = pkgbase_vote($atype, $ids, false); list($ret, $output) = pkgbase_vote($atype, $ids, false);
} elseif (current_action("do_Delete")) { } elseif (current_action("do_Delete")) {
if (isset($_POST['confirm_Delete'])) { if (isset($_POST['confirm_Delete'])) {
$via = isset($_POST['via']) ? $_POST['via'] : NULL;
if (!isset($_POST['merge_Into']) || empty($_POST['merge_Into'])) { 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']); unset($_GET['ID']);
} }
else { else {
$merge_base_id = pkgbase_from_name($_POST['merge_Into']); $merge_base_id = pkgbase_from_name($_POST['merge_Into']);
if ($merge_base_id) { 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']); unset($_GET['ID']);
} }
else { else {
......
...@@ -37,6 +37,9 @@ if ($atype == "Trusted User" || $atype == "Developer"): ?> ...@@ -37,6 +37,9 @@ if ($atype == "Trusted User" || $atype == "Developer"): ?>
<input type="hidden" name="IDs[<?= $base_id ?>]" value="1" /> <input type="hidden" name="IDs[<?= $base_id ?>]" value="1" />
<input type="hidden" name="ID" value="<?= $base_id ?>" /> <input type="hidden" name="ID" value="<?= $base_id ?>" />
<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" /> <input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
<?php if (isset($_GET['via'])): ?>
<input type="hidden" name="via" value="<?= intval($_GET['via']) ?>" />
<?php endif; ?>
<p><input type="checkbox" name="confirm_Delete" value="1" /> <p><input type="checkbox" name="confirm_Delete" value="1" />
<?= __("Confirm package deletion") ?></p> <?= __("Confirm package deletion") ?></p>
<p><input type="submit" class="button" name="do_Delete" value="<?= __("Delete") ?>" /></p> <p><input type="submit" class="button" name="do_Delete" value="<?= __("Delete") ?>" /></p>
......
...@@ -438,10 +438,11 @@ function pkgbase_unflag($atype, $base_ids) { ...@@ -438,10 +438,11 @@ function pkgbase_unflag($atype, $base_ids) {
* @param string $atype Account type, output of account_from_sid * @param string $atype Account type, output of account_from_sid
* @param array $base_ids Array of package base IDs to delete * @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 $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 * @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) { if (!$atype) {
return array(false, __("You must be logged in before you can delete packages.")); 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) { ...@@ -537,6 +538,10 @@ function pkgbase_delete ($atype, $base_ids, $merge_base_id) {
$q = "DELETE FROM PackageBases WHERE ID IN (" . implode(",", $base_ids) . ")"; $q = "DELETE FROM PackageBases WHERE ID IN (" . implode(",", $base_ids) . ")";
$dbh->exec($q); $dbh->exec($q);
if ($via) {
pkgbase_close_request(intval($via));
}
return array(true, __("The selected packages have been deleted.")); return array(true, __("The selected packages have been deleted."));
} }
...@@ -546,10 +551,11 @@ function pkgbase_delete ($atype, $base_ids, $merge_base_id) { ...@@ -546,10 +551,11 @@ function pkgbase_delete ($atype, $base_ids, $merge_base_id) {
* @param string $atype Account type, output of account_from_sid * @param string $atype Account type, output of account_from_sid
* @param array $base_ids Array of package base IDs to adopt/disown * @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 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 * @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 (!$atype) {
if ($action) { if ($action) {
return array(false, __("You must be logged in before you can adopt packages.")); 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) { ...@@ -590,6 +596,10 @@ function pkgbase_adopt ($atype, $base_ids, $action=true) {
$dbh->exec($q); $dbh->exec($q);
if ($via) {
pkgbase_close_request(intval($via));
}
if ($action) { if ($action) {
pkgbase_notify(account_from_sid($_COOKIE["AURSID"]), $base_ids); pkgbase_notify(account_from_sid($_COOKIE["AURSID"]), $base_ids);
return array(true, __("The selected packages have been adopted.")); return array(true, __("The selected packages have been adopted."));
......
...@@ -44,6 +44,17 @@ ...@@ -44,6 +44,17 @@
<td<?php if (time() - intval($row['RequestTS']) > $REQUEST_IDLE_TIME): ?> class="flagged"<?php endif; ?>><?= gmdate("Y-m-d H:i", intval($row['RequestTS'])) ?></td> <td<?php if (time() - intval($row['RequestTS']) > $REQUEST_IDLE_TIME): ?> class="flagged"<?php endif; ?>><?= gmdate("Y-m-d H:i", intval($row['RequestTS'])) ?></td>
<?php if ($row['Status'] == 0): ?> <?php if ($row['Status'] == 0): ?>
<td> <td>
<?php if ($row['BaseID']): ?>
<?php if ($row['Type'] == 'deletion'): ?>
<a href="<?= get_pkgbase_uri($row['Name']) ?>delete/?via=<?= intval($row['ID']) ?>"><?= __('Accept') ?></a>
<?php elseif ($row['Type'] == 'orphan'): ?>
<form action="<?= get_pkgbase_uri($row['Name']) . 'disown/'; ?>" method="post">
<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
<input type="hidden" name="via" value="<?= intval($row['ID']) ?>" />
<input type="submit" class="button text-button" name="do_Disown" value="<?= __('Accept') ?>" />
</form>
<?php endif; ?>
<?php endif; ?>
<form action="<?= get_uri('/pkgbase/'); ?>" method="post"> <form action="<?= get_uri('/pkgbase/'); ?>" method="post">
<fieldset> <fieldset>
<input type="hidden" name="IDs[<?= $row['BaseID'] ?>]" value="1" /> <input type="hidden" name="IDs[<?= $row['BaseID'] ?>]" value="1" />
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment