You are here

function cacheflush_cron_validate in CacheFlush 7

Same name and namespace in other branches
  1. 7.3 modules/cacheflush_cron/cacheflush_cron.module \cacheflush_cron_validate()
  2. 7.2 cacheflush_cron/cacheflush_cron.module \cacheflush_cron_validate()

Implements hook_validate().

1 string reference to 'cacheflush_cron_validate'
cacheflush_cron_form_alter in cacheflush_cron/cacheflush_cron.module
Implements hook_form_alter().

File

cacheflush_cron/cacheflush_cron.module, line 97
Cacheflush cron job.

Code

function cacheflush_cron_validate(&$form, &$form_state) {

  //Valide Crone Rule text field
  if ($form_state['values']['cacheflush_cron_sett'] == '1') {
    if ($form_state['cacheflush_preset_is_edit'] == 'TRUE') {
      $form_state['cacheflush_preset_list'][$form_state['cacheflush_preset_id']]['#cron']['checkbox'] = $form_state['values']['cacheflush_cron_sett'];
    }
    else {
      if (!preg_match('/^\\s*([0-9*, \\/-]+[]+[0-9*, \\/-]+[]+[0-9*, \\/-]+[]+[0-9*, \\/-]+[]+[0-9*, \\/-]+)\\s*$/', $form_state['values']['cacheflush_cron_rule'])) {
        form_error($form['cron_fieldset']['cacheflush_cron_rule'], t('Invalid rule: ' . $form_state['values']['cacheflush_cron_rule']));
      }
      else {
        $form_state['cacheflush_preset_list'][$form_state['cacheflush_preset_id']]['#cron'] = array(
          'checkbox' => 1,
          'rule' => $form_state['values']['cacheflush_cron_rule'],
        );
      }
    }
  }
  else {
    if (isset($form_state['cacheflush_preset_list'][$form_state['cacheflush_preset_id']]['#cron'])) {
      $form_state['cacheflush_preset_list'][$form_state['cacheflush_preset_id']]['#cron']['checkbox'] = 0;
    }
  }
}