* Finish task#43847,43860
This commit is contained in:
@@ -292,6 +292,24 @@ class gitlab extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse gitlab group.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param string $orderBy
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function groupBrowse($gitlabID, $orderBy = 'name_asc')
|
||||
{
|
||||
$gitlabGroupList = $this->gitlab->apiGetGroups($gitlabID, $orderBy);
|
||||
|
||||
$this->view->gitlabID = $gitlabID;
|
||||
$this->view->gitlabGroupList = $gitlabGroupList;
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse gitlab project.
|
||||
*
|
||||
@@ -334,7 +352,7 @@ class gitlab extends control
|
||||
* Edit a gitlab user.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $projectID
|
||||
* @param int $userID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
@@ -350,7 +368,7 @@ class gitlab extends control
|
||||
|
||||
$userPairs = $this->loadModel('user')->getPairs('noclosed|noletter');
|
||||
$user = $this->gitlab->apiGetSingleUser($gitlabID, $userID);
|
||||
$zentaoBindAccount = $this->dao->select('account')->from(TABLE_OAUTH)->where('providerType')->eq('gitlab')->andWhere('providerID')->eq($gitlabID)->andWhere('openID')->eq($user->id)->fetch();
|
||||
$zentaoBindAccount = $this->dao->select('account')->from(TABLE_OAUTH)->where('providerType')->eq('gitlab')->andWhere('providerID')->eq($gitlabID)->andWhere('openID')->eq($user->id)->fetch('account');
|
||||
|
||||
$this->view->user = $user;
|
||||
$this->view->userPairs = $userPairs;
|
||||
@@ -359,6 +377,23 @@ class gitlab extends control
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a gitlab user.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $userID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function deleteUser($gitlabID, $userID, $confirm = 'no')
|
||||
{
|
||||
if($confirm != 'yes') die(js::confirm($this->lang->gitlab->user->confirmDelete , inlink('deleteUser', "gitlabID=$gitlabID&userID=$userID&confirm=yes")));
|
||||
|
||||
$reponse = $this->gitlab->apiDeleteUser($gitlabID, $userID);
|
||||
if(!$reponse or substr($reponse->message, 0, 2) == '20') die(js::reload('parent'));
|
||||
die(js::alert($reponse->message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse gitlab project.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
.text-c-name > .avatar {vertical-align: middle;display: inline-block;margin-right: 5px;}
|
||||
.text-c-name > span {vertical-align: middle;}
|
||||
@@ -23,6 +23,7 @@ $lang->gitlab->deleteAction = 'Delete GitLab';
|
||||
$lang->gitlab->gitlabProject = "GitLab Project";
|
||||
$lang->gitlab->browseProject = "GitLab Project List";
|
||||
$lang->gitlab->browseUser = "User List";
|
||||
$lang->gitlab->browseGroup = "Group List";
|
||||
$lang->gitlab->gitlabIssue = "GitLab Issue";
|
||||
$lang->gitlab->zentaoProduct = 'Zentao Product';
|
||||
$lang->gitlab->objectType = 'Type'; // task, bug, story
|
||||
@@ -98,3 +99,19 @@ $lang->gitlab->user->edit = "Edit {$lang->gitlab->gitlabAccount}";
|
||||
$lang->gitlab->user->emptyError = "cannot be empty";
|
||||
$lang->gitlab->user->passwordError = "The second password is inconsistent!";
|
||||
$lang->gitlab->user->bindError = "The user has been bound!";
|
||||
$lang->gitlab->user->confirmDelete = 'Do you want to delete this GitLab user?';
|
||||
|
||||
$lang->gitlab->group = new stdclass;
|
||||
$lang->gitlab->group->id = "Group ID";
|
||||
$lang->gitlab->group->name = "Group name";
|
||||
$lang->gitlab->group->path = "Group URL";
|
||||
$lang->gitlab->group->description = "Group description";
|
||||
$lang->gitlab->group->avatar = "Group avatar";
|
||||
$lang->gitlab->group->visibility = "Visibility level";
|
||||
$lang->gitlab->group->requestAccessEnabledTip = "Allow users to request access (if visibility is public or internal)";
|
||||
$lang->gitlab->group->lfsEnabledTip = "Allow projects within this group to use Git LFS(This setting can be overridden in each project)";
|
||||
$lang->gitlab->group->create = "Create Group";
|
||||
$lang->gitlab->group->edit = "Edit Group";
|
||||
$lang->gitlab->group->createOn = "Created on";
|
||||
$lang->gitlab->group->members = "Group Members";
|
||||
$lang->gitlab->group->confirmDelete = 'Do you want to delete this GitLab group?';
|
||||
@@ -23,6 +23,7 @@ $lang->gitlab->deleteAction = '删除GitLab';
|
||||
$lang->gitlab->gitlabProject = "{$lang->gitlab->common}项目";
|
||||
$lang->gitlab->browseProject = "{$lang->gitlab->common}项目列表";
|
||||
$lang->gitlab->browseUser = "用户列表";
|
||||
$lang->gitlab->browseGroup = "群组列表";
|
||||
$lang->gitlab->gitlabIssue = "{$lang->gitlab->common} issue";
|
||||
$lang->gitlab->zentaoProduct = '禅道产品';
|
||||
$lang->gitlab->objectType = '类型'; // task, bug, story
|
||||
@@ -98,3 +99,19 @@ $lang->gitlab->user->edit = "编辑{$lang->gitlab->gitlabAccount}";
|
||||
$lang->gitlab->user->emptyError = "不能为空";
|
||||
$lang->gitlab->user->passwordError = "二次密码不一致!";
|
||||
$lang->gitlab->user->bindError = "该用户已经被绑定!";
|
||||
$lang->gitlab->user->confirmDelete = '确认删除该GitLab用户吗?';
|
||||
|
||||
$lang->gitlab->group = new stdclass;
|
||||
$lang->gitlab->group->id = "群组ID";
|
||||
$lang->gitlab->group->name = "群组名称";
|
||||
$lang->gitlab->group->path = "群组URL";
|
||||
$lang->gitlab->group->description = "群组描述";
|
||||
$lang->gitlab->group->avatar = "群组头像";
|
||||
$lang->gitlab->group->visibility = "可见性级别";
|
||||
$lang->gitlab->group->requestAccessEnabledTip = "允许用户请求访问(如果可见性是公开或内部的)";
|
||||
$lang->gitlab->group->lfsEnabledTip = "允许该组内的项目使用 Git LFS(可以在每个项目中覆盖此设置)";
|
||||
$lang->gitlab->group->create = "添加群组";
|
||||
$lang->gitlab->group->edit = "编辑群组";
|
||||
$lang->gitlab->group->createOn = "创建于";
|
||||
$lang->gitlab->group->members = "群组成员";
|
||||
$lang->gitlab->group->confirmDelete = '确认删除该GitLab群组吗?';
|
||||
+45
-3
@@ -471,6 +471,31 @@ class gitlabModel extends model
|
||||
return $users;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get groups of one gitlab.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param string $orderBy
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function apiGetGroups($gitlabID, $orderBy)
|
||||
{
|
||||
$apiRoot = $this->getApiRoot($gitlabID);
|
||||
$url = sprintf($apiRoot, "/groups");
|
||||
list($order, $sort) = explode('_', $orderBy);
|
||||
|
||||
$allResults = array();
|
||||
for($page = 1; true; $page++)
|
||||
{
|
||||
$results = json_decode(commonModel::http($url . "&statistics=true&order_by={$order}&sort={$sort}&page={$page}&per_page=100"));
|
||||
if(!empty($results)) $allResults = array_merge($allResults, $results);
|
||||
if(count($results)<100 or $page > 10) break;
|
||||
}
|
||||
|
||||
return $allResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get projects of one gitlab.
|
||||
*
|
||||
@@ -490,8 +515,8 @@ class gitlabModel extends model
|
||||
for($page = 1; true; $page++)
|
||||
{
|
||||
$results = json_decode(commonModel::http($host . "?private_token={$gitlab->token}&simple=true&page={$page}&per_page=100"));
|
||||
if(empty($results) or $page > 10) break;
|
||||
$allResults = array_merge($allResults, $results);
|
||||
if(!empty($results)) $allResults = array_merge($allResults, $results);
|
||||
if(count($results)<100 or $page > 10) break;
|
||||
}
|
||||
|
||||
return $allResults;
|
||||
@@ -579,7 +604,24 @@ class gitlabModel extends model
|
||||
|
||||
$apiRoot = $this->getApiRoot($gitlabID);
|
||||
$url = sprintf($apiRoot, "/projects/{$projectID}");
|
||||
return json_decode(commonModel::http($url, $project, $options = array(CURLOPT_CUSTOMREQUEST => 'DELETE')));
|
||||
return json_decode(commonModel::http($url, array(), $options = array(CURLOPT_CUSTOMREQUEST => 'DELETE')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a gitab user by api.
|
||||
*
|
||||
* @param int $gitlabID
|
||||
* @param int $userID
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public function apiDeleteUser($gitlabID, $userID)
|
||||
{
|
||||
if(empty($userID)) return false;
|
||||
|
||||
$apiRoot = $this->getApiRoot($gitlabID);
|
||||
$url = sprintf($apiRoot, "/users/{$userID}");
|
||||
return json_decode(commonModel::http($url, array(), $options = array(CURLOPT_CUSTOMREQUEST => 'DELETE')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
<th class='c-id'><?php common::printOrderLink('id', $orderBy, $vars, $lang->gitlab->id);?></th>
|
||||
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->gitlab->name);?></th>
|
||||
<th class='text-left'><?php common::printOrderLink('url', $orderBy, $vars, $lang->gitlab->url);?></th>
|
||||
<th class='c-actions-5'><?php echo $lang->actions;?></th>
|
||||
<th class='c-actions-6'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -48,8 +48,9 @@
|
||||
<?php
|
||||
$disabled = !empty($gitlab->isAdminToken) ? '' : 'disabled';
|
||||
common::printLink('gitlab', 'projectBrowse', "gitlabID=$id", "<i class='icon icon-project'></i> ", '',"title={$lang->gitlab->browseProject} class='btn btn-primary'");
|
||||
common::printLink('gitlab', 'groupBrowse', "gitlabID=$id", "<i class='icon icon-folder-outline'></i> ", '', "title={$lang->gitlab->browseGroup} class='btn btn-primary'");
|
||||
common::printLink('gitlab', 'edit', "gitlabID=$id", "<i class='icon icon-edit'></i> ", '',"title={$lang->gitlab->edit} class='btn btn-primary'");
|
||||
common::printLink('gitlab', 'userBrowse', "gitlabID=$id", "<i class='icon icon-team'></i> ", '', "title={$lang->gitlab->browseUser} class='btn {$disabled}' ,'disabled'");
|
||||
common::printLink('gitlab', 'userBrowse', "gitlabID=$id", "<i class='icon icon-persons'></i> ", '', "title={$lang->gitlab->browseUser} class='btn {$disabled}' ,'disabled'");
|
||||
common::printLink('gitlab', 'bindUser', "id=$id", "<i class='icon icon-link'></i> ", '', "title={$lang->gitlab->bindUser} class='btn {$disabled}' ,'disabled'");
|
||||
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'");
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* The browse 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="mainMenu" class="clearfix">
|
||||
<div class="btn-toolbar pull-right">
|
||||
<?php if(common::hasPriv('gitlab', 'createProject')) common::printLink('gitlab', 'createProject', "gitlabID=$gitlabID", "<i class='icon icon-plus'></i> " . $lang->gitlab->group->create, '', "class='btn btn-primary'");?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if(empty($gitlabGroupList)):?>
|
||||
<div class="table-empty-tip">
|
||||
<p>
|
||||
<span class="text-muted"><?php echo $lang->noData;?></span>
|
||||
<?php if(common::hasPriv('gitlab', 'createProject')):?>
|
||||
<?php echo html::a($this->createLink('gitlab', 'createProject', "gitlabID=$gitlabID"), "<i class='icon icon-plus'></i> " . $lang->gitlab->group->create, '', "class='btn btn-info'");?>
|
||||
<?php endif;?>
|
||||
</p>
|
||||
</div>
|
||||
<?php else:?>
|
||||
<div id='mainContent' class='main-row'>
|
||||
<form class='main-table' id='ajaxForm' method='post'>
|
||||
<table id='gitlabGroupList' class='table has-sort-head table-fixed'>
|
||||
<thead>
|
||||
<tr>
|
||||
<?php $vars = "gitlabID=$gitlabID&orderBy=%s";?>
|
||||
<th class='c-id'><?php common::printOrderLink('id', $orderBy, $vars, $lang->gitlab->group->id);?></th>
|
||||
<th class='c-name text-left'><?php common::printOrderLink('name', $orderBy, $vars, $lang->gitlab->group->name);?></th>
|
||||
<th class='text-left'><?php common::printOrderLink('path', $orderBy, $vars, $lang->gitlab->group->path);?></th>
|
||||
<th class='text-left'><?php echo $lang->gitlab->group->createOn;?></th>
|
||||
<th class='c-actions-3'><?php echo $lang->actions;?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($gitlabGroupList as $id => $gitlabGroup): ?>
|
||||
<tr class='text'>
|
||||
<td class='text-center'><?php echo $gitlabGroup->id;?></td>
|
||||
<td class='text-c-name' title='<?php echo $gitlabGroup->name;?>'>
|
||||
<?php echo html::avatar(substr($gitlabGroup->name, 0, 1), 20); ?>
|
||||
<span><?php echo $gitlabGroup->name;?></span>
|
||||
</td>
|
||||
<td class='text' title='<?php echo $gitlabGroup->path;?>'><?php echo $gitlabGroup->path;?></td>
|
||||
<td class='text' title='<?php echo substr($gitlabGroup->created_at, 0, 10);?>'><?php echo substr($gitlabGroup->created_at, 0, 10);?></td>
|
||||
<td class='c-actions text-left'>
|
||||
<?php
|
||||
common::printLink('gitlab', 'groupMembers', "gitlabID=$gitlabID&groupID=$gitlabGroup->id", "<i class='icon icon-team'></i> ", '',"title={$lang->gitlab->group->members} class='btn btn-primary'");
|
||||
common::printLink('gitlab', 'editGroup', "gitlabID=$gitlabID&groupID=$gitlabGroup->id", "<i class='icon icon-edit'></i> ", '', "title={$lang->gitlab->group->edit} class='btn btn-primary'");
|
||||
if(common::hasPriv('gitlab', 'delete')) echo html::a($this->createLink('gitlab', 'deleteGroup', "gitlabID=$gitlabID&groupID=$gitlabGroup->id"), '<i class="icon-trash"></i>', 'hiddenwin', "title='{$lang->gitlab->group->confirmDelete}' class='btn'");
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach;?>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<?php endif;?>
|
||||
<?php include '../../common/view/footer.html.php';?>
|
||||
@@ -45,7 +45,7 @@
|
||||
<td class='text-c-name' title='<?php echo $gitlabProject->name;?>'><?php echo $gitlabProject->name;?></td>
|
||||
<td class='text text-c-counts'>
|
||||
<span title="<?php echo $lang->gitlab->project->star;?>"><i class="icon icon-star"></i> <?php echo $gitlabProject->star_count;?></span>
|
||||
<span title="<?php echo $lang->gitlab->project->fork;?>"><i class="icon icon-code-fork"></i> <?php echo $gitlabProject->forks_count;?></span>
|
||||
<span title="<?php echo $lang->gitlab->project->fork;?>"><i class="icon icon-treemap"></i> <?php echo $gitlabProject->forks_count;?></span>
|
||||
</td>
|
||||
<td class='text' title='<?php echo substr($gitlabProject->last_activity_at, 0, 10);?>'><?php echo substr($gitlabProject->last_activity_at, 0, 10);?></td>
|
||||
<td class='c-actions text-left'>
|
||||
|
||||
Reference in New Issue
Block a user