You are here

function workflow_transition_allowed in Workflow 7

Same name and namespace in other branches
  1. 5.2 workflow.module \workflow_transition_allowed()
  2. 5 workflow.module \workflow_transition_allowed()
  3. 6.2 workflow.module \workflow_transition_allowed()
  4. 6 workflow.module \workflow_transition_allowed()
  5. 7.2 workflow.deprecated.inc \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

TRUE if the role is allowed to do the transition.

3 calls to workflow_transition_allowed()
WorkflowTransition::execute in includes/Entity/WorkflowTransition.php
Execute a transition (change state of a node). @deprecated: workflow_execute_transition() --> WorkflowTransition::execute().
workflow_allowable_transitions in ./workflow.module
Get allowable transitions for a given workflow state. Typical use:
_workflow_admin_ui_transition_grid_form in workflow_admin_ui/workflow_admin_ui.pages.inc
Form builder. Build the grid of transitions for defining a workflow.

File

./workflow.module, line 541
Support workflows made up of arbitrary states.

Code

function workflow_transition_allowed($tid, $role = NULL) {
  $transition = workflow_get_workflow_transitions_by_tid($tid);
  $allowed = $transition->roles;
  $allowed = explode(',', $allowed);
  if ($role) {
    if (!is_array($role)) {
      $role = array(
        $role,
      );
    }
    return array_intersect($role, $allowed) == TRUE;
  }
}