protected function WorkflowTransition::isAllowed in Workflow 7.2
Same name and namespace in other branches
- 7 includes/Entity/WorkflowTransition.php \WorkflowTransition::isAllowed()
Verifies if the given transition is allowed.
- In settings;
- In permissions;
- By permission hooks, implemented by other modules.
Parameters
$roles:
$user:
$force:
Return value
bool TRUE if OK, else FALSE. TRUE if OK, else FALSE.
Having both $roles AND $user seems redundant, but $roles have been tampered with, even though they belong to the $user.
See also
WorkflowConfigTransition::isAllowed()
1 call to WorkflowTransition::isAllowed()
- WorkflowTransition::execute in includes/
Entity/ WorkflowTransition.php - Execute a transition (change state of a node).
File
- includes/
Entity/ WorkflowTransition.php, line 229 - Contains workflow\includes\Entity\WorkflowTransition. Contains workflow\includes\Entity\WorkflowTransitionController.
Class
- WorkflowTransition
- Implements an actual Transition.
Code
protected function isAllowed($roles, $user, $force) {
if ($force || $user->uid == 1) {
return TRUE;
}
// Check allow-ability of state change if user is not superuser (might be cron).
// Get the WorkflowConfigTransition.
// @todo: some day, WorkflowConfigTransition can be a parent of WorkflowTransition.
$workflow = $this
->getWorkflow();
$config_transitions = $workflow
->getTransitionsBySidTargetSid($this->old_sid, $this->new_sid);
$config_transition = reset($config_transitions);
if (!$config_transition || !$config_transition
->isAllowed($roles)) {
$t_args = array(
'%old_sid' => $this->old_sid,
'%new_sid' => $this->new_sid,
);
watchdog('workflow', 'Attempt to go to nonexistent transition (from %old_sid to %new_sid)', $t_args, WATCHDOG_ERROR);
return FALSE;
}
return TRUE;
}