isAllowed

@param $resourceId
@param $privilege

@return mixed
506459
protected function isAllowed($resourceId, $privilege)
    {
        $rcmUserService = $this->getServiceLocator()->get(
            'RcmUser\Service\RcmUserService'
        );

        return $rcmUserService->isAllowed(
            $resourceId,
            $privilege
        );
    }
98295
public function deletePermissions($resourceId)
    {
        $rules = $this->aclDataService->getRulesByResource($resourceId)
            ->getData();
        /** @var \RcmUser\Acl\Entity\AclRole $role */
        foreach ($rules as $rule) {
            $result = $this->aclDataService->deleteRule($rule);

            if (!$result->isSuccess()) {
                return false;
            }
        }

        return true;
    }
339624
public function delete(Resource\ResourceId $resourceId)
    {
        $this->crudRepositoryAdapter->deleteResource($this->resourceType, $resourceId);
    }
200086
public function show($resourceId, $childResouceId)
    {
        $parameters = $this->request->getParameters();
        $model = $this->repository
        ->setResource($resourceId)
        ->setRelation($this->relation())
        ->getItem($childResouceId, $parameters);
        return $this->modelResponse($model);
    }
97791
function isAllowed($role, $resource, $privilege)
	{
		if ($this->mode == self::MODE_OPTIMISTIC) {
			$roles = $this->aclModel->getTableSelection()
				->select('role')
				->where('namespace', $this->getNamespaceRepository()->getCurrentNamespace())
				->where('resource', $resource)
				->where('privilege', $privilege)
				->fetchPairs('role', 'role');
			return count($roles) == 0 || array_key_exists($role, $roles);
		} elseif($this->mode == self::MODE_PESSIMISTIC) {
			return (bool) $this->aclModel->getTableSelection()
				->select('id')
				->where('namespace', $this->getNamespaceRepository()->getCurrentNamespace())
				->where('role', $role)
				->where('resource', $resource)
				->where('privilege', $privilege)
				->count();
		}
	}
559050
public function getResource($resourceId)
    {
        if (isset($this->resources[$resourceId])) {
            return $this->resources[$resourceId];
        }

        $dynamicResource = $this->dynamicResourceMapper($resourceId);

        if (!empty($dynamicResource)) {
            return $dynamicResource;
        }

        return null;
    }
822398
public function allowedUserGroups( $privilege = self::PRIVILEGE_DEFAULT )
    {
        $result = array();

        if ( null === $this->userGroups )
        {
            $this->userGroups = $this->getMapper()
                                     ->findUserGroups();
        }

        foreach ( $this->userGroups as $id => $name )
        {
            if ( $this->isAllowed( 'user.group.' . $id, $privilege ) )
            {
                $result[$id] = $name;
            }
        }

        return $result;
    }
634476
public function allowed($action, $resourceType)
    {
        $resourceType = $resourceType instanceof Resource ? $resourceType->getResourceType() : $resourceType;

        // Get all the ids from privileges which match the given resource type.
        $ids = array_unique(array_map(function (Permission $permission) {
            return $permission->getResourceId();
        }, array_filter($this->getPermissions(), function (Permission $permission) use ($resourceType) {
            return $permission instanceof Privilege && $permission->getResourceType() === $resourceType;
        })));

        return array_values(array_filter($ids, function ($id) use ($action, $resourceType) {
            return $this->can($action, $resourceType, $id);
        }));
    }
206569
private function checkEdition(TokenInterface $token, ResourceRights $resourceRights)
    {
        $user = $token->getUser();
        $resource = $resourceRights->getResource();

        if (!$this->hasAdminToolAccess($token, 'formalibre_reservation_tool') || $user === 'anon.') {
            return VoterInterface::ACCESS_DENIED;
        }
        $userOrganizations = $user->getOrganizations();
        $resourceOrganizations = $resource->getOrganizations();

        foreach ($userOrganizations as $userOrga) {
            foreach ($resourceOrganizations as $resourceOrga) {
                if ($userOrga->getId() === $resourceOrga->getId()) {
                    return VoterInterface::ACCESS_GRANTED;
                }
            }
        }

        return VoterInterface::ACCESS_DENIED;
    }
