diff options
| author | Arne Schröder, M. A <schroeder@data-quest.de> | 2025-03-26 11:26:46 +0000 |
|---|---|---|
| committer | Thomas Hackl <hackl@data-quest.de> | 2025-03-28 13:14:15 +0100 |
| commit | bd6201de55e67c83f2185ec0495e375783e744db (patch) | |
| tree | c4d03f3487319440b284c3be5a344e9bd14c60ae | |
| parent | d2b0799fe31c93cb0f21109d2a0e14fec578ca42 (diff) | |
Resolve "ILIAS-Schnittstelle: Inkompatibilität mit ILIAS 9"
Closes #4995
Merge request studip/studip!3888
| -rw-r--r-- | app/controllers/admin/ilias_interface.php | 60 | ||||
| -rw-r--r-- | app/controllers/course/ilias_interface.php | 9 | ||||
| -rw-r--r-- | app/controllers/my_ilias_accounts.php | 3 | ||||
| -rw-r--r-- | app/views/admin/ilias_interface/edit_content.php | 20 | ||||
| -rw-r--r-- | app/views/admin/ilias_interface/index.php | 2 | ||||
| -rw-r--r-- | app/views/admin/ilias_interface/soap_methods.php | 8 | ||||
| -rw-r--r-- | app/views/course/ilias_interface/add_groups.php | 7 | ||||
| -rw-r--r-- | app/views/course/ilias_interface/add_object.php | 12 | ||||
| -rw-r--r-- | app/views/course/ilias_interface/index.php | 8 | ||||
| -rw-r--r-- | app/views/course/ilias_interface/view_object.php | 4 | ||||
| -rw-r--r-- | lib/ilias_interface/ConnectedIlias.class.php | 116 | ||||
| -rw-r--r-- | lib/ilias_interface/IliasModule.class.php | 8 | ||||
| -rw-r--r-- | lib/ilias_interface/IliasSoap.class.php | 75 | ||||
| -rw-r--r-- | lib/ilias_interface/studip_referrer_9x.php | 125 | ||||
| -rw-r--r-- | phpstan.neon.dist | 1 |
15 files changed, 327 insertions, 131 deletions
diff --git a/app/controllers/admin/ilias_interface.php b/app/controllers/admin/ilias_interface.php index 37b1664..c327c29 100644 --- a/app/controllers/admin/ilias_interface.php +++ b/app/controllers/admin/ilias_interface.php @@ -124,7 +124,7 @@ class Admin_IliasInterfaceController extends AuthenticatedController $this->valid_url = false; $this->ilias_version = ''; $this->ilias_version_date = ''; - $this->clients = []; + $this->ilias_clients = []; if ($index === 'new') { // default values $this->ilias_config = [ @@ -170,7 +170,7 @@ class Admin_IliasInterfaceController extends AuthenticatedController // get ILIAS server info if (Request::get('ilias_url')) { $info = ConnectedIlias::getIliasInfo(Request::get('ilias_url')); - if (count($info)) { + if (is_array($info) && count($info)) { $this->valid_url = true; $this->ilias_config['url'] = Request::get('ilias_url'); $this->ilias_config['http_connection_timeout'] = (int) Request::get('ilias_http_connection_timeout'); @@ -247,8 +247,18 @@ class Admin_IliasInterfaceController extends AuthenticatedController */ public function edit_content_action($index) { - $this->ilias_config = $this->ilias_configs[$index]; $this->ilias_index = $index; + $this->ilias_datafields = []; + + $connected_ilias = new ConnectedIlias($index); + $this->ilias_config = $connected_ilias->ilias_config; + + if ($admin_id = $connected_ilias->soap_client->lookupUser($this->ilias_config['admin'])) { + $user = $connected_ilias->soap_client->getUser($admin_id); + if (!empty($user) && array_key_exists('udfs', $user)) { + $this->ilias_datafields = $user['udfs']; + } + } } /** @@ -257,8 +267,11 @@ class Admin_IliasInterfaceController extends AuthenticatedController */ public function edit_permissions_action($index) { - $this->ilias_config = $this->ilias_configs[$index]; $this->ilias_index = $index; + + $connected_ilias = new ConnectedIlias($index); + $this->ilias_config = $connected_ilias->ilias_config; + $this->global_roles = $connected_ilias->soap_client->getRoles('global', -1); } /** @@ -420,28 +433,31 @@ class Admin_IliasInterfaceController extends AuthenticatedController */ public function soap_methods_action($index) { - if ($this->ilias_configs[$index]['is_active']) { - $ilias = new ConnectedIlias($index); - $this->soap_methods = $ilias->getSoapMethods(); - ksort($this->soap_methods); - $this->ilias_index = $index; - if (Request::get('ilias_soap_method')) { - $this->ilias_soap_method = Request::get('ilias_soap_method'); - foreach ($this->soap_methods[Request::get('ilias_soap_method')] as $param) { - switch ($param) { - case "sid" : $this->params[$param] = $ilias->soap_client->getSID(); - break; - case "user_id" : $this->params[$param] = $ilias->user->getId(); - break; - } + $ilias = new ConnectedIlias($index); + + $this->soap_methods = $ilias->getSoapMethods(); + ksort($this->soap_methods); + $this->ilias_index = $index; + if (Request::get('ilias_soap_method')) { + $this->ilias_soap_method = Request::get('ilias_soap_method'); + foreach ($this->soap_methods[Request::get('ilias_soap_method')] as $param) { + switch ($param) { + case "sid" : $this->params[$param] = $ilias->soap_client->getSID(); + break; + case "user_id" : $this->params[$param] = is_object($ilias->user) ? $ilias->user->getId() : ''; + break; } - } elseif (Request::get('ilias_call')) { - $params = []; - foreach ($this->soap_methods[Request::get('ilias_call')] as $param) { + } + } elseif (Request::get('ilias_call')) { + $params = []; + foreach ($this->soap_methods[Request::get('ilias_call')] as $param) { + if ($param === 'user_ids') { + $params[$param] = [Request::get('ilias_soap_param_'.$param)]; + } else { $params[$param] = Request::get('ilias_soap_param_'.$param); } - $this->result = $ilias->soap_client->call(Request::get('ilias_call'), $params); } + $this->result = $ilias->soap_client->call(Request::get('ilias_call'), $params); } } } diff --git a/app/controllers/course/ilias_interface.php b/app/controllers/course/ilias_interface.php index 96196da..ee34048 100644 --- a/app/controllers/course/ilias_interface.php +++ b/app/controllers/course/ilias_interface.php @@ -26,9 +26,8 @@ class Course_IliasInterfaceController extends AuthenticatedController { parent::before_filter($action, $args); - if (Request::isXhr()) { - $this->dialog = true; - } + $this->dialog = Request::isXhr(); + if (!Config::Get()->ILIAS_INTERFACE_ENABLE ) { throw new AccessDeniedException(_('ILIAS-Interface ist nicht aktiviert.')); } else @@ -173,7 +172,7 @@ class Course_IliasInterfaceController extends AuthenticatedController Icon::create('group2') )->asDialog('size=auto'); } - if ($this->author_permission) { + if ($this->author_permission && !empty($this->ilias_interface_config['show_tools_page'])) { $widget->addLink( _('Externe Accounts verwalten'), $this->url_for('my_ilias_accounts'), @@ -380,7 +379,7 @@ class Course_IliasInterfaceController extends AuthenticatedController } // exclude all modules that are already assigned to course foreach ($this->ilias_modules as $module_id => $module) { - if ($course_modules[$this->ilias_index][$module_id]) { + if (!empty($course_modules[$this->ilias_index][$module_id])) { unset($this->ilias_modules[$module_id]); } } diff --git a/app/controllers/my_ilias_accounts.php b/app/controllers/my_ilias_accounts.php index fc4c00d..01ce191 100644 --- a/app/controllers/my_ilias_accounts.php +++ b/app/controllers/my_ilias_accounts.php @@ -217,8 +217,7 @@ class MyIliasAccountsController extends AuthenticatedController } // refer to ILIAS target file - header('Location: '. $this->ilias->getTargetFile() . $parameters); - $this->render_nothing(); + $this->redirect($this->ilias->getTargetFile() . $parameters); } } } diff --git a/app/views/admin/ilias_interface/edit_content.php b/app/views/admin/ilias_interface/edit_content.php index ce48668..a45c5fc 100644 --- a/app/views/admin/ilias_interface/edit_content.php +++ b/app/views/admin/ilias_interface/edit_content.php @@ -11,43 +11,43 @@ <input type="hidden" name="ilias_content_settings" size="50" maxlength="255" value="1"> <label> <span class="required"><?= _('Wurzelkategorie für Stud.IP-Daten') ?></span> - <? if ($ilias_config['root_category']) : ?> + <? if (!empty($ilias_config['root_category'])) : ?> <div><?=htmlReady($ilias_config['root_category_name']).' (ID '.htmlReady($ilias_config['root_category']).')'?></div> <? else : ?> - <input type="text" name="ilias_root_category_name" size="50" maxlength="255" value="<?= htmlReady($ilias_config['root_category_name']) ?>" required> + <input type="text" name="ilias_root_category_name" size="50" maxlength="255" value="<?= empty($ilias_config['root_category_name']) ? '' : htmlReady($ilias_config['root_category_name']) ?>" required> <? endif ?> </label> - <? if ($ilias_config['user_data_category']) : ?> + <? if (!empty($ilias_config['user_data_category'])) : ?> <label> <span class="required"><?= _('Kategorie mit User-Daten') ?></span> <div><?= _('User_daten').' (ID '.htmlReady($ilias_config['user_data_category']).')'?></div> </label> <? endif ?> <label> - <input type="checkbox" name="ilias_category_create_on_add_module" value="1" <?= $ilias_config['category_create_on_add_module'] ? 'checked' : '' ?>> + <input type="checkbox" name="ilias_category_create_on_add_module" value="1" <?= !empty($ilias_config['category_create_on_add_module']) ? 'checked' : '' ?>> <span><?= _('Persönliche ILIAS-Kategorie erst erzeugen, wenn Lernobjekte angelegt werden') ?></span> </label> <? if (array_key_exists('version', $ilias_config) && (ConnectedIlias::getIntVersion($ilias_config['version']) >= 50400) && (ConnectedIlias::getIntVersion($ilias_config['version']) < 60000)) : ?> <label> - <input type="checkbox" name="ilias_category_to_desktop" value="1" <?= $ilias_config['category_to_desktop'] ? 'checked' : '' ?>> + <input type="checkbox" name="ilias_category_to_desktop" value="1" <?= !empty($ilias_config['category_to_desktop']) ? 'checked' : '' ?>> <span><?= _('Persönliche ILIAS-Kategorie auf den Schreibtisch legen') ?></span> </label> <? endif ?> <label> - <input type="checkbox" name="ilias_delete_ilias_users" value="1" <?= $ilias_config['delete_ilias_users'] ? 'checked' : '' ?>> + <input type="checkbox" name="ilias_delete_ilias_users" value="1" <?= !empty($ilias_config['delete_ilias_users']) ? 'checked' : '' ?>> <span><?= _('Beim Löschen von Stud.IP-Accounts ILIAS-Accounts ebenfalls löschen (alle zugehörigen Objekte werden gelöscht!)') ?></span> </label> <label> <span><?= _('Prefix für automatisch angelegte Usernamen') ?></span> <? if ($ilias_config['is_active']) : ?> - <div><?=$ilias_config['user_prefix'] ? htmlReady($ilias_config['user_prefix']) : _('Kein Präfix')?></div> + <div><?=!empty($ilias_config['user_prefix']) ? htmlReady($ilias_config['user_prefix']) : _('Kein Präfix')?></div> <? else : ?> - <input type="text" name="ilias_user_prefix" size="50" maxlength="255" value="<?= htmlReady($ilias_config['user_prefix']) ?>"> + <input type="text" name="ilias_user_prefix" size="50" maxlength="255" value="<?= empty($ilias_config['user_prefix']) ? '' : htmlReady($ilias_config['user_prefix']) ?>"> <? endif ?> </label> <label> <span><?= _('Datenfeld (Name) mit Matrikelnummer (nur ausfüllen, wenn die Matrikelnummer in einem Datenfeld gespeichert wird)') ?></span> - <input type="text" name="ilias_matriculation" size="50" maxlength="255" value="<?= htmlReady($ilias_config['matriculation']) ?>"> + <input type="text" name="ilias_matriculation" size="50" maxlength="255" value="<?= empty($ilias_config['matriculation']) ? '' : htmlReady($ilias_config['matriculation']) ?>"> </label> <label> <span class="required"><?= _('Struktur für angelegte Kurse') ?></span> @@ -97,7 +97,7 @@ <label> <? foreach ($modules_available as $module_index => $module_name) : ?> <label> - <input type="checkbox" name="ilias_modules_<?=$module_index?>" value="1" <?=$ilias_config['modules'][$module_index] ? ' checked':''?>> + <input type="checkbox" name="ilias_modules_<?=$module_index?>" value="1" <?=!empty($ilias_config['modules'][$module_index]) ? ' checked':''?>> <?=htmlReady($module_name)?> </label> <? endforeach ?> diff --git a/app/views/admin/ilias_interface/index.php b/app/views/admin/ilias_interface/index.php index d786a97..8bee478 100644 --- a/app/views/admin/ilias_interface/index.php +++ b/app/views/admin/ilias_interface/index.php @@ -33,7 +33,7 @@ <? foreach ($ilias_configs as $ilias_index => $ilias_config) : ?> <tr id="ilias-<?= htmlReady($ilias_index)?>"> <td> - <? if ($ilias_config['is_active']) { + <? if (!empty($ilias_config['is_active'])) { $text = _('Diese ILIAS-Installation ist aktiv. Klicken Sie hier, um sie zu deaktivieren.'); $img = 'checkbox-checked'; $cmd = 'deactivate'; diff --git a/app/views/admin/ilias_interface/soap_methods.php b/app/views/admin/ilias_interface/soap_methods.php index 1901074..aa84917 100644 --- a/app/views/admin/ilias_interface/soap_methods.php +++ b/app/views/admin/ilias_interface/soap_methods.php @@ -9,7 +9,7 @@ */ ?> <form class="default" action="<?= $controller->url_for('admin/ilias_interface/soap_methods/'.$ilias_index) ?>" method="post"> - <? if ($result) : ?> + <? if (!empty($result)) : ?> <article class="studip"> <section><?=_('Ergebnis')?></section> <? if (is_array($result)) : ?> @@ -22,7 +22,7 @@ </article> <? endif ?> <?= CSRFProtection::tokenTag() ?> - <? if (!$ilias_soap_method) : ?> + <? if (empty($ilias_soap_method)) : ?> <label> <span class="required"><?= _('SOAP-Methode') ?></span> <select name="ilias_soap_method"> @@ -36,12 +36,12 @@ <? foreach ($soap_methods[$ilias_soap_method] as $param) : ?> <label> <span> <?= $param ?></span> - <input type="text" name="ilias_soap_param_<?=$param?>" size="50" value="<?=$params[$param]?>"> + <input type="text" name="ilias_soap_param_<?=$param?>" size="50" value="<?=!empty($params[$param]) ? $params[$param] : ''?>"> </label> <? endforeach ?> <? endif ?> <footer> - <? if (!$ilias_soap_method) : ?> + <? if (empty($ilias_soap_method)) : ?> <?= Studip\Button::createAccept(_('Weiter'), 'submit') ?> <? else : ?> <?= Studip\Button::createAccept(_('Ausführen'), 'submit') ?> diff --git a/app/views/course/ilias_interface/add_groups.php b/app/views/course/ilias_interface/add_groups.php index 495aa5f..2a6bc2f 100644 --- a/app/views/course/ilias_interface/add_groups.php +++ b/app/views/course/ilias_interface/add_groups.php @@ -1,6 +1,6 @@ <form class="default" action="<?= $controller->url_for('course/ilias_interface/add_groups/'.$ilias_index) ?>" method="post"> <?= CSRFProtection::tokenTag() ?> - <? if (!$ilias_index) : ?> + <? if (empty($ilias_index)) : ?> <label> <span class="required"><?= _('ILIAS-Installation auswählen') ?></span> <select name="ilias_index" required> @@ -10,7 +10,6 @@ <? endforeach ?> </select> </label> - <? elseif ($mode == 'add_groups') : ?> <? else : ?> <div> <input type="hidden" name="cmd" value="create_groups"> @@ -24,8 +23,8 @@ </div> <? endif ?> <footer data-dialog-button> - <? if ($ilias->isActive() && $submit_text) : ?> - <?= Studip\Button::create($submit_text, 'submit', ($dialog && ! $ilias_index) ? ['data-dialog' => 'size=auto'] : []) ?> + <? if ($ilias->isActive() && !empty($submit_text)) : ?> + <?= Studip\Button::create($submit_text, 'submit', ($dialog && empty($ilias_index)) ? ['data-dialog' => 'size=auto'] : []) ?> <? endif ?> <?= Studip\Button::createCancel(_('Schließen'), 'cancel', $dialog ? ['data-dialog' => 'close'] : []) ?> </footer> diff --git a/app/views/course/ilias_interface/add_object.php b/app/views/course/ilias_interface/add_object.php index 8550337..ddb4fed 100644 --- a/app/views/course/ilias_interface/add_object.php +++ b/app/views/course/ilias_interface/add_object.php @@ -1,6 +1,6 @@ <form class="default" action="<?= $controller->url_for('course/ilias_interface/add_object/'.$mode.'/'.$ilias_index) ?>" method="post"> <?= CSRFProtection::tokenTag() ?> -<? if (!$ilias_index) : ?> +<? if (empty($ilias_index)) : ?> <label> <span class="required"><?= _('ILIAS-Installation auswählen') ?></span> <select name="ilias_index" required> @@ -41,7 +41,7 @@ <? elseif ($mode === 'assign_own_course') : ?> <div> <input type="hidden" name="cmd" value="assign_course"> - <? if ($submit_text) : ?> + <? if (!empty($submit_text)) : ?> <label> <span><?= _('ILIAS-Kurs wählen') ?></span> <select name="ilias_course_id" required> @@ -90,7 +90,7 @@ ]) ?> </td> <td> - <a href="<?= $controller->link_for($module->getRoute('view_course'), compact('ilias_search', 'mode')) ?>" <?= $dialog ? 'data-dialog=""' : ''?>> + <a href="<?= $controller->link_for($module->getRoute('view_course'), ['ilias_search' => !empty($ilias_search) ? $ilias_search : '', 'mode' => !empty($mode) ? $mode : '']) ?>" <?= !empty($dialog) ? 'data-dialog=""' : ''?>> <?= htmlReady($module->getTitle()) ?> </a> </td> @@ -102,7 +102,7 @@ Icon::create('info-circle'), [ 'title' => _('Info'), - 'formaction' => $controller->url_for($module->getRoute('view_course') .'?ilias_search='.urlencode($ilias_search)), + 'formaction' => $controller->url_for($module->getRoute('view_course') . (!empty($ilias_search) ? '?ilias_search='.urlencode($ilias_search) : '')), 'data-dialog' => '' ] )->condition($edit_permission)->addButton( @@ -122,8 +122,8 @@ </table> <? endif ?> <footer data-dialog-button> - <? if ($ilias && $ilias->isActive() && $submit_text) : ?> - <?= Studip\Button::create($submit_text, 'submit', ($dialog && $keep_dialog) ? ['data-dialog' => 'size=auto;reload-on-close'] : []) ?> + <? if (!empty($ilias) && $ilias->isActive() && !empty($submit_text)) : ?> + <?= Studip\Button::create($submit_text, 'submit', ($dialog && !empty($keep_dialog)) ? ['data-dialog' => 'size=auto;reload-on-close'] : []) ?> <? endif ?> <?= Studip\Button::createCancel(_('Schließen'), 'cancel', $dialog ? ['data-dialog' => 'close'] : []) ?> </footer> diff --git a/app/views/course/ilias_interface/index.php b/app/views/course/ilias_interface/index.php index 7d33f20..f713580 100644 --- a/app/views/course/ilias_interface/index.php +++ b/app/views/course/ilias_interface/index.php @@ -1,7 +1,7 @@ <form method="post"> -<? foreach($ilias_list as $ilias_index => $ilias) : ?> - <? if (!count($ilias->getCourseModules()) && !$courses[$ilias_index] && !$edit_permission) continue; ?> - <? if ($anker_target == $ilias_index) : ?> +<? foreach ($ilias_list as $ilias_index => $ilias) : ?> + <? if (!count($ilias->getCourseModules()) && empty($courses[$ilias_index]) && empty($edit_permission)) continue; ?> + <? if (!empty($anker_target) && ($anker_target === $ilias_index)) : ?> <a name='anker'></a> <? endif?> <table class="default"> @@ -80,7 +80,7 @@ </td> </tr> <? endforeach ?> - <? elseif (!$courses[$ilias_index]) : ?> + <? elseif (empty($courses[$ilias_index])) : ?> <tr> <td colspan="4"> <?= _('Es sind keine Lernobjekte mit dieser Veranstaltung verknüpft.')?> diff --git a/app/views/course/ilias_interface/view_object.php b/app/views/course/ilias_interface/view_object.php index 457e07e..d05669d 100644 --- a/app/views/course/ilias_interface/view_object.php +++ b/app/views/course/ilias_interface/view_object.php @@ -5,11 +5,11 @@ <input type="hidden" name="ilias_ref_id" value="<?=htmlReady($module_id)?>"> <?= $this->render_partial('my_ilias_accounts/_ilias_module.php') ?> <footer data-dialog-button> - <? if ($ilias->isActive() && $mode && $edit_permission) : ?> + <? if ($ilias->isActive() && !empty($mode) && $edit_permission) : ?> <?= Studip\LinkButton::create(_('Zurück'), $controller->url_for('course/ilias_interface/add_object/'.$mode.'/'.$ilias_index.'?ilias_search=' . $ilias_search), $dialog ? ['data-dialog' => 'size=auto'] : []) ?> <?= Studip\LinkButton::create(_('Hinzufügen'), $controller->url_for($module->getRoute('add') .'?ilias_search=' . $ilias_search), $dialog ? ['data-dialog' => ''] : []) ?> <? endif ?> - <? if ($ilias->isActive() && !$mode) : ?> + <? if ($ilias->isActive() && empty($mode)) : ?> <? if ($edit_permission && $module->isAllowed('delete')) : ?> <?= Studip\LinkButton::create(_('Entfernen'), $controller->url_for($module->getRoute('remove') . '?ilias_search=' . $ilias_search), ['data-confirm' => $module->siblings_count < 2 ? sprintf(_('Dies ist die einzige Instanz des Objekts "%s". Durch das Entfernen aus dem Kurs wird das Objekt unwiderruflich gelöscht! Wollen Sie das Objekt wirklich löschen?'), $module->getTitle()) : sprintf(_('Wollen Sie das Objekt "%s" jetzt entfernen?'), $module->getTitle())]) ?> <? endif ?> diff --git a/lib/ilias_interface/ConnectedIlias.class.php b/lib/ilias_interface/ConnectedIlias.class.php index 09bc52f..31b9396 100644 --- a/lib/ilias_interface/ConnectedIlias.class.php +++ b/lib/ilias_interface/ConnectedIlias.class.php @@ -97,12 +97,9 @@ class ConnectedIlias // init current user (only if ILIAS installation is active) if ($this->ilias_config['is_active']) { $this->user = new IliasUser($this->index, $this->ilias_config['version']); - if ($this->user->isConnected()) { - $ilias_user_exists = $this->soap_client->lookupUser($this->user->getUsername()); - if (!$this->soap_client->getError() && !$ilias_user_exists) { - $this->user->unsetConnection(true); - } - } + + $this->checkIliasUserEntry(); + // create account automatically if it doesn't exist if (! $this->user->isConnected()) { $this->soap_client->setCachingStatus(false); @@ -145,7 +142,58 @@ class ConnectedIlias { $this->ilias_interface_config = Config::get()->ILIAS_INTERFACE_BASIC_SETTINGS; + $interface_config_options = [ + 'show_course_paths' => true, + ]; + + foreach ($interface_config_options as $option_key => $option_value) { + if (!array_key_exists($option_key, $this->ilias_interface_config)) { + $this->ilias_interface_config[$option_key] = $option_value; + } + } + $ilias_configs = Config::get()->ILIAS_INTERFACE_SETTINGS; + $config_options = [ + 'is_active' => false, + 'name' => '', + 'version' => '', + 'url' => '', + 'client' => '', + 'ldap_enable' => '', + 'no_account_updates' => false, + 'admin' => 'ilias_soap_admin', + 'admin_pw' => '', + 'http_connection_timeout' => 30, + 'http_request_timeout' => 30, + + 'root_category_name' => '', + 'root_category' => '', + 'user_prefix' => 'studip_', + 'delete_ilias_users' => '', + 'delete_ilias_courses' => '', + 'reconnect_accounts' => false, + 'user_data_category' => '', + 'matriculation' => '', + 'discipline_1' => ['id' => ''], + 'discipline_2' => ['id' => ''], + 'allow_change_account' => false, + 'category_create_on_add_module' => false, + 'category_to_desktop' => false, + 'cat_semester' => '', + 'course_semester' => '', + 'course_veranstaltungsnummer' => false, + 'modules' => [], + + 'author_role_name' => '', + 'author_role' => '', + 'author_perm' => '' + ]; + foreach ($config_options as $option_key => $option_value) { + if (!array_key_exists($option_key, $ilias_configs[$this->index])) { + $ilias_configs[$this->index][$option_key] = $option_value; + } + } + $this->ilias_config = $ilias_configs[$this->index]; } @@ -760,17 +808,12 @@ class ConnectedIlias foreach ($this->ilias_config['modules'] as $type => $name) { $types[] = $type; } - $result = $this->soap_client->getTreeChilds($parent_id, $types); - $user_result = $this->soap_client->getTreeChilds($parent_id, $types, $this->user->getId()); - + $result = $this->soap_client->getTreeChilds($parent_id, $types, $this->user->getId()); if ($result) { foreach($result as $ref_id => $data) { if ($data['type'] == 'fold') { unset($result[$ref_id]); $result = $result + $this->getChilds($ref_id); - } else { - $result[$ref_id]['accessInfo'] = $user_result[$ref_id]['accessInfo']; - $result[$ref_id]['references'][$ref_id] = $user_result[$ref_id]['references'][$ref_id]; } } } @@ -1097,29 +1140,51 @@ class ConnectedIlias return null; } + /** - * check user + * check Ilias user entry * - * checks if ILIAS user exists, creates new user if not + * checks if ILIAS user exists and removes auth_extern entry otherwise * @access public * @return boolean returns user status */ - public function checkUser() + public function checkIliasUserEntry() { - if ($this->user->getId()) { - $user_exists = $this->soap_client->getUser($this->user->getId()); - if (!is_array($user_exists)) { + if ($this->user->isConnected()) { + $ilias_user_id = $this->soap_client->lookupUser($this->user->getUsername()); + $ilias_user_exists = $this->soap_client->getUser($this->user->getId()); + if (!$this->soap_client->getError() && empty($ilias_user_id) && ! is_array($ilias_user_exists)) { + $this->soap_client->setCachingStatus(false); + $this->soap_client->clearCache(); + $user_id = $this->soap_client->lookupUser($this->user->getUsername()); + $user_exists = $this->soap_client->getUser($this->user->getId()); $admin_user_id = $this->soap_client->lookupUser($this->ilias_config['admin']); $admin_user_exists = $this->soap_client->getUser($admin_user_id); - if (is_array($admin_user_exists)) { + if (is_array($admin_user_exists) && empty($user_id) && ! is_array($user_exists)) { $this->user->unsetConnection(true); - if ($this->newUser()) { - PageLayout::postSuccess(_("Neue Verknüpfung zu ILIAS-User angelegt.")); - } + return false; } - } else return true; + } } - return false; + return true; + } + + /** + * check user + * + * checks if ILIAS user exists, creates new user if not + * @access public + * @return boolean returns user status + */ + public function checkUser() + { + if (! $this->checkIliasUserEntry()) { + if ($this->newUser()) { + PageLayout::postSuccess(_("Neue Verknüpfung zu ILIAS-User angelegt.")); + } + return false; + } + return true; } /** @@ -1184,7 +1249,6 @@ class ConnectedIlias $member_data["role"] = self::CRS_MEMBER_ROLE; $type = "Member"; break; - default: } $member_data["passed"] = self::CRS_PASSED_VALUE; if ($type != "") { @@ -1231,7 +1295,7 @@ class ConnectedIlias } $view_permission = false; - if ((in_array($this->operations[self::OPERATION_READ], $this->tree_allowed_operations)) && (in_array($this->operations[self::OPERATION_VISIBLE], $this->tree_allowed_operations))) { + if ((in_array($this->getOperation(self::OPERATION_READ), $this->tree_allowed_operations)) && (in_array($this->getOperation(self::OPERATION_VISIBLE), $this->tree_allowed_operations))) { $view_permission = true; } return $view_permission; diff --git a/lib/ilias_interface/IliasModule.class.php b/lib/ilias_interface/IliasModule.class.php index f9bf958..d3ec88c 100644 --- a/lib/ilias_interface/IliasModule.class.php +++ b/lib/ilias_interface/IliasModule.class.php @@ -54,10 +54,14 @@ class IliasModule $this->make_date = $module_data['create_date']; $this->change_date = $module_data['last_update']; $supported_modules = ConnectedIlias::getSupportedModuleTypes(); - $this->module_type_name = $supported_modules[$this->module_type]; + if (!empty($supported_modules[$this->module_type])) { + $this->module_type_name = $supported_modules[$this->module_type]; + } else { + $this->module_type_name = $this->module_type; + } $this->owner = $module_data['owner']; $this->author_studip = false; - if (is_array($module_data['references'][$module_id]['operations'])) { + if (!empty($module_data['references'][$module_id]['operations']) && is_array($module_data['references'][$module_id]['operations'])) { $this->allowed_operations = $module_data['references'][$module_id]['operations']; } else { $this->allowed_operations = []; diff --git a/lib/ilias_interface/IliasSoap.class.php b/lib/ilias_interface/IliasSoap.class.php index 9ae6f85..ed0e21d 100644 --- a/lib/ilias_interface/IliasSoap.class.php +++ b/lib/ilias_interface/IliasSoap.class.php @@ -132,6 +132,7 @@ class IliasSoap extends StudipSoapClient } $cache_index = md5($method . ':' . json_encode($params)); + if ($this->caching_active && isset($this->soap_cache[$cache_index]) && $method !== 'login') { $result = $this->soap_cache[$cache_index]; } else { @@ -364,7 +365,7 @@ class IliasSoap extends StudipSoapClient $single_object['references'][(string)$reference[0]['ref_id']]['path_types'][] = (string)$element[0]['type']; } } - if ($single_object['ref_id']) { + if (!empty($single_object['ref_id'])) { $objects[$single_object['ref_id']] = $single_object; } elseif (!$condition_field) { $objects[] = $single_object; @@ -393,7 +394,7 @@ class IliasSoap extends StudipSoapClient 'types' => $types, 'key' => $key, 'combination' => $combination, - 'user_id' => (int)$user_id + 'user_id' => !empty($user_id) ? (int)$user_id : null ]; $result = $this->call('searchObjects', $param); @@ -414,12 +415,12 @@ class IliasSoap extends StudipSoapClient * @param string user_id ilias-user-id * @return array object */ - function getObjectByReference($ref, $user_id = "") + function getObjectByReference($ref, $user_id = false) { $param = [ 'sid' => $this->getSID(), 'reference_id' => $ref, - 'user_id' => (int)$user_id + 'user_id' => !empty($user_id) ? (int)$user_id : null ]; $result = $this->call('getObjectByReference', $param); @@ -446,13 +447,12 @@ class IliasSoap extends StudipSoapClient $param = [ 'sid' => $this->getSID(), 'title' => $key, - 'user_id' => 0 + 'user_id' => null ]; $result = $this->call('getObjectsByTitle', $param); if ($result != false) { $objects = $this->parseIliasObject($result); - //$objects = $this->parseXML($result); foreach($objects as $index => $object_data) { if (($type != "") AND ($object_data["type"] != $type)) @@ -481,7 +481,7 @@ class IliasSoap extends StudipSoapClient $param = [ 'sid' => $this->getSID(), 'title' => $key, - 'user_id' => 0 + 'user_id' => null ]; $result = $this->call('getObjectsByTitle', $param); @@ -500,7 +500,6 @@ class IliasSoap extends StudipSoapClient if (sizeof($object_data["references"]) > 0) { return key($object_data["references"]); - //return $object_data["references"][0]["ref_id"]; } } return false; @@ -607,14 +606,12 @@ class IliasSoap extends StudipSoapClient * @param string user_id user-id for permissions * @return array objects */ - function getTreeChilds($ref_id, $types = "", $user_id = "") + function getTreeChilds($ref_id, $types, $user_id) { - if ($types == "") - $types = []; $param = [ 'sid' => $this->getSID(), - 'ref_id' => $ref_id, - 'types' => $types, + 'ref_id' => (int)$ref_id, + 'types' => (array)$types, 'user_id' => (int)$user_id ]; @@ -692,8 +689,7 @@ class IliasSoap extends StudipSoapClient $result = $this->call('getUserRoles', $param); if ($result != false) { - // TODO: change to simple xml - $objects = $this->parseXML($result); + $objects = $this->parseIliasObject($result); $roles = []; foreach ($objects as $count => $role) $roles[$count] = $role["obj_id"]; @@ -719,8 +715,7 @@ class IliasSoap extends StudipSoapClient $result = $this->call('getLocalRoles', $param); if ($result != false) { - // TODO: change to simple xml - $objects = $this->parseXML($result); + $objects = $this->parseIliasObject($result); return $objects; } return false; @@ -744,13 +739,10 @@ class IliasSoap extends StudipSoapClient $xml = "<!DOCTYPE Objects SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_object_0_1.dtd\"> <Objects> - <Object type=\"$type\" obj_id=\"\"> - <Title> - $title - </Title> - <Description> - $description - </Description> + <Object type=\"$type\" obj_id=\"\" offline=\"\"> + <Title>$title</Title> + <Description>$description</Description> + <ImportId></ImportId> </Object> </Objects>"; @@ -785,13 +777,10 @@ class IliasSoap extends StudipSoapClient $xml = "<!DOCTYPE Objects SYSTEM \"http://www.ilias.uni-koeln.de/download/dtd/ilias_object_0_1.dtd\"> <Objects> - <Object type=\"$type\" obj_id=\"\"> - <Title> - $title - </Title> - <Description> - $description - </Description> + <Object type=\"$type\" obj_id=\"\" offline=\"\"> + <Title>$title</Title> + <Description>$description</Description> + <ImportId></ImportId> </Object> </Objects>"; @@ -991,13 +980,12 @@ class IliasSoap extends StudipSoapClient $param = [ 'sid' => $this->getSID(), 'user_ids' => [$user_id], - 'attach_roles' => 0 + 'attach_roles' => null ]; $result = $this->call('getUserXML', $param); if ($result != false) { - // TODO: change to simple xml - $objects = $this->parseXML($result); + $objects = $this->parseIliasObject($result); $all_objects = []; foreach($objects as $count => $object_data){ if (is_array($object_data["references"])) @@ -1640,12 +1628,14 @@ class IliasSoap extends StudipSoapClient $s = simplexml_load_string($result); foreach ($s->rows->row as $row) { $ref_id = (string)$row->column[0]; - $xml = $this->parseXML((string)$row->column[1]); - $course = array_pop($xml); - $ret[$ref_id] = $course['title']; + $s2 = simplexml_load_string((string)$row->column[1]); + + if (is_object($s2->MetaData)) { + $ret[$ref_id] = trim($s2->MetaData->General->Title); + } } } - if (is_array($ret)) { + if (!empty($ret)) { return $ret; } else { return false; @@ -1666,19 +1656,18 @@ class IliasSoap extends StudipSoapClient $param = [ 'sid' => $this->getSID(), 'reference_id' => $id, - 'user_id' => 0 + 'user_id' => null ]; $result = $this->call('getObjectByReference', $param); if ($result != false) { - // TODO: change to simple xml - $objects = $this->parseXML($result); + $objects = $this->parseIliasObject($result); if(is_array($objects)){ foreach($objects as $index => $object_data){ if(is_array($object_data['references'])){ - foreach($object_data['references'] as $reference){ - if($reference['ref_id'] == $id && $reference['accessInfo'] != 'object_deleted') return $object_data['obj_id']; + foreach($object_data['references'] as $ref_id => $reference){ + if($ref_id == $id && $reference['accessInfo'] != 'object_deleted') return $object_data['obj_id']; } } } diff --git a/lib/ilias_interface/studip_referrer_9x.php b/lib/ilias_interface/studip_referrer_9x.php new file mode 100644 index 0000000..8cfad26 --- /dev/null +++ b/lib/ilias_interface/studip_referrer_9x.php @@ -0,0 +1,125 @@ +<?php +/* Copyright (c) 1998-2014 ILIAS open source, Extended GPL, see docs/LICENSE */ + +/** +* redirect script for studip-users +* +* @author Arne Schroeder <schroeder@data-quest.de> +* @author Andre Noack <noack@data-quest.de> +* +*/ + +/* ILIAS Version 9.x */ + +if (file_exists("./ilias.ini.php")) { + require_once("./Services/Init/classes/class.ilIniFile.php"); + $ilIliasIniFile = new ilIniFile("./ilias.ini.php"); + $ilIliasIniFile->read(); + $serverSettings = $ilIliasIniFile->readGroup("server"); + if (isset($serverSettings["studip"]) && $serverSettings["studip"] != 1) { + echo 'Option "studip" in ilias.ini.php is not enabled. You need to add studip = "1" to the server section.'; + exit(); + } + + $cookie_path = dirname($_SERVER['PHP_SELF']); + if (substr($cookie_path,-1) != "/") { + $cookie_path .= "/"; + } + if (isset($_GET['sess_id'])) { + setcookie('PHPSESSID',$_GET['sess_id'],0, $cookie_path); + $_COOKIE['PHPSESSID'] = $_GET['sess_id']; + } + + if (isset($_GET['client_id'])) { + setcookie('ilClientId',$_GET['client_id'],0, $cookie_path); + $_COOKIE['ilClientId'] = $_GET['client_id']; + } + + require_once "./include/inc.header.php"; + + $base_url= "ilias.php?baseClass=ilDashboardGUI"; + + + // redirect to specified page + $redirect = false; + switch($_GET['target']) { + case 'start': + switch($_GET['type']) { + case 'lm': + $base_url = "ilias.php?baseClass=ilLMPresentationGUI"; + break; + case 'tst': + $base_url = "ilias.php?cmd=infoScreen&cmdClass=ilobjtestgui&baseClass=ilRepositoryGUI"; + break; + case 'svy': + $base_url = "ilias.php?cmd=infoScreen&cmdClass=ilObjSurveyGUI&baseClass=ilRepositoryGUI"; + break; + case 'exc': + $base_url = "ilias.php?cmd=infoScreen&cmdClass=ilExerciseHandlerGUI&baseClass=ilRepositoryGUI"; + break; + case 'sahs': + $base_url = "ilias.php?baseClass=ilSAHSPresentationGUI"; + break; + case 'htlm': + $base_url = "ilias.php?baseClass=ilHTLMPresentationGUI"; + break; + case 'glo': + $base_url = "ilias.php?baseClass=ilGlossaryPresentationGUI"; + break; + case 'cat': + case 'crs': + $base_url = "ilias.php?cmd=view&cmdClass=ilobjcoursegui&baseClass=ilRepositoryGUI"; + break; + case 'webr': + $base_url = "ilias.php?cmd=calldirectlink&baseClass=ilLinkResourceHandlerGUI"; + break; + } + break; + case 'new': + $base_url = "ilias.php?baseClass=ilRepositoryGUI&cmd=create&new_type=".preg_replace('/[^a-z]/', '', $_GET['type']); + break; + case 'edit': + switch($_GET['type']) + { + case 'lm': + $base_url = "ilias.php?baseClass=ilLMEditorGUI"; + break; + case 'tst': + $base_url = "ilias.php?baseClass=ilObjTestGUI"; + break; + case 'sahs': + $base_url = "ilias.php?baseClass=ilSAHSEditGUI"; + break; + case 'htlm': + $base_url = "ilias.php?baseClass=ilHTLMEditorGUI"; + break; + case 'glo': + $base_url = "ilias.php?baseClass=ilGlossaryEditorGUI"; + break; + case 'svy': + $base_url = "ilias.php?baseClass=ilObjSurveyGUI"; + break; + case 'exc': + $base_url = "ilias.php?baseClass=ilExerciseHandlerGUI"; + break; + case 'crs': + $base_url = "ilias.php?baseClass=ilrepositorygui&cmd=edit"; + break; + case 'webr': + $base_url = "ilias.php?baseClass=ilLinkResourceHandlerGUI"; + break; + } + break; + } + if ($base_url) + { + if (!empty($_GET['ref_id'])) { + $base_url .= "&ref_id=".(int)$_GET['ref_id']; + } + $token_repository = new ilCtrlTokenRepository(); + $token = $token_repository->getToken(); + $base_url .= '&' . ilCtrlInterface::PARAM_CSRF_TOKEN . '=' . $token->getToken(); + header("Location: " . $base_url); + exit(); + } +} diff --git a/phpstan.neon.dist b/phpstan.neon.dist index 17ff7c6..6a6a6d8 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -18,6 +18,7 @@ parameters: - lib/classes/ZipArchiveLegacyTrait.php - lib/elearning/studip_referrer.php - lib/soap/StudipSoapClient_PHP5.class.php + - lib/ilias_interface/studip_referrer_9x.php tmpDir: .caches earlyTerminatingMethodCalls: RESTAPI\RouteMap: |
