blob: ad091f7e610502e4737d8927239c978ab368a743 (
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
<?php
/**
* MvvTreeRoot.php
* The root element of a path or tree of MVV objects. This is the root of the
* tree or the end of a path.
*
* 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 Peter Thienel <thienel@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @since 3.5
*/
class MvvTreeRoot implements MvvTreeItem
{
/**
* @see MvvTreeItem::getTrailParentId()
*/
public function getTrailParentId()
{
return null;
}
/**
* @see MvvTreeItem::getTrailParent()
*/
public function getTrailParent()
{
return null;
}
/**
* @see MvvTreeItem::getChildren()
*/
public function getChildren()
{
$institute = [];
$query = "SELECT DISTINCT inst.fakultaets_id
FROM mvv_modul_inst mmi
JOIN mvv_modul USING (modul_id)
JOIN mvv_modulteil USING (modul_id)
JOIN mvv_lvgruppe_modulteil USING (modulteil_id)
JOIN mvv_studiengang USING (institut_id)
LEFT JOIN Institute inst USING (institut_id)
LEFT JOIN Institute fak ON (fak.institut_id = inst.fakultaets_id)
WHERE mmi.gruppe = ?
AND mvv_studiengang.stat IN (?)
ORDER BY fak.name ASC";
$statement = DBManager::get()->prepare($query);
$statement->execute(['hauptverantwortlich', Studiengang::getPublicStatus()]);
foreach ($statement->fetchAll(PDO::FETCH_COLUMN) as $faculty_id) {
$institute[$faculty_id] = new Fachbereich($faculty_id);
}
return $institute;
}
/**
* @see MvvTreeItem::hasChildren()
*/
public function hasChildren()
{
return count($this->getChildren()) > 0;
}
public function getDisplayName()
{
return Config::get()->UNI_NAME_CLEAN;
}
public function getId()
{
return 'root';
}
/**
* @see MvvTreeItem::isAssignable()
*/
public function isAssignable()
{
return false;
}
/**
* @see MvvTreeItem::getParents()
*/
public function getParents($mode = null)
{
return [];
}
/**
* @see MvvTreeItem::getTrails()
*/
public function getTrails($types = null, $mode = null, $path = null, $in_recursion = false)
{
$path = $path ?: ModuleManagementModelTreeItem::$TRAIL_DEFAULT;
$types = $types ?: $path;
$trails = [];
$class_name = get_class($this);
$next = $path[array_search($class_name, $path) + 1];
$parents = $this->getParents($next);
foreach ($parents as $parent) {
if ($parent) {
foreach ($parent->getTrails($types, $mode, $path, true) as $trail) {
if (in_array($class_name, $types)) {
$trail[$class_name] = $this;
}
if (!$in_recursion) {
if (($mode & MvvTreeItem::TRAIL_SHOW_INCOMPLETE)
|| count($trail) == count($types)) {
$trails[] = $trail;
}
} else {
$trails[] = $trail;
}
}
}
}
if (empty($trails) && in_array($class_name, $types)) {
$trails = [[$class_name => $this]];
}
return $trails;
}
}
|