Index: branches/RC/core/units/general/helpers/sections_helper.php =================================================================== diff -u -r8929 -r9046 --- branches/RC/core/units/general/helpers/sections_helper.php (.../sections_helper.php) (revision 8929) +++ branches/RC/core/units/general/helpers/sections_helper.php (.../sections_helper.php) (revision 9046) @@ -160,6 +160,57 @@ } return $ret; } + + /** + * Returns first child, that is not a folder + * + * @param string $section_name + * @param Array $tree + * @return stirng + */ + function getFirstChild($section_name, $check_permission = false) + { + $section_data =& $this->getSectionData($section_name); + + $children = isset($section_data['children']) && $section_data['children'] ? $section_data['children'] : false; + if ($children) { + // 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) { + continue; + } + + break; + } + + return $this->getFirstChild($child_section, $check_permission); + } + + return $section_name; + } + + /** + * Returns section for permission checking based on given section + * + * @param string $section_name + * @return string + */ + function getPermSection($section_name) + { + $ret = $section_name; + $section_data =& $this->getSectionData($section_name); + + if ($section_data && isset($section_data['perm_prefix'])) { + // this section uses other section permissions + $ret = $this->Application->getUnitOption($section_data['perm_prefix'].'.main', 'PermSection'); + } + return $ret; + } } ?> \ No newline at end of file