diff options
| author | Arne Schröder, M. A. <schroeder@data-quest.de> | 2024-12-19 14:48:40 +0000 |
|---|---|---|
| committer | Rasmus Fuhse <fuhse@data-quest.de> | 2024-12-19 14:48:40 +0000 |
| commit | a4d431b8a07c0c7ab25242a38f1950b4f6107813 (patch) | |
| tree | 46ea74dd78d310b4cb5b3bc7b3f6217317a52a69 /app/controllers/admin/ilias_interface.php | |
| parent | 7cbba1ec8a0de90e02632fe06beebb2e672a07a2 (diff) | |
Resolve "Erweiterte Rollenzuweisung für ILIAS-Accounts"
Closes #4267
Merge request studip/studip!3370
Diffstat (limited to 'app/controllers/admin/ilias_interface.php')
| -rw-r--r-- | app/controllers/admin/ilias_interface.php | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/app/controllers/admin/ilias_interface.php b/app/controllers/admin/ilias_interface.php index 750e33d..9399a63 100644 --- a/app/controllers/admin/ilias_interface.php +++ b/app/controllers/admin/ilias_interface.php @@ -51,6 +51,8 @@ class Admin_IliasInterfaceController extends AuthenticatedController PageLayout::setHelpKeyword('Basis.Ilias'); $this->modules_available = ConnectedIlias::getSupportedModuleTypes(); + $this->studip_roles = ['autor', 'tutor', 'dozent', 'admin', 'root']; + $this->sidebar = Sidebar::get(); } @@ -151,7 +153,8 @@ class Admin_IliasInterfaceController extends AuthenticatedController 'author_role_name' => 'Author', 'author_role' => '', - 'author_perm' => 'tutor' + 'author_perm' => 'tutor', + 'additional_roles' => [] ]; // fetch existing indicies from previously connected ILIAS installations @@ -258,6 +261,9 @@ class Admin_IliasInterfaceController extends AuthenticatedController { $this->ilias_config = $this->ilias_configs[$index]; $this->ilias_index = $index; + + $connected_ilias = new ConnectedIlias($index); + $this->global_roles = $connected_ilias->soap_client->getRoles('global', -1); } /** @@ -283,7 +289,7 @@ class Admin_IliasInterfaceController extends AuthenticatedController { CSRFProtection::verifyUnsafeRequest(); - if (Request::submitted('submit')) { + if (Request::submittedSome('submit', 'add_additional_role', 'remove_additional_role')) { // set basic server settings if (Request::getInstance()->offsetExists('ilias_name')) { $this->ilias_configs[$index]['name'] = Request::get('ilias_name'); @@ -373,10 +379,59 @@ class Admin_IliasInterfaceController extends AuthenticatedController // set permissions settings if (Request::getInstance()->offsetExists('ilias_author_role_name')) { + $this->global_roles = $connected_ilias->soap_client->getRoles('global', -1); $this->ilias_configs[$index]['author_role_name'] = Request::get('ilias_author_role_name'); $this->ilias_configs[$index]['author_perm'] = Request::get('ilias_author_perm'); $this->ilias_configs[$index]['allow_change_account'] = Request::get('ilias_allow_change_account'); + // remove ilias role assignment + if ( + Request::submitted('remove_additional_role') + && Request::option('studip_role') + && array_key_exists('additional_roles', $this->ilias_configs[$index]) + ) { + $studip_role = Request::option('studip_role'); + $ilias_role = Request::option('remove_additional_role'); + if ( + in_array($studip_role, $this->studip_roles) + && array_key_exists($studip_role, $this->ilias_configs[$index]['additional_roles']) + && array_key_exists($ilias_role, $this->ilias_configs[$index]['additional_roles'][$studip_role]) + ) { + unset($this->ilias_configs[$index]['additional_roles'][$studip_role][$ilias_role]); + PageLayout::postSuccess(sprintf(_('ILIAS-Rollenzuweisung der Stud.IP-Rechtestufe %s wurde entfernt.'), $studip_role)); + } + } + + // add ilias role assignment + if ( + Request::submitted('add_additional_role') + && Request::option('add_studip_role') + && Request::option('add_ilias_role') + ) { + $studip_role = Request::option('add_studip_role'); + $ilias_role = Request::option('add_ilias_role'); + $role_already_assigned = false; + if (!array_key_exists('additional_roles', $this->ilias_configs[$index])) { + $this->ilias_configs[$index]['additional_roles'] = []; + } + if ( + in_array($studip_role, $this->studip_roles) + && (array_key_exists($ilias_role, $this->global_roles)) + ) { + if (!array_key_exists($studip_role, $this->ilias_configs[$index]['additional_roles'])) { + $this->ilias_configs[$index]['additional_roles'][$studip_role] = []; + } + if (array_key_exists($ilias_role, $this->global_roles)) { + $this->ilias_configs[$index]['additional_roles'][$studip_role][$ilias_role] = [ + 'id' => $this->global_roles[$ilias_role]['id'], + 'name' => $this->global_roles[$ilias_role]['name']]; + PageLayout::postSuccess(sprintf(_('ILIAS-Rolle %s wird Stud.IP-Rechtestufe %s zugewiesen.'), $this->global_roles[$ilias_role]['name'], $studip_role)); + } else { + PageLayout::postError(_('ILIAS-Rolle nicht gefunden.')); + } + } + } + //store config entry Config::get()->store('ILIAS_INTERFACE_SETTINGS', $this->ilias_configs); PageLayout::postSuccess(_('ILIAS-Berechtigungseinstellungen wurden gespeichert.')); |
