/** * delete comment (via ajax) */ public function deleteAction() { $add_comment_form = new Application_Form_AddComment(); $comment_id = (int) $this->getRequest()->getParam('comment_id'); $resource_id = (int) $this->getRequest()->getParam('resource_id'); $resource_type = $this->getRequest()->getParam('resource_type'); $Comments = new Application_Model_Comments(); $Comments->deleteComment($comment_id); $new_comments_data = $Comments->getCommentsForResources(array($resource_id), $resource_type); $this->view->comments = isset($new_comments_data[$resource_id]) ? $new_comments_data[$resource_id] : false; $this->view->resource_type = $resource_type; $this->view->resource_id = $resource_id; $this->view->add_comment_form = $add_comment_form; $comments_html = $this->view->render('/partial/comments.phtml'); $json = array(); $json['html'] = $comments_html; $this->getHelper('json')->sendJson($json); }
/** * Update reported resource (via ajax) */ public function updatereportedAction() { $report_id = (int) $this->getRequest()->getParam('report_id'); $mark_reported = (int) $this->getRequest()->getParam('mark_reported'); $Reports = new Application_Model_Reports(); $report = $Reports->getReport($report_id); $ret = false; if ($mark_reported == 1) { switch ($report['resource_type']) { case 'post': // posts $Posts = new Application_Model_Posts(); $ret = $Posts->markHidden($report['resource_id']); break; case 'user': case 'group': case 'page': // profiles $Profiles = new Application_Model_Profiles(); $ret = $Profiles->markHidden($report['resource_id']); break; case 'message': // messages $Messages = new Application_Model_Messages(); $ret = $Messages->markHidden($report['resource_id']); break; case 'comment': // comments $Comments = new Application_Model_Comments(); $ret = $Comments->deleteComment($report['resource_id']); break; case 'image': // images $Images = new Application_Model_Images(); $ret = $Images->deleteImage($report['resource_id'], 'posts'); $Reports->clearReports($report['resource_id'], 'image'); break; default: break; } } $Reports->updateReport($report_id, $mark_reported); $this->getHelper('json')->sendJson($ret); }
public function deleteAction() { $cid = $this->getRequest()->getParam('cid'); if ($cid) { $model = new Application_Model_Comments(); $model->deleteComment($cid); } $this->redirect('comments/list'); }