Index: trunk/core/units/general/helpers/permissions_helper.php =================================================================== diff -u -N -r6093 -r6428 --- trunk/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 6093) +++ trunk/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 6428) @@ -305,6 +305,7 @@ if (!$this->Application->LoggedIn()) { $redirect_template = $params['login_template']; + if (!$redirect_template && $this->Application->IsAdmin()) $redirect_template = 'login'; $redirect_params = Array('next_template' => $t); } else { @@ -335,7 +336,13 @@ */ function CheckPermission($name, $type = 1, $cat_id = null) { - if ($this->Application->GetVar('u_id') == -1) { + $user_id = $this->Application->GetVar('u_id'); + return $this->CheckUserPermission($user_id, $name, $type, $cat_id); + } + + function CheckUserPermission($user_id, $name, $type = 1, $cat_id = null) + { + if ($user_id == -1) { // "root" is allowed anywhere return $name == 'SYSTEM_ACCESS.READONLY' ? 0 : 1; } @@ -371,7 +378,16 @@ WHERE (PermId = '.$perm_id.') AND (CategoryId = '.$cat_id.')'; $view_filters = Array(); - $groups = explode(',', $this->Application->RecallVar('UserGroups')); + 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)'; }