function _addOption()
 {
     $this->autoRender = false;
     $this->autoLayout = false;
     $response = array();
     $option = $this->data['FieldOption']['text'] = Sanitize::getString($this->data, 'text');
     $value = $this->data['FieldOption']['value'] = Sanitize::stripAll($this->data, 'text');
     $fieldid = $this->data['FieldOption']['fieldid'] = Sanitize::getInt($this->data, 'field_id');
     $fieldName = Sanitize::getString($this->data, 'name');
     // Begin validation
     if ($value == '') {
         $validation = __t("The field is empty.", true);
         $response[] = "jQuery('#jr_fieldOption{$fieldid}').siblings('.jr_loadingSmall').after('<span class=\"jr_validation\">&nbsp;" . $validation . "</span>');";
         return $this->ajaxResponse($response);
     }
     // Save
     $result = $this->FieldOption->save($this->data);
     switch ($result) {
         case 'success':
             // Begin update display
             $option = $this->data['FieldOption']['text'];
             $value = $this->data['FieldOption']['value'];
             $response = "\n                        jQuery('#{$fieldName}').addOption('{$value}','" . addslashes($option) . "');\n                        jQuery('#jr_fieldOption{$fieldid}').val('');            \n                        jQuery('#submitButton{$fieldid}').removeAttr('disabled');\n                    ";
             return $this->ajaxResponse($response);
         case 'duplicate':
             $validation = sprintf(__t("%s already exists", true), $value);
             break;
         case 'db_error':
             $validation = s2Messages::submitErrorGeneric();
             break;
     }
     $response[] = "jQuery('#{$fieldName}').selectOptions('" . addslashes($option) . "');";
     $response[] = "jQuery('#jr_fieldOption{$fieldid}').siblings('.jr_loadingSmall').after('<span class=\"jr_validation\">&nbsp;" . $validation . "</span>');";
     return $this->ajaxResponse($response);
 }
 function _save()
 {
     $response = array();
     $this->data['Vote']['user_id'] = $this->_user->id;
     $this->data['Vote']['review_id'] = (int) $this->data['Vote']['review_id'];
     # Exact vote check to prevent form tampering. User can cheat the js and enter any interger, thus increasing the count
     $this->data['Vote']['vote_yes'] = Sanitize::getInt($this->data['Vote'], 'vote_yes') ? 1 : 0;
     $this->data['Vote']['vote_no'] = Sanitize::getInt($this->data['Vote'], 'vote_no') ? 1 : 0;
     $this->data['Vote']['created'] = gmdate('Y-m-d H:i:s');
     $this->data['Vote']['ipaddress'] = $this->ipaddress;
     if (!$this->data['Vote']['review_id']) {
         return $this->ajaxError(s2Messages::submitErrorGeneric());
     }
     // Find duplicates
     $duplicate = $this->Vote->findCount(array('conditions' => array('review_id = ' . $this->data['Vote']['review_id'], 'ipaddress = ' . $this->Vote->Quote($this->data['Vote']['ipaddress']))));
     // It's a guest so we only care about checking the IP address if this feature is not disabled and
     // server is not localhost
     if (!$this->_user->id) {
         if (!$this->Config->vote_ipcheck_disable && $this->ipaddress != '127.0.0.1') {
             // Do the ip address check everywhere except in localhost
             $duplicate = $this->Vote->findCount(array('conditions' => array('review_id = ' . $this->data['Vote']['review_id'], 'ipaddress = ' . $this->Vote->Quote($this->ipaddress))));
         }
     } else {
         $duplicate = $this->Vote->findCount(array('conditions' => array('review_id = ' . $this->data['Vote']['review_id'], "(user_id = {$this->_user->id}" . ($this->ipaddress != '127.0.0.1' && !$this->Config->vote_ipcheck_disable ? " OR ipaddress = " . $this->Vote->Quote($this->ipaddress) . ") " : ')'))));
     }
     if ($duplicate > 0) {
         # Hides vote buttons and shows message alert
         $response[] = "jQuery('#jr_reviewVote{$this->data['Vote']['review_id']}').fadeOut('medium',function(){\n                jQuery(this).html('" . __t("You already voted.", true, true) . "').fadeIn();\n            });";
         return $this->ajaxResponse($response);
     }
     if ($this->Vote->store($this->data)) {
         # Hides vote buttons and shows message alert
         $response[] = "jQuery('#jr_reviewVote{$this->data['Vote']['review_id']}').fadeOut('medium',function(){\n                jQuery(this).html('" . __t("Thank you for your vote.", true, true) . "').fadeIn();\n            });";
         # Facebook wall integration only for positive votes
         $facebook_integration = Sanitize::getBool($this->Config, 'facebook_enable') && Sanitize::getBool($this->Config, 'facebook_votes');
         $token = cmsFramework::getCustomToken($this->data['Vote']['review_id']);
         $facebook_integration and $this->data['Vote']['vote_yes'] and $response[] = "\n                jQuery.ajax({url:s2AjaxUri+jreviews.ajax_params()+'&url=facebook/_postVote/id:{$this->data['Vote']['review_id']}&{$token}=1',dataType:'script'});\n            ";
         return $this->ajaxResponse($response);
     }
     return $this->ajaxError(s2Messages::submitErrorDb());
 }