function taxonomy_defaults_form_submit in Taxonomy Defaults 7
Same name and namespace in other branches
- 5 taxonomy_defaults.module \taxonomy_defaults_form_submit()
- 6.2 taxonomy_defaults.admin.inc \taxonomy_defaults_form_submit()
- 6 taxonomy_defaults.admin.inc \taxonomy_defaults_form_submit()
Store settings in the variable table.
File
- ./
taxonomy_defaults.admin.inc, line 119 - Administration forms for the taxonomy_defaults module
Code
function taxonomy_defaults_form_submit($form, &$form_state) {
foreach (node_type_get_types() as $type => $name) {
if (!is_array($form_state['values'][$type])) {
continue;
}
foreach ($form_state['values'][$type] as $vid => $values) {
variable_set("taxdef_{$type}_{$vid}_visible", !$values['hide_vocab']);
if (isset($values['tags'])) {
$typed_input = $values['tags'];
$typed_terms = drupal_explode_tags($typed_input);
$inserted = array();
foreach ($typed_terms as $typed_term) {
// See if the term exists in the chosen vocabulary
// and return the tid; otherwise, add a new record.
$possibilities = taxonomy_get_term_by_name($typed_term);
$typed_term_tid = NULL;
// tid match, if any.
foreach ($possibilities as $possibility) {
if ($possibility->vid == $vid) {
$typed_term_tid = $possibility->tid;
}
}
if ($typed_term_tid) {
$inserted[] = $typed_term_tid;
}
else {
drupal_set_message(t("'@term' does not exist.", array(
'@term' => $typed_term,
'@vocab' => $vid,
)), 'warning');
}
}
variable_set("taxdef_{$type}_{$vid}", $inserted);
}
else {
variable_set("taxdef_{$type}_{$vid}", is_array($values['select']) ? $values['select'] : array(
$values['select'],
));
}
}
}
drupal_set_message(t('The configuration options have been saved.'));
}