public function setstatusAction() { $request = $this->getRequest(); $post_id = (int) $request->getPost('id'); $post = new DatabaseObject_BlogPost($this->db); if (!$post->loadForUser($this->identity->user_id, $post_id)) { $this->_redirect($this->getUrl()); } $url = $this->getUrl('preview') . '?id=' . $post->getId(); if ($request->getPost('edit')) { $this->_redirect($this->getUrl('edit') . '?id=' . $post->getId()); } else { if ($request->getPost('publish')) { $post->sendLive(); $post->save(); $this->messenger->addMessage('Post send live'); } else { if ($request->getPost('unpublish')) { $post->sendBackToDraft(); $post->save(); $this->messenger->addMessage('Post unpublished'); } else { if ($request->getPost('delete')) { $post->delete(); $url = $this->getUrl(); $this->messenger->addMessage('Post deleted'); } } } } $this->_redirect($url); }