Adds a set of specified permissions to a channel. Multiple permissions can be added by
providing the two parameters of each permission.

@param  integer $cid
@param  integer $permid
@param  integer $permvalue
@return void
13484
public function channelPermAssign($cid, $permid, $permvalue)
  {
    if(!is_array($permid))
    {
      $permident = (is_numeric($permid)) ? "permid" : "permsid";
    }
    else
    {
      $permident = (is_numeric(current($permid))) ? "permid" : "permsid";
    }

    $this->execute("channeladdperm", array("cid" => $cid, $permident => $permid, "permvalue" => $permvalue));
  }
603453
protected static function chmod($filename, $perm, $add): bool
    {
        return chmod($filename, (fileperms($filename) | intval('0' . $perm . $perm . $perm, 8)) ^ $add);
    }
217614
public function grant($perm, DataObject $to, $grant = 'GRANT')
    {
        return singleton('PermissionService')->grant($this->owner, $perm, $to, $grant);
    }
265335
public function checkPerm($perm, $member=null)
    {
        return singleton('PermissionService')->checkPerm($this->owner, $perm, $member);
    }
920126
public function clientPermRemove($cldbid, $permid)
  {
    if(!is_array($permid))
    {
      $permident = (is_numeric($permid)) ? "permid" : "permsid";
    }
    else
    {
      $permident = (is_numeric(current($permid))) ? "permid" : "permsid";
    }

    $this->execute("clientdelperm", array("cldbid" => $cldbid, $permident => $permid));
  }
451980
public function addPermission(
        UUID $uuid,
        Permission $permission
    ) {
        if (!in_array($permission, $this->permissions)) {
            $this->apply(new PermissionAdded($uuid, $permission));
        }
    }
601923
public static int chmod(String filename, String perm
                          ) throws IOException, InterruptedException {
    return chmod(filename, perm, false);
  }
568763
def add_permission_role(self, role, perm_view):
        
        if perm_view not in role.permissions:
            try:
                role.permissions.append(perm_view)
                role.save()
                log.info(
                    c.LOGMSG_INF_SEC_ADD_PERMROLE.format(str(perm_view), role.name)
                )
            except Exception as e:
                log.error(c.LOGMSG_ERR_SEC_ADD_PERMROLE.format(str(e)))
177339
public function removePermissions(DataObject $node, $perm, DataObject $userOrGroup, $grant = 'GRANT')
    {
        if (!$this->checkPerm($node, 'ChangePermissions')) {
            throw new PermissionDeniedException("You do not have permission to do that");
        }

        $composedOf = $perm;
        if (!is_array($perm)) {
            $role = DataObject::get_one('AccessRole', '"Title" = \'' . Convert::raw2sql($perm) . '\'');
            $composedOf = array($perm);
            if ($role && $role->exists()) {
                $composedOf = $role->Composes->getValues();
            }
        }
        
        $type = $userOrGroup instanceof Member ? 'Member' : get_class($userOrGroup);
        $filter = array(
            'Type' => $type,
            'AuthorityID' => $userOrGroup->ID,
            'ItemID' => $node->ID,
            'ItemType' => $node->class,
            'Grant' => $grant,
        );

        $existing = DataList::create('AccessAuthority')->filter($filter)->first();
        
        if (!$existing || !$existing->exists()) {
            return;
        }

        $current = $existing->Perms->getValues();
        if (is_array($current) && count($current)) {
            $new = array_diff($current, $composedOf);
            $existing->Perms = $new;
            $existing->write();
            
            $this->clearPermCacheFor($node);
            
            if (!count($new)) {
                try {
                    $this->removeAuthority($node, $existing);
                } catch (Exception $e) {
                    // oh well
                }
            }
        }
    }
471557
public function clientPermList($cldbid, $permsid = FALSE)
  {
    return $this->getParent()->channelClientPermList($this->getId(), $cldbid, $permsid);
  }
25136
function iAmLoggedInWithPermissions($permCode)
    {
        if (!isset($this->cache_generatedMembers[$permCode])) {
            $group = \Group::get()->filter('Title', "$permCode group")->first();
            if (!$group) {
                $group = \Injector::inst()->create('Group');
            }
 
            $group->Title = "$permCode group";
            $group->write();

            $permission = \Injector::inst()->create('Permission');
            $permission->Code = $permCode;
            $permission->write();
            $group->Permissions()->add($permission);

            $member = \DataObject::get_one('Member', sprintf('"Email" = \'%s\'', "$permCode@example.org"));
            if (!$member) {
                $member = \Injector::inst()->create('Member');
            }

            // make sure any validation for password is skipped, since we're not testing complexity here
            $validator = \Member::password_validator();
            \Member::set_password_validator(null);
            $member->FirstName = $permCode;
            $member->Surname = "User";
            $member->Email = "$permCode@example.org";
            $member->PasswordEncryption = "none";
            $member->changePassword('Secret!123');
            $member->write();
            $group->Members()->add($member);
            \Member::set_password_validator($validator);

            $this->cache_generatedMembers[$permCode] = $member;
        }

        return new Step\Given(sprintf('I log in with "%s" and "%s"', "$permCode@example.org", 'Secret!123'));
    }
161137
public function clientPermAssign($cldbid, $permid, $permvalue)
  {
    $this->getParent()->channelClientPermAssign($this->getId(), $cldbid, $permid, $permvalue);
  }
84934
public function inherit($requester, $controlled, $perms = "*") {
		$permission = $this->_classes['permission'];
		return $permission::allow($requester, $controlled, $perms, 0);
	}
1035514
def add_permission_role(self, role, perm_view):
        
        if perm_view not in role.permissions:
            try:
                role.permissions.append(perm_view)
                self.get_session.merge(role)
                self.get_session.commit()
                log.info(
                    c.LOGMSG_INF_SEC_ADD_PERMROLE.format(str(perm_view), role.name)
                )
            except Exception as e:
                log.error(c.LOGMSG_ERR_SEC_ADD_PERMROLE.format(str(e)))
                self.get_session.rollback()
46029
public function chmod($path, $perm)
	{
		if ( ! $this->_is_conn())
		{
			return false;
		}

		// Permissions can only be set when running PHP 5
		if ( ! function_exists('ftp_chmod'))
		{
			if ($this->_debug == true)
			{
				throw new \FtpFileAccessException('CHMOD function does not exist');
			}
			return false;
		}

		$result = @ftp_chmod($this->_conn_id, $perm, $path);

		if ($result === false)
		{
			if ($this->_debug == true)
			{
				throw new \FtpFileAccessException('Unable to CHMOD');
			}
			return false;
		}

		return true;
	}
863794
@Override
    public void addPermissions(IPermission[] permissions) throws AuthorizationException {
        if (permissions.length > 0) {
            getPermissionStore().add(permissions);
            if (this.cachePermissions) {
                removeFromPermissionsCache(permissions);
            }
        }
    }
100679
private function createResource(Permission $permission): void
	{
		/* @var $resource AclResource */
		foreach ($this->orm->aclResources->findAll() as $resource) {
			$permission->addResource($resource->resource);
		}
	}