* Adjust code.

This commit is contained in:
zenggang
2023-10-12 07:48:06 +00:00
parent c37b98feb7
commit 8a3afe05da
40 changed files with 495 additions and 293 deletions
+4 -4
View File
@@ -23,7 +23,7 @@ class gitlab extends control
if(stripos($this->methodName, 'ajax') === false)
{
if(!commonModel::hasPriv('space', 'browse')) $this->loadModel('common')->deny('space', 'browse', false);
if(!in_array(strtolower(strtolower($this->methodName)), array('browseproject', 'browsegroup', 'browseuser', 'browsebranch', 'browsetag')))
{
if(!commonModel::hasPriv('instance', 'manage')) $this->loadModel('common')->deny('instance', 'manage', false);
@@ -174,7 +174,7 @@ class gitlab extends control
$accountList[$user] = $openID;
}
if(count($repeatUsers)) return $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->gitlab->bindUserError, join(',', $repeatUsers))));
if(count($repeatUsers)) return $this->send(array('result' => 'fail', 'message' => sprintf($this->lang->gitlab->bindUserError, join(',', array_unique($repeatUsers)))));
$user = new stdclass;
$user->providerID = $gitlabID;
@@ -423,10 +423,10 @@ class gitlab extends control
if(!$this->app->user->admin)
{
$openID = $this->gitlab->getUserIDByZentaoAccount($gitlabID, $this->app->user->account);
if(!$openID) return print(js::alert($this->lang->gitlab->mustBindUser) . js::locate($this->createLink('gitlab', 'browse')));
if(!$openID) return print(js::alert($this->lang->gitlab->mustBindUser) . js::locate($this->createLink('space', 'browse')));
$members = $this->gitlab->apiGetGroupMembers($gitlabID, $groupID, $openID);
if(empty($members) or $members[0]->access_level < $this->config->gitlab->accessLevel['owner']) return print(js::alert($this->lang->gitlab->noAccess) . js::locate($this->createLink('gitlab', 'browse')));
if(empty($members) or $members[0]->access_level < $this->config->gitlab->accessLevel['owner']) return print(js::alert($this->lang->gitlab->noAccess) . js::locate($this->createLink('space', 'browse')));
}
if($_POST)
+2 -2
View File
@@ -655,7 +655,7 @@ class gitlabModel extends model
*/
public function apiGetGroups($gitlabID, $orderBy = 'id_desc', $minRole = '', $keyword = '')
{
$apiRoot = $this->getApiRoot($gitlabID, false);
$apiRoot = $this->getApiRoot($gitlabID, $minRole == 'owner' ? true : false);
$url = sprintf($apiRoot, "/groups");
if($minRole == 'owner')
{
@@ -1270,7 +1270,7 @@ class gitlabModel extends model
public function addPushWebhook($repo, $token = '')
{
$hook = new stdClass;
$hook->url = (defined('RUN_MODE') && RUN_MODE == 'test' ? 'http://unittest' : common::getSysURL()) . '/api.php/v1/gitlab/webhook?repoID='. $repo->id;
$hook->url = common::getSysURL() . '/api.php/v1/gitlab/webhook?repoID='. $repo->id;
$hook->push_events = true;
$hook->merge_requests_events = true;
if($token) $hook->token = $token;