/**
  * Edit reported post
  */
 public function editpostAction()
 {
     $Reports = new Application_Model_Reports();
     $total_counts = $Reports->getTotalCount();
     $this->buildMenu($total_counts);
     $request = $this->getRequest();
     $page = (int) $request->getParam('page');
     $post_id = (int) $request->getParam('post');
     $Posts = new Application_Model_Posts();
     $post = $Posts->getPost($post_id);
     // load and fill up form
     $edit_post_form = new Application_Form_EditPost();
     $edit_post_form->getElement('content')->setValue($post['content']);
     $edit_post_form->getElement('privacy')->setValue($post['privacy']);
     $this->view->edit_post_form = $edit_post_form;
     if ($request->isPost() && $edit_post_form->isValid($_POST)) {
         $content = $edit_post_form->getElement('content')->getValue();
         $privacy = $edit_post_form->getElement('privacy')->getValue();
         $new_post_content = Application_Plugin_Common::preparePost($content);
         $Posts->updatePost($post_id, $new_post_content, $privacy);
         Application_Plugin_Alerts::success($this->view->translate('Post updated'));
         if ($page > 0) {
             $this->redirect('reports/reviewposts/page/' . $page);
         }
     }
 }
 /**
  * Edit post (ajax)
  */
 public function editAction()
 {
     $request = $this->getRequest();
     $post_id = (int) $request->getParam('post');
     $Posts = new Application_Model_Posts();
     $post = $Posts->getPost($post_id, true);
     $posts_wall_profile = $Posts->getPostsWallProfileData($post_id);
     if (!$post) {
         $this->getHelper('json')->sendJson($this->view->translate('Resource not available'));
         return;
     }
     // load and fill up form
     $edit_post_form = new Application_Form_EditPost();
     $edit_post_form->getElement('content')->setValue(html_entity_decode($post['content']));
     $edit_post_form->getElement('privacy')->setValue($post['privacy']);
     // no privacy edit for groups & pages
     if ($posts_wall_profile['type'] == 'group' || $posts_wall_profile['type'] == 'page') {
         $edit_post_form->removeElement('privacy');
     }
     // get and render form only
     if ($request->isPost() && $request->getParam('form_render')) {
         $edit_post_form->setAction(Zend_Controller_Front::getInstance()->getBaseUrl() . '/posts/edit/post/' . $post_id);
         $this->getHelper('json')->sendJson($edit_post_form->render());
         return;
     }
     if ($request->isPost() && $edit_post_form->isValid($_POST)) {
         $content = $edit_post_form->getElement('content')->getValue();
         if ($edit_post_form->getElement('privacy') && $edit_post_form->getElement('privacy')->getValue()) {
             $privacy = $edit_post_form->getElement('privacy')->getValue();
         } else {
             $privacy = $post['privacy'];
         }
         $new_post_content = Application_Plugin_Common::preparePost($content);
         $Posts->updatePost($post_id, $new_post_content, $privacy);
         $this->getHelper('json')->sendJson($this->view->RenderOutput($new_post_content['content'], 'post'));
         return;
     }
     $this->getHelper('json')->sendJson($this->view->translate('Error - not permitted'));
     return;
 }