Пример #1
0
 function _save()
 {
     $this->autoRender = false;
     $this->autoLayout = false;
     $response = array();
     # Validate form token
     $this->components = array('security');
     $this->__initComponents();
     if ($this->invalidToken) {
         return $this->ajaxError(s2messages::invalidToken());
     }
     if ($this->Config->user_report) {
         $this->data['Report']['report_text'] = Sanitize::getString($this->data['Report'], 'report_text');
         $listing_id = $this->data['Report']['listing_id'] = Sanitize::getInt($this->data['Report'], 'listing_id');
         $review_id = $this->data['Report']['review_id'] = Sanitize::getInt($this->data['Report'], 'review_id');
         $post_id = $this->data['Report']['post_id'] = Sanitize::getInt($this->data['Report'], 'post_id');
         $extension = $this->data['Report']['extension'] = Sanitize::getString($this->data['Report'], 'extension');
         if ($this->data['Report']['report_text'] != '') {
             $this->data['Report']['user_id'] = $this->_user->id;
             $this->data['Report']['ipaddress'] = $this->ipaddress;
             $this->data['Report']['created'] = date('Y-m-d H:i:s');
             $this->data['Report']['approved'] = 0;
             if ($this->_user->id) {
                 $this->data['Report']['name'] = $this->_user->name;
                 $this->data['Report']['username'] = $this->_user->username;
                 $this->data['Report']['email'] = $this->_user->email;
             } else {
                 $this->data['Report']['name'] = 'Guest';
                 $this->data['Report']['username'] = '******';
             }
             if ($this->Report->store($this->data)) {
                 $update_text = __t("Your report was submitted, thank you.", true);
                 $response[] = "jQuery('#jr_reportLink" . ($post_id > 0 ? $post_id : $review_id) . "').remove();";
                 return $this->ajaxUpdateDialog($update_text, $response);
             }
             return $this->ajaxError(s2Messages::submitErrorDb());
         }
         # Validation failed
         if (isset($this->Security)) {
             $reponse[] = "jQuery('jr_reportToken').val('" . $this->Security->reissueToken() . "')";
         }
         return $this->ajaxValidation(__t("The message is empty.", true), $response);
     }
 }
Пример #2
0
 function _save()
 {
     $response = array();
     $formToken = cmsFramework::getCustomToken($this->review_id);
     if ($this->denyAccess == true || !Sanitize::getString($this->params['form'], $formToken)) {
         return $this->ajaxError(s2Messages::accessDenied());
     }
     # Validate form token
     $this->components = array('security');
     $this->__initComponents();
     if ($this->invalidToken) {
         return $this->ajaxError(s2messages::invalidToken());
     }
     // Check if an owner reply already exists
     $this->OwnerReply->fields = array();
     if ($reply = $this->OwnerReply->findRow(array('fields' => array('OwnerReply.owner_reply_text', 'OwnerReply.owner_reply_approved'), 'conditions' => array('OwnerReply.id = ' . $this->review_id)))) {
         if ($reply['OwnerReply']['owner_reply_approved'] == 1) {
             $error_text = __t("A reply for this review already exists.", true);
             $response[] = "jQuery('#jr_ownerReplyLink{$this->review_id}').remove();";
             return $this->ajaxError($error_text, $response);
         }
     }
     if ($this->Config->owner_replies) {
         if ($this->data['OwnerReply']['owner_reply_text'] != '' && $this->data['OwnerReply']['id'] > 0) {
             $this->data['OwnerReply']['owner_reply_created'] = date('Y-m-d H:i:s');
             $this->data['OwnerReply']['owner_reply_approved'] = 1;
             // Replies will be moderated by default
             if ($this->OwnerReply->store($this->data)) {
                 $update_text = $this->data['OwnerReply']['owner_reply_approved'] ? __t("Your reply was submitted and has been approved.", true) : __t("Your reply was submitted and will be published once it is verified.", true);
                 $response[] = "jQuery('#jr_ownerReplyLink{$this->review_id}').remove();";
                 return $this->ajaxUpdateDialog($update_text, $response);
             }
             return $this->ajaxError(s2Messages::submitErrorDb());
         }
         # Validation failed
         if (isset($this->Security)) {
             $reponse[] = "jQuery('s2Token').val('" . $this->Security->reissueToken() . "')";
         }
         return $this->ajaxValidation(__t("The reply is empty.", true), $response);
     }
 }