mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Add an option to filter by user to pkgreq_list()
When a user is specified, the function only returns package requests which are either opened by the given user or affecting packages maintained by the given user. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
d45585e36d
commit
ff8eb62a75
1 changed files with 8 additions and 1 deletions
|
@ -19,10 +19,11 @@ function pkgreq_count() {
|
|||
*
|
||||
* @param int $offset The index of the first request to return
|
||||
* @param int $limit The maximum number of requests to return
|
||||
* @param int $uid Only return packages affecting the given user
|
||||
*
|
||||
* @return array List of pacakge requests with details
|
||||
*/
|
||||
function pkgreq_list($offset, $limit) {
|
||||
function pkgreq_list($offset, $limit, $uid=false) {
|
||||
$dbh = DB::connect();
|
||||
|
||||
$q = "SELECT PackageRequests.ID, ";
|
||||
|
@ -35,6 +36,12 @@ function pkgreq_list($offset, $limit) {
|
|||
$q.= "FROM PackageRequests INNER JOIN RequestTypes ON ";
|
||||
$q.= "RequestTypes.ID = PackageRequests.ReqTypeID ";
|
||||
$q.= "INNER JOIN Users ON Users.ID = PackageRequests.UsersID ";
|
||||
|
||||
if ($uid) {
|
||||
$q.= "WHERE PackageRequests.UsersID = " . intval($uid). " ";
|
||||
$q.= "OR Users.ID = " . intval($uid) . " ";
|
||||
}
|
||||
|
||||
$q.= "ORDER BY Open DESC, RequestTS DESC ";
|
||||
$q.= "LIMIT " . $limit . " OFFSET " . $offset;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue