Determine if one or more actions are allowed

@param string|array $action
@param string|\BeatSwitch\Lock\Resources\Resource $resource
@param int $resourceId
@return bool
494478
public function can($action, $resource = null, $resourceId = null)
    {
        $this->assertLockInstanceIsSet();

        return $this->lock->can($action, $resource, $resourceId);
    }
1118991
public function canSubresourceMultiple($subresources, $action) : bool {
		if (!is_array($subresources)) {
			$subresources = [$subresources];
		}
		foreach ($subresources as $v) {
			if (!$this->canSubresourceCached($v, $action)) {
				return false;
			}
		}
		return true;
	}
184060
public function isExportFileAction($resource, $action)
    {
        return isset($this->exportFileActions[$resource]) && in_array($action, $this->exportFileActions[$resource]);
    }
1304548
public function cannot($action, $resource = null, $resourceId = null)
    {
        $this->assertLockInstanceIsSet();

        return $this->lock->cannot($action, $resource, $resourceId);
    }
541427
public function toggle($action, $resource = null, $resourceId = null)
    {
        $this->assertLockInstanceIsSet();

        $this->lock->toggle($action, $resource, $resourceId);
    }
623947
public function canSubresourceExtended($resource_id, $subresource, $action, $module_id = null) : bool {
		// rearrange controllers
		if (!isset(self::$cached_controllers_by_ids)) {
			self::$cached_controllers_by_ids = [];
			foreach (self::$cached_controllers as $k => $v) {
				self::$cached_controllers_by_ids[$v['id']] = $k;
			}
		}
		// if we got a string
		if (is_string($resource_id)) {
			$resource_id = self::$cached_controllers[$resource_id]['id'] ?? null;
		}
		// if resource is not present we return false
		if (empty(self::$cached_controllers_by_ids[$resource_id])) return false;
		// missing features
		if (!empty(self::$cached_controllers[self::$cached_controllers_by_ids[$resource_id]]['missing_features'])) return false;
		// load all actions from datasource
		if (is_null(self::$cached_actions) && !\Object\Error\Base::$flag_database_tenant_not_found) {
			self::$cached_actions = \Object\ACL\Resources::getStatic('actions', 'primary');
		}
		// super admin
		if (\User::get('super_admin')) {
			// prohibitive actions
			if (empty(self::$cached_actions[$action]['prohibitive'])) {
				return true;
			}
		}
		if (is_string($action)) $action = self::$cached_actions[$action]['id'];
		// load all sub-resources from datasource
		if (is_null(self::$cached_subresources) && !\Object\Error\Base::$flag_database_tenant_not_found) {
			self::$cached_subresources = \Object\ACL\Resources::getStatic('subresources', 'primary');
		}
		if (is_string($subresource)) $subresource = self::$cached_subresources[$subresource]['id'];
		// see if we have subresources overrides
		$subresources = \User::get('subresources');
		if (!empty($subresources)) {
			// process permissions
			$all_actions = $subresources[$resource_id][$subresource][-1] ?? [];
			$actual_action = $subresources[$resource_id][$subresource][$action] ?? [];
			$temp = array_merge_hard($all_actions, $actual_action);
			if (!empty($temp)) {
				if (!empty($module_id)) {
					$temp = $temp[$module_id] ?? null;
				} else { // find any active permision
					$temp2 = $temp;
					$temp = null;
					foreach ($temp2 as $k => $v) {
						if ($v === 0) {
							$temp = 0;
							break;
						}
					}
				}
			}
			if ($temp === 0) {
				return true;
			} else if (!empty($temp)) {
				return false;
			}
		}
		// go through roles
		foreach (\User::roles() as $v) {
			$temp = $this->processSubresourceRole($v, $resource_id, $subresource, $action, $module_id);
			if ($temp === 1) {
				return true;
			} else if ($temp === 2) {
				return false;
			}
		}
		// go through teams
		foreach (\User::teams() as $v) {
			$temp = $this->processSuresourceTeam($v, $resource_id, $subresource, $action, $module_id);
			if ($temp === 1) {
				return true;
			} else if ($temp === 2) {
				return false;
			}
		}
		return false;
	}
