function workflow_node_tab_access in Workflow 6.2
Same name and namespace in other branches
- 6 workflow.module \workflow_node_tab_access()
- 7.2 workflow.deprecated.inc \workflow_node_tab_access()
- 7 workflow.node.inc \workflow_node_tab_access()
Menu access control callback. Determine access to Workflow tab.
1 string reference to 'workflow_node_tab_access'
- workflow_menu in ./
workflow.module - Implementation of hook_menu().
File
- ./
workflow.module, line 39 - Support workflows made up of arbitrary states.
Code
function workflow_node_tab_access($node = NULL) {
global $user;
$wid = workflow_get_workflow_for_type($node->type);
if ($wid === FALSE) {
// No workflow associated with this node type.
return FALSE;
}
$roles = array_keys($user->roles);
if ($node->uid == $user->uid) {
$roles = array_merge(array(
'author',
), $roles);
}
$workflow = db_fetch_object(db_query("SELECT * FROM {workflows} WHERE wid = %d", $wid));
$allowed_roles = $workflow->tab_roles ? explode(',', $workflow->tab_roles) : array();
if (user_access('administer nodes') || array_intersect($roles, $allowed_roles)) {
return TRUE;
}
else {
return FALSE;
}
}