function agenda_admin_configure_validate in Agenda 6.2
Same name and namespace in other branches
- 6 agenda.admin.php \agenda_admin_configure_validate()
- 7.2 agenda.admin.php \agenda_admin_configure_validate()
- 7 agenda.admin.php \agenda_admin_configure_validate()
Validate function for the admin configuration
File
- ./
agenda.admin.php, line 276 - Administration interface for the agenda module
Code
function agenda_admin_configure_validate($form, &$form_state) {
// clear the cache
drupal_set_message(t('Cache cleared for agenda block'));
cache_clear_all('agenda_block_' . $form['agenda_bid']['#value'], 'cache');
// calendars (has the form of a valid email address and an optional access key)
$calendars = $form_state['values']['agenda_calendars'];
$ids = preg_split('@\\r\\n?|\\n@', $calendars);
if (empty($ids)) {
form_set_error('agenda_calendars', t('Field can not be left blank'));
}
foreach ($ids as $id) {
if (!_agenda_parse_googleid($id)) {
form_set_error('agenda_calendars', t('Invalid calendar ID'));
}
}
// start (strtotime parseable)
$string = $form_state['values']['agenda_start'];
if (false === strtotime($string)) {
form_set_error('agenda_start', t('Unable to parse newer-than input with strtotime'));
}
// end (strtotime parseable)
$string = $form_state['values']['agenda_end'];
if (false === strtotime($string)) {
form_set_error('agenda_end', t('Unable to parse older-than input with strtotime'));
}
// datelimit (positive integer)
$datelimit = $form_state['values']['agenda_datelimit'];
if (!is_numeric($datelimit)) {
form_set_error('agenda_datelimit', t('You must specify a number.'));
}
elseif ($datelimit <= 0) {
form_set_error('agenda_datelimit', t('The number must be positive.'));
}
// cachetime (positive integer)
$cachetime = $form_state['values']['agenda_cachetime'];
if (!is_numeric($cachetime)) {
form_set_error('agenda_cachetime', t('You must specify the number of seconds to cache calendar data.'));
}
elseif ($cachetime <= 0) {
form_set_error('agenda_cachetime', t('The cache time must be positive.'));
}
// timezone
if (!@date_default_timezone_set($form_state['values']['agenda_timezone'])) {
form_set_error('agenda_timezone', t('Invalid timezone.'));
}
}