Does the user have the permission?
@param  string|array $permissions Permission to lookup
@return boolean
342123
public function has($permissions, $all = true)
    {
        if (! is_array($permissions)) {
            $permissions    =   (array) $permissions;
        }

        $permissions=   array_unique($permissions);
        $filtered   =   [];
        $usersRoles =   $this->roles;
        $allowed    =   false;
        $filtered   =   array_where($permissions, [$this, 'permissionFilter']);
        $filteredCount  =   count($filtered);

        // Does the permission lookup require all permissions to be found?
        if (true === $all) {
            return count($permissions) === $filteredCount;
        }

        // Nope, just as long as they have one of them
        return 0 < $filteredCount;
    }
280851
public function canAny($permissions, &$failed = null)
    {
        $permissions = is_array($permissions) ? collect($permissions) : $permissions;

        $failed = $permissions->reject(function ($permission) {
            return $this->can($permission);
        })->values();

        return $permissions->count() !== $failed->count();
    }
401711
public function permissions($permissions = null)
    {
        if (!$this->protect()) {
            return $this;
        }

        if ($permissions === null) {
            return $this->_allow;
        }

        if (is_string($permissions) && $permissions == 'all') {
            $permissions = true;
        }

        if (is_string($permissions) && $permissions == 'none') {
            $permissions = false;
        }

        if (is_array($permissions)) {
            foreach ($permissions as $permission) {
                if (!in_array($permission, $this->_availablePermissions)) {
                    throw new Exception(sprintf('Invalid permission: %s', $permission));
                }

                if (!$this->crypto()->permissionImplemented($permission)) {
                    throw new Exception(sprintf('Permission not implemented in crypto engine: %s', $permission));
                }
            }
        }

        $this->_allow = $permissions;

        return $this;
    }
564699
public function hasPermission($permission)
    {
        foreach($this->roles as $role){
            if($role->hasPermission($permission))
                return true;
        }
        return false;
    }
910423
public function hasPermission($permission)
    {
        $perm_id = $this->getPermissionId($permission);
        $roles = $this->getRolesWithPermission($perm_id);

        foreach ($roles as $role)
            if ($this->hasRole($role))
                return true;

        return false;
    }
1284364
public function findAllWithAccess($permissions)
	{
		return array_filter($this->findAll(), function($user) use ($permissions)
		{
			return $user->hasAccess($permissions);
		});
	}
510393
public function filterByPermission($permissions)
    {
        $permissions = is_array($permissions) ? $permissions : func_get_args();

        foreach ($permissions as $permission) {
            if (!$this->auth->user()->can($permission)) {
                throw new PermissionDeniedException("You don't have permission to \"{$permission}\".");
            }
        }
    }
303776
public function roleLoadPermissions($roles)
    {
        if (!$roles) {
            return false;
        }
        $multi = is_array($roles);
        if (!$multi) {
            $roles = [$roles];
        }
        $permissions_ids = [];

        foreach ($roles as $role) {
            if (!is_array($role->_permission_ids)) {
                $role->_permission_ids = explode(',', $role->_permission_ids);
            }
            $permissions_ids = array_merge($permissions_ids, $role->_permission_ids);
        }
        $perms = $this->permissionFetchById($permissions_ids);
        foreach ($perms as $perm) {
            foreach ($roles as $role) {
                if (in_array($perm->permission_id, $role->_permission_ids)) {
                    $role->addPermission($perm);
                    continue;
                }
            }
        }
        return true;
    }
99422
protected function checkPermissions($file, $permissions = '0444')
    {
        if (substr(sprintf('%o', fileperms($file)), -4) === $permissions) {
            return true;
        }

        $vars = array('%name' => $file, '%perm' => $permissions);
        return $this->translation->text('File %name is not secure. The file permissions must be %perm', $vars);
    }
255228
protected function checkPermissions(array &$permissions) {
    $available = array_keys($this->getAllPermissions());

    foreach ($permissions as $permission) {
      if (!in_array($permission, $available)) {
        throw new \RuntimeException(sprintf('Invalid permission "%s".', $permission));
      }
    }
  }
355350
public function findWithPermission($permission)
    {
        return array_filter(
            $this->findAll(),
            function ($user) use ($permission) {
                return $user->has($permission);
            }
        );
    }
444166
public function hasPermission($permission)
    {
        return (is_array($this->permissions) &&
                isset($this->permissions[$permission]) &&
                $this->permissions[$permission] == true
               ) ||
               (
                   isset($this->permissions['administrator']) &&
                $this->permissions['administrator'] == true
               );
    }
278352
public function syncPermissions(array $permissions)
    {
        foreach ($this->permissions as $current)
        {
            /** @var Permission $current */
            if ($current->isAllowed() && ! in_array($current->getName(), $permissions))
            {
                $this->removePermission($current);
            }
        }

        $this->allow($permissions);
    }
940256
private function getAllowedPermissions($permissions)
    {
        $allowedPermissions = [];
        foreach ($permissions as $permission => $allowed) {
            if ($allowed) {
                $allowedPermissions[] = $permission;
            }
        }

        return $allowedPermissions;
    }
1136586
public function setPermissions(array $permissions)
    {
        if (!is_array($permissions) || empty($permissions)) {
            throw new InvalidArgumentException('You have to provide at least one permission!');
        }
        $this->permissions = $permissions;
    }
603569
public function has($permissions, $all = true)
    {
        if (! is_array($permissions)) {
            $permissions    =   (array) $permissions;
        }

        $permissions=   array_unique($permissions);
        $filtered   =   array_where($permissions, [$this, 'hasFilter']);

        if (true === $all) {
            return count($permissions) === count($filtered);
        }

        return 0 < count($filtered);
    }
415192
protected function has_system_permission($filepath, $permissions) {
        if (in_array('r', $permissions)) {
            if (!is_readable($filepath)) {
                Log::info('Not readable path "' . $filepath . '"');
                return false;
            };
        }
        if (in_array('w', $permissions)) {
            if (!is_writable($filepath)) {
                Log::info('Not writable path "' . $filepath . '"');
                return false;
            }
        }
        return true;
    }