643320
public function isUnlocked(ResourceNode $resourceNode): bool
    {
        if ($resourceNode->getAccessCode()) {
            // check if the current user already has unlocked the resource
            // maybe store it another way to avoid require it each time the user session expires
            return !empty($this->session->get($resourceNode->getUuid()));
        }

        // the current resource does not require a code
        return true;
    }
539441
public function isAllowed($role, $resource) {

		if(false === is_string($role)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($role)), E_USER_ERROR);
		}

		if(false === is_string($resource)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($resource)), E_USER_ERROR);
		}

		if(true === isset($this -> permissions[$role][$resource])) {
			return $this -> permissions[$role][$resource];
		}

		return false;
	}
523564
protected function resolvePrivileges($permissions, $action, Resource $resource)
    {
        // Search for privileges in the permissions.
        foreach ($permissions as $permission) {
            // If we've found a valid privilege, return true.
            if ($permission instanceof Privilege && $permission->isAllowed($this, $action, $resource)) {
                return true;
            }
        }

        return false;
    }
1271722
public function deny($action, $resource = null, $resourceId = null, $conditions = [])
    {
        $this->assertLockInstanceIsSet();

        $this->lock->deny($action, $resource, $resourceId, $conditions);
    }
374465
protected function _actionIsEnabled($action)
    {
        $actions = $this->type['actions'];

        if (array_key_exists($action, $actions)) {
            return $actions[$action];
        }
        return true;
    }
822689
protected function checkAuth($action,$resource)
	{
		return true; // remove after testing
		try {
			$userModel  = new User();
			$auth       = new BasicAuthenticator($userModel);
			$user       = $auth->currentUser();
			if ($user instanceof UserInterface) {
				$authorizer = new Authorizer( $user );
				$result     = $authorizer->can( $action, $resource );
			} else {
				$result = false;
			}
		} catch (\Exception $e) {
			\error_log($e->getMessage());
			$result = false;
		}
		return $result;
	}
506459
protected function isAllowed($resourceId, $privilege)
    {
        $rcmUserService = $this->getServiceLocator()->get(
            'RcmUser\Service\RcmUserService'
        );

        return $rcmUserService->isAllowed(
            $resourceId,
            $privilege
        );
    }
22952
protected function resolveRestrictions($permissions, $action, Resource $resource)
    {
        foreach ($permissions as $permission) {
            // If we've found a matching restriction, return false.
            if ($permission instanceof Restriction && ! $permission->isAllowed($this, $action, $resource)) {
                return false;
            }
        }

        return true;
    }
903827
public function grant($permissions, $resourceName = null, $resourceId = null)
    {
        return $this->lock()->allow($permissions, $resourceName, $resourceId);
    }
982575
public function clear($action = null, $resource = null, $resourceId = null)
    {
        $actions = (array) $action;
        $resourceObject = $this->convertResourceToObject($resource, $resourceId);
        $permissions = $this->getPermissions();

        if ($action === null && $resource === null) {
            // Clear every permission for this lock instance.
            foreach ($permissions as $permission) {
                $this->removePermission($permission);
            }
        } elseif ($action === null && $resource !== null) {
            // Clear all permissions for a given resource.
            /** @todo Needs to be implemented */
        } else {
            // Clear every permission for the given actions.
            foreach ($actions as $action) {
                $this->clearPermission($action, $resourceObject, $permissions);
            }
        }
    }
965871
public function listAllowedByClass($resourceClass, string $action = ''): array
    {
        $permissions = $this->groupPermissions->getResourcePermissionsByClass($resourceClass);
        $permitted = [];
        foreach ($permissions as $permission) {
            if (!$action || $permission->can($action)) {
                $permitted[] = $permission->getResourceId();
            }
        }

        return array_unique($permitted);
    }