Checks if a user and/or a group has a permission.

@param mixed $id_option
@param string $type
@param bool $force
@return bool
343646
public function has(string $id_option = null, string $type = 'page', bool $force = false): bool
  {
    if ( !$force && $this->user && $this->user->is_dev() ){
      return true;
    }
    if ( $id_option = $this->_get_id_option($id_option, $type) ){
      $option = $this->opt->option($id_option);
      if ( !empty($option['public']) ){
        return true;
      }
      return $this->pref->has($id_option, $force);
    }
    return false;
  }
706632
public function checkRestrictedGrantType($client_id, $grant_type)
	{
		// get client details
		$client = $this->getClientDetails($client_id);

		// check to make sure grant type is acceptable for client
		if (isset($client['grant_types']))
		{
			$grant_types = explode(' ', $client['grant_types']);
			return in_array($grant_type, (array) $grant_types);
		}

		return true;
	}
112754
public function view($type = null, $id = null)
    {
        $this->_validateActionIsEnabled('view');

        $this->_event('beforeView', [
            'id' => $id
        ]);

        $data = $this->Model->get($id, [
            'contain' => $this->type['contain']
        ]);
        $this->set('data', $data);

        $this->_event('afterView', [
            'id' => $id
        ]);
    }
645131
public function user_has(string $id_option, string $id_user): bool
  {
    return (bool)$this->_retrieve_ids($id_option, $id_user);
  }
893989
public function checkAccess(array $permissions = [], bool $force = false): bool
    {
        // Guests are not allowed by default
        if ($this->isGuest()) {
            return false;
        }

        // Allow access to all users when permissions argument is empty
        if (empty($permissions)) {
            return true;
        }

        // Administrators are supermen :P
        if ($this->isAdmin()) {
            return true;
        }

        // User has the right to do this?
        if (count(array_intersect($permissions, $this->perissions)) > 0) {
            return true;
        }

        // You aren't allowed, by default.
        return false;
    }
228
public function hasPermissionForId($id)
    {
        try {
            $em = $this->entityManager->getDoctrineEntityManager();
            $permission = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->find($id);
            
            if ($permission !== null) {
                return true;
            }
            
            return false;
        } catch (\Exception $e) {
            throw new Exception('Cannot check if there is a permission for the given id "' . $id . '".', 0, $e);
        }
    }
110092
public function checkProfileEditPermission($user_id) {
    $current_user_id = App::make('sentry')->getUser()->id;

    // edit his profile
    if ($user_id == $current_user_id) {
      return true;
    }
    // has special permission to edit other user profiles
    $edit_perm = Config::get('authentication::permissions.edit_profile');
    if ($this->hasPermission($edit_perm)) {
      return true;
    }

    return false;
  }
644850
public function supportsConstraint($type, array $options = [])
    {
        if (in_array($type, $this->types)) {
            $this->type = $type;
            return true;
        }

        return false;
    }
185917
public function check(Permission $permission, TokenInterface $token, $objectLanguage = null)
    {
        $user = $token->getUser();

        $masks = $this->getEffectiveMasks();
        if (isset($masks[$this->userClass][$user->getId()])) {
            if ($masks[$this->userClass][$user->getId()] & $permission->getBit()) {
                return true;
            }
        }
        foreach ($user->getGroups() as $group) {
            if (isset($masks[$this->groupClass][$group->getId()])) {
                if ($masks[$this->groupClass][$group->getId()] & $permission->getBit()) {
                    return true;
                }
            }
        }

        return false;
    }
748337
public function checkRestrictedGrantType($client_id, $grant_type)
	{
		$client = $this->repo->find($client_id);

		if(!$client) {
			return false;
		}

		$restrictedTypes = $client->getRestrictedGrantTypes();

		// Null restricted type assuemd to be true.
		if(is_null($restrictedTypes)) {
			return true;
		}


		return in_array($grant_type, $restrictedTypes);
	}
228376
public function get(string $id_option = null, string $type = 'page', bool $force = false): ?array
  {
    /*
    if ( $all = $this->get_all($id_option, $type) ){
      $r = [];
      foreach ( $all as $a ){
        if ( $this->has($a['id'], '', $force) ){
          $r[] = $a;
        }
      }
      return $r;
    }
    */
    if (
      ($id_option = $this->_get_id_option($id_option, $type)) &&
      $this->has($id_option, $type, $force)
    ){
      return $this->pref->option($id_option);
    }
    return null;
  }
905009
private function hasPermission(AuthenticatedUserInterface $user, string $uri) {

        // Collect permissions
        $permissions = $this->getParameterByKey("permissions");

        // Iterate over permission
        foreach ($permissions as $permissionPath => $acceptableRoles) {
            if($permissionPath[0] !== "/") {
                $permissionPath = "/".$permissionPath;
            }
            if(substr($permissionPath,-1) !== "/") {
                $permissionPath = $permissionPath."/";
            }
            $match = preg_match($permissionPath,$uri);
            if ($match == 1) {
                if(in_array(Role::ANON_USER,$acceptableRoles)) return true;
                foreach ($acceptableRoles as $permissionRole) {
                    if(in_array($permissionRole,$user->getRoles())) return true;
                }
                return false;
            }
        }
        return false;
    }
1357524
public function hasPermission($id)
    {
        if ($id instanceof Eloquent) $id = $id->getKey();

        return $this->getPermissionFromGroup($id) !== null;
    }
188328
public function group_has(string $id_option, string $id_group): bool
  {
    return (bool)$this->_retrieve_ids($id_option, null, $id_group);
  }
1076655
public boolean hasPermissionsById(String id, Collection<Permission> permissions) {
        AuthorizationInfo authorizationInfo = getAuthorizationInfoById(id);
        return authorizationInfo != null && isPermittedAll(permissions, authorizationInfo);
    }
827069
private function checkRolePermission($roleName, $permissionName, $type = 'global', $item = null)
    {
        if ($type === 'global') {
            return $this->checkRoleGlobalPermission($roleName, $permissionName);
        } elseif ($type === 'roles-hierarchy') {
            return $this->checkRoleHierarchyPermission($roleName, $permissionName, $item);
        } elseif ($type === 'contenttype') {
            return $this->checkRoleContentTypePermission($roleName, $permissionName, $item);
        }

        throw new \InvalidArgumentException('Unknown permission type to check');
    }
281785
public function hasPermission($permission, $force = false)
    {
        if (! is_null($this->getUser())) {
            return $this->getUser()->hasPermission($permission, $force);
        }

        return false;
    }