src/Administration.php
private function modifyRolesForUserByColumnValue($columnName, $columnValue, callable $modification) {
		try {
			$userData = $this->db->selectRow(
				'SELECT id, roles_mask FROM ' . $this->makeTableName('users') . ' WHERE ' . $columnName . ' = ?',
				[ $columnValue ]
			);
		}
		catch (Error $e) {
			throw new DatabaseError($e->getMessage());
		}

		if ($userData === null) {
			return false;
		}

		$newRolesBitmask = $modification($userData['roles_mask']);

		try {
			$this->db->exec(
				'UPDATE ' . $this->makeTableName('users') . ' SET roles_mask = ? WHERE id = ?',
				[
					$newRolesBitmask,
					(int) $userData['id']
				]
			);

			return true;
		}
		catch (Error $e) {
			throw new DatabaseError($e->getMessage());
		}
	}
private function modifyRolesForUserByColumnValue($columnName, $columnValue, callable $modification) {
		try {
			$userData = $this->db->selectRow(
				'SELECT id, roles_mask FROM ' . $this->makeTableName('users') . ' WHERE ' . $columnName . ' = ?',
				[ $columnValue ]
			);
		}
		catch (Error $e) {
			throw new DatabaseError($e->getMessage());
		}

		if ($userData === null) {
			return false;
		}

		$newRolesBitmask = $modification($userData['roles_mask']);

		try {
			$this->db->exec(
				'UPDATE ' . $this->makeTableName('users') . ' SET roles_mask = ? WHERE id = ?',
				[
					$newRolesBitmask,
					(int) $userData['id']
				]
			);

			return true;
		}
		catch (Error $e) {
			throw new DatabaseError($e->getMessage());
		}
	}
private function modifyRolesForUserByColumnValue ( $ columnName , $ columnValue , callable $ modification ) { try { $ userData = $ this -> db -> selectRow ( 'SELECT id, roles_mask FROM ' . $ this -> makeTableName ( 'users' ) . ' WHERE ' . $ columnName . ' = ?' , [ $ columnValue ] ) ; } catch ( Error $ e ) { throw new DatabaseError ( $ e -> getMessage ( ) ) ; } if ( $ userData === null ) { return false ; } $ newRolesBitmask = $ modification ( $ userData [ 'roles_mask' ] ) ; try { $ this -> db -> exec ( 'UPDATE ' . $ this -> makeTableName ( 'users' ) . ' SET roles_mask = ? WHERE id = ?' , [ $ newRolesBitmask , ( int ) $ userData [ 'id' ] ] ) ; return true ; } catch ( Error $ e ) { throw new DatabaseError ( $ e -> getMessage ( ) ) ; } }
Modifies the roles for the user where the column with the specified name has the given value

You must never pass untrusted input to the parameter that takes the column name

@param string $columnName the name of the column to filter by
@param mixed $columnValue the value to look for in the selected column
@param callable $modification the modification to apply to the existing bitmask of roles
@return bool whether any user with the given column constraints has been found
@throws AuthError if an internal problem occurred (do *not* catch)

@see Role
Modifies the roles for the user where the column with the specified name has the given value