Merge branch 'jihu' of https://gitlab.zcorp.cc/easycorp/zentaopms into jihu
This commit is contained in:
@@ -318,14 +318,14 @@ $lang->devops->menu = new stdclass();
|
||||
$lang->devops->menu->code = array('link' => "{$lang->repo->common}|repo|browse|repoID=%s", 'alias' => 'diff,view,revision,log,blame,showsynccomment');
|
||||
$lang->devops->menu->compile = array('link' => "{$lang->devops->compile}|job|browse", 'subModule' => 'compile,job');
|
||||
$lang->devops->menu->jenkins = array('link' => "Jenkins|jenkins|browse", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->gitlab = array('link' => "gitlab|gitlab|browse", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->gitlab = array('link' => "Gitlab|gitlab|browse", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->maintain = array('link' => "{$lang->devops->repo}|repo|maintain", 'alias' => 'create,edit');
|
||||
$lang->devops->menu->rules = array('link' => "{$lang->devops->rules}|repo|setrules");
|
||||
|
||||
$lang->devops->menuOrder[5] = 'code';
|
||||
$lang->devops->menuOrder[10] = 'compile';
|
||||
$lang->devops->menuOrder[15] = 'jenkins';
|
||||
$lang->devops->menuOrder[16] = 'gitlab';
|
||||
$lang->devops->menuOrder[14] = 'gitlab';
|
||||
$lang->devops->menuOrder[20] = 'maintain';
|
||||
$lang->devops->menuOrder[25] = 'rules';
|
||||
|
||||
|
||||
@@ -64,6 +64,18 @@ class gitlab extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* bind a gitlab.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function bind()
|
||||
{
|
||||
echo 123;die;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a gitlab.
|
||||
*
|
||||
@@ -106,17 +118,17 @@ class gitlab extends control
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax get tasks.
|
||||
* Ajax get gitlab token permissions.
|
||||
*
|
||||
* @param int $id
|
||||
* @param string $host
|
||||
* @param string $token
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function ajaxGetTasks($id)
|
||||
public function ajaxCheckToken($host, $token)
|
||||
{
|
||||
if(empty($id)) die(json_encode(array('' => '')));
|
||||
$host = helper::safe64Decode($host);
|
||||
$permissions = $this->gitlab->getPermissionsByToken($host, $token);
|
||||
|
||||
$tasks = $this->gitlab->getTasks($id);
|
||||
die(json_encode($tasks));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
$(function () {
|
||||
$('#token, #url').change(function () {
|
||||
//取用户名
|
||||
var uid = $("#uid").val();
|
||||
|
||||
//调ajax
|
||||
$.ajax({
|
||||
url: "uidchuli.php",
|
||||
data: {u: uid},
|
||||
type: "POST",
|
||||
dataType: "TEXT",
|
||||
success: function (data) {
|
||||
if (data > 0) {
|
||||
$("#ts").html("该应户名已存在");
|
||||
$("#ts").css("color", "red");
|
||||
} else {
|
||||
$("#ts").html("该应户名可用");
|
||||
$("#ts").css("color", "green");
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
})
|
||||
});
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
$lang->gitlab->common = 'gitlab';
|
||||
$lang->gitlab->common = 'Gitlab';
|
||||
$lang->gitlab->browse = '浏览gitlab';
|
||||
$lang->gitlab->create = '添加gitlab';
|
||||
$lang->gitlab->edit = '编辑gitlab';
|
||||
$lang->gitlab->bind = '绑定用户';
|
||||
$lang->gitlab->delete = '删除';
|
||||
$lang->gitlab->confirmDelete = '确认删除该gitlab吗?';
|
||||
|
||||
@@ -13,10 +14,11 @@ $lang->gitlab->id = 'ID';
|
||||
$lang->gitlab->name = '名称';
|
||||
$lang->gitlab->url = '服务地址';
|
||||
$lang->gitlab->token = 'Token';
|
||||
$lang->gitlab->account = '用户名';
|
||||
$lang->gitlab->password = '密码';
|
||||
|
||||
$lang->gitlab->lblCreate = '添加gitlab服务器';
|
||||
$lang->gitlab->desc = '描述';
|
||||
$lang->gitlab->tokenFirst = 'Token不为空时,优先使用Token。';
|
||||
$lang->gitlab->tips = '使用密码时,请在gitlab全局安全设置中禁用"防止跨站点请求伪造"选项。';
|
||||
|
||||
/* 交互提示。*/
|
||||
$lang->gitlab->tokenPermissions = "当前token非root权限。";
|
||||
|
||||
+28
-39
@@ -21,7 +21,7 @@ class gitlabModel extends model
|
||||
*/
|
||||
public function getByID($id)
|
||||
{
|
||||
$gitlab = $this->dao->select('*')->from(TABLE_GITLAB)->where('id')->eq($id)->fetch();
|
||||
$gitlab = $this->dao->select('*')->from(TABLE_JENKINS)->where('id')->eq($id)->fetch();
|
||||
$gitlab->password = base64_decode($gitlab->password);
|
||||
|
||||
return $gitlab;
|
||||
@@ -37,8 +37,9 @@ class gitlabModel extends model
|
||||
*/
|
||||
public function getList($orderBy = 'id_desc', $pager = null)
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_GITLAB)
|
||||
return $this->dao->select('*')->from(TABLE_JENKINS)
|
||||
->where('deleted')->eq('0')
|
||||
->andwhere('type')->eq('1')
|
||||
->orderBy($orderBy)
|
||||
->page($pager)
|
||||
->fetchAll('id');
|
||||
@@ -51,41 +52,13 @@ class gitlabModel extends model
|
||||
*/
|
||||
public function getPairs()
|
||||
{
|
||||
$gitlab = $this->dao->select('id,name')->from(TABLE_GITLAB)
|
||||
$gitlab = $this->dao->select('id,name')->from(TABLE_JENKINS)
|
||||
->where('deleted')->eq('0')
|
||||
->orderBy('id')->fetchPairs('id', 'name');
|
||||
$gitlab = array('' => '') + $gitlab;
|
||||
return $gitlab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gitlab tasks.
|
||||
*
|
||||
* @param int $id
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getTasks($id)
|
||||
{
|
||||
$gitlab = $this->getById($id);
|
||||
|
||||
$gitlabServer = $gitlab->url;
|
||||
$gitlabUser = $gitlab->account;
|
||||
$gitlabPassword = $gitlab->token ? $gitlab->token : $gitlab->password;
|
||||
|
||||
$userPWD = "$gitlabUser:$gitlabPassword";
|
||||
$response = common::http($gitlabServer . '/api/json/items/list', '', array(CURLOPT_USERPWD => $userPWD));
|
||||
$response = json_decode($response);
|
||||
|
||||
$tasks = array();
|
||||
if(isset($response->jobs))
|
||||
{
|
||||
foreach($response->jobs as $job) $tasks[basename($job->url)] = $job->name;
|
||||
}
|
||||
return $tasks;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a gitlab.
|
||||
*
|
||||
@@ -97,12 +70,11 @@ class gitlabModel extends model
|
||||
$gitlab = fixer::input('post')
|
||||
->add('createdBy', $this->app->user->account)
|
||||
->add('createdDate', helper::now())
|
||||
->skipSpecial('url,token,account,password')
|
||||
->add('type', 1)
|
||||
->skipSpecial('url,token')
|
||||
->get();
|
||||
|
||||
$gitlab->password = base64_encode($gitlab->password);
|
||||
|
||||
$this->dao->insert(TABLE_GITLAB)->data($gitlab)
|
||||
$this->dao->insert(TABLE_JENKINS)->data($gitlab)
|
||||
->batchCheck($this->config->gitlab->create->requiredFields, 'notempty')
|
||||
->batchCheck("url", 'URL')
|
||||
->autoCheck()
|
||||
@@ -123,12 +95,10 @@ class gitlabModel extends model
|
||||
$gitlab = fixer::input('post')
|
||||
->add('editedBy', $this->app->user->account)
|
||||
->add('editedDate', helper::now())
|
||||
->skipSpecial('url,token,account,password')
|
||||
->skipSpecial('url,token')
|
||||
->get();
|
||||
|
||||
$gitlab->password = base64_encode($gitlab->password);
|
||||
|
||||
$this->dao->update(TABLE_GITLAB)->data($gitlab)
|
||||
$this->dao->update(TABLE_JENKINS)->data($gitlab)
|
||||
->batchCheck($this->config->gitlab->edit->requiredFields, 'notempty')
|
||||
->batchCheck("url", 'URL')
|
||||
->autoCheck()
|
||||
@@ -136,4 +106,23 @@ class gitlabModel extends model
|
||||
->exec();
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get gitlab token permissions.
|
||||
*
|
||||
* @param string $host
|
||||
* @param string $token
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getPermissionsByToken($host, $token)
|
||||
{
|
||||
$host = rtrim($host, '/');
|
||||
$host .= '/api/v4/activities';
|
||||
|
||||
$results = json_decode(file_get_contents($host . "?private_token=$token"));
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
* The edit view file of gitlab module of ZenTaoPMS.
|
||||
*
|
||||
* @copyright Copyright 2009-2017 青岛易软天创网络科技有限公司(QingDao Nature Easy Soft Network Technology Co,LTD, www.cnezsoft.com)
|
||||
* @license ZPL (http://zpl.pub/page/zplv12.html)
|
||||
* @author Gang Liu <liugang@cnezsoft.com>
|
||||
* @package gitlab
|
||||
* @version $Id$
|
||||
* @link http://www.zentao.net
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php'; ?>
|
||||
<div id='mainContent' class='main-row'>
|
||||
<div class='main-col main-content'>
|
||||
<div class='center-block'>
|
||||
<div class='main-header'>
|
||||
<h2><?php echo $lang->gitlab->edit; ?></h2>
|
||||
</div>
|
||||
<form id='gitlabForm' method='post' class='form-ajax'>
|
||||
<table class='table table-form'>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->name; ?></th>
|
||||
<td class='required'><?php echo html::input('name', $gitlab->name, "class='form-control'"); ?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->url; ?></th>
|
||||
<td class='required'><?php echo html::input('url', $gitlab->url, "class='form-control'"); ?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->token;?></th>
|
||||
<td><?php echo html::input('token', $gitlab->token, "class='form-control'");?></td>
|
||||
<td><?php echo $lang->gitlab->tokenFirst;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td class='text-center form-actions'>
|
||||
<?php echo html::submitButton(); ?>
|
||||
<?php echo html::backButton() ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include '../../common/view/footer.html.php'; ?>
|
||||
@@ -37,6 +37,7 @@
|
||||
<td class='c-actions text-left'>
|
||||
<?php
|
||||
common::printIcon('gitlab', 'edit', "gitlabID=$id", '', 'list', 'edit');
|
||||
common::printIcon('gitlab', 'bind', "gitlabID=$id", '', 'list', 'group');
|
||||
if(common::hasPriv('gitlab', 'delete')) echo html::a($this->createLink('gitlab', 'delete', "gitlabID=$id"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->gitlab->delete}' class='btn'");
|
||||
?>
|
||||
</td>
|
||||
|
||||
@@ -29,20 +29,11 @@
|
||||
<td class='required'><?php echo html::input('url', '', "class='form-control'"); ?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->account;?></th>
|
||||
<td><?php echo html::input('account', '', "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->token;?></th>
|
||||
<td><?php echo html::input('token', '', "class='form-control'");?></td>
|
||||
<td><?php echo $lang->gitlab->tokenFirst;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->password;?></th>
|
||||
<td><?php echo html::password('password', '', "class='form-control'");?></td>
|
||||
<td><?php echo $lang->gitlab->tips;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td class='text-center form-actions'>
|
||||
|
||||
@@ -29,20 +29,11 @@
|
||||
<td class='required'><?php echo html::input('url', $gitlab->url, "class='form-control'"); ?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->account;?></th>
|
||||
<td><?php echo html::input('account', $gitlab->account, "class='form-control'");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->token;?></th>
|
||||
<td><?php echo html::input('token', $gitlab->token, "class='form-control'");?></td>
|
||||
<td><?php echo $lang->gitlab->tokenFirst;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->gitlab->password;?></th>
|
||||
<td><?php echo html::password('password', $gitlab->password, "class='form-control'");?></td>
|
||||
<td><?php echo $lang->gitlab->tips;?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td class='text-center form-actions'>
|
||||
|
||||
Reference in New Issue
Block a user