Exemplo n.º 1
0
 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);
         }
     }
 }
Exemplo n.º 2
0
 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);
         }
     }
 }
Exemplo n.º 3
0
 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));
     }
 }