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
					
				@ -494,29 +494,22 @@ 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");
 | 
			
		||||
		}
 | 
			
		||||
		if($a->name == $b->name) {
 | 
			
		||||
			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");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if(
 | 
			
		||||
			($a->name == $b->name) ||
 | 
			
		||||
			($b->can("protected") && $a->class->name == "admin") ||
 | 
			
		||||
			(!$b->can("protected") && $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");
 | 
			
		||||
			return false;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	private function redirect_to_user(User $duser) {
 | 
			
		||||
		global $page, $user;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user