function om_tools_admin_submit in OM Tools 8.2
Same name and namespace in other branches
- 8 om_tools.module \om_tools_admin_submit()
- 6.2 inc/om_tools.admin.inc \om_tools_admin_submit()
- 6 om_tools.module \om_tools_admin_submit()
- 7.2 inc/om_tools.admin.inc \om_tools_admin_submit()
- 7 om_tools.module \om_tools_admin_submit()
1 Submit for all settings
File
- inc/
om_tools.admin.inc, line 74 - OM Tools Admin Configuration
Code
function om_tools_admin_submit($form, $form_state) {
$form_values = $form_state['values'];
$tools = om_tools_get();
$reset_tools = '';
$reset = 0;
//dsm($form_values);
$om_tools = array();
foreach ($form_values as $name => $value) {
list($module) = explode('_', $name);
if (in_array($module, $tools)) {
$om_tools[$module][$name] = $value;
}
$om_tool_name = array_reverse(explode('_', $name));
if ($om_tool_name[0] == 'reset') {
$reset += $value;
if ($value != 0) {
array_shift($om_tool_name);
$reset_tools .= '<li>' . ucwords(implode(' ', array_reverse($om_tool_name))) . '</li>';
}
}
}
//dsm($om_tools);
if ($form_values['op'] == t('Initialize Settings')) {
drupal_set_message(t('Your settings have been initialized successfully.'));
}
elseif ($form_values['op'] == t('Save Settings')) {
drupal_set_message(t('Your settings have been saved.'));
}
elseif ($form_values['op'] == t('Save Settings Again')) {
drupal_set_message(t('Your settings have been saved again.'));
}
if ($reset) {
$reset == 1 ? $reset_text = 'tool has' : ($reset_text = 'tools have');
drupal_set_message(t('The values of the following ' . $reset_text . ' been reset: <ul>' . $reset_tools . '</ul>You need to hit <strong>"Save Settings Again"</strong> button.'));
}
// Save all settings in 1 variable
variable_set('om_tools', $om_tools);
}