blob: f5d7f71d2194f3b7bb70ff93112f1b03259d2eb8 (
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
<?php
# Lifter010: TODO
/*
* CourseNavigation.php - navigation for course / institute area
*
* 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.
*
* @author Elmar Ludwig
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
*/
class CourseNavigation extends Navigation
{
private $range;
/**
* Initialize a new Navigation instance.
*/
public function __construct(Range $range)
{
if (!($range instanceof Course) && !($range instanceof Institute)) {
throw new InvalidArgumentException('Invalid range type "' . get_class($range) . '" for course navigation');
}
$this->range = $range;
// check if logged in
if (User::findCurrent()) {
$coursetext = _('Veranstaltungen');
$courseinfo = _('Meine Veranstaltungen & Einrichtungen');
$courselink = 'dispatch.php/my_courses';
} else {
$coursetext = _('Freie Veranstaltungen');
$courseinfo = _('Freie Veranstaltungen');
$courselink = 'dispatch.php/public_courses';
}
parent::__construct($coursetext, $courselink);
if (User::findCurrent()) {
$this->setImage(Icon::create('seminar', Icon::ROLE_NAVIGATION, ['title' => $courseinfo]));
}
}
/**
* Add an array of navigation items to the subnavigation of this
* object. The new items are inserted at the appropriate position
* for this tool according to the order defined in tools_activated.
*
* @param int $plugin_id id of the module
* @param array $navigations navigation items to add
*/
public function addToolNavigation($plugin_id, array $navigations)
{
$found = null;
$where = null;
foreach ($this->range->tools as $tool) {
if ($found && $tool->metadata['navigation']) {
$where = $tool->metadata['navigation'];
break;
}
if ($tool->plugin_id == $plugin_id) {
$tool->metadata['navigation'] = key($navigations);
$found = $tool;
}
}
foreach ($navigations as $key => $nav) {
if (
$this->range instanceof Institute
|| Seminar_Perm::get()->have_studip_perm($found->getVisibilityPermission(), $this->range->id)
) {
if (isset($found->metadata['displayname'])) {
$nav->setTitle($found->getDisplayname());
}
$this->insertSubNavigation($key, $nav, $where);
}
}
}
}
|