src/Auth/AuthMiddleware.php
public function hasAccessToComment($commentID)
    {

        $this->isLoggedIn();

        $userid = $this->di->get("session")->get("userid");
        $comment = new Comment();
        $comment->setDb($this->di->get("db"));
        $user = new User();
        $user->setDb($this->di->get("db"));

        $user->find("id", $userid);
        $comment->find("id", $commentID);

        if (($comment->user_id == $userid) || $this->isAdmin()) {
            return true;
        }
        $this->di->get("response")->redirect("user");
        return false;
    }
public function hasAccessToComment($commentID)
    {

        $this->isLoggedIn();

        $userid = $this->di->get("session")->get("userid");
        $comment = new Comment();
        $comment->setDb($this->di->get("db"));
        $user = new User();
        $user->setDb($this->di->get("db"));

        $user->find("id", $userid);
        $comment->find("id", $commentID);

        if (($comment->user_id == $userid) || $this->isAdmin()) {
            return true;
        }
        $this->di->get("response")->redirect("user");
        return false;
    }
public function hasAccessToComment ( $ commentID ) { $ this -> isLoggedIn ( ) ; $ userid = $ this -> di -> get ( "session" ) -> get ( "userid" ) ; $ comment = new Comment ( ) ; $ comment -> setDb ( $ this -> di -> get ( "db" ) ) ; $ user = new User ( ) ; $ user -> setDb ( $ this -> di -> get ( "db" ) ) ; $ user -> find ( "id" , $ userid ) ; $ comment -> find ( "id" , $ commentID ) ; if ( ( $ comment -> user_id == $ userid ) || $ this -> isAdmin ( ) ) { return true ; } $ this -> di -> get ( "response" ) -> redirect ( "user" ) ; return false ; }
Check if the user have access to the comment

@param integer $commentID Comment ID

@return boolean True if the user is admin or is the owner of the comment
Check if the user have access to the comment