Index: branches/5.1.x/core/units/helpers/sections_helper.php =================================================================== diff -u -N -r13168 -r13750 --- branches/5.1.x/core/units/helpers/sections_helper.php (.../sections_helper.php) (revision 13168) +++ branches/5.1.x/core/units/helpers/sections_helper.php (.../sections_helper.php) (revision 13750) @@ -1,6 +1,6 @@ debugMode = $this->Application->isDebugMode(); + $this->superAdminMode = $this->Application->RecallVar('super_admin'); + $this->BuildTree(); } @@ -236,7 +254,7 @@ $current_data = isset($this->Tree[$section_name]) ? $this->Tree[$section_name] : Array(); if ($current_data) { - trigger_error('Section "' . $section_name . '" declaration (originally defined in "' . $current_data['SectionPrefix'] . '") was overwriten from "' . $prefix . '"', E_USER_NOTICE); + trigger_error('Section "' . $section_name . '" declaration (originally defined in "' . $current_data['SectionPrefix'] . '") was overwriten from "' . $prefix . '"', E_USER_WARNING); } $this->Tree[$section_name] = array_merge_recursive2($current_data, $section_params); @@ -276,11 +294,7 @@ // get 1st child ksort($children, SORT_NUMERIC); foreach ($children as $child_priority => $child_section) { - $section_data =& $this->getSectionData($child_section); - - $perm_section = $this->getPermSection($child_section); - $perm_status = $check_permission ? $this->Application->CheckPermission($perm_section.'.view') : true; - if ((isset($section_data['show_mode']) && $section_data['show_mode']) || !$perm_status) { + if (!$this->sectionVisible($child_section, $check_permission)) { continue; } @@ -294,6 +308,44 @@ } /** + * Checks if given section is visible by it's definition and optionally by user permission + * + * @param string $section_name + * @param bool $check_permission + * @return bool + */ + function sectionVisible($section_name, $check_permission = false) + { + $section_data =& $this->getSectionData($section_name); + + if (isset($section_data['show_mode']) && is_numeric($section_data['show_mode'])) { + $show_mode = $section_data['show_mode']; + + // if super admin section -> show in super admin mode & debug mode + $show_section = $show_mode == smNORMAL || ((($show_mode & smSUPER_ADMIN) == smSUPER_ADMIN) && ($this->superAdminMode || $this->debugMode)); + + if (!$show_section) { + // if section is in debug mode only && debug mode -> show + $show_section = (($show_mode & smDEBUG) == smDEBUG) && $this->debugMode; + } + + if (!$show_section) { + // visibility by section definition + return false; + } + } + + // visibility by section permission + if ($check_permission) { + $perm_section = $this->getPermSection($section_name); + + return $this->Application->CheckPermission($perm_section.'.view'); + } + + return true; + } + + /** * Returns section for permission checking based on given section * * @param string $section_name