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

@param  integer $cldbid
@param  integer $permid
@param  integer $permvalue
@return void
161137
public function clientPermAssign($cldbid, $permid, $permvalue)
  {
    $this->getParent()->channelClientPermAssign($this->getId(), $cldbid, $permid, $permvalue);
  }
1281114
function permissions($Role, $OnlyIDs = true)
	{
	    if (! is_numeric ($Role))
	        $Role = $this->returnId($Role);

		if ($OnlyIDs)
		{
			$Res = Jf::sql ( "SELECT PermissionID AS `ID` FROM {$this->tablePrefix()}rolepermissions WHERE RoleID=? ORDER BY PermissionID", $Role );
			if (is_array ( $Res ))
			{
				$out = array ();
				foreach ( $Res as $R )
					$out [] = $R ['ID'];
				return $out;
			}
			else
				return null;
		} else {
	        return Jf::sql ( "SELECT `TP`.ID, `TP`.Title, `TP`.Description FROM {$this->tablePrefix()}permissions AS `TP`
		        LEFT JOIN {$this->tablePrefix()}rolepermissions AS `TR` ON (`TR`.PermissionID=`TP`.ID)
		        WHERE RoleID=? ORDER BY TP.ID", $Role );
		}
	}
471557
public function clientPermList($cldbid, $permsid = FALSE)
  {
    return $this->getParent()->channelClientPermList($this->getId(), $cldbid, $permsid);
  }
603153
public function addPermission($name){
        if($name && in_array($name, self::$permissions)){
            $this->data['permissions'][] = array(
                'name' => $name
            ); 
        }
    }
954390
public static void addPermission(Permission perm)
  {
    ClassLoader loader = Thread.currentThread().getContextClassLoader();

    addPermission(perm, loader);
  }
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));
  }
1314077
protected function assignPermissions(array $config) : void
    {
        $this->stdout("Assign permissions: " . count($config) . "\n", Console::FG_YELLOW);
        foreach ($config as $item) {
            if (!$permission = $this->assignPermission($item)) {
                $this->stdout("\t- error assigned permission: " . Json::encode($item) . "\n", Console::FG_RED);
            }
        }
    }
616727
public function addPermission($permission) {
		$per                                 = new permission($permission);
		$this->role->sharedPermissionList [] = $per->get();
		R::store($this->role);
	}
1324082
private void primAdd(IPermission[] perms) throws Exception {
        Connection conn = null;
        int rc = 0;

        try {
            conn = RDBMServices.getConnection();
            String sQuery = getInsertPermissionSql();
            PreparedStatement ps = conn.prepareStatement(sQuery);
            try {
                RDBMServices.setAutoCommit(conn, false);

                for (int i = 0; i < perms.length; i++) {
                    primAdd(perms[i], ps);
                    if (log.isDebugEnabled()) log.debug("RDBMPermissionImpl.primAdd(): " + ps);
                    rc = ps.executeUpdate();

                    if (rc != 1) {
                        String errMsg = "Problem adding " + perms[i] + " RC: " + rc;
                        log.error(errMsg);
                        RDBMServices.rollback(conn);
                        throw new AuthorizationException(errMsg);
                    }
                }
            } finally {
                ps.close();
            }

            RDBMServices.commit(conn);

        } catch (Exception ex) {
            log.error("Exception adding permissions " + Arrays.toString(perms), ex);
            RDBMServices.rollback(conn);
            throw ex;
        } finally {
            try {
                RDBMServices.setAutoCommit(conn, true);
            } finally {
                RDBMServices.releaseConnection(conn);
            }
        }
    }
963163
public Result<Void> addPerm(AuthzTrans trans, RoleDAO.Data role, PermDAO.Data perm) {
		// Note: Prepared Statements for Collection updates aren't supported
		String pencode = perm.encode();
		try {
			getSession(trans).execute(UPDATE_SP + TABLE + " SET perms = perms + {'" + 
				pencode + "'} WHERE " +
				"ns = '" + role.ns + "' AND name = '" + role.name + "';");
		} catch (DriverException | APIException | IOException e) {
			reportPerhapsReset(trans,e);
			return Result.err(Result.ERR_Backend, CassAccess.ERR_ACCESS_MSG);
		}

		wasModified(trans, CRUD.update, role, "Added permission " + pencode + " to role " + role.fullName());
		return Result.ok();
	}
