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