function key_config_form_submit in Key 7.3
Same name and namespace in other branches
- 7.2 includes/key.admin.inc \key_config_form_submit()
Form submission handler for key_config_form().
1 string reference to 'key_config_form_submit'
- key_config_form in includes/
key.admin.inc - Form constructor for the key configuration form.
File
- includes/
key.admin.inc, line 359 - Administrative functionality for managing key configurations.
Code
function key_config_form_submit($form, &$form_state) {
$key_value_data = $form_state['storage']['key_value'];
// Update the key configuration in form state storage.
foreach (array_keys($form_state['storage']['key_config']) as $id) {
if (isset($form_state['values'][$id])) {
$form_state['storage']['key_config'][$id] = $form_state['values'][$id];
}
}
$key_provider = key_get_plugin('key_provider', $form_state['values']['key_provider']);
$original_key = $form_state['storage']['original_key'];
$config = $form_state['storage']['key_config'];
foreach (_key_get_plugin_types() as $type) {
$plugin = key_get_plugin($type, $config[$type]);
$plugin_form_state = _key_create_plugin_form_state($type, $form_state);
if ($submit_function = ctools_plugin_get_function($plugin, 'submit configuration form')) {
$submit_function($form, $plugin_form_state);
$form_state['values'][$type . '_settings'] = $plugin_form_state['values'];
_key_move_form_state_storage($plugin_form_state, $form_state);
}
}
// If the key provider allows a key value to be set.
if ($key_provider['key value']['accepted'] && ($set_key_value_function = ctools_plugin_get_function($key_provider, 'set key value'))) {
// If either the key provider has changed or the submitted value
// is not the same as the obscured value.
if ($original_key && $original_key['key_provider'] != $form_state['values']['key_provider'] || $key_value_data['submitted'] != $key_value_data['obscured']) {
// Set the key value.
$plugin_form_state = _key_create_plugin_form_state('key_provider', $form_state);
$set_key_value_function($config, $plugin_form_state, $key_value_data['processed_submitted']);
$form_state['values']['key_provider_settings'] = $plugin_form_state['values'];
_key_move_form_state_storage($plugin_form_state, $form_state);
}
}
$fields = array(
'id' => (string) $form_state['values']['id'],
'label' => (string) $form_state['values']['label'],
'description' => (string) $form_state['values']['description'],
'key_type' => (string) $form_state['values']['key_type'],
'key_type_settings' => isset($form_state['values']['key_type_settings']) ? serialize($form_state['values']['key_type_settings']) : array(),
'key_provider' => (string) $form_state['values']['key_provider'],
'key_provider_settings' => isset($form_state['values']['key_provider_settings']) ? serialize($form_state['values']['key_provider_settings']) : array(),
'key_input' => (string) $form_state['values']['key_input'],
'key_input_settings' => isset($form_state['values']['key_input_settings']) ? serialize($form_state['values']['key_input_settings']) : array(),
);
$save_result = key_save_key($fields, $form_state['storage']['original_key']);
// If the save was successful, redirect to the list page.
if ($save_result) {
$form_state['redirect'] = KEY_MENU_PATH . '/list';
}
}