Example #1
0
 public function responseAction()
 {
     $id = $this->_request->getParam('id', 0);
     if (!$id) {
         $this->_redirect('/ads/categories-list/');
     }
     $ads = new Ads();
     $ad = $ads->find($id)->current();
     if (!$ad) {
         $this->_redirect('/ads/categories-list/');
     }
     $form = new AdsResponseForm();
     $form->getSubForm('ads_responses')->getElement('ad_id')->setValue($id);
     if (Standart_Main::buttonPressed('doResponse')) {
         if ($form->isValid($_POST)) {
             $values = $form->getValues();
             $akismetData = array('user_ip' => $_SERVER['REMOTE_ADDR'], 'user_agent' => $_SERVER['HTTP_USER_AGENT'], 'comment_type' => 'comment', 'comment_author' => $values['ads_responses']['name'], 'comment_author_email' => $values['ads_responses']['email'], 'comment_content' => $values['ads_responses']['content']);
             $akismet = new Zend_Service_Akismet(Zend_Registry::get('config')->akismet->apiKey, Zend_Registry::get('config')->host->default);
             if ($akismet->isSpam($akismetData)) {
                 $values['ads_responses']['is_spam'] = 1;
                 $this->view->message(Standart_Main::translate('adsResponseIsSpam'), 'error');
             }
             $adsResponses = new Ads_Responses();
             $adsResponses->insert($values['ads_responses']);
             $this->_redirect('/ads/response/id/' . $id . '/');
         } else {
             $this->view->message(Standart_Main::translate('invalidFormData'), 'error');
         }
     }
     $this->view->form = $form;
 }