예제 #1
0
 public function addreportAction()
 {
     if (!$this->_helper->requireUser()->isValid()) {
         return;
     }
     $user_id = $this->_helper->api()->user()->getViewer()->getIdentity();
     $qid = $this->getRequest()->getParam('qid');
     $objReport = new Questionanswer_Model_Report(array());
     $this->view->form = $form = new Questionanswer_Form_Index_AddReport();
     $id = '0';
     // Posting form
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $data_array = $form->getValues();
             $url = $data_array['qid'];
             $date_updated = date('Y-m-d H:i:s');
             $objReport->addReports($user_id, $data_array['type'], $data_array['content'], $url, $date_updated);
         }
         $this->_forward('success', 'utility', 'core', array('smoothboxClose' => true, 'parentRefresh' => true, 'format' => 'smoothbox', 'messages' => array('Sent report successful!.')));
     } else {
         foreach ($form->getElements() as $name => $element) {
             if ($name == "qid") {
                 $element->setValue($qid);
             }
         }
     }
 }