public function flagcommentAction() { if ($value_id = $this->getRequest()->getParam('value_id') and $answer_id = $this->getRequest()->getParam('answer_id')) { $application = $this->getApplication(); $answer = new Comment_Model_Answer(); $answer->find($answer_id); $comment = new Comment_Model_Comment(); $comment->find($answer->getCommentId()); if ($answer->getId() and $comment->getValueId() == $value_id) { $answer->setFlag($answer->getFlag() + 1); $answer->save(); $message = $this->_('Your flag has successfully been notified'); $html = array('success' => 1, 'message' => $message); $this->_sendHtml($html); } } }
public function findallAction() { if ($comment_id = $this->getRequest()->getParam('comment_id')) { $comment = new Comment_Model_Comment(); $comment->find($comment_id); $customer = new Customer_Model_Customer(); $noLogo = $customer->getImageLink(); if ($comment->getId()) { $answer = new Comment_Model_Answer(); $answers = $answer->findByComment($comment->getId()); $data = array(); foreach ($answers as $answer) { $data[] = array("id" => $answer->getId(), "author" => $answer->getCustomerName(), "picture" => $noLogo, "message" => $answer->getText(), "created_at" => $this->_durationSince($answer->getCreatedAt())); } $this->_sendHtml($data); } } }
public function deleteAction() { if ($this->getRequest()->getPost() and $this->getCurrentOptionValue()) { try { $answer_id = $this->getRequest()->getPost('answer_id'); if (!$answer_id) { throw new Exception(''); } $answer = new Comment_Model_Answer(); $answer->find($answer_id); if ($answer->getId() and $answer->getComment()->getValueId() != $this->getCurrentOptionValue()->getId()) { throw new Exception(''); } $answer->delete(); $html = array('success' => 1); } catch (Exception $e) { $html = array('message' => $this->_('An error occurred while deleting this answer. Please try again later.'), 'message_button' => 1, 'message_loader' => 1); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }