Check if permission for action.

@param ActionEvent $event The event.

@return bool
329914
private function checkPermission(ActionEvent $event)
    {
        $actionName = $event->getAction()->getName();

        $environment     = $event->getEnvironment();
        $basicDefinition = $environment->getDataDefinition()->getBasicDefinition();

        if ((('create' === $actionName) && (true === $basicDefinition->isCreatable()))
            || (('cut' === $actionName) && (true === $basicDefinition->isEditable()))
            || (false === \in_array($actionName, ['create', 'cut']))
        ) {
            return true;
        }

        $permissionMessage = 'You have no permission for model ' . $actionName .' ';
        switch ($actionName) {
            case 'create':
                $permissionMessage .= 'in ' . $environment->getDataDefinition()->getName();
                break;

            case 'cut':
                $permissionMessage .= $environment->getInputProvider()->getParameter('source');
                break;

            default:
        }

        $event->setResponse(
            \sprintf(
                '<div style="text-align:center; font-weight:bold; padding:40px;">%s.</div>',
                $permissionMessage
            )
        );

        return false;
    }
38698
private boolean checkPermissions(Activity activity) {
        String[] permissions = getRequiredAndroidPermissions();
        return handler.areAllPermissionsGranted(activity, permissions);
    }
1119326
public function hasPermission($permission)
    {
        if ($this->id == self::ADMINISTRATOR_ID) {
            return true;
        }

        return $this->permissions->contains('permission', $permission);
    }
984192
def _action_enabled(self, event, action):
        """"""
        event_actions = self._aconfig.get(event)
        if event_actions is None:
            return True
        if event_actions is False:
            return False
        return action in event_actions
50447
public function rights(ResourceActionEvent $event)
    {
        // forward to the resource type
        $options = [];

        $params = $event->getOptions();

        if (isset($params['recursive']) && 'true' === $params['recursive']) {
            $options[] = Options::IS_RECURSIVE;
        }

        $data = $event->getData();
        $this->crud->update(ResourceNode::class, $data, $options);
        $this->lifecycleManager->rights($event->getResourceNode(), $event->getData());

        $event->setResponse(new JsonResponse(
            $this->serializer->serialize($event->getResourceNode())
        ));
    }
1121963
public function onAddPermissions(AddPermissionsEventInterface $event)
    {
        $permissionTree = ['routes' => []];
        foreach ($this->router->getRouteCollection()->getIterator() as $name => $route) {
            if (!($route instanceof RouteInterface)) {
                continue;
            }

            $permissions = $route->getPermissions();
            if (is_null($permissions)) {
                continue;
            }

            $permissionTree['routes'][$name] = $permissions;
        }
        $event->insertTree($permissionTree);
    }
1095624
public static function isSupportedEvent(string $event): bool
    {
        if ($ets = self::$allowedEvents) {
            return \in_array($event, $ets, true);
        }

        return true;
    }
438015
public function canAccessAction(string $controllerName, string $action): bool
    {
        if (isset($this->actions[$controllerName][$action])) {
            if (!$this->actions[$controllerName][$action]) {
                return true;
            }

            foreach ($this->actions[$controllerName][$action] as $role) {
                if ($this->hasRoleWithName($role)) {
                    return true;
                }
            }

            return false;
        }

        return $this->canAccessController($controllerName);
    }
375016
private function checkPermission(ActionEvent $event)
    {
        if (true === $event->getEnvironment()->getDataDefinition()->getBasicDefinition()->isEditable()) {
            return true;
        }

        $event->setResponse(
            '<div style="text-align:center; font-weight:bold; padding:40px;">
                    You have no permission for paste a model.
                </div>'
        );

        return false;
    }
1314445
public function checkAction($actions)
    {
        if (!$this->action) {
            return false;
        }

        if (in_array($this->action, (array)$actions)) {
            return true;
        }

        return false;
    }
325203
public function hasPermissionTo($action)
    {
        return $this->allPermissions->has(
            function($permission) use ($action) {
                return $permission->action == $action;
            }
        );
    }
39669
protected function resolvePermissions($action, Resource $resource)
    {
        $permissions = $this->getPermissions();

        // Search for restrictions in the permissions. We'll do this first
        // because restrictions should override any privileges.
        if (! $this->resolveRestrictions($permissions, $action, $resource)) {
            return false;
        }

        // Check if one of the caller's roles has permission to do the action on the resource.
        foreach ($this->getLockInstancesForCallerRoles() as $roleLock) {
            if ($roleLock->can($action, $resource)) {
                return true;
            }
        }

        // If no restrictions are found, pass when a privilege is found on either the roles or caller.
        return $this->resolvePrivileges($permissions, $action, $resource);
    }
70123
public function has_events($event)
	{
		if (isset($this->_events[$event]) and count($this->_events[$event]) > 0)
		{
			return true;
		}
		return false;
	}
803131
def _checkPermissions(self, user, event):
        """"""

        for role in user.account.roles:
            if role in event.roles:
                self.log('Access granted', lvl=verbose)
                return True

        self.log('Access denied', lvl=verbose)
        return False
999629
public function can($action, $resource = null, $resourceId = null)
    {
        $actions = (array) $action;
        $resource = $this->convertResourceToObject($resource, $resourceId);
        $permissions = $this->getPermissions();

        foreach ($actions as $action) {
            if ($aliases = $this->getAliasesForAction($action)) {
                if ($this->can($aliases, $resource) && $this->resolveRestrictions($permissions, $action, $resource)) {
                    return true;
                }
            }

            if (! $this->resolvePermissions($action, $resource)) {
                return false;
            }
        }

        return true;
    }
594238
public function handleEvent(ActionEvent $event)
    {
        $this->event = $event;
        $this->process();
        $this->event = null;
    }
1228526
public static function setPermissionsSetfacl(Event $event)
	{
		$http_user = self::getHttpdUser($event);
		foreach (self::getWritableDirs($event) as $path) {
			self::SetfaclPermissionsSetter($event, $http_user, $path);
		}
		foreach (self::getWritableFiles($event) as $path) {
			self::ChmodPermissionsSetter($event, $http_user, $path, 'file');
		}
	}