From f5061b58333f46d4341c2091f3052b95a04c9bc4 Mon Sep 17 00:00:00 2001 From: Felix Pahlow <felix.pahlow@itz.uni-halle.de> Date: Fri, 9 Dec 2022 09:57:18 +0000 Subject: [PATCH] Skip recursive lookup if no modules are chosen from ILIAS #1615 Closes #1615 Merge request studip/studip!1040 --- lib/elearning/Ilias4ConnectedCMS.class.php | 3 +- lib/ilias_interface/ConnectedIlias.class.php | 40 +++++++++++--------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/lib/elearning/Ilias4ConnectedCMS.class.php b/lib/elearning/Ilias4ConnectedCMS.class.php index f569756516b..d45168ff007 100644 --- a/lib/elearning/Ilias4ConnectedCMS.class.php +++ b/lib/elearning/Ilias4ConnectedCMS.class.php @@ -41,7 +41,8 @@ class Ilias4ConnectedCMS extends Ilias3ConnectedCMS } /** - * Helper function to fetch childs including objects in folders + * Helper function to fetch children including objects in folders + * The typo in the function name, 'childs', is intentional to reflect the name of the ILIAS-SOAP call. * * @access public * @param string $parent_id diff --git a/lib/ilias_interface/ConnectedIlias.class.php b/lib/ilias_interface/ConnectedIlias.class.php index 86e0efa083e..e2d63275087 100644 --- a/lib/ilias_interface/ConnectedIlias.class.php +++ b/lib/ilias_interface/ConnectedIlias.class.php @@ -687,7 +687,8 @@ class ConnectedIlias } /** - * Helper function to fetch childs including objects in folders + * Helper function to fetch children including objects in folders + * The typo in the function name, 'childs', is intentional to reflect the name of the ILIAS-SOAP call. * * @access public * @param string $parent_id @@ -695,28 +696,31 @@ class ConnectedIlias */ public function getChilds($parent_id) { $types[] = 'fold'; - 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()); - - 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]; + if (isset($this->ilias_config['modules']) && $this->ilias_config['modules']) { + 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()); + + 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]; + } } } } - if (is_array($result)) + if (isset($result) && is_array($result)) { return $result; - else - return []; + } else { + return []; + } } /** -- GitLab