diff options
| author | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
|---|---|---|
| committer | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
| commit | 4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch) | |
| tree | 5c07151ae61276d334e88f6309c30d439a85c12e /lib/modules/CoreOverview.php | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'lib/modules/CoreOverview.php')
| -rw-r--r-- | lib/modules/CoreOverview.php | 125 |
1 files changed, 125 insertions, 0 deletions
diff --git a/lib/modules/CoreOverview.php b/lib/modules/CoreOverview.php new file mode 100644 index 0000000..94005da --- /dev/null +++ b/lib/modules/CoreOverview.php @@ -0,0 +1,125 @@ +<?php + +/* + * Copyright (c) 2012 Rasmus Fuhse <fuhse@data-quest.de> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + */ + +class CoreOverview extends CorePlugin implements StudipModule +{ + /** + * {@inheritdoc} + */ + public function getIconNavigation($course_id, $last_visit, $user_id) + { + $sql = "SELECT COUNT(nw.news_id) AS count, + COUNT(IF((nw.chdate > IFNULL(b.visitdate, :threshold) AND nw.user_id !=:user_id), nw.news_id, NULL)) AS neue + FROM news_range AS a + LEFT JOIN news AS nw + ON a.news_id = nw.news_id + AND UNIX_TIMESTAMP() BETWEEN date AND date + expire + LEFT JOIN object_user_visits AS b + ON b.object_id = a.news_id + AND b.user_id = :user_id + AND b.plugin_id = :plugin_id + WHERE a.range_id = :course_id + GROUP BY a.range_id"; + + $statement = DBManager::get()->prepare($sql); + $statement->bindValue(':user_id', $user_id); + $statement->bindValue(':course_id', $course_id); + $statement->bindValue(':threshold', object_get_visit_threshold()); + $statement->bindValue(':plugin_id', $this->getPluginId()); + $statement->execute(); + $result = $statement->fetch(PDO::FETCH_ASSOC); + if (!$result) { + return null; + } + + $nav = new Navigation(_('Ankündigungen'), ''); + if ($result['neue']) { + $nav->setURL('?new_news=true'); + $nav->setImage(Icon::create('news', Icon::ROLE_ATTENTION), [ + 'title' => sprintf( + ngettext( + '%1$d Ankündigung, %2$d neue', + '%1$d Ankündigungen, %2$d neue', + $result['count'] + ), + $result['count'], + $result['neue'] + ) + ]); + $nav->setBadgeNumber($result['neue']); + } elseif ($result['count']) { + $nav->setImage(Icon::create('news', Icon::ROLE_CLICKABLE), [ + 'title' => sprintf( + ngettext( + '%d Ankündigung', + '%d Ankündigungen', + $result['count'] + ), + $result['count'] + ) + ]); + } + return $nav; + } + + /** + * {@inheritdoc} + */ + public function getTabNavigation($course_id) + { + $object_type = get_object_type($course_id, ['sem', 'inst']); + if ($object_type === 'sem') { + $course = Course::find($course_id); + $sem_class = $GLOBALS['SEM_CLASS'][$GLOBALS['SEM_TYPE'][$course->status]['class']] ?: SemClass::getDefaultSemClass(); + } else { + $institute = Institute::find($course_id); + $sem_class = SemClass::getDefaultInstituteClass($institute->type); + } + + $navigation = new Navigation(_('Übersicht')); + $navigation->setImage(Icon::create('seminar', Icon::ROLE_INFO_ALT)); + $navigation->setActiveImage(Icon::create('seminar', Icon::ROLE_INFO)); + if ($object_type !== 'sem') { + $navigation->addSubNavigation('info', new Navigation(_('Kurzinfo'), 'dispatch.php/institute/overview')); + $navigation->addSubNavigation('courses', new Navigation(_('Veranstaltungen'), 'show_bereich.php?level=s&id='.$course_id)); + $navigation->addSubNavigation('schedule', new Navigation(_('Veranstaltungs-Stundenplan'), 'dispatch.php/institute/schedule/index/' . $course_id)); + + if ($GLOBALS['perm']->have_studip_perm('admin', $course_id)) { + $navigation->addSubNavigation('admin', new Navigation(_('Administration der Einrichtung'), 'dispatch.php/institute/basicdata/index?new_inst=TRUE')); + } + } else { + $navigation->addSubNavigation('info', new Navigation(_('Kurzinfo'), 'dispatch.php/course/overview')); + if (!$sem_class['studygroup_mode']) { + $navigation->addSubNavigation('details', new Navigation(_('Details'), 'dispatch.php/course/details/')); + } + } + return ['main' => $navigation]; + } + + /** + * {@inheritdoc} + */ + public function getMetadata() + { + return [ + 'displayname' => _('Übersicht'), + 'summary' => _('Ankündigungen, Termine, Fragebögen & Details'), + 'icon' => Icon::create('home', Icon::ROLE_INFO), + 'icon_clickable' => Icon::create('home', Icon::ROLE_CLICKABLE) + ]; + } + + public function getInfoTemplate($course_id) + { + // TODO: Implement getInfoTemplate() method. + return null; + } +} |
