function workbench_moderation_menu_local_tasks_alter in Workbench Moderation 7.3
Same name and namespace in other branches
- 7 workbench_moderation.module \workbench_moderation_menu_local_tasks_alter()
Implements hook_menu_local_tasks_alter().
Hide the node revisions tab conditionally.
Check if the node type is subject to moderation. If so, unset the revision tab. This step is necessary because hook_menu_alter cannot change the menu item type on a node type by node type basis for node/%node/revision.
Additionally, workbench_menu_alter() is used to change the page callback for node/%node/revisions so that this URL redirects to node/%node/moderation for node types subject to moderation.
File
- ./
workbench_moderation.module, line 252 - Content moderation for Workbench.
Code
function workbench_moderation_menu_local_tasks_alter(&$data, $router_item, $root_path) {
// Do we need to bother doing anything?
if (empty($data['tabs'][0]['output'])) {
return;
}
// Check the path.
$arg = arg(0, $root_path);
$arg1 = arg(1, $root_path);
if ($arg != 'node' || $arg1 != '%') {
return;
}
// Get the node for the current menu router.
if ($node = menu_get_object()) {
// Here is the reason this hook implementation exists:
// If this is a node that gets moderated, don't show 'node/%/revisions'
if (workbench_moderation_node_moderated($node) === TRUE) {
foreach ($data['tabs'][0]['output'] as $key => $value) {
if (!empty($value['#link']['path']) && $value['#link']['path'] == 'node/%/revisions') {
unset($data['tabs'][0]['output'][$key]);
$data['tabs'][0]['count'] -= 1;
break;
}
}
}
}
}