blob: 1d8fd229e9d56489166448acaec3f9a91b500bdd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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 = UserConfig::get($GLOBALS['user']->id)->getValue('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;
}
}
|