diff options
| author | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-07-22 16:07:19 +0200 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+github@gmail.com> | 2021-07-22 16:19:12 +0200 |
| commit | a3da1483a9e689846179159355badfec8073dbec (patch) | |
| tree | 770dcca6bdf5f6f2a11b0e7fcbbeda6919a3fc52 /lib/classes/MvvTreeRoot.php | |
current code from svn, revision 62608
Diffstat (limited to 'lib/classes/MvvTreeRoot.php')
| -rw-r--r-- | lib/classes/MvvTreeRoot.php | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/lib/classes/MvvTreeRoot.php b/lib/classes/MvvTreeRoot.php new file mode 100644 index 0000000..ad091f7 --- /dev/null +++ b/lib/classes/MvvTreeRoot.php @@ -0,0 +1,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; + } + +} |
