mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Add a package request list
Introduce a new navigation point "Requests" that shows a list of pending package requests. This functionality is only available to Trusted Users. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
48cc8207bf
commit
8260111bcc
5 changed files with 148 additions and 0 deletions
|
@ -14,6 +14,62 @@ if (!check_user_privileges()) {
|
|||
header('Location: /');
|
||||
exit();
|
||||
}
|
||||
|
||||
if (!isset($base_id)) {
|
||||
$results = pkgbase_request_list();
|
||||
$total = count($results);
|
||||
|
||||
/* Sanitize paging variables. */
|
||||
if (isset($_GET['O'])) {
|
||||
$_GET['O'] = intval($_GET['O']);
|
||||
if ($_GET['O'] < 0)
|
||||
$_GET['O'] = 0;
|
||||
} else {
|
||||
$_GET['O'] = 0;
|
||||
}
|
||||
|
||||
if (isset($_GET["PP"])) {
|
||||
$_GET["PP"] = intval($_GET["PP"]);
|
||||
if ($_GET["PP"] < 50)
|
||||
$_GET["PP"] = 50;
|
||||
else if ($_GET["PP"] > 250)
|
||||
$_GET["PP"] = 250;
|
||||
} else {
|
||||
$_GET["PP"] = 50;
|
||||
}
|
||||
|
||||
/* Calculate the results to use. */
|
||||
$first = $_GET['O'] + 1;
|
||||
|
||||
/* Calculation of pagination links. */
|
||||
$per_page = ($_GET['PP'] > 0) ? $_GET['PP'] : 50;
|
||||
$current = ceil($first / $per_page);
|
||||
$pages = ceil($total / $per_page);
|
||||
$templ_pages = array();
|
||||
|
||||
if ($current > 1) {
|
||||
$templ_pages['« ' . __('First')] = 0;
|
||||
$templ_pages['‹ ' . __('Previous')] = ($current - 2) * $per_page;
|
||||
}
|
||||
|
||||
if ($current - 5 > 1)
|
||||
$templ_pages["..."] = false;
|
||||
|
||||
for ($i = max($current - 5, 1); $i <= min($pages, $current + 5); $i++) {
|
||||
$templ_pages[$i] = ($i - 1) * $per_page;
|
||||
}
|
||||
|
||||
if ($current + 5 < $pages)
|
||||
$templ_pages["... "] = false;
|
||||
|
||||
if ($current < $pages) {
|
||||
$templ_pages[__('Next') . ' ›'] = $current * $per_page;
|
||||
$templ_pages[__('Last') . ' »'] = ($pages - 1) * $per_page;
|
||||
}
|
||||
|
||||
$SID = $_COOKIE['AURSID'];
|
||||
include('pkgreq_results.php');
|
||||
} else {
|
||||
?>
|
||||
|
||||
<div class="box">
|
||||
|
@ -51,5 +107,7 @@ if (!check_user_privileges()) {
|
|||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
html_footer(AUR_VERSION);
|
||||
|
||||
|
|
|
@ -963,6 +963,26 @@ function pkgbase_update_category($base_id, $category_id) {
|
|||
$dbh->exec($q);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all package requests
|
||||
*
|
||||
* @return array List of pacakge requests with details
|
||||
*/
|
||||
function pkgbase_request_list() {
|
||||
$dbh = DB::connect();
|
||||
|
||||
$q = "SELECT PackageRequests.ID, ";
|
||||
$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.= "FROM PackageRequests INNER JOIN RequestTypes ON ";
|
||||
$q.= "RequestTypes.ID = PackageRequests.ReqTypeID ";
|
||||
$q.= "INNER JOIN Users ON Users.ID = PackageRequests.UsersID";
|
||||
|
||||
return $dbh->query($q)->fetchAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* File a deletion/orphan request against a package base
|
||||
*
|
||||
|
|
|
@ -5,6 +5,7 @@ $ROUTES = array(
|
|||
'/index.php' => 'home.php',
|
||||
'/packages' => 'packages.php',
|
||||
'/pkgbase' => 'pkgbase.php',
|
||||
'/requests' => 'pkgreq.php',
|
||||
'/register' => 'account.php',
|
||||
'/account' => 'account.php',
|
||||
'/accounts' => 'account.php',
|
||||
|
|
|
@ -57,6 +57,9 @@
|
|||
<li><a href="<?= get_uri('/packages/'); ?>"><?= __("Packages"); ?></a></li>
|
||||
<?php if (isset($_COOKIE['AURSID'])): ?>
|
||||
<li><a href="<?= get_uri('/packages/'); ?>?SeB=m&K=<?= username_from_sid($_COOKIE["AURSID"]); ?>"><?= __("My Packages"); ?></a></li>
|
||||
<?php if (check_user_privileges()): ?>
|
||||
<li><a href="<?= get_uri('/requests/') ; ?>"><?= __("Requests"); ?></a></li>
|
||||
<?php endif; ?>
|
||||
<li><a href="<?= get_uri('/submit/'); ?>"><?= __("Submit"); ?></a></li>
|
||||
<?php if (check_user_privileges()): ?>
|
||||
<li><a href="<?= get_uri('/accounts/') ; ?>"><?= __("Accounts"); ?></a></li>
|
||||
|
|
66
web/template/pkgreq_results.php
Normal file
66
web/template/pkgreq_results.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<div id="pkglist-results" class="box">
|
||||
<div class="pkglist-stats">
|
||||
<p><?= __('%d package requests found. Page %d of %d.', $total, $current, $pages) ?></p>
|
||||
<?php if (count($templ_pages) > 1): ?>
|
||||
<p class="pkglist-nav">
|
||||
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
|
||||
<?php if ($pagestart === false): ?>
|
||||
<span class="page"><?= $pagenr ?></span>
|
||||
<?php elseif ($pagestart + 1 == $first): ?>
|
||||
<span class="page"><?= $pagenr ?></span>
|
||||
<?php else: ?>
|
||||
<a class="page" href="<?= get_uri('/requests/'); ?>?<?= mkurl('O=' . $pagestart) ?>"><?= $pagenr ?></a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<table class="results">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?= __("Package") ?></th>
|
||||
<th><?= __("Type") ?></th>
|
||||
<th><?= __("Comments") ?></th>
|
||||
<th><?= __("Filed by") ?></th>
|
||||
<th><?= __("Date") ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php while (list($indx, $row) = each($results)): ?>
|
||||
<tr class="<?= ($indx % 2 == 0) ? 'odd' : 'even' ?>">
|
||||
<?php if ($row['BaseID']): ?>
|
||||
<td><a href="<?= htmlspecialchars(get_pkgbase_uri($row["Name"]), ENT_QUOTES); ?>"><?= htmlspecialchars($row["Name"]) ?></a></td>
|
||||
<?php else: ?>
|
||||
<td><?= htmlspecialchars($row["Name"]) ?></td>
|
||||
<?php endif; ?>
|
||||
<td><?= htmlspecialchars(ucfirst($row['Type']), ENT_QUOTES); ?></td>
|
||||
<td class="wrap"><?= htmlspecialchars($row['Comments'], ENT_QUOTES); ?></td>
|
||||
<td>
|
||||
<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>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="pkglist-stats">
|
||||
<p><?= __('%d package requests found. Page %d of %d.', $total, $current, $pages) ?></p>
|
||||
<?php if (count($templ_pages) > 1): ?>
|
||||
<p class="pkglist-nav">
|
||||
<?php foreach ($templ_pages as $pagenr => $pagestart): ?>
|
||||
<?php if ($pagestart === false): ?>
|
||||
<span class="page"><?= $pagenr ?></span>
|
||||
<?php elseif ($pagestart + 1 == $first): ?>
|
||||
<span class="page"><?= $pagenr ?></span>
|
||||
<?php else: ?>
|
||||
<a class="page" href="<?= get_uri('/requests/'); ?>?<?= mkurl('O=' . $pagestart) ?>"><?= $pagenr ?></a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
Loading…
Add table
Reference in a new issue