public function detailsAction() { if ($datas = $this->getRequest()->getParams()) { try { if (empty($datas['comment_id']) or empty($datas['option_value_id'])) { throw new Exception($this->_('An error occurred during process. Please try again later.')); } $comment_id = $datas['comment_id']; $comment = new Comment_Model_Comment(); if ($comment_id != 'new') { $comment->find($comment_id); if (!$comment->getId() or $comment->getValueId() != $this->getCurrentOptionValue()->getId()) { throw new Exception($this->_('An error occurred during process. Please try again later.')); } } else { $comment->setId($comment_id); } $html = $this->getLayout()->addPartial('view_details', 'core_view_mobile_default', "comment/l{$this->_layout_id}/view/details.phtml")->setCurrentComment($comment)->toHtml(); $html = array('html' => $html, 'title' => $this->getApplication()->getName()); } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage()); } $this->_sendHtml($html); } }
public function getComment() { if (is_null($this->_comment)) { $comment = new Comment_Model_Comment(); $comment->find($this->getCommentId()); $this->_comment = $comment; } return $this->_comment; }
public function editAction() { if ($this->getCurrentOptionValue()) { $comment_id = $this->getRequest()->getPost('comment_id'); $comment = new Comment_Model_Comment(); $comment->find($comment_id); if ($comment->getId() and $comment->getValueId() == $this->getCurrentOptionValue()->getId()) { $html = array('answers_html' => $this->getLayout()->addPartial('content', 'core_view_default', 'comment/application/edit/answers.phtml')->setCurrentComment($comment)->setOptionValue($this->getCurrentOptionValue())->toHtml()); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
public function showAction() { $html = ''; if ($id = $this->getRequest()->getParam('id')) { try { $comment = new Comment_Model_Comment(); $comment->find($id)->setisVisible(1)->save(); $html = array('success' => '1', 'success_message' => $this->_('Information successfully shown'), 'message_timeout' => 2, 'message_button' => 0, 'message_loader' => 0); } catch (Exception $e) { $html = array('error' => 1, 'message' => $e->getMessage()); } $this->getLayout()->setHtml(Zend_Json::encode($html)); } }
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); } } }