function certificate_settings_form_submit in Certificate 6
Same name and namespace in other branches
- 8.3 certificate.admin.inc \certificate_settings_form_submit()
- 6.2 certificate.admin.inc \certificate_settings_form_submit()
- 7.3 certificate.admin.inc \certificate_settings_form_submit()
- 7.2 certificate.admin.inc \certificate_settings_form_submit()
- 3.x certificate.admin.inc \certificate_settings_form_submit()
Submit handler for global field mapping form.
@TODO: If there is an older selected field with more options, delete them from variables (count($field_options_array)).
File
- ./
certificate.admin.inc, line 439 - Administrative pages for the module.
Code
function certificate_settings_form_submit($form, &$form_state) {
// Delete any old variables, for example if there was an older selected field with more options.
$variables = db_query("SELECT name FROM {variable} WHERE name LIKE '%s_%%'", 'certificate_type');
while ($variable = db_fetch_object($variables)) {
variable_del($variable->name);
}
// Get the field key.
$settings = $form_state['values']['certificate_settings'];
$selected = reset($form_state['values']['certificate_settings']['types']);
$field_options = certificate_fields();
// Set type variable.
variable_set('certificate_field_certificate_type', $selected);
// Get field's options from types selection.
if (variable_get('certificate_field_grouping', 0)) {
$field_options_array = variable_get('certificate_field_groups', array());
}
else {
$field_options_array = certificate_get_selected_type_options();
}
// Set variables for mappings.
if ($field_options_array) {
foreach ($field_options_array as $key => $option_name) {
variable_set('certificate_type_' . $key . '_template', $settings['map'][$key]);
}
}
// Save module provided mappings.
foreach ($form_state['values']['certificate_settings']['map'] as $key => $val) {
if (is_array($val)) {
// Custom map group.
variable_set("certificate_map_{$key}", $val);
}
}
// Friendly message.
drupal_set_message(t('The certificate mapping options have been saved.'));
}