mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Fix pagination in the package request list
This was not implemented properly in commit 8260111
(Add a package
request list, 2014-06-24).
Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
64c4e51698
commit
a149fc493f
2 changed files with 20 additions and 5 deletions
|
@ -14,9 +14,6 @@ if (!isset($base_id)) {
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = pkgreq_list();
|
|
||||||
$total = count($results);
|
|
||||||
|
|
||||||
/* Sanitize paging variables. */
|
/* Sanitize paging variables. */
|
||||||
if (isset($_GET['O'])) {
|
if (isset($_GET['O'])) {
|
||||||
$_GET['O'] = max(intval($_GET['O']), 0);
|
$_GET['O'] = max(intval($_GET['O']), 0);
|
||||||
|
@ -30,6 +27,9 @@ if (!isset($base_id)) {
|
||||||
$_GET["PP"] = 50;
|
$_GET["PP"] = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$results = pkgreq_list($_GET['O'], $_GET['PP']);
|
||||||
|
$total = pkgreq_count();
|
||||||
|
|
||||||
/* Calculate the results to use. */
|
/* Calculate the results to use. */
|
||||||
$first = $_GET['O'] + 1;
|
$first = $_GET['O'] + 1;
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,26 @@
|
||||||
include_once("config.inc.php");
|
include_once("config.inc.php");
|
||||||
include_once("pkgbasefuncs.inc.php");
|
include_once("pkgbasefuncs.inc.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of package requests
|
||||||
|
*
|
||||||
|
* @return int The total number of package requests
|
||||||
|
*/
|
||||||
|
function pkgreq_count() {
|
||||||
|
$dbh = DB::connect();
|
||||||
|
$q = "SELECT COUNT(*) FROM PackageRequests";
|
||||||
|
return $dbh->query($q)->fetchColumn();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all package requests
|
* Get a list of all package requests
|
||||||
*
|
*
|
||||||
|
* @param int $offset The index of the first request to return
|
||||||
|
* @param int $limit The maximum number of requests to return
|
||||||
|
*
|
||||||
* @return array List of pacakge requests with details
|
* @return array List of pacakge requests with details
|
||||||
*/
|
*/
|
||||||
function pkgreq_list() {
|
function pkgreq_list($offset, $limit) {
|
||||||
$dbh = DB::connect();
|
$dbh = DB::connect();
|
||||||
|
|
||||||
$q = "SELECT PackageRequests.ID, ";
|
$q = "SELECT PackageRequests.ID, ";
|
||||||
|
@ -21,6 +35,7 @@ function pkgreq_list() {
|
||||||
$q.= "RequestTypes.ID = PackageRequests.ReqTypeID ";
|
$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 ";
|
$q.= "ORDER BY Status ASC, RequestTS DESC ";
|
||||||
|
$q.= "LIMIT " . $limit . " OFFSET " . $offset;
|
||||||
|
|
||||||
return $dbh->query($q)->fetchAll();
|
return $dbh->query($q)->fetchAll();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue