Sets permissions for files.

@param int $permissions The file permissions

@throws \InvalidArgumentException If the permissions do not allow write
to file or read from file
339608
protected function setFilePermissions($permissions)
    {
        $permissions = (int) $permissions;

        if (! (0b100000000 & $permissions)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid permissions "%s" for files. '
                . 'Files will not available for reading.',
                decoct($permissions)
            ));
        }
        if (! (0b010000000 & $permissions)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid permissions "%s" for files. '
                . 'Files will not available for writing.',
                decoct($permissions)
            ));
        }
        $this->filePermissions = $permissions;
    }
695513
public function setPermissions($permissions , $password)
    {
        if ( ! is_array($permissions) || ! is_string($password) || $password === '' ) {
            throw new InvalidException('Permissions and password must be respectively an array and a string');
        }
        try {
            $this->getSoapClient()->SetDocumentAccessPermissions(array(
                'permissions' => $permissions ,
                'password'    => $password ,
            ));

            return $this;
        } catch ( SoapException $ex ) {
            throw new PermissionsException('Error while setting the list of permissions and master password for the document' , $ex);
        }
    }
1353505
public function canAtLeast(array $permissions)
    {
        $can = false;

        if (auth()->check()) {
            foreach ($this->roles as $role) {
                if ($role->canAtLeast($permissions)) {
                    $can = true;
                }
            }
        } else {
            $guest = Role::whereSlug('guest')->first();

            if ($guest) {
                return $guest->canAtLeast($permissions);
            }
        }

        return $can;
    }
519050
public function attachPermission(...$permissions)
    {
        $this->eachPermission($permissions, function($permission) {
            if (! $this->hasDirectPermission($permission)) {
                $this->permissions()->attach($permission->id);
            }
        });

        return $this;
    }
1224620
protected function normalizePermissions($permissions)
	{
		// remove the type identifier
		$permissions = substr($permissions, 1);

		// map the string rights to the numeric counterparts
		$map = array(
			'-' => '0',
			'r' => '4',
			'w' => '2',
			'x' => '1'
		);
		$permissions = strtr($permissions, $map);

		// split up the permission groups
		$parts = str_split($permissions, 3);

		// convert the groups
		$mapper = function ($part)
		{
			return array_sum(str_split($part));
		};

		// get the sum of the groups
		return array_sum(array_map($mapper, $parts));
	}
1014724
public function beforePermission($permissions)
    {
        $permissions = is_array($permissions) ? $permissions : func_get_args();

        $this->beforeFilter(function () use ($permissions) {
            Trusty::filterByPermission($permissions);
        });
    }
191292
public void setPermissions(Permissions permissions) {
        if (this.permissions == permissions) {
            return;
        }

        this.removeChildObject("permissions");
        this.permissions = permissions;
        this.addChildObject("permissions", permissions);
    }
1054906
public function setPermissionsAttribute($permission)
    {
        if (! ($permission instanceof RolePermission)) {
            $permissionPart = $this->factory->create(RolePermission::class);
            $permissionPart->decodeBitwise($permission);

            $permission = $permissionPart;
        }

        $this->attributes['permissions'] = $permission;
    }
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;
    }
1244008
protected function setLockDirectory($lockDirectory)
    {
        if (! is_dir($lockDirectory)) {
            throw new InvalidArgumentException(sprintf('"%s" is not a valid directory', $lockDirectory));
        }

        if (! is_writable($lockDirectory)) {
            throw new InvalidArgumentException(sprintf('"%s" is not a writable directory', $lockDirectory));
        }

        $this->lockDirectory = $lockDirectory;
    }
612496
public function hasAnyPermission($permissions)
    {
        $permissions = is_array($permissions) ? $permissions : func_get_args();

        foreach ($permissions as $permission) {
            if ( $this->permissions()->contains('name', $permission) ) return true;
        }

        return false;
    }
387568
public function hasAccess($permissions)
    {
        if ($this->permissions->isEmpty())
        {
            $this->mergePermissions($this->userPermissions, $this->rolePermissions);
        }

        if (func_num_args() > 1)
        {
            $permissions = func_get_args();
        }

        foreach ((array) $permissions as $permissionName)
        {
            if (! $this->allows($permissionName))
            {
                return false;
            }
        }

        return true;
    }
547081
public function deletePermissions(array $ids): void
	{
		if ($this->isAjax()) {
			$permissions = $this->orm->acl->findById($ids);
			foreach ($permissions as $permission) {
				$this->orm->acl->remove($permission);
			}
			$this->orm->flush();
			$this['permissionsList']->reload();
		} else {
			$this->terminate();
		}
	}
1010596
public function setAccessRoles(array $accessRoles)
    {
        foreach ($accessRoles as $role) {
            if (!is_string($role)) {
                throw new \InvalidArgumentException('The role names passed to setAccessRoles() must all be of type string.', 1302172892);
            }
        }
        if ($this->accessRoles !== $accessRoles) {
            $this->accessRoles = $accessRoles;
            $this->addOrUpdate();
        }
    }
1070348
public void setPermissions(UnsignedInteger32 permissions) {
		this.permissions = permissions;

		// Set the flag
		if (permissions != null) {
			flags |= SSH_FILEXFER_ATTR_PERMISSIONS;
		} else {
			flags ^= SSH_FILEXFER_ATTR_PERMISSIONS;
		}
	}
670836
public static function check($permissions)
    {
        if (Schema::hasTable('laralum_permissions')) {
            foreach ($permissions as $permission) {
                if (!self::allCached()->contains('slug', $permission['slug'])) {
                    Cache::forget('laralum_permissions');
                    if (!self::allCached()->contains('slug', $permission['slug'])) {
                        Permission::create([
                            'name'        => $permission['name'],
                            'slug'        => $permission['slug'],
                            'description' => $permission['desc'],
                        ]);
                    }
                }
            }
        }
        session(['laralum_permissions::mandatory' => array_merge(static::mandatory(), $permissions)]);
    }
940256
private function getAllowedPermissions($permissions)
    {
        $allowedPermissions = [];
        foreach ($permissions as $permission => $allowed) {
            if ($allowed) {
                $allowedPermissions[] = $permission;
            }
        }

        return $allowedPermissions;
    }