function om_tools_admin_advanced_submit in OM Tools 8.2
Same name and namespace in other branches
- 6.2 inc/om_tools.admin.inc \om_tools_admin_advanced_submit()
- 7.2 inc/om_tools.admin.inc \om_tools_admin_advanced_submit()
Admin Advanced Submit OM Tools API 2.0
File
- inc/
om_tools.admin.inc, line 186 - OM Tools Admin Configuration
Code
function om_tools_admin_advanced_submit($form, $form_state) {
$form_values = $form_state['values'];
//dsm($form_values['om_tools_admin_advanced']['admin_advanced']);
$module = $form_values['om_tools_admin_advanced']['admin_advanced_module'];
//dsm($module);
${$module} = '';
ob_start();
eval($form_values['om_tools_admin_advanced']['admin_advanced']);
ob_end_clean();
//dsm($$module);
// OM Tools backup container
$backup_values = variable_get($module . '_backup', '');
// file versions
// current settings
$display_values_current = '';
om_tools_display_values_get($display_values_current, ${$module}, $backup_values, $module);
$om_settings_current = om_file_directory_path() . '/' . $module . '_current.gz';
// backup settings
$display_values_backup = '';
om_tools_display_values_get($display_values_backup, ${$module}, $backup_values, $module);
$om_settings_backup = om_file_directory_path() . '/' . $module . '_backup.gz';
//dsm($$module);
// update data
if ($form_values['op'] == t('Save')) {
variable_set($module, ${$module});
// open file for writing with maximum compression
$om_settings_current_compress = gzopen($om_settings_current, "w9");
gzwrite($om_settings_current_compress, $display_values_current);
gzclose($om_settings_current_compress);
drupal_set_message(t('All settings are saved.'));
}
elseif ($form_values['op'] == t('Backup')) {
variable_set($module . '_backup', ${$module});
// open file for writing with maximum compression
$om_settings_backup_compress = gzopen($om_settings_backup, "w9");
gzwrite($om_settings_backup_compress, $display_values_backup);
gzclose($om_settings_backup_compress);
drupal_set_message(t('Backup is successful.'));
}
elseif ($form_values['op'] == t('Update Backup')) {
variable_set($module . '_backup', ${$module});
// open file for writing with maximum compression
$om_settings_backup_compress = gzopen($om_settings_backup, "w9");
gzwrite($om_settings_backup_compress, $display_values_backup);
gzclose($om_settings_backup_compress);
drupal_set_message(t('Backup is updated successfully.'));
}
elseif ($form_values['op'] == t('Restore')) {
${$module} = variable_get($module . '_backup', '');
if (!empty(${$module})) {
variable_set($module, ${$module});
drupal_set_message(t('All settings are restored from backup.'));
}
else {
drupal_set_message(t('Backup file is empty.'));
}
}
elseif ($form_values['op'] == t('Delete')) {
variable_set($module, '');
drupal_set_message(t('All settings have been deleted.'));
}
}