Skip to content
Snippets Groups Projects
Commit 28245366 authored by Thomas Hackl's avatar Thomas Hackl
Browse files

permission handling finally working as planned

parent 8404cc8b
No related branches found
No related tags found
No related merge requests found
......@@ -25,21 +25,23 @@ class MatrixRoom extends SimpleORMap
const POWER_LEVEL_AUTOR = 0;
const POWER_LEVEL_TUTOR = 50;
const POWER_LEVEL_DOZENT = 50;
const EVENT_POWER_LEVELS = [
const ROOM_POWER_LEVELS = [
'events' => [
'ban' => self::POWER_LEVEL_TUTOR,
'invite' => self::POWER_LEVEL_TUTOR,
'kick' => self::POWER_LEVEL_TUTOR,
'm.room.name' => self::POWER_LEVEL_DOZENT,
'm.room.power_levels' => self::POWER_LEVEL_DOZENT,
'notifications' => [
'room' => self::POWER_LEVEL_TUTOR
],
'redact' => self::POWER_LEVEL_TUTOR
],
'events_default' => self::POWER_LEVEL_AUTOR,
'state_default' => self::POWER_LEVEL_TUTOR,
'users_default' => self::POWER_LEVEL_AUTOR
'notifications' => [
'room' => self::POWER_LEVEL_TUTOR
],
'defaults' => [
'events_default' => self::POWER_LEVEL_AUTOR,
'state_default' => self::POWER_LEVEL_TUTOR,
'users_default' => self::POWER_LEVEL_AUTOR
]
];
protected static function configure($config = [])
......@@ -67,7 +69,7 @@ class MatrixRoom extends SimpleORMap
// Invite all members with existing Matrix account to newly created room.
$invites = [];
// Permission levels in the room to create.
/*$permissions = [
$permissions = [
$sysaccount->getUserId() => 100
];
$accounts = [];
......@@ -88,18 +90,21 @@ class MatrixRoom extends SimpleORMap
$power_level = MatrixRoom::POWER_LEVEL_AUTOR;
}
// Collect accounts for auto-joining room.
$accounts[$mapped->matrix_account_id] = $mapped->getLinkedAccount();
// Collect permissions for setting power levels.
$permissions[$mapped->matrix_account_id] = $power_level;
}
}
$power_levels = self::EVENT_POWER_LEVELS;
$power_levels['users'] = $permissions;*/
$permission_set = new Patrix\RoomPermissionSet(
self::ROOM_POWER_LEVELS['defaults'],
$permissions,
self::ROOM_POWER_LEVELS['events'],
self::ROOM_POWER_LEVELS['notifications'],
self::POWER_LEVEL_AUTOR
);
$newRoom = MatrixClient::get()->createRoom($sysaccount, Context::getHeaderLine(), false, '',
[], self::EVENT_POWER_LEVELS);
[],$permission_set);
$mapping = new self();
$mapping->range_id = $context->getId();
......@@ -141,12 +146,16 @@ class MatrixRoom extends SimpleORMap
$perm = self::POWER_LEVEL_AUTOR;
}
}
$permission = [
$account->getUserName() => $perm
];
// Get existing room permissions so that they are not completely overwritten when adding the current user.
$permissions = MatrixClient::get()
->getRoomPermissionLevels($sysaccount, $this->getLinkedRoom())
->getUserPermissions();
//MatrixClient::get()->setRoomUserPermissionLevels($sysaccount, $this->getLinkedRoom(), $permission);
$permissions[$account->getUserName()] = $perm;
// Set correct permission for current user.
MatrixClient::get()->setRoomUserPermissionLevels($sysaccount, $this->getLinkedRoom(), $permissions);
}
}
}
\ No newline at end of file
pluginname=Matrix-Chat
pluginclassname=MatrixPlugin
origin=data-quest
version=0.85
version=0.9
screenshot=assets/images/matrix_logo.png
description=Matrix chat for Stud.IP courses
studipMinVersion=4.5
......
libpatrix @ c05790e0
Subproject commit a63da521cef79651fbdc95b90298b5b67882957d
Subproject commit c05790e055ca90fe7d5867ee6dbd26fd695814ad
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment