You are here

function workflow_node_tab_access in Workflow 6

Same name and namespace in other branches
  1. 6.2 workflow.module \workflow_node_tab_access()
  2. 7.2 workflow.deprecated.inc \workflow_node_tab_access()
  3. 7 workflow.node.inc \workflow_node_tab_access()

Menu access control callback. Determine access to Workflow tab.

1 call to workflow_node_tab_access()
workflow_tab_form in ./workflow.pages.inc
Form builder. Allow workflow state change and scheduling from 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;
  }
}