Index: trunk/core/kernel/application.php =================================================================== diff -u -r4594 -r4625 --- trunk/core/kernel/application.php (.../application.php) (revision 4594) +++ trunk/core/kernel/application.php (.../application.php) (revision 4625) @@ -1764,15 +1764,30 @@ return $ret; } - function CheckPermission($name, $cat_id = null) + /** + * Check current user permissions based on it's group permissions in specified category + * + * @param string $name permission name + * @param int $cat_id category id, current used if not specified + * @param int $type permission type {1 - system, 0 - per category} + * @return int + */ + function CheckPermission($name, $type, $cat_id = null) { if ($this->GetVar('u_id') == -1 && ($name == 'ADMIN' || $name == 'LOGIN')) { + // "root" is permitted to login in any case return 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); } @@ -1792,7 +1807,8 @@ $sql = 'SELECT PermissionValue FROM '.TABLE_PREFIX.'Permissions WHERE Permission = "'.$name.'" AND CatId = '.$category_id.' - AND GroupId IN ('.$groups.')'; + AND GroupId IN ('.$groups.') + AND Type = '.$type; $res = $this->Conn->GetOne($sql); if ($res !== false) { return $res;