diff --git a/app/controllers/my_courses.php b/app/controllers/my_courses.php index ad340035bce65b32aa082ac475ef06ba36b83187..b3e43e351f211b60188a269252d248502df78e1d 100644 --- a/app/controllers/my_courses.php +++ b/app/controllers/my_courses.php @@ -603,7 +603,7 @@ class MyCoursesController extends AuthenticatedController if (is_array($courses)) { if ($group_field !== 'sem_number') { // tlx: If array is 2-dimensional, merge it into a 1-dimensional - $courses = call_user_func_array('array_merge', $courses); + $courses = array_merge(...array_values($courses)); } foreach ($courses as $course) { @@ -753,7 +753,7 @@ class MyCoursesController extends AuthenticatedController foreach ($_inner as $course) { $_courses[$course['seminar_id']] = $course; - if ($course['children']) { + if (isset($course['children']) && is_array($couse['children'])) { foreach ($course['children'] as $child) { $_courses[$child['seminar_id']] = $child; } diff --git a/lib/classes/MyRealmModel.php b/lib/classes/MyRealmModel.php index 5a6c67b104947646e09cb6d5d43609a40d16e524..7b9f8662d1f449038e00270d205960ce68f7e23b 100644 --- a/lib/classes/MyRealmModel.php +++ b/lib/classes/MyRealmModel.php @@ -634,7 +634,12 @@ class MyRealmModel */ public static function groupBySemTree(&$sem_courses) { + $_tmp_courses = []; foreach ($sem_courses as $sem_key => $collection) { + if (!isset($_tmp_courses[$sem_key])) { + $_tmp_courses[$sem_key] = []; + } + //We have to store the sem_tree names separately //since we first need the sem_tree IDs as array keys. //This makes it more easy to get the ordering @@ -644,10 +649,18 @@ class MyRealmModel if (!empty($course['sem_tree'])) { foreach ($course['sem_tree'] as $tree) { $sem_tree_names[$tree['sem_tree_id']] = $tree['name']; + + if (!isset($_tmp_courses[$sem_key][(string)$tree['sem_tree_id']])) { + $_tmp_courses[$sem_key][(string)$tree['sem_tree_id']] = []; + } $_tmp_courses[$sem_key][(string)$tree['sem_tree_id']][$course['seminar_id']] = $course; } } else { - $_tmp_courses[$sem_key][""][$course['seminar_id']] = $course; + if (!isset($_tmp_courses[$sem_key][''])) { + $_tmp_courses[$sem_key][''] = []; + } + + $_tmp_courses[$sem_key][''][$course['seminar_id']] = $course; } } uksort($_tmp_courses[$sem_key], function ($a, $b) use ($sem_tree_names) { @@ -655,8 +668,7 @@ class MyRealmModel 'StudipSemTree', ['build_index' => true] ); - return (int)($the_tree->tree_data[$a]['index'] - - $the_tree->tree_data[$b]['index']); + return (int)($the_tree->tree_data[$a]['index'] ?? 0 - $the_tree->tree_data[$b]['index'] ?? 0); }); //At this point the $_tmp_courses array is sorted by the ordering //of the sem_tree. @@ -664,9 +676,13 @@ class MyRealmModel //of the $_tmp_courses array with the sem_tree names: foreach ($_tmp_courses[$sem_key] as $sem_tree_id => $courses) { foreach ($courses as $course) { - $_tmp_courses[$sem_key][(string)$sem_tree_names[$sem_tree_id]][$course['seminar_id']] = $course; + $index = (string)($sem_tree_names[$sem_tree_id] ?? ''); + if (!isset($_tmp_courses[$sem_key][$index])) { + $_tmp_courses[$sem_key][$index] = []; + } + $_tmp_courses[$sem_key][$index][$course['seminar_id']] = $course; } - if ($sem_tree_names[$sem_tree_id]) { + if (isset($sem_tree_names[$sem_tree_id])) { unset($_tmp_courses[$sem_key][$sem_tree_id]); } } diff --git a/lib/models/StudipStudyArea.class.php b/lib/models/StudipStudyArea.class.php index 4ef7a5783fb27322680da9453ae314a3df13ab7c..66505261d24b65de13aae56ffef4864d2647a143 100644 --- a/lib/models/StudipStudyArea.class.php +++ b/lib/models/StudipStudyArea.class.php @@ -127,7 +127,7 @@ class StudipStudyArea extends SimpleORMap public function getName() { if ($this->studip_object_id) { - return $this->institute->name; + return $this->institute ? $this->institute->name : _('Unbekannte Einrichtung'); } return $this->content['name']; }