function variable_realm_select_variables_form_submit in Variable 7
Same name and namespace in other branches
- 7.2 variable_realm/variable_realm.form.inc \variable_realm_select_variables_form_submit()
Select variables for realm.
File
- variable_realm/
variable_realm.form.inc, line 39 - Administrative forms for variable realms.
Code
function variable_realm_select_variables_form_submit($form, &$form_state) {
// Get realm name and current list of variables.
$realm_name = $form_state['values']['realm_name'];
$old_variables = variable_realm_get_variable_list($realm_name);
// Get main variable names
$variables = $form_state['values']['variables'];
$variables = array_keys(array_filter($variables));
// Translate variable names
foreach ($variables as $index => $name) {
$variables[$index] = str_replace(array(
'<',
'>',
), array(
'[',
']',
), $name);
}
// Hook for modules to alter this variable list.
drupal_alter('variable_realm_variable_list', $variables, $realm_name);
// And save the list to a variable.
variable_set('variable_realm_list_' . $realm_name, $variables);
// Spawn multiple variables and translate into actual variables
$new_list = variable_children($variables);
// Delete variables from realm that are not in the new list.
$old_list = variable_children($old_variables);
foreach (array_diff($old_list, $new_list) as $name) {
variable_realm_delete_variable($realm_name, $name);
drupal_set_message(t('Deleted existing values of %name from realm variables.', array(
'%name' => $name,
)));
}
}