simplify user_can_edit_user -- many nested if/else's to one if
This commit is contained in:
parent
b1d634a8de
commit
fc4bd27529
@ -494,27 +494,20 @@ class UserPage extends Extension {
|
|||||||
private function user_can_edit_user(User $a, User $b) {
|
private function user_can_edit_user(User $a, User $b) {
|
||||||
if($a->is_anonymous()) {
|
if($a->is_anonymous()) {
|
||||||
$this->theme->display_error(401, "Error", "You aren't logged in");
|
$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;
|
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 {
|
else {
|
||||||
if($a->can("edit_user_info")) {
|
$this->theme->display_error(401, "Error", "You need to be an admin to change other people's details");
|
||||||
return true;
|
return false;
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->theme->display_error(401, "Error", "You need to be an admin to change other people's details");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function redirect_to_user(User $duser) {
|
private function redirect_to_user(User $duser) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user