示例#1
0
 public function save()
 {
     // unchecked check boxes are not in POST, so set false values.
     if (!isset($_POST['occurrence:confidential'])) {
         $_POST['occurrence:confidential'] = 'f';
     }
     if (!isset($_POST['occurrence:zero_abundance'])) {
         $_POST['occurrence:zero_abundance'] = 'f';
     }
     parent::save();
 }
示例#2
0
 /**
  * Override the save method so we can convert the report parameters form into a JSON
  * value to store in the triggers.json_params field.
  */
 public function save()
 {
     // build the parameters JSON value from the params form
     $params = array();
     foreach ($_POST as $key => $value) {
         if (substr($key, 0, 7) == 'params-') {
             // The last part of the key is the field name
             $tokens = explode('-', $key);
             $param = array_pop($tokens);
             $params[$param] = $value;
         }
     }
     $_POST['params_json'] = json_encode($params);
     parent::save();
 }
 public function save()
 {
     if ($_POST['metaFields:disabled_input'] === 'NO') {
         // Build the validation_rules field from the set of controls that are associated with it.
         $rules = array();
         foreach (array('required', 'alpha', 'email', 'url', 'alpha_numeric', 'numeric', 'standard_text', 'date_in_past', 'time', 'digit', 'integer') as $rule) {
             if (array_key_exists('valid_' . $rule, $_POST) && $_POST['valid_' . $rule] == 1) {
                 array_push($rules, $rule);
             }
         }
         // trim the input data, incase spaces are left in the validation parameters which would affect our tests
         $_POST = array_map('trim', $_POST);
         if (array_key_exists('valid_length', $_POST) && $_POST['valid_length'] == 1 && !empty($_POST['valid_length_max'])) {
             $min = empty($_POST['valid_length_min']) ? '0' : $_POST['valid_length_min'];
             $rules[] = 'length[' . $min . ',' . $_POST['valid_length_max'] . ']';
         }
         if (array_key_exists('valid_decimal', $_POST) && $_POST['valid_decimal'] == 1 && !empty($_POST['valid_dec_format'])) {
             $rules[] = 'decimal[' . $_POST['valid_dec_format'] . ']';
         }
         if (array_key_exists('valid_regex', $_POST) && $_POST['valid_regex'] == 1 && !empty($_POST['valid_regex_format'])) {
             $rules[] = 'regex[' . $_POST['valid_regex_format'] . ']';
         }
         if (array_key_exists('valid_min', $_POST) && $_POST['valid_min'] == 1) {
             $rules[] = 'minimum[' . $_POST['valid_min_value'] . ']';
         }
         if (array_key_exists('valid_max', $_POST) && $_POST['valid_max'] == 1) {
             $rules[] = 'maximum[' . $_POST['valid_max_value'] . ']';
         }
         $_POST[$this->model->object_name . ':validation_rules'] = implode("\r\n", $rules);
         // Make sure checkboxes have a value as unchecked values don't appear in $_POST
         // @todo: If we use Indicia client helper controls for the attribute edit page, this becomes unnecessary
         if (!array_key_exists($this->model->object_name . ':public', $_POST)) {
             $_POST[$this->model->object_name . ':public'] = '0';
         }
         if (!array_key_exists($this->model->object_name . ':multi_value', $_POST)) {
             $_POST[$this->model->object_name . ':multi_value'] = '0';
         }
     }
     parent::save();
 }
 public function save()
 {
     /*
     // unchecked check boxes are not in POST, so set false values.
     if (!isset($_POST['subject_observation:confidential']))
       $_POST['subject_observation:confidential']='f';
     if (!isset($_POST['subject_observation:zero_abundance']))
       $_POST['subject_observation:zero_abundance']='f';
     */
     parent::save();
 }