Index: branches/5.0.x/core/units/helpers/sections_helper.php =================================================================== diff -u -N -r13528 -r13572 --- branches/5.0.x/core/units/helpers/sections_helper.php (.../sections_helper.php) (revision 13528) +++ branches/5.0.x/core/units/helpers/sections_helper.php (.../sections_helper.php) (revision 13572) @@ -1,6 +1,6 @@ debugMode = $this->Application->isDebugMode(); + $this->superAdminMode = $this->Application->RecallVar('super_admin'); + $this->BuildTree(); } @@ -269,11 +287,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; } @@ -287,6 +301,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 Index: branches/5.0.x/core/units/admin/admin_tag_processor.php =================================================================== diff -u -N -r12972 -r13572 --- branches/5.0.x/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 12972) +++ branches/5.0.x/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 13572) @@ -1,6 +1,6 @@ SelectParam($params, 'name,render_as,block'); $sections_helper =& $this->Application->recallObject('SectionsHelper'); + /* @var $sections_helper kSectionsHelper */ + $section_data =& $sections_helper->getSectionData($section_name); $params['children_count'] = isset($section_data['children']) ? count($section_data['children']) : 0; @@ -101,24 +103,10 @@ return $ret; } - $debug_mode = $this->Application->isDebugMode(); - $super_admin_mode = $this->Application->RecallVar('super_admin'); - ksort($section_data['children'], SORT_NUMERIC); foreach ($section_data['children'] as $section_name) { - $section_data =& $sections_helper->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) && ($super_admin_mode || $debug_mode)); - if (!$show_section) { - // if section is in debug mode only && debug mode -> show - $show_section = (($show_mode & smDEBUG) == smDEBUG) && $debug_mode; - } - if (!$show_section) { - continue; - } + if (!$sections_helper->sectionVisible($section_name)) { + continue; } $params['section_name'] = $section_name; @@ -250,25 +238,13 @@ return ''; } - $debug_mode = $this->Application->isDebugMode(); - $super_admin_mode = $this->Application->RecallVar('super_admin'); - ksort($section_data['children'], SORT_NUMERIC); foreach ($section_data['children'] as $section_name) { $params['section_name'] = $section_name; $section_data =& $sections_helper->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) && ($super_admin_mode || $debug_mode)); - if (!$show_section) { - // if section is in debug mode only && debug mode -> show - $show_section = (($show_mode & smDEBUG) == smDEBUG) && $debug_mode; - } - if (!$show_section) { - continue; - } + if (!$sections_helper->sectionVisible($section_name)) { + continue; } if (isset($section_data['tabs_only']) && $section_data['tabs_only']) {