function domain_settings_form_submit in Domain Access 6.2
Same name and namespace in other branches
- 7.3 domain_settings/domain_settings.module \domain_settings_form_submit()
- 7.2 domain_settings/domain_settings.module \domain_settings_form_submit()
Submit handler for domain-specific settings.
1 string reference to 'domain_settings_form_submit'
- domain_settings_form_alter in domain_settings/
domain_settings.module - Implement hook_form_alter()
File
- domain_settings/
domain_settings.module, line 122 - Allows domain-specific use of Drupal system settings forms.
Code
function domain_settings_form_submit($form, &$form_state) {
$domain_id = $form_state['values']['domain_id'];
$reset = FALSE;
if ($form_state['values']['op'] == $form_state['values']['reset']) {
$reset = TRUE;
}
$values = array();
foreach ($form_state['values'] as $key => $value) {
if (!in_array($key, array(
'op',
'submit',
'reset',
'form_build_id',
'form_token',
'form_id',
'domain_id',
))) {
$values[$key] = $value;
}
}
// -1 is the primary domain.
foreach ($values as $name => $value) {
// Handle checkboxes when array_filter is set. (Do not return empty checkboxes at all.)
if (is_array($value) && isset($form_state['values']['array_filter'])) {
$value = array_keys(array_filter($value));
}
if ($domain_id == -1 || $domain_id == DOMAIN_SETTINGS_ALL_DOMAINS) {
if ($reset) {
variable_del($name);
if ($name == 'site_name') {
db_query("UPDATE {domain} SET sitename = '%s' WHERE domain_id = 0", 'Drupal');
variable_set('domain_sitename', 'Drupal');
}
}
else {
variable_set($name, $value);
if ($name == 'site_name') {
db_query("UPDATE {domain} SET sitename = '%s' WHERE domain_id = 0", $value);
variable_set('domain_sitename', $value);
}
}
}
else {
if ($reset) {
domain_conf_variable_delete($domain_id, $name);
if ($name == 'site_name') {
db_query("UPDATE {domain} SET sitename = '%s' WHERE domain_id = %d", 'Drupal', $domain_id);
}
}
else {
domain_conf_variable_save($domain_id, $name, $value);
if ($name == 'site_name') {
db_query("UPDATE {domain} SET sitename = '%s' WHERE domain_id = %d", $value, $domain_id);
}
}
}
if ($domain_id == DOMAIN_SETTINGS_ALL_DOMAINS && !$reset) {
foreach (domain_domains() as $id => $value) {
domain_conf_variable_delete($id, $name);
}
}
}
// Set a message about the affected domains.
$extra = '';
if ($domain_id > 0) {
$domain = domain_lookup($domain_id);
$affected = $domain['sitename'];
}
elseif ($domain_id == -1) {
$default = domain_default();
$affected = $default['sitename'];
$extra = t('These settings will be inherited unless overridden per domain.');
}
else {
$affected = t('all domains');
}
if ($reset) {
drupal_set_message(t('The configuration options have been reset to their default values for %domains.', array(
'%domains' => $affected,
)));
}
else {
drupal_set_message(t('The configuration options have been saved for %domains. !extra', array(
'%domains' => $affected,
'!extra' => $extra,
)));
}
module_invoke_all('domain_settings', $domain_id, $form_state['values']);
cache_clear_all();
}