Exemple #1
0
 /**
  * Load data from Request form fields.
  *
  * @return boolean true if loaded data seems valid.
  */
 function load_from_Request()
 {
     // Category
     param('goal_gcat_ID', 'integer', true);
     param_check_not_empty('goal_gcat_ID', T_('Please select a category.'));
     $this->set_from_Request('gcat_ID');
     // Name
     $this->set_string_from_param('name', true);
     // Key
     $this->set_string_from_param('key', true);
     // Temporary Redirection URL:
     $this->set_string_from_param('temp_redir_url');
     // Normal Redirection URL:
     param('goal_redir_url', 'string');
     if ($this->get('temp_redir_url') != '') {
         // Normal Redirection URL is required when Temporary Redirection URL is not empty
         param_check_not_empty('goal_redir_url', T_('Please enter Normal Redirection URL.'));
     }
     $this->set_from_Request('redir_url');
     if ($this->get('temp_redir_url') != '' && $this->get('temp_redir_url') == $this->get('redir_url')) {
         // Compare normal and temp urls
         param_error('goal_temp_redir_url', T_('Temporary Redirection URL should not be equal to Normal Redirection URL'));
         param_error('goal_redir_url', NULL, '');
     }
     // Temporary Start
     $temp_start_date = param_date('goal_temp_start_date', T_('Please enter a valid date.'), false);
     if (!empty($temp_start_date)) {
         $temp_start_time = param('goal_temp_start_time', 'string');
         $temp_start_time = empty($temp_start_time) ? '00:00:00' : param_time('goal_temp_start_time');
         $this->set('temp_start_ts', form_date($temp_start_date, $temp_start_time));
     } else {
         $this->set('temp_start_ts', NULL);
     }
     // Temporary End
     $temp_end_date = param_date('goal_temp_end_date', T_('Please enter a valid date.'), false);
     if (!empty($temp_end_date)) {
         $temp_end_time = param('goal_temp_end_time', 'string');
         $temp_end_time = empty($temp_end_time) ? '00:00:00' : param_time('goal_temp_end_time');
         $this->set('temp_end_ts', form_date($temp_end_date, $temp_end_time));
     } else {
         $this->set('temp_end_ts', NULL);
     }
     if ($this->get('temp_start_ts') !== NULL && $this->get('temp_end_ts') !== NULL && strtotime($this->get('temp_start_ts')) >= strtotime($this->get('temp_end_ts'))) {
         // Compare Start and End dates
         param_error('goal_temp_start_date', NULL, '');
         param_error('goal_temp_start_time', NULL, '');
         param_error('goal_temp_end_date', NULL, '');
         param_error('goal_temp_end_time', T_('Temporary Start Date/Time should not be greater than Temporary End Date/Time'));
     }
     // Default value:
     param('goal_default_value', 'string');
     param_check_decimal('goal_default_value', T_('Default value must be a number.'));
     $this->set_from_Request('default_value', 'goal_default_value', true);
     // Notes
     param('goal_notes', 'text');
     $this->set_from_Request('notes', 'goal_notes');
     return !param_errors_detected();
 }
Exemple #2
0
 /**
  * Load data from Request form fields.
  *
  * @return boolean true if loaded data seems valid.
  */
 function load_from_Request()
 {
     // Name
     $this->set_string_from_param('name', true);
     // Key
     $this->set_string_from_param('key', true);
     // Redir URL:
     $this->set_string_from_param('redir_url');
     // Default value:
     param('goal_default_value', 'string');
     param_check_decimal('goal_default_value', T_('Default value must be a number.'));
     $this->set_from_Request('default_value', 'goal_default_value', true);
     return !param_errors_detected();
 }