From abf9c1903c67354ae017a20a33c308eaf0a77b1e Mon Sep 17 00:00:00 2001 From: stinkinkevin Date: Sun, 25 Oct 2015 17:04:40 -0700 Subject: [PATCH] Add the 'enable' method in PostController --- app/Controller/PostController.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/Controller/PostController.php b/app/Controller/PostController.php index 7545f70..37f832d 100644 --- a/app/Controller/PostController.php +++ b/app/Controller/PostController.php @@ -129,5 +129,27 @@ function disable($id=null){ } } + function enable($id=null){ + $post=$this->Post->read(null,$id); + if (!id && empty($post)) { + $this->Session->setFlash(__('You must provide a valid ID number to disable a post', true)); + $this->redirect(array('action'=>'index')); + } + + if (!empty($post)) { + $post['Post']['published'] = 1; + if ($this->Post->save($post)){ + $this->Session->setFlash(__('Post ID '.$id.' has been enabled.',true)); + } else { + $this->Session->setFlash(__('Post ID'.$id.' was not saved.',true)); + } + $this->redirect(array('action'=>'index')); + } else { + $this->Session->setFlash(__('No Post by that ID was found.', true)); + $this->redirect(array('action'=>'index')); + } + + } + } ?> \ No newline at end of file