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 /lib | |
| parent | d2b0799fe31c93cb0f21109d2a0e14fec578ca42 (diff) | |
Resolve "ILIAS-Schnittstelle: Inkompatibilität mit ILIAS 9"
Closes #4995
Merge request studip/studip!3888
Diffstat (limited to 'lib')
| -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 |
4 files changed, 253 insertions, 71 deletions
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(); + } +} |
