* Adjust display style.
This commit is contained in:
@@ -24,8 +24,6 @@ class gitlab extends control
|
||||
*/
|
||||
public function browse($orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
{
|
||||
if(common::hasPriv('gitlab', 'create')) $this->lang->TRActions = html::a(helper::createLink('gitlab', 'create'), "<i class='icon icon-plus'></i> " . $this->lang->gitlab->create, '', "class='btn btn-primary'");
|
||||
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
|
||||
@@ -50,12 +48,18 @@ class gitlab extends control
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
$tokenValid = $this->gitlab->apiGetCurrentUser($this->post->url, $this->post->token);
|
||||
if($tokenValid['result'] == 'fail') $this->send($tokenValid);
|
||||
if(strpos($host, 'http') !== 0) $this->send(array('result' => 'fail', 'message' => array('url' => array($this->lang->gitlab->hostError))));
|
||||
if(!$this->post->token) $this->send(array('result' => 'fail', 'message' => array('token' => array($this->lang->gitlab->tokenError))));
|
||||
|
||||
$user = $this->gitlab->apiGetCurrentUser($this->post->url, $this->post->token);
|
||||
|
||||
if(!is_object($user)) $this->send(array('result' => 'fail', 'message' => array('url' => array($this->lang->gitlab->hostError))));
|
||||
if(isset($user->is_admin) and $user->is_admin == true) $this->send(array('result' => 'success'));
|
||||
$this->send(array('result' => 'fail', 'message' => array('token' => array($this->lang->gitlab->tokenError))));
|
||||
|
||||
$gitlabID = $this->gitlab->create();
|
||||
|
||||
if(dao::isError()) $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
if($this->viewType == 'json') $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'id' => $gitlabID));
|
||||
$this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => inlink('browse')));
|
||||
}
|
||||
|
||||
@@ -76,10 +80,11 @@ class gitlab extends control
|
||||
public function bindUser($id)
|
||||
{
|
||||
$gitlab = $this->gitlab->getByID($id);
|
||||
$this->view->title = $this->lang->gitlab->bind;
|
||||
$this->view->zentaoUsers = $this->dao->select('account,email,realname')->from(TABLE_USER)->fetchAll('account');
|
||||
$this->view->gitlabUsers = $this->gitlab->apiGetUsers($gitlab);
|
||||
$this->view->matchedInfo = $this->gitlab->getMatchedUsers($this->view->gitlabUsers);
|
||||
$this->view->title = $this->lang->gitlab->bindUser;
|
||||
$zentaoUsers = $this->dao->select('account,email,realname')->from(TABLE_USER)->fetchAll('account');
|
||||
$this->view->userPairs = $this->loadModel('user')->getPairs();
|
||||
$this->view->gitlabUsers = $this->gitlab->apiGetUsers($gitlab);
|
||||
$this->view->matchedResult = $this->gitlab->getMatchedUsers($this->view->gitlabUsers, $zentaoUsers);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
|
||||
@@ -4,9 +4,11 @@ $lang->gitlab->common = 'Gitlab';
|
||||
$lang->gitlab->browse = '浏览gitlab';
|
||||
$lang->gitlab->create = '添加gitlab';
|
||||
$lang->gitlab->edit = '编辑gitlab';
|
||||
$lang->gitlab->bind = '绑定用户';
|
||||
$lang->gitlab->bindUser = '绑定用户';
|
||||
$lang->gitlab->delete = '删除';
|
||||
$lang->gitlab->confirmDelete = '确认删除该gitlab吗?';
|
||||
$lang->gitlab->gitlabAccount = 'gitlab用户';
|
||||
$lang->gitlab->zentaoAccount = '禅道用户';
|
||||
|
||||
$lang->gitlab->browseAction = 'gitlab列表';
|
||||
$lang->gitlab->deleteAction = '删除gitlab';
|
||||
|
||||
@@ -80,14 +80,8 @@ class gitlabModel extends model
|
||||
*/
|
||||
public function apiGetCurrentUser($host, $token)
|
||||
{
|
||||
if(strpos($host, 'http') !== 0) return array('result' => 'fail', 'message' => array('url' => array($this->lang->gitlab->hostError)));
|
||||
if(!$this->post->token) return array('result' => 'fail', 'message' => array('token' => array($this->lang->gitlab->tokenError)));
|
||||
$api = rtrim($host, '/') . "/api/v4/user?private_token=$token";
|
||||
$response = json_decode(commonModel::http($api));
|
||||
|
||||
if(!is_object($response)) return array('result' => 'fail', 'message' => array('url' => array($this->lang->gitlab->hostError)));
|
||||
if(isset($response->is_admin) and $response->is_admin == true) return array('result' => 'success');
|
||||
return array('result' => 'fail', 'message' => array('token' => array($this->lang->gitlab->tokenError)));
|
||||
return json_decode(commonModel::http($api));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,17 +108,15 @@ class gitlabModel extends model
|
||||
$user->realname = $gitlabUser->name;
|
||||
$user->account = $gitlabUser->username;
|
||||
$user->email = $gitlabUser->email;
|
||||
$user->avatar = $gitlabUser->avatar_url;
|
||||
|
||||
$users[] = $user;
|
||||
}
|
||||
a($users);
|
||||
return $users;
|
||||
}
|
||||
|
||||
public function getMatchedUsers($gitlabUsers)
|
||||
public function getMatchedUsers($gitlabUsers, $zentaoUsers)
|
||||
{
|
||||
$zentaoUsers = $this->dao->select('account,email,realname')->from(TABLE_USER)->fetchAll('account');
|
||||
|
||||
$matches = new stdclass;
|
||||
foreach($gitlabUsers as $gitlabUser)
|
||||
{
|
||||
@@ -136,7 +128,8 @@ class gitlabModel extends model
|
||||
}
|
||||
}
|
||||
|
||||
foreach($gitlabUser as $gitlabUser)
|
||||
$matchedUsers = array();
|
||||
foreach($gitlabUsers as $gitlabUser)
|
||||
{
|
||||
$matchedZentaoUsers = array();
|
||||
if(isset($matches->accounts[$gitlabUser->account])) $matchedZentaoUsers = array_merge($matchedZentaoUsers, $matches->accounts[$gitlabUser->account]);
|
||||
@@ -146,15 +139,11 @@ class gitlabModel extends model
|
||||
$matchedZentaoUsers = array_unique($matchedZentaoUsers);
|
||||
if(count($matchedZentaoUsers) == 1)
|
||||
{
|
||||
$matchedUsers[$gitlabUser->id] = current($matchedZentaoUsers);
|
||||
}
|
||||
else
|
||||
{
|
||||
$unmatchedUsers[$gitlabUser->id] = $gitlabUser;
|
||||
$gitlabUser->zentaoAccount = current($matchedZentaoUsers);
|
||||
$matchedUsers[] = $gitlabUser;
|
||||
}
|
||||
}
|
||||
|
||||
return array('matched' => $matchedUsers, 'unmatched' => $unmatchedUsers);
|
||||
return $matchedUsers;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,20 +17,35 @@
|
||||
</div>
|
||||
<form method='post' class='load-indicator main-form' enctype='multipart/form-data' target='hiddenwin' id="batchCreateForm">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-form">
|
||||
<table class="table table-form w-500px">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class='col-id'><?php echo $lang->gitlab->gitlabAccount;?></th>
|
||||
<th class='col-id'><?php echo $lang->gitlab->zentaoAccount;?></th>
|
||||
<th class='w-150px'><?php echo $lang->gitlab->gitlabAccount;?></th>
|
||||
<th class='w-150px'><?php echo $lang->gitlab->zentaoAccount;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($gitlabUsers as $gitlabUser):?>
|
||||
<?php
|
||||
?>
|
||||
<tr class="template">
|
||||
<td>$idPlus</td>
|
||||
<td class='text-left<?php echo zget($visibleFields, $product->type, ' hidden')?>'><?php echo html::select('branch[$id]', $branches, $branch, "class='form-control chosen' onchange='setModuleAndPlan(this.value, $productID, \$id)'");?></td>
|
||||
<?php if(isset($gitlabUser->zentaoAccount)) continue;?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php echo html::image($gitlabUser->avatar, "height=40");?>
|
||||
<strong>
|
||||
<?php echo html::hidden('gitlabUsers[]', $gitlabUser->id) . $gitlabUser->realname;?>
|
||||
<br><?php echo "(" . $gitlabUser->account . ") <" . $gitlabUser->email . ">"; ?>
|
||||
</strong>
|
||||
</td>
|
||||
<td><?php echo html::select('zentaoUsers[]', $userPairs, '', "class='form-control select chosen'" );?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
<?php foreach($gitlabUsers as $gitlabUser):?>
|
||||
<?php if(!isset($gitlabUser->zentaoAccount)) continue;?>
|
||||
<tr>
|
||||
<td>
|
||||
<strong><?php echo html::hidden('gitlabUsers[]', $gitlabUser->id) . $gitlabUser->realname;?></strong>
|
||||
<p><?php echo "(" . $gitlabUser->account . ") <" . $gitlabUser->email . ">"; ?></p>
|
||||
</td>
|
||||
<td><?php echo html::select('zentaoUsers[]', $userPairs, $gitlabUser->zentaoAccount, "class='form-control select chosen'" );?></td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
@@ -46,48 +61,4 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
$(function()
|
||||
{
|
||||
var imageTitles = <?php echo empty($titles) ? '""' : json_encode($titles);?>;
|
||||
var storyTitles = <?php echo empty($titles) ? '""' : json_encode(array_keys($titles));?>;
|
||||
|
||||
$('#batchCreateForm').batchActionForm(
|
||||
{
|
||||
idEnd: <?php echo max((empty($titles) ? 0 : count($titles)), 9)?>,
|
||||
rowCreator: function($row, index)
|
||||
{
|
||||
$row.find('select.chosen,select.picker-select').each(function()
|
||||
{
|
||||
var $select = $(this);
|
||||
if($select.hasClass('picker-select')) $select.parent().find('.picker').remove();
|
||||
if(index == 0) $select.find("option[value='ditto']").remove();
|
||||
if(index > 0) $select.val('ditto');
|
||||
if($select.attr('id').indexOf('branch') >= 0) $select.val('<?php echo $branch;?>')
|
||||
$select.chosen();
|
||||
setTimeout(function()
|
||||
{
|
||||
$select.next('.chosen-container').find('.chosen-drop').width($select.closest('td').width() + 50);
|
||||
}, 200);
|
||||
});
|
||||
var storyTitle = storyTitles && storyTitles[index];
|
||||
if (storyTitle !== undefined && storyTitle !== null)
|
||||
{
|
||||
$row.find('.input-story-title').val(storyTitle).after('<input type="hidden" name="uploadImage[' + index + ']" id="uploadImage[' + index + ']" value="' + imageTitles[storyTitle] + '">');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('change', "#mainContent select[name^=needReview]", function()
|
||||
{
|
||||
select = $(this).parent('td').next('td').children("select[name^=reviewer]");
|
||||
$(select).removeAttr('disabled');
|
||||
if($(this).val() == 0) $(select).attr('disabled', 'disabled');
|
||||
$(select).trigger("chosen:updated");
|
||||
})
|
||||
});
|
||||
</script>
|
||||
<?php if(isset($execution)) js::set('execution', $execution);?>
|
||||
<?php js::set('storyType', $type);?>
|
||||
<?php include '../../common/view/pastetext.html.php';?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
|
||||
Reference in New Issue
Block a user