function _datex_admin_form_submit in Datex 7.3
Form submit for datex admin form.
This admin form could be implemented better.
1 string reference to '_datex_admin_form_submit'
- datex_admin_form in ./
datex.admin.inc - Provides administration form for datex module (menu callback).
File
- ./
datex.admin.inc, line 114 - Datex administration forms.
Code
function _datex_admin_form_submit($form, &$form_state) {
$v = $form_state['values'];
$schema = variable_get('datex_schema');
$new_name = empty($v['datex_new_schema_machine_name']) ? '' : $v['datex_new_schema_machine_name'];
if ($new_name) {
$schema[$new_name] = [];
drupal_set_message(t("New schema created: @s", [
'@s' => $new_name,
]));
}
foreach ($v['datex_schemas'] as $select) {
if ($select !== 'default' && isset($schema[$select])) {
unset($schema[$select]);
drupal_set_message(check_plain(t('Schema removed') . ': ' . $select));
}
else {
if ($select === 'default') {
$schema['default'] = [];
$message = t('Default schema was reset.');
drupal_set_message(check_plain($message));
}
}
}
variable_set('datex_schema', $schema);
if (module_exists('datex_popup')) {
variable_set('datex_popup_theme', $v['datex_popup_theme']);
}
$bc = $v['datex_block_count'];
$old_bc = variable_get('datex_block_count', 1);
if ($bc !== '' && is_numeric($bc) && intval($bc) !== $old_bc) {
variable_set('datex_block_count', $bc);
drupal_set_message(t("Clear the cache for changes to take effect"));
$fmt = variable_get('datex_block_format', []);
$cal = variable_get('datex_block_calendar', []);
for ($i = $bc; $i < $old_bc; $i++) {
unset($fmt[$i]);
unset($cal[$i]);
}
variable_set('datex_block_count', $bc);
variable_set('datex_block_formats', $fmt);
}
drupal_set_message(t('Configuration saved.'));
if ($new_name) {
drupal_goto('admin/config/regional/date-time/datex/edit/' . $new_name);
}
}