コード例 #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);
         }
     }
 }
コード例 #2
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));
     }
 }