1123199
public function getPermissionIdFromName($perm_name)
    {
        $permission = static::$app['db']->connection()
            ->table('permissions')->where('name', '=', $perm_name)->first();

        return $permission->id;
    }
1061858
function (perm) {
                        var permObjId;

                        // Look for a matching action type and object type first
                        if (perm.get('action_type') !== actType || perm.get('object_type') !== objType) {
                            return false;
                        }

                        // Grab the object id (if specified, could be null)
                        permObjId = perm.get('object_id');

                        // If we didn't specify a model (any thing)
                        // or the permission didn't have an id scope set
                        // then the "thing" has permission
                        if (!modelId || !permObjId) {
                            return true;
                        }

                        // Otherwise, check if the id's match
                        // TODO: String vs Int comparison possibility here?
                        return modelId === permObjId;
                    }
1058669
public Result<Void> addRole(AuthzTrans trans, PermDAO.Data perm, String roleFullName) {
		// Note: Prepared Statements for Collection updates aren't supported
		//ResultSet rv =
		try {
			getSession(trans).execute(UPDATE_SP + TABLE + " SET roles = roles + {'"	+ roleFullName + "'} " +
				"WHERE " +
					"ns = '" + perm.ns + "' AND " +
					"type = '" + perm.type + "' AND " +
					"instance = '" + perm.instance + "' AND " +
					"action = '" + perm.action + "';"
					);
		} catch (DriverException | APIException | IOException e) {
			reportPerhapsReset(trans,e);
			return Result.err(Result.ERR_Backend, CassAccess.ERR_ACCESS_MSG);
		}

		wasModified(trans, CRUD.update, perm, "Added role " + roleFullName + " to perm " +
				perm.ns + '.' + perm.type + '|' + perm.instance + '|' + perm.action);
		return Result.ok();
	}
358427
public function clientPermList($cldbid, $permsid = FALSE)
  {
    $this->clientListReset();

    return $this->execute("clientpermlist", array("cldbid" => $cldbid, $permsid ? "-permsid" : null))->toAssocArray($permsid ? "permsid" : "permid");
  }
1245106
function isPermissionsLocked() {
        if($this->parentID === null) {
            throw new \BadMethodCallException('This channel does not have a parent');
        }
        
        $parent = $this->parent;
        
        if($parent->permissionOverwrites->count() !== $this->permissionOverwrites->count()) {
            return false;
        }
        
        return !((bool) $this->permissionOverwrites->first(function ($perm) use ($parent) {
            $permp = $parent->permissionOverwrites->get($perm->id);
            return (!$permp || $perm->allowed->bitfield !== $permp->allowed->bitfield || $perm->denied->bitfield !== $permp->denied->bitfield);
        }));
    }
83958
function cmd_SITE($fd, $cmd)
    {
        if (substr($cmd[1], 0, 6) == "CHMOD ")
        {
            $user = $this->getUser($fd);
            $chmod = explode(" ", $cmd[1], 3);
            $file = $this->fillDirName($user, $chmod[2]);
            $this->debug("CHMOD: $file to {$chmod[1]}");
            if (chmod($file, octdec($chmod[1])))
            {
                $this->send($fd, "200 Permissions changed on {$chmod[2]}");
            }
            else
            {
                $this->send($fd, "550 Could not change perms on " . $chmod[2] . ": Permission denied");
            }
        }
        else
        {
            $this->send($fd, "500 Unknown Command");
        }
    }
1099527
public function permissionGetNameById($permid)
  {
    foreach($this->permissionList() as $name => $perm)
    {
      if($perm["permid"] == $permid) return new Str($name);
    }

    throw new Exception("invalid permission ID", 0xA02);
  }