Fixed error regarding User::is_level_or_lower().
It was returning false for anonymous users, it now returns true.
This commit is contained in:
parent
46fcd2f21b
commit
678b055f52
@ -831,11 +831,6 @@ class User extends Rails\ActiveRecord\Base
|
||||
|
||||
private function parse_is_level_or($method)
|
||||
{
|
||||
# For anonymous users
|
||||
if (!$this->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list($name, $operator) = explode('_or_', substr($method, 3));
|
||||
$name = ucfirst($name);
|
||||
$levels = CONFIG()->user_levels;
|
||||
@ -845,9 +840,19 @@ class User extends Rails\ActiveRecord\Base
|
||||
$level = $levels[$name];
|
||||
|
||||
if ($operator == 'higher') {
|
||||
return $this->level >= $level;
|
||||
# For anonymous users
|
||||
if (!$this->id) {
|
||||
return false;
|
||||
} else {
|
||||
return $this->level >= $level;
|
||||
}
|
||||
} elseif ($operator == 'lower') {
|
||||
return $this->level <= $level;
|
||||
# For anonymous users
|
||||
if (!$this->id) {
|
||||
return true;
|
||||
} else {
|
||||
return $this->level <= $level;
|
||||
}
|
||||
} else {
|
||||
throw new InvalidArgumentException("Invalid user level operator " . $operator);
|
||||
}
|
||||
|
Reference in New Issue
Block a user