Add function is_admin() to Session
This commit is contained in:
		
							parent
							
								
									ac16070040
								
							
						
					
					
						commit
						332d13a0c8
					
				@ -65,11 +65,17 @@ final class Session
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static function is_admin(){
 | 
			
		||||
        if (!self::is_login()) return false;
 | 
			
		||||
 | 
			
		||||
        $O_userModel = new UserModel();
 | 
			
		||||
        return $O_userModel->isUserAdmin($_SESSION["ID"]);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public static function admin_or_die(){
 | 
			
		||||
        Session::login_or_die();
 | 
			
		||||
 | 
			
		||||
        $O_userModel = new UserModel();
 | 
			
		||||
        if (!$O_userModel->isUserAdmin($_SESSION["ID"])) {
 | 
			
		||||
        if (!self::is_admin()) {
 | 
			
		||||
            header("Location: /");
 | 
			
		||||
            die();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user