Merge pull request #446 from shish/simplify_uceu
simplify user_can_edit_user -- many nested if/else's to one if
This commit is contained in:
commit
0744b50a71
1 changed files with 9 additions and 16 deletions
|
@ -494,27 +494,20 @@ class UserPage extends Extension {
|
|||
private function user_can_edit_user(User $a, User $b) {
|
||||
if($a->is_anonymous()) {
|
||||
$this->theme->display_error(401, "Error", "You aren't logged in");
|
||||
return false;
|
||||
}
|
||||
if($a->name == $b->name) {
|
||||
|
||||
if(
|
||||
($a->name == $b->name) ||
|
||||
($b->can("protected") && $a->class->name == "admin") ||
|
||||
(!$b->can("protected") && $a->can("edit_user_info"))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
if($b->can("protected")) {
|
||||
if($a->class->name == "admin") {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$this->theme->display_error(401, "Error", "You need to be an admin to change other people's details");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if($a->can("edit_user_info")) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
$this->theme->display_error(401, "Error", "You need to be an admin to change other people's details");
|
||||
}
|
||||
$this->theme->display_error(401, "Error", "You need to be an admin to change other people's details");
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private function redirect_to_user(User $duser) {
|
||||
|
|
Reference in a new issue