diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2017-02-07 08:25:41 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2017-02-08 19:18:27 +0100 |
commit | ff8eb62a7581ecb5448a3770e22a500dfcac45da (patch) | |
tree | dfee7f396fc3c552db2d380a1fc951fdb19e4b7d /web | |
parent | d45585e36d6cbd9483f4a5b18cbbc346757ca6a0 (diff) | |
download | aur-ff8eb62a7581ecb5448a3770e22a500dfcac45da.tar.gz aur-ff8eb62a7581ecb5448a3770e22a500dfcac45da.tar.xz |
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>
Diffstat (limited to 'web')
-rw-r--r-- | web/lib/pkgreqfuncs.inc.php | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/web/lib/pkgreqfuncs.inc.php b/web/lib/pkgreqfuncs.inc.php index 7a171ed4..7dcab135 100644 --- a/web/lib/pkgreqfuncs.inc.php +++ b/web/lib/pkgreqfuncs.inc.php @@ -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; |