diff options
| author | Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> | 2022-05-11 07:19:42 +0000 |
|---|---|---|
| committer | Elmar Ludwig <elmar.ludwig@uni-osnabrueck.de> | 2022-05-11 07:19:42 +0000 |
| commit | 20240b2aacb15ab3264afbfbbc9dae952db4bb63 (patch) | |
| tree | 597cae73c5ae7ab9eda6d066d45430c3f17a4560 /lib/modules/QuickSelection.php | |
| parent | c054faf90288a75fc3680480434ba93b7f5b287b (diff) | |
convert old core plugins to new model, re #814
Merge request studip/studip!440
Diffstat (limited to 'lib/modules/QuickSelection.php')
| -rw-r--r-- | lib/modules/QuickSelection.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/modules/QuickSelection.php b/lib/modules/QuickSelection.php new file mode 100644 index 0000000..f1a7a2c --- /dev/null +++ b/lib/modules/QuickSelection.php @@ -0,0 +1,57 @@ +<?php +/* + * QuickSelection.php - widget plugin for start page + * + * Copyright (C) 2014 - Nadine Werner <nadwerner@uos.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 QuickSelection extends CorePlugin implements PortalPlugin +{ + public function getPluginName() + { + return _('Schnellzugriff'); + } + + public function getMetadata() + { + return [ + 'description' => _('Mit dem Schnellzugriff-Widget können Sie Links zu bestimmten Bereichen in Stud.IP verwalten.') + ]; + } + + public function getPortalTemplate() + { + $names = WidgetHelper::getWidgetUserConfig($GLOBALS['user']->id, 'QUICK_SELECTION'); + + $template = $GLOBALS['template_factory']->open('start/quickselection'); + $template->navigation = $this->getFilteredNavigation($names); + + $navigation = new Navigation('', 'dispatch.php/quickselection/configuration'); + $navigation->setImage(Icon::create('edit', 'clickable', ["title" => _('Konfigurieren')]), ['data-dialog'=>'size=auto']); + + $template->icons = [$navigation]; + + return $template; + } + + private function getFilteredNavigation($items) + { + $result = []; + + $navigation = Navigation::getItem('/start'); + foreach ($navigation as $name => $nav) { + // if config is new (key:value) display values which are not in config array + // otherwise hide items which are not in config array + // This is important for patching. + if (!isset($items[$name]) || $items[$name] !== 'deactivated') { + $result[] = $nav; + } + } + + return $result; + } +} |
