* Adjust code.
This commit is contained in:
@@ -81,7 +81,33 @@ class gitlab extends control
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
if($this->post->zentaoUsers)
|
||||
{
|
||||
$data = array();
|
||||
$number = 0;
|
||||
foreach($this->post->zentaoUsers as $gitlabId => $account)
|
||||
{
|
||||
if($account)
|
||||
{
|
||||
$data[$number]['openID'] = $gitlabId;
|
||||
$data[$number]['account'] = $account;
|
||||
$data[$number]['providerType'] = 'gitlab';
|
||||
$data[$number]['providerID'] = $id;
|
||||
$number++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($data as $bindUser)
|
||||
{
|
||||
if(!$this->gitlab->checkAccountId($bindUser['openID'],$bindUser['providerID']))
|
||||
{
|
||||
$this->dao->insert(TABLE_OAUTH)->data($bindUser)->exec();
|
||||
}else
|
||||
{
|
||||
$this->dao->update(TABLE_OAUTH)->data($bindUser)->where('openID')->eq($bindUser['openID'])->andWhere('providerID')->eq($bindUser['providerID'])->exec();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$gitlab = $this->gitlab->getByID($id);
|
||||
|
||||
+14
-1
@@ -97,7 +97,7 @@ class gitlabModel extends model
|
||||
{
|
||||
$api = rtrim($gitlab->url, '/') . '/api/v4/users?private_token=' . $gitlab->token;
|
||||
$response = json_decode(commonModel::http($api));
|
||||
|
||||
|
||||
if (!$response) return array();
|
||||
$users = array();
|
||||
|
||||
@@ -194,6 +194,19 @@ class gitlabModel extends model
|
||||
return $gitlab_url;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check if gitlab id exists
|
||||
*
|
||||
* @param string
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function checkAccountId($openID,$providerID)
|
||||
{
|
||||
return $this->dao->select('openID')->from(TABLE_OAUTH)->where('openID')->eq($openID)->andWhere('providerID')->eq($providerID)->fetch('openID');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get hooks.
|
||||
*
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<div class="main-header">
|
||||
<h2><?php echo $lang->gitlab->bindUser;?></h2>
|
||||
</div>
|
||||
<form method='post' class='load-indicator main-form' enctype='multipart/form-data' target='hiddenwin' id="batchCreateForm">
|
||||
<form method='post' class='load-indicator main-form' enctype='multipart/form-data'>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-borderless w-600px">
|
||||
<thead>
|
||||
|
||||
Reference in New Issue
Block a user