From e67b28357ce04e1c2af8cf8a07d66159e44ba73a Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Wed, 31 Aug 2022 07:12:28 +0000 Subject: transfer CourseHistory plugin into main, fixes #1497 Closes #1497 Merge request studip/studip!936 --- app/controllers/course/history.php | 49 ++++++++++++++++++++++++++++++++++++++ app/views/course/history/index.php | 45 ++++++++++++++++++++++++++++++++++ lib/modules/CoreOverview.class.php | 3 +++ 3 files changed, 97 insertions(+) create mode 100644 app/controllers/course/history.php create mode 100644 app/views/course/history/index.php diff --git a/app/controllers/course/history.php b/app/controllers/course/history.php new file mode 100644 index 0000000..9a8e4e9 --- /dev/null +++ b/app/controllers/course/history.php @@ -0,0 +1,49 @@ +have_studip_perm('admin', Context::getId())) { + throw new AccessDeniedException(); + } + + Navigation::activateItem('/course/main/history'); + PageLayout::setTitle(_('Änderungsverlauf')); + } + + public function index_action() + { + $this->history = $this->getHistory(Context::get()); + } + + private function getHistory(Course $course): array + { + $result = []; + LogEvent::findEachBySQL( + function (LogEvent $event) use (&$result) { + if (!isset($result[$event->action_id])) { + $result[$event->action_id] = [ + 'name' => "{$event->action->name}: {$event->action->description}", + 'events' => [], + ]; + } + + $result[$event->action_id]['events'][] = $event; + }, + "? IN (affected_range_id, coaffected_range_id, user_id) ORDER BY mkdate DESC", + [$course->id] + ); + + $result = array_values($result); + usort($result, function ($a, $b) { + return strcasecmp($a['name'], $b['name']); + }); + + return $result; + } +} diff --git a/app/views/course/history/index.php b/app/views/course/history/index.php new file mode 100644 index 0000000..42deca9 --- /dev/null +++ b/app/views/course/history/index.php @@ -0,0 +1,45 @@ +formatEvent()); + $info = str_replace('admission_turnout', _('max. Teilnehmerzahl'), $info); + $info = str_replace('=>', '→', $info); + + return $info; + +}; +?> + + hideClose() ?> + + + + + + + $type): ?> + 0) echo 'class="collapsed"'; ?>> + + + + + + + + + + + +
+ + + +
mkdate) ?> + + info && $GLOBALS['perm']->have_perm('root')): ?> +
: info) ?> + + dbg_info && $GLOBALS['perm']->have_perm('root')): ?> +
: dbg_info) ?> + +
+ diff --git a/lib/modules/CoreOverview.class.php b/lib/modules/CoreOverview.class.php index 39145ae..fff3050 100644 --- a/lib/modules/CoreOverview.class.php +++ b/lib/modules/CoreOverview.class.php @@ -100,6 +100,9 @@ class CoreOverview extends CorePlugin implements StudipModule if (!$sem_class['studygroup_mode']) { $navigation->addSubNavigation('details', new Navigation(_('Details'), 'dispatch.php/course/details/')); } + if ($GLOBALS['perm']->have_studip_perm('admin', $course_id)) { + $navigation->addSubNavigation('history', new Navigation(_('Änderungsverlauf'), 'dispatch.php/course/history')); + } } return ['main' => $navigation]; } -- cgit v1.0