You are here

function workflow_transition_allowed in Workflow 5

Same name and namespace in other branches
  1. 5.2 workflow.module \workflow_transition_allowed()
  2. 6.2 workflow.module \workflow_transition_allowed()
  3. 6 workflow.module \workflow_transition_allowed()
  4. 7.2 workflow.deprecated.inc \workflow_transition_allowed()
  5. 7 workflow.module \workflow_transition_allowed()

See if a transition is allowed for a given role.

Parameters

int $tid:

mixed $role: A single role (int or string 'author') or array of roles.

Return value

bool

3 calls to workflow_transition_allowed()
workflow_allowable_transitions in ./workflow.module
Get allowable transitions for a given workflow state.
workflow_execute_transition in ./workflow.module
Execute a transition (change state of a node).
workflow_transition_grid_form in ./workflow.module
Build the grid of transitions for defining a workflow.

File

./workflow.module, line 1107

Code

function workflow_transition_allowed($tid, $role = null) {
  $allowed = db_result(db_query("SELECT roles FROM {workflow_transitions} WHERE tid=%d", $tid));
  $allowed = explode(',', $allowed);
  if ($role) {
    if (!is_array($role)) {
      $role = array(
        $role,
      );
    }
    return array_intersect($role, $allowed) == TRUE;
  }
  else {
    return $allowed == TRUE;

    // allowed for anybody?
  }
}