* Adjust check is bind user.
This commit is contained in:
@@ -42,18 +42,17 @@ class gitlab extends control
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
|
||||
/* Admin user don't need bind. */
|
||||
$isBindUser = (int)$this->app->user->admin;
|
||||
$gitlabList = $this->gitlab->getList($orderBy, $pager);
|
||||
$myGitLabs = $this->gitlab->getGitLabListByAccount();
|
||||
|
||||
foreach($gitlabList as $gitlab)
|
||||
{
|
||||
$token = $this->gitlab->apiGetCurrentUser($gitlab->url, $gitlab->token);
|
||||
$gitlab->isAdminToken = (isset($token->is_admin) and $token->is_admin);
|
||||
|
||||
if(!$isBindUser) $isBindUser = (int)$this->gitlab->getUserIDByZentaoAccount($gitlab->id, $this->app->user->account);
|
||||
$gitlab->isBindUser = $isBindUser;
|
||||
$gitlab->isBindUser = true;
|
||||
if(!$this->app->user->admin and !isset($myGitLabs[$gitlab->id])) $gitlab->isBindUser = false;
|
||||
}
|
||||
|
||||
|
||||
$this->view->title = $this->lang->gitlab->common . $this->lang->colon . $this->lang->gitlab->browse;
|
||||
$this->view->gitlabList = $gitlabList;
|
||||
$this->view->orderBy = $orderBy;
|
||||
|
||||
@@ -144,6 +144,23 @@ class gitlabModel extends model
|
||||
->fetch('openID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get GitLab id list by user account.
|
||||
*
|
||||
* @param string $account
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getGitLabListByAccount($account = '')
|
||||
{
|
||||
if(!$account) $account = $this->app->user->account;
|
||||
|
||||
return $this->dao->select('providerID')->from(TABLE_OAUTH)
|
||||
->where('providerType')->eq('gitlab')
|
||||
->andWhere('account')->eq($account)
|
||||
->fetchPairs('providerID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get project pairs of one gitlab.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user