You are here

function elysia_cron_settings_form_validate in Elysia Cron 5

Same name and namespace in other branches
  1. 5.2 elysia_cron.admin.inc \elysia_cron_settings_form_validate()
  2. 6.2 elysia_cron.admin.inc \elysia_cron_settings_form_validate()
  3. 6 elysia_cron.admin.inc \elysia_cron_settings_form_validate()
  4. 7.2 elysia_cron.admin.inc \elysia_cron_settings_form_validate()
  5. 7 elysia_cron.admin.inc \elysia_cron_settings_form_validate()

File

./elysia_cron.admin.inc, line 542

Code

function elysia_cron_settings_form_validate($_dco_form, &$_dco_form_state) {
  extract(_dcf_form_validate($_dco_form, $_dco_form_state));
  global $elysia_cron_settings;
  $script = $form_state['values']['elysia_cron_script'];
  if ($script) {
    $errors = elysia_cron_decode_script($script, false);
    if ($errors) {
      form_set_error('elysia_cron_script', t('Invalid lines:') . implode('<br>', $errors));
    }
  }
  foreach ($form_state['values'] as $key => $value) {
    if ($value && preg_match('/^_elysia_cron_([^_]+_[^_]+)_(.*)$/', $key, $r) && ($r[1] == 'job_rule' || $r[1] == 'ch_rule')) {
      if (!preg_match('/^\\s*([0-9*,\\/-]+[ ]+[0-9*,\\/-]+[ ]+[0-9*,\\/-]+[ ]+[0-9*,\\/-]+[ ]+[0-9*,\\/-]+)\\s*$/', $value)) {
        form_set_error($key, t('Invalid rule: !rule', array(
          '!rule' => $value,
        )));
      }
    }
  }
}