diff --git a/app/controllers/admin/courseplanning.php b/app/controllers/admin/courseplanning.php index 4b6597537e5f743c1e5ae3b9aaca73a04a4c0903..2271acfdbac096aafd6fd642d9b129f705365532 100644 --- a/app/controllers/admin/courseplanning.php +++ b/app/controllers/admin/courseplanning.php @@ -851,7 +851,6 @@ class Admin_CourseplanningController extends AuthenticatedController } $seminars = array_map('reset', $courses); - $visit_data = get_objects_visits(array_keys($seminars), 'sem', null, null, array_keys(MyRealmModel::getDefaultModules())); if (!empty($seminars)) { foreach ($seminars as $seminar_id => $seminar) { @@ -861,6 +860,9 @@ class Admin_CourseplanningController extends AuthenticatedController $seminars[$seminar_id]['dozenten'] = $dozenten; if (in_array('contents', $params['view_filter'])) { + $tools = new SimpleCollection(ToolActivation::findbyRange_id($seminar_id, "ORDER BY position")); + $visit_data = get_objects_visits([$seminar_id], 0, null, null, $tools->pluck('plugin_id')); + $seminars[$seminar_id]['tools'] = $tools; $seminars[$seminar_id]['visitdate'] = $visit_data[$seminar_id][0]['visitdate']; $seminars[$seminar_id]['last_visitdate'] = $visit_data[$seminar_id][0]['last_visitdate']; $seminars[$seminar_id]['sem_class'] = $sem_types[$seminar['status']]->getClass(); diff --git a/app/controllers/admin/courses.php b/app/controllers/admin/courses.php index cd0935a3693521ec90b95bbd5752fd80700721af..11f9ced9c6195d176b114b9b2567919190f3d4ef 100644 --- a/app/controllers/admin/courses.php +++ b/app/controllers/admin/courses.php @@ -1229,7 +1229,6 @@ class Admin_CoursesController extends AuthenticatedController } $seminars = array_map('reset', $courses); - $visit_data = get_objects_visits(array_keys($seminars), 0, null, null, array_keys(MyRealmModel::getDefaultModules())); if (!empty($seminars)) { foreach ($seminars as $seminar_id => $seminar) { @@ -1239,9 +1238,11 @@ class Admin_CoursesController extends AuthenticatedController $seminars[$seminar_id]['dozenten'] = $dozenten; if (in_array('contents', $params['view_filter'])) { + $tools = new SimpleCollection(ToolActivation::findbyRange_id($seminar_id, "ORDER BY position")); + $visit_data = get_objects_visits([$seminar_id], 0, null, null, $tools->pluck('plugin_id')); $seminars[$seminar_id]['visitdate'] = $visit_data[$seminar_id][0]['visitdate']; $seminars[$seminar_id]['last_visitdate'] = $visit_data[$seminar_id][0]['last_visitdate']; - $seminars[$seminar_id]['tools'] = new SimpleCollection(ToolActivation::findbyRange_id($seminar_id, "ORDER BY position")); + $seminars[$seminar_id]['tools'] = $tools; $seminars[$seminar_id]['navigation'] = MyRealmModel::getAdditionalNavigations( $seminar_id, $seminars[$seminar_id], diff --git a/lib/classes/MyRealmModel.php b/lib/classes/MyRealmModel.php index cf4a508adc0bd1c5578f9014dbc2362df98baa0d..7b981c3ab241ba3148f6a6dc3c36775be218f9c2 100644 --- a/lib/classes/MyRealmModel.php +++ b/lib/classes/MyRealmModel.php @@ -302,7 +302,6 @@ class MyRealmModel // filtering courses $member_ships = User::findCurrent()->course_memberships->toGroupedArray('seminar_id', 'status gruppe'); - $visits = get_objects_visits($courses->pluck('id'), 0, null, null, array_keys(self::getDefaultModules())); $children = []; $semester_assign = []; @@ -314,6 +313,8 @@ class MyRealmModel $_course['sem_class'] = $course->getSemClass(); $_course['obj_type'] = 'sem'; + $visits = get_objects_visits([$course->id], 0, null, null, $course->tools->pluck('plugin_id')); + if ($group_field === 'sem_tree_id') { $_course['sem_tree'] = $course->study_areas->toArray(); } @@ -515,15 +516,8 @@ class MyRealmModel $statement->execute(); // Update all activated modules - foreach (self::getDefaultModules() as $id => $module) { - // Skip modules that were already handled above - if ($module === 'vote') { - continue; - } - - if ($object->tools->findBy('plugin_id', $id)) { - object_set_visit($object->id, $id); - } + foreach ($object->tools as $module) { + object_set_visit($object->id, $module->plugin_id); } // Update object itself @@ -597,36 +591,27 @@ class MyRealmModel if (empty($memberShips)) { return null; } - + $institutes = []; $insts = new SimpleCollection($memberShips); - $ids = $insts->pluck('institut_id'); - $visits = get_objects_visits($ids, 0, null, null, array_keys(self::getDefaultModules('institute'))); - - $institutes = $insts->map(function ($a) use ($visits) { - $inst = $a->institute->toArray(); - $inst['tools'] = $a->institute->tools; - $inst['perms'] = $a->inst_perms; - $inst['visitdate'] = $visits[$a->institut_id]['inst']['visitdate']; - $inst['last_visitdate'] = $visits[$a->institut_id]['inst']['last_visitdate']; - - return $inst; - }); - - - if ($institutes) { - foreach ($institutes as $index => $inst) { - $institutes[$index]['obj_type'] = 'inst'; - $institutes[$index]['navigation'] = self::getAdditionalNavigations( - $inst['institut_id'], - $institutes[$index], - SemClass::getDefaultInstituteClass($inst['type']), - $GLOBALS['user']->id, - $visits[$inst['institut_id']] - ); - } - unset($Modules); + foreach ($insts as $inst) { + $index = $inst->institute->id; + $visits = get_objects_visits([$index], 0, null, null, $inst->institute->tools->pluck('plugin_id')); + $institutes[$index] = $inst->institute->toArray(); + $institutes[$index]['tools'] = $inst->institute->tools; + $institutes[$index]['perms'] = $inst->inst_perms; + $institutes[$index]['visitdate'] = $visits[$index][0]['visitdate']; + $institutes[$index]['last_visitdate'] = $visits[$index][0]['last_visitdate']; + $institutes[$index]['obj_type'] = 'inst'; + $institutes[$index]['navigation'] = self::getAdditionalNavigations( + $index, + $institutes[$index], + SemClass::getDefaultInstituteClass($inst->institute->type), + $GLOBALS['user']->id, + $visits[$index] + ); } + return $institutes; } @@ -801,14 +786,14 @@ class MyRealmModel ) ); - $visit_data = get_objects_visits(array_keys($studygroups), 'sem', null, null, array_keys(self::getDefaultModules())); - $data_fields = 'name seminar_id visible veranstaltungsnummer start_time duration_time status visible ' . 'chdate admission_binding admission_prelim'; $studygroup_data = []; foreach ($studygroup_memberships as $membership) { $studygroup = $studygroups[$membership->seminar_id]; + $visit_data = get_objects_visits([$studygroup->id], 0, null, null, $studygroup->tools->pluck('plugin_id')); $data = $studygroup->toArray($data_fields); + $data['tools'] = $studygroup->tools; $data['sem_class'] = $studygroup->getSemClass(); $data['start_semester'] = $studygroup->start_semester->name; $data['end_semester'] = $studygroup->end_semester->name; diff --git a/lib/object.inc.php b/lib/object.inc.php index 64ce281b442bb6a205cd1022240f31bb9873d44e..dcb310e8ad1d44004c41a60b27b6b1600b789bfc 100644 --- a/lib/object.inc.php +++ b/lib/object.inc.php @@ -154,7 +154,7 @@ function object_get_visit($object_id, $plugin_id, $mode = "last", $open_object_i * @param string|null $mode The return-mode: 'last' for the last visit, other for actual-visit; * pass null to get an array of visit date and last visit date * @param mixed $user_id User id to gather the data for, pass null for current user - * @param array $additional_types Additional types to get data for. The returned array is then enlarged + * @param array $additional_plugins Additional types to get data for. The returned array is then enlarged * by one dimension * @return array associate array with the object id as key and the according data as value *