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:
Daku 2014-08-26 15:19:27 +01:00
commit 0744b50a71

View file

@ -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) {