Index: trunk/core/units/general/helpers/permissions_helper.php =================================================================== diff -u -N -r6583 -r7391 --- trunk/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 6583) +++ trunk/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 7391) @@ -9,10 +9,10 @@ */ var $Permissions = Array(); - function LoadPermissions($group_id, $cat_id, $type = 1) + function LoadPermissions($group_id, $cat_id, $type = 1, $prefix = '') { $perm_table = $this->Application->getUnitOption('perm', 'TableName'); - $perm_table = $this->Application->GetTempName($perm_table); + $perm_table = $this->Application->GetTempName($perm_table, 'prefix:'.$prefix); $sql = 'SELECT * FROM '.$perm_table.' WHERE (GroupId = '.$group_id.') AND (CatId = '.$cat_id.') AND (Type = '.$type.')'; @@ -337,7 +337,7 @@ */ function CheckPermission($name, $type = 1, $cat_id = null) { - $user_id = $this->Application->GetVar('u_id'); + $user_id = $this->Application->RecallVar('user_id'); return $this->CheckUserPermission($user_id, $name, $type, $cat_id); } @@ -367,6 +367,17 @@ // that (perm cache creator) code thinks that it is allowed & adds corresponding record and code below will // return incorrect results + if ($user_id == $this->Application->RecallVar('user_id')) { + $groups = explode(',', $this->Application->RecallVar('UserGroups')); + } + else { // checking not current user + $sql = 'SELECT GroupId FROM '.TABLE_PREFIX.'UserGroup + WHERE (PortalUserId = '.$user_id.') AND + ( (MembershipExpires IS NULL) OR ( MembershipExpires >= UNIX_TIMESTAMP() ) )'; + $groups = $this->Conn->GetCol($sql); + array_push($groups, $this->Application->ConfigValue('User_LoggedInGroup') ); + } + if (preg_match('/(.*)\.VIEW$/', $name) && ($type == 0)) { // cached view permission of category: begin $sql = 'SELECT PermissionConfigId @@ -379,16 +390,6 @@ WHERE (PermId = '.$perm_id.') AND (CategoryId = '.$cat_id.')'; $view_filters = Array(); - if ($user_id == $this->Application->GetVar('u_id')) { - $groups = explode(',', $this->Application->RecallVar('UserGroups')); - } - else { // checking not current user - $sql = 'SELECT GroupId FROM '.TABLE_PREFIX.'UserGroup - WHERE (PortalUserId = '.$user_id.') AND - ( (MembershipExpires IS NULL) OR ( MembershipExpires >= UNIX_TIMESTAMP() ) )'; - $groups = $this->Conn->GetCol($sql); - array_push($groups, $this->Application->ConfigValue('User_LoggedInGroup') ); - } foreach ($groups as $group) { $view_filters[] = 'FIND_IN_SET('.$group.', ACL)'; } @@ -414,7 +415,7 @@ } $perm_value = 0; - $groups = $this->Application->RecallVar('UserGroups'); + $groups = implode(',',$groups); foreach ($cat_hierarchy as $category_id) { $sql = 'SELECT SUM(PermissionValue) FROM '.TABLE_PREFIX.'Permissions @@ -450,7 +451,7 @@ return 2; } - if ($owner_id == $this->Application->GetVar('u_id')) { + if ($owner_id == $this->Application->RecallVar('user_id')) { // user is item's OWNER -> check this permissions first $live_modify = $this->CheckPermission($perm_prefix.'.OWNER.MODIFY', ptCATEGORY, $category_id); if ($live_modify) {