Пример #1
0
 public function processFeedbackAction()
 {
     $post = $this->request->getPost();
     $form = new FeedbackForm();
     $form->setInputFilter(new FeedbackFilter());
     $form->setData($post);
     if (!$form->isValid()) {
         $model = new ViewModel(array('error' => true, 'form' => $form));
         $model->setTemplate('page/page/contacts');
         return $model;
     }
     $data = $form->getData();
     $sm = $this->getServiceLocator();
     $dbAdapter = $sm->get('DbAdapter');
     $feedback = new Feedback();
     $feedbackTable = new FeedbackTable($dbAdapter);
     $feedback->exchangeArray($data);
     $feedbackTable->save($feedback);
     return $this->redirect()->toRoute(NULL, array('controller' => 'page', 'action' => 'confirm-feedback'));
 }
Пример #2
0
 public function deleteFeedbackAction()
 {
     $this->auth();
     $feedbackTable = new FeedbackTable($this->getServiceLocator()->get('dbAdapter'));
     $request = $this->getRequest();
     $response = $this->getResponse();
     if ($request->isPost()) {
         $postData = $request->getPost();
         $feedbackId = (int) $postData->id;
         $rowset = $feedbackTable->deleteFeedback($feedbackId);
         if ($rowset) {
             $status = 'ok';
         } else {
             $status = 'bad';
         }
     }
     $answer = array('status' => $status);
     $response->setContent(\Zend\Json\Json::encode($answer));
     $response->getHeaders()->addHeaders(array('Content-Type' => 'application/json'));
     return $response;
 }