function taxonomy_menu_vocab_submit in Taxonomy menu 7.2
Same name and namespace in other branches
- 8 taxonomy_menu.admin.inc \taxonomy_menu_vocab_submit()
- 6.2 taxonomy_menu.module \taxonomy_menu_vocab_submit()
- 7 taxonomy_menu.module \taxonomy_menu_vocab_submit()
Form submission handler for taxonomy_form_vocabulary().
Check to see if the user has selected a different menu, and only rebuild if this is the case.
See also
taxonomy_menu_form_taxonomy_form_vocabulary()
1 string reference to 'taxonomy_menu_vocab_submit'
- taxonomy_menu_form_taxonomy_form_vocabulary in ./
taxonomy_menu.admin.inc - Form constructor for the vocabulary editing form. We add our taxonomy_menu settings in here on a per-vocabulary basis.
File
- ./
taxonomy_menu.admin.inc, line 182 - Administrative page callbacks for the Taxonomy menu module.
Code
function taxonomy_menu_vocab_submit($form, &$form_state) {
// Initialize flag variables for updating/rebuilding the taxonomy menu.
$update = FALSE;
$insert = FALSE;
$menu_disabled = $form_state['values']['taxonomy_menu']['vocab_parent'] == '0';
$vid = $form_state['values']['vid'];
// Flatten array of submitted settings so we can save them more easily.
$flatten_settings = _taxonomy_menu_flatten_form_settings($form_state['values']['taxonomy_menu']);
// If menu location has been set to disabled, don't throw notices by trying to
// explode 0 with ':' .
$vocab_parent = $flatten_settings['vocab_parent'];
$menu_location = $vocab_parent == '0' ? '0:0' : $vocab_parent;
list($flatten_settings['vocab_menu'], $flatten_settings['vocab_parent']) = explode(':', $menu_location);
// Get all the settings that have changed since the last submit. If some of
// them have changed, then update the taxonomy menu.
$changed_settings = array();
if ($vid != 0) {
$changed_settings = _taxonomy_menu_get_changed_settings($flatten_settings, $vid);
if (!empty($changed_settings)) {
$update = TRUE;
// Options have changed, save/update the menu.
$menu_change = in_array('vocab_parent', $changed_settings) || in_array('vocab_menu', $changed_settings);
if ($menu_change) {
// Menu location has changed.
if ($menu_disabled) {
// Menu was disabled, delete all existing menu links.
taxonomy_menu_menu_links_delete($vid);
}
else {
// Menu location has been changed and is not disabled.
$old_vocab_parent = taxonomy_menu_variable_get('vocab_parent', $vid, '0');
$old_vocab_menu = taxonomy_menu_variable_get('vocab_menu', $vid, '0');
if ($old_vocab_menu == '0' && $old_vocab_parent == '0') {
// Menu was disabled before, create new links.
$insert = TRUE;
}
}
// Do a full menu rebuild in case we have removed or moved the menu.
variable_set('menu_rebuild_needed', TRUE);
}
}
elseif (!$flatten_settings['rebuild']) {
// Display a notification message. Nothing to update.
drupal_set_message(t('The Taxonomy menu was not updated. Nothing to update.'), 'status');
}
}
// Save all the submitted values.
_taxonomy_menu_save_form_settings($flatten_settings, $vid);
// We don't need to check for the disabled menu location because the rebuild
// function will delete the taxonomy menu in all cases.
if ($flatten_settings['rebuild']) {
taxonomy_menu_rebuild($vid);
}
elseif ($insert) {
// Update only menu links that are available in taxonomy_menu table.
taxonomy_menu_menu_links_insert($vid);
}
elseif ($update) {
// Update only menu links that are available in taxonomy_menu table.
taxonomy_menu_menu_links_update($vid);
}
}