mirror of
https://github.com/e107inc/e107.git
synced 2025-08-11 17:14:42 +02:00
Issue #5473 Permission improvements
This commit is contained in:
@@ -1280,6 +1280,18 @@ class e_admin_dispatcher
|
||||
return $this->adminMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the administrative menu data.
|
||||
*
|
||||
* @param array $menu The menu data to set.
|
||||
* @return $this
|
||||
*/
|
||||
public function setMenuData($menu)
|
||||
{
|
||||
$this->adminMenu = $menu;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get admin menu array
|
||||
* @return array
|
||||
@@ -1586,13 +1598,23 @@ class e_admin_dispatcher
|
||||
return 'e_admin_controller';
|
||||
}
|
||||
|
||||
public function hasPerms($perms)
|
||||
{
|
||||
return getperms($perms);
|
||||
}
|
||||
|
||||
public function setAccess($access)
|
||||
{
|
||||
$this->access = $access;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic Admin Menu Generator
|
||||
*
|
||||
* @return string
|
||||
* @return string|array
|
||||
*/
|
||||
public function renderMenu()
|
||||
public function renderMenu($debug=false)
|
||||
{
|
||||
|
||||
$tp = e107::getParser();
|
||||
@@ -1601,7 +1623,7 @@ class e_admin_dispatcher
|
||||
|
||||
foreach($this->getMenuData() as $key => $val)
|
||||
{
|
||||
if(isset($val['perm']) && $val['perm'] !== '' && !getperms($val['perm']))
|
||||
if(isset($val['perm']) && $val['perm'] !== '' && !$this->hasPerms($val['perm']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -1616,6 +1638,13 @@ class e_admin_dispatcher
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Check if the parent group has valid permissions
|
||||
$parentData = $this->getMenuData()[$parentKey] ?? null;
|
||||
if ($parentData && isset($parentData['perm']) && $parentData['perm'] !== '' && !$this->hasPerms($parentData['perm']))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1663,6 +1692,27 @@ class e_admin_dispatcher
|
||||
{
|
||||
if(!empty($item['sub']))
|
||||
{
|
||||
|
||||
$hasValidSubItems = false;
|
||||
foreach($item['sub'] as $subKey => $subItem)
|
||||
{
|
||||
if(isset($subItem['perm']) && $this->hasPerms($subItem['perm']))
|
||||
{
|
||||
$hasValidSubItems = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If no valid sub-items, remove the group
|
||||
if(!$hasValidSubItems)
|
||||
{
|
||||
unset($var[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$item['link'] = '#';
|
||||
$item['link_caret'] = true;
|
||||
$item['link_data'] = [
|
||||
@@ -1676,7 +1726,6 @@ class e_admin_dispatcher
|
||||
// Check if any sub-item is active to expand the parent
|
||||
foreach($item['sub'] as $subKey => &$subItem)
|
||||
{
|
||||
|
||||
if($selected === $subKey && !empty($subItem['group']))
|
||||
{
|
||||
$parent = $subItem['group'];
|
||||
@@ -1719,7 +1768,10 @@ class e_admin_dispatcher
|
||||
|
||||
$var['_extras_'] = array('icon' => $icon, 'return' => true);
|
||||
|
||||
// e107::getMessage()->addDebug(print_a($var, true));
|
||||
if($debug)
|
||||
{
|
||||
return $var;
|
||||
}
|
||||
|
||||
return $toggle . e107::getNav()->admin($this->getMenuTitle(), $selected, $var);
|
||||
|
||||
|
@@ -45,11 +45,11 @@ class plugin_blank_admin extends e_admin_dispatcher
|
||||
* @var array
|
||||
*/
|
||||
protected $adminMenu = array(
|
||||
'main/list' => array('caption'=> 'Manage', 'perm' => '0'),
|
||||
'main/create' => array('caption'=> 'LAN_CREATE', 'perm' => '0'),
|
||||
'main/list' => array('caption'=> 'Manage', 'perm' => 'P'),
|
||||
'main/create' => array('caption'=> 'LAN_CREATE', 'perm' => 'P'),
|
||||
'main/prefs' => array('caption'=> 'Settings', 'perm' => '0', 'icon'=>'fa-cog'),
|
||||
'main/custom' => array('caption'=> 'Custom Pages', 'perm' => '0', 'icon'=>'fa-asterisk'),
|
||||
'main/custom1' => array('group'=>'main/custom', 'caption' => 'Custom Page 1', 'perm' => '0', 'icon' => ''),
|
||||
'main/custom' => array('caption'=> 'Custom Pages', 'perm' => 'P', 'icon'=>'fa-asterisk'),
|
||||
'main/custom1' => array('group'=>'main/custom', 'caption' => 'Custom Page 1', 'perm' => 'P', 'icon' => ''),
|
||||
'main/custom2' => array('group'=>'main/custom', 'caption' => 'Custom Page 2', 'perm' => '0', 'icon' => ''),
|
||||
);
|
||||
|
||||
|
@@ -1425,7 +1425,7 @@ td.visible-print,th.visible-print{display:table-cell!important}
|
||||
}
|
||||
.popover{color:#fff}
|
||||
.popover-title{font-weight:700}
|
||||
.navbar{background-image:linear-gradient(#303030,#212121 60%,#171717);filter:none;border:1px solid rgba(0,0,0,.6);text-shadow:1px 1px 1px rgba(0,0,0,.3)}
|
||||
.navbar{background-image:linear-gradient(#303030,#212121 60%,#171717);filter:none;border:2px solid #000;text-shadow:1px 1px 1px rgba(0,0,0,.3)}
|
||||
.navbar-inverse{background-image:linear-gradient(#303030,#212121 60%,#171717);filter:none}
|
||||
.navbar-inverse .badge{background-color:#080808}
|
||||
.navbar-nav>li>a{ border-right:1px solid rgba(0,0,0,.2);border-left:1px solid rgba(255,255,255,.1)}
|
||||
@@ -1543,9 +1543,9 @@ div.admin-left-panel .panel { background: none; border:0}
|
||||
|
||||
span.sidebar-toggle-switch { float: right; display: block; width: 20px; height: 20px; cursor: pointer; }
|
||||
|
||||
thead tr, .navbar { background-image: none !important; border-left:0; border-right:0; background-color: #2f2f2f; }
|
||||
thead tr { background-image: none !important; border-left:0; border-right:0; background-color: #2f2f2f; }
|
||||
thead th, thead tr, .table > thead > tr > th { border-bottom: 0; border-left:0; border-right:0 }
|
||||
|
||||
.navbar { background-image: none !important; }
|
||||
|
||||
|
||||
|
||||
@@ -1564,8 +1564,13 @@ thead th, thead tr, .table > thead > tr > th { border-bottom: 0; border-left:0;
|
||||
background: #373737;
|
||||
height: 100%;
|
||||
padding-left: 5px;
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
div.is-table-row .admin-left-panel:hover {
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
div.is-table-row .admin-right-panel {
|
||||
padding-left: 100px;
|
||||
width:100%;
|
||||
|
Reference in New Issue
Block a user