From ce37bf9985da591b13f3e525400a66125bd9beb1 Mon Sep 17 00:00:00 2001 From: zenggang Date: Wed, 26 Jan 2022 01:58:00 +0000 Subject: [PATCH] * Fix bug#18978 --- module/gitlab/model.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/module/gitlab/model.php b/module/gitlab/model.php index 3e68946ba6..6b285fd7f8 100644 --- a/module/gitlab/model.php +++ b/module/gitlab/model.php @@ -62,16 +62,17 @@ class gitlabModel extends model * Get gitlab api base url by gitlab id. * * @param int $gitlabID + * @param bool $sudo * @access public * @return string */ - public function getApiRoot($gitlabID) + public function getApiRoot($gitlabID, $sudo = true) { $gitlab = $this->getByID($gitlabID); if(!$gitlab) return ''; $sudoParam = ''; - if(!$this->app->user->admin) + if($sudo == true and !$this->app->user->admin) { $openID = $this->getUserIDByZentaoAccount($gitlabID, $this->app->user->account); if($openID) $sudoParam = "&sudo={$openID}"; @@ -1103,7 +1104,7 @@ class gitlabModel extends model */ public function apiGetHooks($gitlabID, $projectID) { - $apiRoot = $this->getApiRoot($gitlabID); + $apiRoot = $this->getApiRoot($gitlabID, false); $apiPath = "/projects/{$projectID}/hooks"; $url = sprintf($apiRoot, $apiPath); @@ -1148,7 +1149,7 @@ class gitlabModel extends model foreach($hook as $index => $item) $newHook->$index= $item; - $apiRoot = $this->getApiRoot($gitlabID); + $apiRoot = $this->getApiRoot($gitlabID, false); $url = sprintf($apiRoot, "/projects/{$projectID}/hooks"); return json_decode(commonModel::http($url, $newHook));