Skip to content

Commit

Permalink
Hide global configuration and system information from non super users (
Browse files Browse the repository at this point in the history
…#19697)

* Hide global configuration and system information from non super users

* Use identical operator
  • Loading branch information
Quy authored and Michael Babker committed Feb 26, 2018
1 parent 47b8972 commit eb68081
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 deletions administrator/modules/mod_menu/menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function load($params, $enabled)
$this->enabled = $enabled;
$menutype = $this->params->get('menutype', '*');

if ($menutype == '*')
if ($menutype === '*')
{
$name = $this->params->get('preset', 'joomla');
$levels = MenuHelper::loadPreset($name);
Expand Down Expand Up @@ -256,7 +256,7 @@ protected function preprocess($items)
$item->icon = isset($item->icon) ? $item->icon : '';

// Whether this scope can be displayed. Applies only to preset items. Db driven items should use un/published state.
if (($item->scope == 'help' && !$this->params->get('showhelp')) || ($item->scope == 'edit' && !$this->params->get('shownew')))
if (($item->scope === 'help' && !$this->params->get('showhelp')) || ($item->scope === 'edit' && !$this->params->get('shownew')))
{
continue;
}
Expand All @@ -282,20 +282,20 @@ protected function preprocess($items)
}

// Exclude Mass Mail if disabled in global configuration
if ($item->scope == 'massmail' && (JFactory::getApplication()->get('massmailoff', 0) == 1))
if ($item->scope === 'massmail' && (JFactory::getApplication()->get('massmailoff', 0) == 1))
{
continue;
}

// Exclude item if the component is not authorised
$assetName = $item->element;

if ($item->element == 'com_categories')
if ($item->element === 'com_categories')
{
parse_str($item->link, $query);
$assetName = isset($query['extension']) ? $query['extension'] : 'com_content';
}
elseif ($item->element == 'com_fields')
elseif ($item->element === 'com_fields')
{
parse_str($item->link, $query);

Expand All @@ -314,14 +314,27 @@ protected function preprocess($items)

list($assetName) = isset($query['context']) ? explode('.', $query['context'], 2) : array('com_fields');
}
elseif ($item->element === 'com_config' && !$user->authorise('core.admin'))
{
continue;
}
elseif ($item->element === 'com_admin')
{
parse_str($item->link, $query);

if (isset($query['view']) && $query['view'] === 'sysinfo' && !$user->authorise('core.admin'))
{
continue;
}
}

if ($assetName && !$user->authorise(($item->scope == 'edit') ? 'core.create' : 'core.manage', $assetName))
if ($assetName && !$user->authorise(($item->scope === 'edit') ? 'core.create' : 'core.manage', $assetName))
{
continue;
}

// Exclude if link is invalid
if (!in_array($item->type, array('separator', 'heading', 'container')) && trim($item->link) == '')
if (!in_array($item->type, array('separator', 'heading', 'container')) && trim($item->link) === '')
{
continue;
}
Expand All @@ -330,7 +343,7 @@ protected function preprocess($items)
$item->submenu = $this->preprocess($item->submenu);

// Populate automatic children for container items
if ($item->type == 'container')
if ($item->type === 'container')
{
$exclude = (array) $item->params->get('hideitems') ?: array();
$components = MenusHelper::getMenuItems('main', false, $exclude);
Expand All @@ -347,7 +360,7 @@ protected function preprocess($items)
}

// Remove repeated and edge positioned separators, It is important to put this check at the end of any logical filtering.
if ($item->type == 'separator')
if ($item->type === 'separator')
{
if ($noSeparator)
{
Expand All @@ -368,7 +381,7 @@ protected function preprocess($items)
$language->load($item->element . '.sys', JPATH_ADMINISTRATOR . '/components/' . $item->element, null, false, true);
}

if ($item->type == 'separator' && $item->params->get('text_separator') == 0)
if ($item->type === 'separator' && $item->params->get('text_separator') == 0)
{
$item->title = '';
}
Expand Down Expand Up @@ -402,11 +415,11 @@ protected function populateTree($levels)
{
$class = $this->enabled ? $item->class : 'disabled';

if ($item->type == 'separator')
if ($item->type === 'separator')
{
$this->tree->addChild(new Node\Separator($item->title));
}
elseif ($item->type == 'heading')
elseif ($item->type === 'heading')
{
// We already excluded heading type menu item with no children.
$this->tree->addChild(new Node\Heading($item->title, $class, null, $item->icon), $this->enabled);
Expand All @@ -417,7 +430,7 @@ protected function populateTree($levels)
$this->tree->getParent();
}
}
elseif ($item->type == 'url')
elseif ($item->type === 'url')
{
$cNode = new Node\Url($item->title, $item->link, $item->browserNav, $class, null, $item->icon);
$this->tree->addChild($cNode, $this->enabled);
Expand All @@ -428,7 +441,7 @@ protected function populateTree($levels)
$this->tree->getParent();
}
}
elseif ($item->type == 'component')
elseif ($item->type === 'component')
{
$cNode = new Node\Component($item->title, $item->element, $item->link, $item->browserNav, $class, null, $item->icon);
$this->tree->addChild($cNode, $this->enabled);
Expand All @@ -439,7 +452,7 @@ protected function populateTree($levels)
$this->tree->getParent();
}
}
elseif ($item->type == 'container')
elseif ($item->type === 'container')
{
// We already excluded container type menu item with no children.
$this->tree->addChild(new Node\Container($item->title, $item->class, null, $item->icon), $this->enabled);
Expand Down

0 comments on commit eb68081

Please sign in to comment.