709958
public function isPagesResourceId($resourceId)
    {
        $resources = explode('.', $resourceId);

        return ($this->isSitesResourceId($resourceId) && !empty($resources[2])
            && $resources[2] === self::RESOURCE_PAGES);
    }
647915
function isAllowed(/*iAuthResource*/ $resource = null, /*iIdentity*/ $role = null)
    {
        $role = ($role) ?: $this->identity();

        if (!is_object($resource)
            || (!$resource instanceof PermResource || !method_exists($resource, 'getRouteMatch'))
        )
            throw new \Exception('Invalid Resource Type, Can`t Check The Permissions.');

        $return = true;

        $matchedRouteName = $resource->getRouteMatch()->getMatchedRouteName();

        // Access Admin Route Need Authorized User
        if ($matchedRouteName == \yimaAdminor\Module::ADMIN_ROUTE_NAME)
            $return = $return && $role->hasAuthenticated();

        return $return;
    }
1023093
public function revoke($permissions, $resourceName = null, $resourceId = null)
    {
        return $this->lock()->deny($permissions, $resourceName, $resourceId);
    }
489190
public function allowedUsers( $privilege = self::PRIVILEGE_DEFAULT )
    {
        $auth = $this->getAuthenticationService();

        if ( $auth->hasIdentity() )
        {
            $identity = $auth->getIdentity();

            return array(
                $identity->id => $identity->displayName,
            );
        }
        else
        {
            return array();
        }
    }
377758
public function isAll(string $idRole, string $idResource = null): bool
    {
        $acl = $this->getAcl($idRole);
        if ($idResource) {
            $callback = function ($row) use ($idResource) {
                if ($idResource) {
                    return $row['id_resource'] == $idResource;
                }
                return true;
            };
            $res = array_values(array_filter($acl, $callback));
            if (isset($res[0])) {
                return $res[0]['id_privilege'] == self::ALL;
            }
        }

        $aclAll = array_values($acl);
        if (isset($aclAll[0])) {
            return $aclAll[0]['id_resource'] == self::ALL && $aclAll[0]['id_privilege'] == self::ALL;
        }
        return false;
    }
587563
public static function view_resource($resourceid) {
        global $DB, $CFG;
        require_once($CFG->dirroot . "/mod/resource/lib.php");

        $params = self::validate_parameters(self::view_resource_parameters(),
                                            array(
                                                'resourceid' => $resourceid
                                            ));
        $warnings = array();

        // Request and permission validation.
        $resource = $DB->get_record('resource', array('id' => $params['resourceid']), '*', MUST_EXIST);
        list($course, $cm) = get_course_and_cm_from_instance($resource, 'resource');

        $context = context_module::instance($cm->id);
        self::validate_context($context);

        require_capability('mod/resource:view', $context);

        // Call the resource/lib API.
        resource_view($resource, $course, $cm, $context);

        $result = array();
        $result['status'] = true;
        $result['warnings'] = $warnings;
        return $result;
    }
450360
public function configFor($resourceName, $resourceId = null)
    {
        foreach ($this->providers as $provider) {
            try {
                // Throw NotFound even if other providers dont
                if (!$config = $provider->configFor($resourceName, $resourceId)) {
                    continue;
                }

                return $config;
            } catch (NotFound $e) {
            }
        }

        throw new ResourceNotFoundException("No provider found a config found for '$resourceName' and id '$resourceId'");
    }
461151
public function isIpAuthorized(ResourceNode $resourceNode): bool
    {
        $allowed = $resourceNode->getAllowedIps();
        if (!empty($allowed)) {
            $currentParts = explode('.', $_SERVER['REMOTE_ADDR']);

            foreach ($allowed as $allowedIp) {
                $allowedParts = explode('.', $allowedIp);
                $allowBlock = [];

                foreach ($allowedParts as $key => $val) {
                    if (isset($currentParts[$key])) {
                        $allowBlock[] = ($val === $currentParts[$key] || '*' === $val);
                    }
                }

                if (!in_array(false, $allowBlock)) {
                    return true;
                }
            }

            // the current user ip is not in the allowed list
            return false;
        }

        // the current resource does not restrict ips
        return true;
    }