* Finish task #89847.
This commit is contained in:
+18
-10
@@ -229,7 +229,7 @@ class group extends control
|
||||
|
||||
/* Join changelog when be equal or greater than this version.*/
|
||||
$realVersion = str_replace('_', '.', $version);
|
||||
$changelog = array();
|
||||
$changelog = array();
|
||||
foreach($this->lang->changelog as $currentVersion => $currentChangeLog)
|
||||
{
|
||||
if(version_compare($currentVersion, $realVersion, '>=')) $changelog[] = join(',', $currentChangeLog);
|
||||
@@ -250,9 +250,10 @@ class group extends control
|
||||
$privLang = $this->group->transformPrivLang($privs);
|
||||
$privs = $this->group->getCustomPrivs($menu, $privs);
|
||||
|
||||
$privList = array();
|
||||
$privMethods = array();
|
||||
$selectPrivs = array();
|
||||
$privList = array();
|
||||
$privMethods = array();
|
||||
$selectPrivs = array();
|
||||
$selectedPrivIdList = array();
|
||||
foreach($privs as $priv)
|
||||
{
|
||||
if(!isset($privList[$priv->parentCode])) $privList[$priv->parentCode] = array();
|
||||
@@ -264,7 +265,11 @@ class group extends control
|
||||
|
||||
if(!isset($selectPrivs[$priv->parentCode])) $selectPrivs[$priv->parentCode] = array();
|
||||
if(!isset($selectPrivs[$priv->parentCode][$priv->parent])) $selectPrivs[$priv->parentCode][$priv->parent] = 0;
|
||||
if(!empty($groupPrivs[$priv->module][$priv->method])) $selectPrivs[$priv->parentCode][$priv->parent] ++;
|
||||
if(!empty($groupPrivs[$priv->module][$priv->method]))
|
||||
{
|
||||
$selectPrivs[$priv->parentCode][$priv->parent] ++;
|
||||
if(isset($priv->id)) $selectedPrivIdList[$priv->id] = $priv->id;
|
||||
}
|
||||
}
|
||||
|
||||
$unassignedModule = array_diff(array_keys(get_object_vars($this->lang->resource)), array_keys($privList));
|
||||
@@ -288,10 +293,13 @@ class group extends control
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->privList = $privList;
|
||||
$this->view->privMethods = $privMethods;
|
||||
$this->view->selectPrivs = $selectPrivs;
|
||||
$this->view->privPackages = $privPackages;
|
||||
$relatedPrivData = $this->group->getDependentPrivs($selectedPrivIdList);
|
||||
|
||||
$this->view->privList = $privList;
|
||||
$this->view->privMethods = $privMethods;
|
||||
$this->view->selectPrivs = $selectPrivs;
|
||||
$this->view->privPackages = $privPackages;
|
||||
$this->view->relatedPrivData = json_encode($relatedPrivData);
|
||||
}
|
||||
elseif($type == 'byModule')
|
||||
{
|
||||
@@ -1049,7 +1057,7 @@ class group extends control
|
||||
$privList['depend'][$module]['children'][] = array('title' => $relatedPriv->name, 'relationPriv' => $privID);
|
||||
}
|
||||
|
||||
$privList[$type] = array_values($privList[$type]);
|
||||
$privList['depend'] = array_values($privList[$type]);
|
||||
|
||||
return print(json_encode($privList));
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
.mt-m {margin-top: 16px;}
|
||||
.flex-center {display: flex; justify-content: center; align-items: center;}
|
||||
#mainContent {display: flex; gap: 16px; height: calc(100vh - 165px);}
|
||||
#mainContent > .main {flex: 1 1 75%; overflow-y: auto; min-height: 445px;}
|
||||
#mainContent > .side {flex: 1 1 25%;}
|
||||
.priv-panel {background: #fff; padding: 10px; box-shadow: 0 1px 1px rgb(0 0 0 / 5%), 0 2px 6px 0 rgb(0 0 0 / 5%);}
|
||||
.priv-panel > .panel-content {height: calc(50vh - 160px); overflow-y: auto; min-height: 140px;}
|
||||
#mainContainer {display: flex; gap: 16px; height: calc(100vh - 165px);}
|
||||
#mainContainer > .main {flex: 1 1 75%; overflow-y: auto; min-height: 445px;}
|
||||
#mainContainer > .side {flex: 1 1 25%;}
|
||||
.priv-panel {background: #fff; padding: 10px 16px; box-shadow: 0 1px 1px rgb(0 0 0 / 5%), 0 2px 6px 0 rgb(0 0 0 / 5%); height: 240px;}
|
||||
.priv-panel > .panel-content {height: 200px; overflow-y: auto; min-height: 140px; padding-left: 4px;}
|
||||
.priv-panel > .panel-bottom {padding-top: 20px;}
|
||||
.priv-panel > .panel-title {position: relative;}
|
||||
.priv-panel > .panel-title > .icon-help {position: absolute; top: 3px; margin-left: 8px;}
|
||||
.icon-help + .popover {font-weight: 400;}
|
||||
.menuTree li.has-list:not(:first-child) {margin-top: 20px;}
|
||||
|
||||
/* tree */
|
||||
.tree ul > li {display: inline-block; width: 50%;}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
function initRecomendTree(data)
|
||||
{
|
||||
$(".menuTree.depend").tree(
|
||||
$(".menuTree.recommend").tree(
|
||||
{
|
||||
data: data,
|
||||
initialState: 'active',
|
||||
@@ -28,7 +28,7 @@ function initRecomendTree(data)
|
||||
*/
|
||||
function initDependTree(data)
|
||||
{
|
||||
$(".menuTree.recommend").tree(
|
||||
$(".menuTree.depend").tree(
|
||||
{
|
||||
data: data,
|
||||
initialState: 'active',
|
||||
|
||||
@@ -119,7 +119,7 @@ function changeParentChecked($item, moduleName, packageID)
|
||||
*/
|
||||
function initRecomendTree(data)
|
||||
{
|
||||
$(".menuTree.depend").tree(
|
||||
$(".menuTree.recommend").tree(
|
||||
{
|
||||
data: data,
|
||||
initialState: 'active',
|
||||
@@ -140,7 +140,7 @@ function initRecomendTree(data)
|
||||
*/
|
||||
function initDependTree(data)
|
||||
{
|
||||
$(".menuTree.recommend").tree(
|
||||
$(".menuTree.depend").tree(
|
||||
{
|
||||
data: data,
|
||||
initialState: 'active',
|
||||
@@ -264,8 +264,11 @@ function checkAllChange()
|
||||
|
||||
$(function()
|
||||
{
|
||||
initRecomendTree([]);
|
||||
initDependTree([]);
|
||||
relatedPrivData = $.parseJSON(relatedPrivData);
|
||||
initDependTree(relatedPrivData.depend);
|
||||
if(relatedPrivData.depend) $(".menuTree.depend + .empty-tip").hide();
|
||||
initRecomendTree(relatedPrivData.recommend);
|
||||
if(relatedPrivData.recommend) $(".menuTree.recommend + .empty-tip").hide();
|
||||
|
||||
$('#privList > tbody > tr > th .check-all').change(checkAllChange);
|
||||
$('.priv-footer .check-all').change(checkAllChange);
|
||||
@@ -281,8 +284,8 @@ $(function()
|
||||
{
|
||||
$(this).removeAttr('checked');
|
||||
}
|
||||
var moduleName = $(this).closest('.group-item').attr('data-module');
|
||||
var packageID = $(this).closest('.group-item').attr('data-package');
|
||||
var moduleName = $(this).closest('.group-item').attr('data-module');
|
||||
var packageID = $(this).closest('.group-item').attr('data-package');
|
||||
changeParentChecked($(this), moduleName, packageID);
|
||||
});
|
||||
|
||||
|
||||
@@ -62,6 +62,8 @@ $lang->group->privMethodName = 'Method Name';
|
||||
$lang->group->privView = 'View';
|
||||
$lang->group->privModule = 'Module';
|
||||
$lang->group->repeatPriv = 'The method name of the same module cannot be the same. Please modify the method name and try again.';
|
||||
$lang->group->dependPrivTips = 'Here are the selected permissions in the left Permission Dependency List, which are must-require assigned.';
|
||||
$lang->group->recommendPrivTips = 'Here are the recommended permissions in the left Permission Dependency List, which are recommended to be assigned.';
|
||||
|
||||
$lang->group->batchActions = 'Batch Operation';
|
||||
$lang->group->batchSetDependency = 'Batch Set Dependency';
|
||||
|
||||
@@ -62,6 +62,8 @@ $lang->group->privMethodName = 'Method Name';
|
||||
$lang->group->privView = 'View';
|
||||
$lang->group->privModule = 'Module';
|
||||
$lang->group->repeatPriv = 'The method name of the same module cannot be the same. Please modify the method name and try again.';
|
||||
$lang->group->dependPrivTips = 'Here are the selected permissions in the left Permission Dependency List, which are must-require assigned.';
|
||||
$lang->group->recommendPrivTips = 'Here are the recommended permissions in the left Permission Dependency List, which are recommended to be assigned.';
|
||||
|
||||
$lang->group->batchActions = 'Batch Operation';
|
||||
$lang->group->batchSetDependency = 'Batch Set Dependency';
|
||||
|
||||
@@ -62,6 +62,8 @@ $lang->group->privMethodName = 'Method Name';
|
||||
$lang->group->privView = 'View';
|
||||
$lang->group->privModule = 'Module';
|
||||
$lang->group->repeatPriv = 'The method name of the same module cannot be the same. Please modify the method name and try again.';
|
||||
$lang->group->dependPrivTips = 'Here are the selected permissions in the left Permission Dependency List, which are must-require assigned.';
|
||||
$lang->group->recommendPrivTips = 'Here are the recommended permissions in the left Permission Dependency List, which are recommended to be assigned.';
|
||||
|
||||
$lang->group->batchActions = 'Batch Operation';
|
||||
$lang->group->batchSetDependency = 'Batch Set Dependency';
|
||||
|
||||
@@ -62,6 +62,8 @@ $lang->group->privMethodName = '方法名';
|
||||
$lang->group->privView = '所属视图';
|
||||
$lang->group->privModule = '所属模块';
|
||||
$lang->group->repeatPriv = '同一模块名下的方法名不能相同,请修改后再试。';
|
||||
$lang->group->dependPrivTips = '此处所列的是左侧选中权限的依赖权限列表,是必须要分配的。';
|
||||
$lang->group->recommendPrivTips = '此处所列的是左侧选中权限的推荐权限列表,推荐分配。';
|
||||
|
||||
$lang->group->batchActions = '批量操作';
|
||||
$lang->group->batchSetDependency = '批量设置依赖';
|
||||
|
||||
@@ -2040,4 +2040,45 @@ class groupModel extends model
|
||||
}
|
||||
return $privs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dependent privs.
|
||||
*
|
||||
* @param array $privIdList
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getDependentPrivs($privIdList)
|
||||
{
|
||||
$relatedPrivs = $this->dao->select('t1.relationPriv,t2.parent,t2.module,t2.method,t3.`key`,t3.value')->from(TABLE_PRIVRELATION)->alias('t1')
|
||||
->leftJoin(TABLE_PRIV)->alias('t2')->on('t1.relationPriv=t2.id')
|
||||
->leftJoin(TABLE_PRIVLANG)->alias('t3')->on('t1.relationPriv=t3.objectID')
|
||||
->leftJoin(TABLE_PRIVMANAGER)->alias('t4')->on('t2.parent=t4.id')
|
||||
->where('t1.priv')->in($privIdList)
|
||||
->andWhere('t1.relationPriv')->notin($privIdList)
|
||||
->andWhere('t1.type')->eq('depend')
|
||||
->andWhere('t3.objectType')->eq('priv')
|
||||
->andWhere('t2.edition')->like("%,{$this->config->edition},%")
|
||||
->andWhere('t2.vision')->like("%,{$this->config->vision},%")
|
||||
->fetchAll('relationPriv');
|
||||
|
||||
if(empty($relatedPrivs)) return array();
|
||||
|
||||
$modulePairs = $this->getPrivManagerPairs('module');
|
||||
$managerList = $this->dao->select('*')->from(TABLE_PRIVMANAGER)->fetchAll('id');
|
||||
$relatedPrivs = $this->transformPrivLang($relatedPrivs);
|
||||
$privList = array('depend' => array(), 'recommend' => array());
|
||||
|
||||
foreach($relatedPrivs as $privID => $relatedPriv)
|
||||
{
|
||||
$module = $relatedPriv->module;
|
||||
if(!isset($privList['depend'][$module])) $privList['depend'][$module] = array();
|
||||
$moduleCode = $managerList[$relatedPriv->parent]->type == 'package' ? $managerList[$managerList[$relatedPriv->parent]->parent]->code : $managerList[$relatedPriv->parent]->code;
|
||||
$privList['depend'][$module]['title'] = $modulePairs[$module];
|
||||
$privList['depend'][$module]['children'][] = array('title' => $relatedPriv->name, 'relationPriv' => $privID);
|
||||
}
|
||||
|
||||
$privList['depend'] = array_values($privList['depend']);
|
||||
return $privList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id='mainContent'>
|
||||
<div id='mainContainer'>
|
||||
<div class='main main-content'>
|
||||
<form class="load-indicator main-form form-ajax" id="managePrivForm" method="post" target='hiddenwin'>
|
||||
<table class='table table-hover table-striped table-bordered' id='privList'>
|
||||
@@ -113,8 +113,8 @@
|
||||
|
||||
$i = 1;
|
||||
|
||||
$modulePrivs = count($privList[$moduleName], 1) - count($selectPrivs[$moduleName], 1);
|
||||
$moduleSelect = array_sum($selectPrivs[$moduleName]);
|
||||
$modulePrivs = count($privList[$moduleName], 1) - count($selectPrivs[$moduleName], 1);
|
||||
$moduleSelect = array_sum($selectPrivs[$moduleName]);
|
||||
?>
|
||||
<?php foreach($packages as $packageID => $privs):?>
|
||||
<tr class='<?php echo cycle('even, bg-gray');?>'>
|
||||
@@ -163,7 +163,8 @@
|
||||
<div class="side">
|
||||
<div class="priv-panel">
|
||||
<div class="panel-title">
|
||||
<?php echo $lang->group->dependentPrivs?>
|
||||
<?php echo $lang->group->dependentPrivs;?>
|
||||
<icon class='icon icon-help' data-toggle='popover' data-trigger='focus hover' data-placement='right' data-tip-class='text-muted popover-sm' data-content='<?php echo $lang->group->dependPrivTips;?>'></icon>
|
||||
</div>
|
||||
<div class="panel-content">
|
||||
<div class="menuTree depend menu-active-primary menu-hover-primary"></div>
|
||||
@@ -174,7 +175,8 @@
|
||||
</div>
|
||||
<div class="priv-panel mt-m">
|
||||
<div class="panel-title">
|
||||
<?php echo $lang->group->recommendPrivs?>
|
||||
<?php echo $lang->group->recommendPrivs;?>
|
||||
<icon class='icon icon-help' data-toggle='popover' data-trigger='focus hover' data-placement='right' data-tip-class='text-muted popover-sm' data-content='<?php echo $lang->group->recommendPrivTips;?>'></icon>
|
||||
</div>
|
||||
<div class="panel-content">
|
||||
<div class="menuTree recommend menu-active-primary menu-hover-primary"></div>
|
||||
@@ -198,9 +200,12 @@
|
||||
<?php endif;?>
|
||||
<?php js::set('groupID', $groupID);?>
|
||||
<?php js::set('menu', $menu);?>
|
||||
<?php js::set('relatedPrivData', $relatedPrivData);?>
|
||||
<script>
|
||||
$(document).ready(function()
|
||||
{
|
||||
$(".icon-help").popover();
|
||||
|
||||
/**
|
||||
* 隐藏列表标签。
|
||||
* Hide tabs except the browse list tab.
|
||||
|
||||
Reference in New Issue
Block a user