From 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Thu, 12 Jul 2012 11:21:01 +0000 Subject: standardize the use of unix eol; use svn properties to enforce native eol --- .../day4/blog/protected/pages/posts/ReadPost.php | 112 ++++++++++----------- 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ReadPost.php') diff --git a/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ReadPost.php b/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ReadPost.php index 2aeaa4d3..4c2035e6 100644 --- a/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ReadPost.php +++ b/demos/blog-tutorial/samples/day4/blog/protected/pages/posts/ReadPost.php @@ -1,57 +1,57 @@ -Request['id']; - // retrieves PostRecord with author information filled in - $this->_post=PostRecord::finder()->withAuthor()->findByPk($postID); - if($this->_post===null) // if post id is invalid - throw new THttpException(500,'Unable to find the specified post.'); - // set the page title as the post title - $this->Title=$this->_post->title; - } - - /** - * @return PostRecord the PostRecord currently being viewed - */ - public function getPost() - { - return $this->_post; - } - - /** - * Deletes the post currently being viewed - * This method is invoked when the user clicks on the "Delete" button - */ - public function deletePost($sender,$param) - { - // only the author or the administrator can delete a post - if(!$this->canEdit()) - throw new THttpException('You are not allowed to perform this action.'); - // delete it from DB - $this->_post->delete(); - // redirect the browser to the homepage - $this->Response->redirect($this->Service->DefaultPageUrl); - } - - /** - * @return boolean whether the current user can edit/delete the post being viewed - */ - public function canEdit() - { - // only the author or the administrator can edit/delete a post - return $this->User->Name===$this->Post->author_id || $this->User->IsAdmin; - } -} - +Request['id']; + // retrieves PostRecord with author information filled in + $this->_post=PostRecord::finder()->withAuthor()->findByPk($postID); + if($this->_post===null) // if post id is invalid + throw new THttpException(500,'Unable to find the specified post.'); + // set the page title as the post title + $this->Title=$this->_post->title; + } + + /** + * @return PostRecord the PostRecord currently being viewed + */ + public function getPost() + { + return $this->_post; + } + + /** + * Deletes the post currently being viewed + * This method is invoked when the user clicks on the "Delete" button + */ + public function deletePost($sender,$param) + { + // only the author or the administrator can delete a post + if(!$this->canEdit()) + throw new THttpException('You are not allowed to perform this action.'); + // delete it from DB + $this->_post->delete(); + // redirect the browser to the homepage + $this->Response->redirect($this->Service->DefaultPageUrl); + } + + /** + * @return boolean whether the current user can edit/delete the post being viewed + */ + public function canEdit() + { + // only the author or the administrator can edit/delete a post + return $this->User->Name===$this->Post->author_id || $this->User->IsAdmin; + } +} + ?> \ No newline at end of file -- cgit v1.2.3