* Merge gitea, gogs, gitlab methods to pipeline model.

This commit is contained in:
caoyanyi
2023-12-16 16:58:28 +08:00
parent 8154161fa2
commit 8a61570fc5
4 changed files with 5 additions and 39 deletions
-17
View File
@@ -260,23 +260,6 @@ class giteaModel extends model
return true;
}
/**
* Get Gitea id list by user account.
*
* @param string $account
* @access public
* @return array
*/
public function getListByAccount($account = '')
{
if(!$account) $account = $this->app->user->account;
return $this->dao->select('providerID,openID')->from(TABLE_OAUTH)
->where('providerType')->eq('gitea')
->andWhere('account')->eq($account)
->fetchPairs('providerID');
}
/**
* Get matched gitea users.
*
-17
View File
@@ -219,23 +219,6 @@ class gogsModel extends model
return true;
}
/**
* Get Gogs id list by user account.
*
* @param string $account
* @access public
* @return array
*/
public function getListByAccount($account = '')
{
if(!$account) $account = $this->app->user->account;
return $this->dao->select('providerID,openID')->from(TABLE_OAUTH)
->where('providerType')->eq('gogs')
->andWhere('account')->eq($account)
->fetchPairs('providerID');
}
/**
* Get matched gogs users.
*
+3 -4
View File
@@ -103,7 +103,7 @@ class mr extends control
$this->view->objectID = $objectID;
$this->view->repo = $repo;
$this->view->orderBy = $orderBy;
$this->view->openIDList = $this->app->user->admin ? array() : $this->loadModel(strtolower($repo->SCM))->getListByAccount($this->app->user->account);
$this->view->openIDList = $this->app->user->admin ? array() : $this->loadModel('pipeline')->getProviderPairsByAccount($repo->SCM);
$this->view->users = $this->loadModel('user')->getPairs('noletter');
$this->display();
}
@@ -153,9 +153,8 @@ class mr extends control
$openIDList = array();
if(!$this->app->user->admin)
{
$openIDList += $this->loadModel('gitlab')->getListByAccount($this->app->user->account);
$openIDList += $this->loadModel('gitea')->getListByAccount($this->app->user->account);
$openIDList += $this->loadModel('gogs')->getListByAccount($this->app->user->account);
$this->loadModel('pipeline');
foreach(array('gitlab', 'gitea', 'gogs') as $service) $openIDList += $this->pipeline->getProviderPairsByAccount($service);
}
$this->view->title = $this->lang->mr->common . $this->lang->colon . $this->lang->mr->browse;
+2 -1
View File
@@ -108,7 +108,7 @@ class mrModel extends model
*/
public function getGitlabProjects(int $hostID = 0, array $projectIdList = array()): array
{
$gitlabUsers = $this->loadModel('gitlab')->getListByAccount();
$gitlabUsers = $this->loadModel('pipeline')->getProviderPairsByAccount('gitlab');
if(!$this->app->user->admin && !isset($gitlabUsers[$hostID])) return array();
$minProject = $maxProject = 0;
@@ -125,6 +125,7 @@ class mrModel extends model
/* If not an administrator, need to obtain group member information. */
$groupIDList = array(0 => 0);
$this->loadModel('gitlab');
if(!$this->app->user->admin)
{
$groups = $this->gitlab->apiGetGroups($hostID, 'name_asc', 'reporter');