function cacheflush_cron_form_alter in CacheFlush 7
Implements hook_form_alter().
File
- cacheflush_cron/
cacheflush_cron.module, line 11 - Cacheflush cron job.
Code
function cacheflush_cron_form_alter(&$form, &$form_state, $form_id) {
if ($form_id != 'cacheflush_preset_form') {
return;
}
//Cron fieldset
$form['cron_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Cron'),
'#weight' => 2,
);
//Set cron checkbox
$form['cron_fieldset']['cacheflush_cron_sett'] = array(
'#type' => "checkbox",
'#title' => t('Cron job'),
'#weight' => 1,
'#default_value' => isset($form_state['cacheflush_preset_list'][$form_state['cacheflush_preset_id']]['#cron']['checkbox']) ? $form_state['cacheflush_preset_list'][$form_state['cacheflush_preset_id']]['#cron']['checkbox'] : 0,
'#description' => t('Eneble cron job for this preset.'),
);
if ($form_state['cacheflush_preset_is_edit'] == 'TRUE') {
//Cron Settings Page link container
$form['cron_fieldset']['cacheflush_cron_link'] = array(
'#type' => 'container',
'#weight' => 3,
'#states' => array(
'invisible' => array(
':input[name="cacheflush_cron_sett"]' => array(
'checked' => FALSE,
),
),
),
);
//Cron Settings Page link
$form['cron_fieldset']['cacheflush_cron_link']['markup'] = array(
'#markup' => l('Cron Settings', 'admin/config/system/cron'),
);
}
else {
//Cron rule
$form['cron_fieldset']['cacheflush_cron_rule'] = array(
'#type' => "textfield",
'#title' => t('Cron job rule'),
'#weight' => 2,
'#default_value' => isset($form_state['cacheflush_preset_list'][$form_state['cacheflush_preset_id']]['#cron']) ? $form_state['cacheflush_preset_list'][$form_state['cacheflush_preset_id']]['#cron']['rule'] : '* * * * *',
'#description' => t('Cron job rule example ("*/5 * * * *") // Every 5 minutes.'),
'#states' => array(
'invisible' => array(
':input[name="cacheflush_cron_sett"]' => array(
'checked' => FALSE,
),
),
),
);
}
if ($form_id == 'cacheflush_preset_form') {
$form['#validate'][] = 'cacheflush_cron_validate';
}
}