/** * This is the default method routed to by the frontcontroller */ public function actionIndex() { $this->addView('library/index'); $books = BookDao::get()->findAll(); $id = $this->_auth->getId(); $user = \ezmvc\dao\UserDAO::get()->findById($id); $this->username = $user->Username; $this->firstname = $user->FirstName; $this->lastname = $user->LastName; }
/** * Checks if a user is logged in as the owner of the specified book entry * and throws an exception if not. * @param <type> $table * @param <type> $postid * @return <type> */ private function _requireOwner($id) { $userid = $this->_requireLogin(); $book = BookDao::get()->findById($id); if ($book->UserId !== $userid) { throw new lib\AuthException('You need to be logged in as the owner to perform this operation.'); } }