Skip to content

Commit

Permalink
Add the 'enable' method in PostController
Browse files Browse the repository at this point in the history
  • Loading branch information
stinkinkevin committed Oct 26, 2015
1 parent e6d32b6 commit abf9c19
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions app/Controller/PostController.php
Expand Up @@ -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'));
}

}

}
?>

0 comments on commit abf9c19

Please sign in to comment.