* Finish task#44806

This commit is contained in:
zenggang
2021-11-25 07:52:32 +00:00
parent e80d9acf37
commit 59605b34a6
3 changed files with 15 additions and 7 deletions

View File

@@ -455,16 +455,22 @@ class gitlabModel extends model
* @access public
* @return array
*/
public function apiGetUsers($gitlabID, $onlyLinked = false)
public function apiGetUsers($gitlabID, $onlyLinked = false, $orderBy)
{
/* GitLab API '/users' can only return 20 users per page in default, so we use a loop to fetch all users. */
$page = 1;
$response = array();
$apiRoot = $this->getApiRoot($gitlabID);
/* Get order data. */
$orders = explode('_', $orderBy);
$sort = array_pop($orders);
$order = join('_', $orders);
while(true)
{
/* Also use `per_page=20` to fetch users in API. Fetch active users only. */
$url = sprintf($apiRoot, "/users") . "&page={$page}&per_page=20&active=true";
$url = sprintf($apiRoot, "/users") . "&order_by={$order}&sort={$sort}&page={$page}&per_page=20&active=true";
$result = json_decode(commonModel::http($url));
if(!empty($result))
{