Index: trunk/core/kernel/application.php =================================================================== diff -u -r4814 -r4840 --- trunk/core/kernel/application.php (.../application.php) (revision 4814) +++ trunk/core/kernel/application.php (.../application.php) (revision 4840) @@ -1977,48 +1977,8 @@ */ function CheckPermission($name, $type = 1, $cat_id = null) { - if ($this->GetVar('u_id') == -1) { - // "root" is allowed anywhere - return $name == 'SYSTEM_ACCESS.READONLY' ? 0 : 1; - } - - if ($type == 1) { - // "system" permission are always checked per "Home" category (ID = 0) - $cat_id = 0; - } - - if (!isset($cat_id)) { - $cat_id = $this->GetVar('m_cat_id'); - } - - if ($cat_id == 0) { - $cat_hierarchy = Array(0); - } - else { - $sql = 'SELECT ParentPath FROM '.$this->getUnitOption('c', 'TableName').' WHERE CategoryId = '.$cat_id; - $cat_hierarchy = $this->Conn->GetOne($sql); - $cat_hierarchy = explode('|', $cat_hierarchy); - array_shift($cat_hierarchy); - array_pop($cat_hierarchy); - $cat_hierarchy = array_reverse($cat_hierarchy); - array_push($cat_hierarchy, 0); - } - - $groups = $this->RecallVar('UserGroups'); - - foreach ($cat_hierarchy as $category_id) { - $sql = 'SELECT PermissionValue FROM '.TABLE_PREFIX.'Permissions - WHERE Permission = "'.$name.'" - AND CatId = '.$category_id.' - AND GroupId IN ('.$groups.') - AND Type = '.$type; - $res = $this->Conn->GetOne($sql); - if ($res !== false) { - return $res; - } - } - - return 0; + $perm_helper =& $this->recallObject('PermissionsHelper'); + return $perm_helper->CheckPermission($name, $type, $cat_id); } /**