function _taxonomy_menu_taxonomy_termapi_helper in Taxonomy menu 7
Abstraction of hook_taxonomy_term_<operation>()
3 calls to _taxonomy_menu_taxonomy_termapi_helper()
- taxonomy_menu_taxonomy_term_delete in ./
taxonomy_menu.module - Implements hook_taxonomy_term_delete().
- taxonomy_menu_taxonomy_term_insert in ./
taxonomy_menu.module - Implements hook_taxonomy_term_insert($term).
- taxonomy_menu_taxonomy_term_update in ./
taxonomy_menu.module - Implements hook_taxonomy_term_update().
File
- ./
taxonomy_menu.module, line 471 - Adds links to taxonomy terms into a menu.
Code
function _taxonomy_menu_taxonomy_termapi_helper($term, $operation) {
// Only sync if taxonomy_menu is enabled for this vocab and the 'sync'
// option has been checked.
$menu_name = variable_get(_taxonomy_menu_build_variable('vocab_menu', $term->vid), 0);
$sync = variable_get(_taxonomy_menu_build_variable('sync', $term->vid), 0);
$depth = variable_get(_taxonomy_menu_build_variable('max_depth', $term->vid), 0);
if ($menu_name && $sync && !_taxonomy_menu_term_too_deep($term->tid, $depth)) {
$item = array(
'tid' => $term->tid,
'vid' => $term->vid,
'term' => $term,
'menu_name' => $menu_name,
'mlid' => _taxonomy_menu_get_mlid($term->tid, $term->vid),
);
switch ($operation) {
case 'insert':
$text = 'Added term %term to taxonomy menu %menu_name.';
break;
case 'update':
$text = 'Updated term %term in taxonomy menu %menu_name.';
break;
case 'delete':
$text = 'Deleted term %term from taxonomy menu %menu_name.';
break;
}
$message = t($text, array(
'%term' => $term->name,
'%menu_name' => $menu_name,
));
// Run function.
taxonomy_menu_handler($operation, $item);
// Report status.
drupal_set_message($message, 'status');
// Rebuild the menu.
menu_cache_clear($menu_name);
}
}