/**
* Returns whether or not a user can perform an action
* if a status is given then it will be taken into consideration
* @param $actionName
* @param null $statusName
* @return bool
* @throws \Exception
*/
public function userCanPerformAction($actionName, $statusName = null)
{
if (!$this->user) {
throw new \Exception('No user is defined in this Workflow Manager!');
}
if ($this->user->isAdmin()) {
return true;
}
$requiredUserIds = $this->workflow->getValidUsersForAction($actionName, $statusName);
if ($requiredUserIds === null) {
return true;
}
foreach ($requiredUserIds as $id) {
if (in_array($id, $this->userIds)) {
return true;
}
}
return false;
}