function domain_settings_form_submit in Domain Access 7.3
Same name and namespace in other branches
- 6.2 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 - Implements 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'];
$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;
}
}
// Get the primary domain.
$default = domain_default_id();
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 == $default || $domain_id == DOMAIN_SETTINGS_ALL_DOMAINS) {
variable_set($name, $value);
// Update the site name of the primary domain, if needed.
if ($name == 'site_name') {
db_update('domain')
->condition('domain_id', $default)
->fields(array(
'sitename' => $form_state['values']['site_name'],
))
->execute();
}
if ($domain_id == DOMAIN_SETTINGS_ALL_DOMAINS) {
foreach (domain_domains() as $id => $value) {
domain_conf_delete_variable($id, $name);
}
}
}
else {
domain_conf_variable_save($domain_id, $name, $value);
if ($name == 'site_name') {
variable_set('domain_sitename', $value);
db_update('domain')
->condition('domain_id', $domain_id)
->fields(array(
'sitename' => $form_state['values']['site_name'],
))
->execute();
}
}
}
// Set a message about the affected domains.
$extra = '';
if ($domain_id > 0) {
$domain = domain_lookup($domain_id);
$affected = $domain['sitename'];
if ($domain_id == domain_default_id()) {
$extra = t('These settings will be inherited unless overridden per domain.');
}
}
else {
$affected = t('all domains');
}
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();
}