/** * @param IWebUser $user the user * @return boolean whether the page can be accessed according to the user group level */ protected function isLevelMatched($user) { if ((int) $user->getLevel() === UserGroupsUser::ROOT_LEVEL || empty($this->level)) { return true; } else { if (UserGroupsConfiguration::findRule('super_admin') && isset(Yii::app()->user->accessRules['userGroups']['admin']['admin'])) { return true; } else { if ($user->getIsGuest() || $user->getRecovery()) { return false; } } } // check if all the rules have to match to grant access if (isset($this->level['strict'])) { $strict = true; } foreach ($this->level as $l) { if (is_numeric($l) && $l === $user->getLevel()) { $return = true; } else { if (!is_numeric($l)) { $comparison = $user->getLevel() . $l; if (eval("return {$comparison};")) { $return = true; } else { $strict_end = false; } } else { $strict_end = false; } } // if the rule is not strict and there was a match returns true // otherwise if the rule is strict and there's not return return false if (!isset($strict) && isset($return)) { return true; } else { if (isset($strict) && isset($strict_end)) { return false; } } } if (isset($return)) { return $return; } return false; }