mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Allow for closing package requests
This allows Trusted Users to close package requests via the request list. Also, entries are now sorted such that open requests are shown before closed requests. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
8260111bcc
commit
fc1db28c9b
7 changed files with 73 additions and 17 deletions
|
@ -23,6 +23,7 @@ CREATE TABLE PackageRequests (
|
|||
UsersID INTEGER UNSIGNED NULL DEFAULT NULL,
|
||||
Comments TEXT NOT NULL DEFAULT '',
|
||||
RequestTS BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
Status TINYINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (ID),
|
||||
INDEX (UsersID),
|
||||
INDEX (PackageBaseID),
|
||||
|
|
|
@ -308,6 +308,7 @@ CREATE TABLE PackageRequests (
|
|||
UsersID INTEGER UNSIGNED NULL DEFAULT NULL,
|
||||
Comments TEXT NOT NULL DEFAULT '',
|
||||
RequestTS BIGINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
Status TINYINT UNSIGNED NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (ID),
|
||||
INDEX (UsersID),
|
||||
INDEX (PackageBaseID),
|
||||
|
|
|
@ -24,20 +24,6 @@
|
|||
padding: 0;
|
||||
}
|
||||
|
||||
#actionlist .text-button {
|
||||
color: #07b;
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 0;
|
||||
cursor: pointer;
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
#actionlist .text-button:hover {
|
||||
text-decoration: underline;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.arch-bio-entry ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
|
@ -61,3 +47,19 @@
|
|||
#pkg-updates td.pkg-date {
|
||||
text-align:right;
|
||||
}
|
||||
|
||||
.text-button {
|
||||
background: transparent;
|
||||
border: none !important;
|
||||
margin: 0 !important;
|
||||
padding: 0 !important;
|
||||
font: normal 100% sans-serif;
|
||||
text-decoration: none;
|
||||
color: #07b;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.text-button:hover {
|
||||
text-decoration: underline;
|
||||
color: #666;
|
||||
}
|
||||
|
|
|
@ -96,6 +96,8 @@ if (check_token()) {
|
|||
list($ret, $output) = pkgbase_change_category($base_id, $atype);
|
||||
} elseif (current_action("do_FileRequest")) {
|
||||
list($ret, $output) = pkgbase_file_request($ids, $_POST['type'], $_POST['comments']);
|
||||
} elseif (current_action("do_CloseRequest")) {
|
||||
list($ret, $output) = pkgbase_close_request($_POST['reqid']);
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['comment'])) {
|
||||
|
@ -105,7 +107,11 @@ if (check_token()) {
|
|||
}
|
||||
|
||||
if ($ret) {
|
||||
if (isset($base_id)) {
|
||||
if (current_action("do_CloseRequest")) {
|
||||
/* Redirect back to package request page on success. */
|
||||
header('Location: ' . get_pkgreq_route());
|
||||
exit();
|
||||
} if (isset($base_id)) {
|
||||
/* Redirect back to package base page on success. */
|
||||
header('Location: ' . get_pkgbase_uri($pkgbase_name));
|
||||
exit();
|
||||
|
|
|
@ -975,10 +975,12 @@ function pkgbase_request_list() {
|
|||
$q.= "PackageRequests.PackageBaseID AS BaseID, ";
|
||||
$q.= "PackageRequests.PackageBaseName AS Name, ";
|
||||
$q.= "RequestTypes.Name AS Type, PackageRequests.Comments, ";
|
||||
$q.= "Users.Username AS User, PackageRequests.RequestTS ";
|
||||
$q.= "Users.Username AS User, PackageRequests.RequestTS, ";
|
||||
$q.= "PackageRequests.Status ";
|
||||
$q.= "FROM PackageRequests INNER JOIN RequestTypes ON ";
|
||||
$q.= "RequestTypes.ID = PackageRequests.ReqTypeID ";
|
||||
$q.= "INNER JOIN Users ON Users.ID = PackageRequests.UsersID";
|
||||
$q.= "INNER JOIN Users ON Users.ID = PackageRequests.UsersID ";
|
||||
$q.= "ORDER BY Status ASC, RequestTS DESC";
|
||||
|
||||
return $dbh->query($q)->fetchAll();
|
||||
}
|
||||
|
@ -1070,3 +1072,23 @@ function pkgbase_file_request($ids, $type, $comments) {
|
|||
|
||||
return array(true, __("Added request successfully."));
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a deletion/orphan request
|
||||
*
|
||||
* @param int $id The package request to close
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function pkgbase_close_request($id) {
|
||||
$dbh = DB::connect();
|
||||
|
||||
if (!check_user_privileges()) {
|
||||
return array(false, __("Only TUs and developers can close requests."));
|
||||
}
|
||||
|
||||
$q = "UPDATE PackageRequests SET Status = 1 WHERE ID = " . intval($id);
|
||||
$dbh->exec($q);
|
||||
|
||||
return array(true, __("Request closed successfully."));
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ $ROUTES = array(
|
|||
|
||||
$PKG_PATH = '/packages';
|
||||
$PKGBASE_PATH = '/pkgbase';
|
||||
$PKGREQ_PATH = '/requests';
|
||||
$USER_PATH = '/account';
|
||||
|
||||
function get_route($path) {
|
||||
|
@ -55,6 +56,11 @@ function get_pkgbase_route() {
|
|||
return $PKGBASE_PATH;
|
||||
}
|
||||
|
||||
function get_pkgreq_route() {
|
||||
global $PKGREQ_PATH;
|
||||
return $PKGREQ_PATH;
|
||||
}
|
||||
|
||||
function get_pkg_uri($pkgname) {
|
||||
global $USE_VIRTUAL_URLS;
|
||||
global $PKG_PATH;
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
<th><?= __("Comments") ?></th>
|
||||
<th><?= __("Filed by") ?></th>
|
||||
<th><?= __("Date") ?></th>
|
||||
<th><?= __("Status") ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
@ -41,6 +42,23 @@
|
|||
<a href="<?= get_uri('/account/') . htmlspecialchars($row['User'], ENT_QUOTES) ?>" title="<?= __('View account information for %s', htmlspecialchars($row['User'])) ?>"><?= htmlspecialchars($row['User']) ?></a>
|
||||
</td>
|
||||
<td><?= gmdate("Y-m-d H:i", intval($row['RequestTS'])) ?></td>
|
||||
<?php if ($row['Status'] == 0): ?>
|
||||
<td>
|
||||
<form action="<?= get_uri('/pkgbase/'); ?>" method="post">
|
||||
<fieldset>
|
||||
<input type="hidden" name="IDs[<?= $row['BaseID'] ?>]" value="1" />
|
||||
<input type="hidden" name="ID" value="<?= $row['BaseID'] ?>" />
|
||||
<input type="hidden" name="token" value="<?= htmlspecialchars($_COOKIE['AURSID']) ?>" />
|
||||
<input type="hidden" name="reqid" value="<?= $row['ID'] ?>" />
|
||||
<div>
|
||||
<input type="submit" class="button text-button" name="do_CloseRequest" value="<?= __("Close") ?>" />
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
</td>
|
||||
<?php else: ?>
|
||||
<td><?= __("Closed") ?></td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue