prototype menu with traits

This commit is contained in:
chfhtw
2026-05-13 09:26:15 +02:00
parent e91f8e5ca4
commit 0f1059d5a5
12 changed files with 1128 additions and 0 deletions
+243
View File
@@ -0,0 +1,243 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
use \ReflectionMethod as ReflectionMethod;
/**
* MenuBuilder library
* TODO(chris): docu
*/
class MenuBuilderLib
{
protected $_ci;
protected $children = [];
/**
* Constructor
*/
public function __construct()
{
// Get code igniter instance
$this->_ci =& get_instance();
}
/*private function registerTraits()
{
$class = $this;
$traits = [];
do {
$traits = array_merge(class_uses($class), $traits);
} while ($class = get_parent_class($class));
$config = $this->registerTraitsRecursive($traits);
$this->_ci->addMeta('test', $config);
}
private function registerTraitsRecursive($traits)
{
// TODO(chris): implement
$children = [];
foreach ($traits as $name => $trait) {
$traitId = ucfirst(str_replace("Trait", "", $name));
$initMethod = "init" . $traitId;
$this->_ci->addMeta('traits', $initMethod);
$child = $this->$initMethod();
if (!isset($child['alias']))
$child['alias'] = strtolower($traitId);
$children[$child['alias']] = $child;
$childTraits = class_uses($trait);
$children[$child['alias']]['children'] = $this->registerTraits($childTraits);
}
return $children;
}*/
// TODO(chris): abstract
final protected function getPathTemplate($path)
{
return implode('/', $path) . '/%s';
}
protected function getLinkTemplate($path, $vars)
{
return implode('/', $path) . '/%s';
}
protected function buildMenu()
{
return $this->buildMenuRecursive($this->children, [], []);
}
private function buildMenuRecursive($children, $identifiers, $path)
{
$result = [];
foreach ($children as $key => $segment) {
$node_config = $this->getNodeConfig($key, $segment);
$nodes = $this->buildNode($node_config, $segment, $identifiers, $path);
foreach ($nodes as $k => $node) {
// Convert stdClass to array
if (!is_array($node))
$node = get_object_vars($node);
// Render children
if (isset($node_config['children'])) {
$node_path = explode('/', $node['path']);
$node_identifiers = $identifiers;
if (isset($node_config['identifiers'])) {
if (is_string($node_config['identifiers'])) {
$reflection = new ReflectionMethod($this, $node_config['identifiers']);
$num_segments = $reflection->getNumberOfParameters();
$parameters = array_slice($node_path, $num_segments * -1);
$node_identifiers = call_user_func_array([$this, $node_config['identifiers']], $parameters);
$node_identifiers = array_merge($identifiers, $node_identifiers);
} else {
if (count($node_path) < count($node_config['identifiers']))
return null; // NOTE(chris): wrong number of url segments
foreach ($node_config['identifiers'] as $index => $id_name) {
$pos = count($node_path) - count($node_config['identifiers']) + $index;
$node_identifiers[$id_name] = $node_path[$pos];
}
}
}
$node['children'] = $this->buildMenuRecursive($node_config['children'], $node_identifiers, $node_path);
} else {
$node['leaf'] = true;
}
$nodes[$k] = $node;
}
$result = array_merge($result, $nodes);
}
return $result;
}
final protected function getNodeConfig($key, $segment)
{
$traitname = is_int($key) ? $segment : $key;
$initFunc = 'init' . ucfirst($traitname);
// TODO(chris): check identifiers string: single or function??
return $this->$initFunc();
}
private function buildNode($config, $segment, $identifiers, $path)
{// TODO(chris): why slash at beginning: "/inout"
if (isset($config['build'])) {
$buildFunc = $config['build'];
$path[] = $segment;
$pathTemplate = $this->getPathTemplate($path);
$linkTemplate = $this->getLinkTemplate($path, $identifiers);
return $this->$buildFunc($identifiers, $pathTemplate, $linkTemplate);
} else {
return $this->buildGenericItem($segment, $config, $identifiers, $path);
}
}
/**
* @param array $url_segments
* @return array|null
*/
protected function buildSubmenu($url_segments)
{
$children = $this->children;
$original_path = $url_segments;
$segment = '';
$identifiers = [];
$config = [];
while(count($url_segments)) {
$segment = array_shift($url_segments);
$key = array_search($segment, $children);
if ($key === false)
return []; // NOTE(chris): node not found
$config = $this->getNodeConfig($key, $segment);
if (!isset($config['build']) && !isset($config['name']))
return null; // TODO(chris): invalid config
if (isset($config['identifiers'])) {
if (is_string($config['identifiers'])) {
$reflection = new ReflectionMethod($this, $config['identifiers']);
$num_segments = $reflection->getNumberOfParameters();
$parameters = array_slice($url_segments, 0, $num_segments);
$url_segments = array_slice($url_segments, $num_segments);
$new_identifiers = call_user_func_array([$this, $config['identifiers']], $parameters);
$identifiers = array_merge($identifiers, $new_identifiers);
} else {
if (count($url_segments) < count($config['identifiers']))
return null; // NOTE(chris): wrong number of url segments
foreach ($config['identifiers'] as $id_name) {
$identifiers[$id_name] = array_shift($url_segments);
}
}
}
if (isset($config['children'])) {
$children = $config['children'];
} elseif (count($url_segments)) {
return null; // NOTE(chris): wrong number of url segments
} else {
return [];
}
}
$result = [];
foreach ($children as $key => $segment) {
$node_config = $this->getNodeConfig($key, $segment);
$nodes = $this->buildNode($node_config, $segment, $identifiers, $original_path);
$result = array_merge($result, $nodes);
}
return $result;
}
protected function buildGenericItem($segment, $config, $identifiers, $path)
{
$vars = isset($config['vars']) ? $config['vars'] : [];
$vars = array_merge($identifiers, $vars);
$vars['name'] = $config['name'];
if (!isset($config['children']))
$vars['leaf'] = true;
$vars['path'] = sprintf($this->getPathTemplate($path), $segment);
$vars['link'] = sprintf($this->getLinkTemplate($path, $vars), $segment);
return [ $vars ];
}
}
+89
View File
@@ -0,0 +1,89 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH . 'libraries/MenuBuilderLib.php');
require_once(APPPATH . 'traits/menu/StgTrait.php');
require_once(APPPATH . 'traits/menu/InoutTrait.php');
use \ReflectionMethod as ReflectionMethod;
/**
* StudVw Menu library
*/
class StvMenuLib extends MenuBuilderLib
{
use StgTrait, InoutTrait;
protected $children = [
'stg',
'inout'
];
public function build($url_segments = [])
{
$result = $this->buildSubmenu($url_segments);
if ($result === null)
show_404();
return $result;
}
public function buildAll()
{
return $this->buildMenu();
}
protected function getLinkTemplate($path, $vars)
{
$result = '';
$children = $this->children;
while (count($path)) {
$segment = array_shift($path);
$key = array_search($segment, $children);
$config = $this->getNodeConfig($key, $segment);
if (isset($config['identifiers'])) {
if (is_array($config['identifiers'])) {
$count = count($config['identifiers']);
} else {
$reflection = new ReflectionMethod($this, $config['identifiers']);
$count = $reflection->getNumberOfParameters();
}
while ($count--) {
if (count($path))
$result .= array_shift($path) . '/';
}
} else {
$result .= $segment . '/';
}
if (isset($config['children']))
$children = $config['children'];
else
return [];
}
if (!strpos($result, '/prestudent') && !isset($vars['no_sem_reload']))
$result = 'CURRENT_SEMESTER/' . $result;
return $result . '%s';
}
}
+59
View File
@@ -0,0 +1,59 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
trait InoutTrait
{
protected function initInout()
{
return [
'children' => [
'incoming',
'outgoing',
'SharedStudies' => 'shared_studies'
],
'name' => 'International' // TODO(chris): translate
];
}
protected function initIncoming()
{
return [
'name' => 'Incoming' // TODO(chris): translate
];
}
protected function initOutgoing()
{
return [
'name' => 'Outgoing' // TODO(chris): translate
];
}
protected function initSharedStudies()
{
return [
'name' => 'Gemeinsame Studien' // TODO(chris): translate
];
}
}
@@ -0,0 +1,77 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH . 'traits/menu/Stg/PrestudentTrait.php');
require_once(APPPATH . 'traits/menu/Stg/SemesterTrait.php');
/**
*
*/
trait OrgformTrait
{
use PrestudentTrait, SemesterTrait;
protected function initOrgform()
{
return [
'children' => ['prestudent', 'semester'],
'identifiers' => ['orgform_kurzbz'],
'build' => 'getOrgform'
];
}
protected function getOrgform($vars, $pathTemplate, $linkTemplate)
{
// TODO(chris): permission on stg
// TODO(chris): check vars
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
// NOTE(chris): if mischform show orgforms
$result = $this->_ci->StudiengangModel->load($vars['studiengang_kz']);
if (!hasData($result))
return [];
$stg = current(getData($result));
if (!$stg->mischform)
return [];
$this->_ci->load->model('organisation/Studienordnung_model', 'StudienordnungModel');
$this->_ci->StudienordnungModel->addDistinct();
$this->_ci->StudienordnungModel->addSelect("FORMAT(" . $this->_ci->StudienordnungModel->escape($pathTemplate) . ", p.orgform_kurzbz) AS path");
$this->_ci->StudienordnungModel->addSelect("FORMAT(" . $this->_ci->StudienordnungModel->escape($linkTemplate) . ", p.orgform_kurzbz) AS link");
$this->_ci->StudienordnungModel->addSelect("p.orgform_kurzbz AS name");
$this->_ci->StudienordnungModel->addSelect("studiengang_kz AS stg_kz");
$this->_ci->StudienordnungModel->addJoin('lehre.tbl_studienplan p', 'studienordnung_id');
$result = $this->_ci->StudienordnungModel->loadWhere([
'aktiv' => true,
'studiengang_kz' => $vars['studiengang_kz'],
'p.orgform_kurzbz !=' => 'DDP'
]);
return getData($result) ?: [];
}
}
@@ -0,0 +1,144 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
trait StdsemFilterTrait
{
protected function initInteressenten()
{
return [
'children' => [
'bewebungnichtabgeschickt',
'bewerbungabgeschickt',
'zgv',
'statusbestaetigt',
'reihungstestnichtangemeldet',
'reihungstestangemeldet'
],
'name' => 'Interessenten'
];
}
protected function initBewebungnichtabgeschickt()
{
return [ 'name' => 'Bewerbung nicht abgeschickt' ];
}
protected function initBewerbungabgeschickt()
{
return [ 'name' => 'Bewerbung abgeschickt, Status unbestätigt' ];
}
protected function initZgv()
{
return [ 'name' => 'ZGV erfüllt' ];
}
protected function initStatusbestaetigt()
{
return [
'children' => [
'statusbestaetigtrtnichtangemeldet',
'statusbestaetigtrtangemeldet'
],
'name' => 'Status bestätigt'
];
}
protected function initStatusbestaetigtrtnichtangemeldet()
{
return [ 'name' => 'Nicht zum Reihungstest angemeldet' ];
}
protected function initStatusbestaetigtrtangemeldet()
{
return [ 'name' => 'Reihungstest angemeldet' ];
}
protected function initReihungstestnichtangemeldet()
{
return [ 'name' => 'Nicht zum Reihungstest angemeldet' ];
}
protected function initReihungstestangemeldet()
{
return [ 'name' => 'Reihungstest angemeldet' ];
}
protected function initBewerber()
{
return [
'children' => [
'bewerberrtnichtangemeldet',
'bewerberrtangemeldet'
],
'name' => 'Bewerber'
];
}
protected function initBewerberrtnichtangemeldet()
{
return [ 'name' => 'Nicht zum Reihungstest angemeldet' ];
}
protected function initBewerberrtangemeldet()
{
return [
'children' => [
'bewerberrtangemeldetteilgenommen',
'bewerberrtangemeldetnichtteilgenommen'
],
'name' => 'Reihungstest angemeldet'
];
}
protected function initBewerberrtangemeldetteilgenommen()
{
return [ 'name' => 'Teilgenommen' ];
}
protected function initBewerberrtangemeldetnichtteilgenommen()
{
return [ 'name' => 'Nicht teilgenommen' ];
}
protected function initAufgenommen()
{
return [ 'name' => 'Aufgenommen' ];
}
protected function initWarteliste()
{
return [ 'name' => 'Warteliste' ];
}
protected function initAbsage()
{
return [ 'name' => 'Absage' ];
}
protected function initFilterIncoming()
{
return [ 'name' => 'Incoming' ];
}
}
@@ -0,0 +1,83 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH . 'traits/menu/Stg/Prestudent/Stdsem/StdsemFilterTrait.php');
/**
*
*/
trait StdsemTrait
{
use StdsemFilterTrait;
protected function initStdsem()
{
return [
'children' => [
'interessenten',
'bewerber',
'aufgenommen',
'warteliste',
'absage',
'filterIncoming' => 'incoming'
],
'identifiers' => ['studiensemester_kurzbz'],
'build' => 'getStdsem'
];
}
protected function getStdsem($vars, $pathTemplate, $linkTemplate)
{
// TODO(chris): permission on stg
// TODO(chris): check vars
$number_displayed_past_studiensemester = null;
$this->_ci->load->model('system/Variable_model', 'VariableModel');
$result = $this->_ci->VariableModel->getVariables(getAuthUID(), ['number_displayed_past_studiensemester']);
if (isError($result))
return [];
$data = getData($result);
if ($data && isset($data['number_displayed_past_studiensemester'])) {
$number_displayed_past_studiensemester = $data['number_displayed_past_studiensemester'];
} else {
$this->_ci->load->config('stv');
$number_displayed_past_studiensemester = $this->_ci->config->item('number_displayed_past_studiensemester_default');
}
$this->_ci->load->model('organisation/Studiensemester_model', 'StudiensemesterModel');
$this->_ci->StudiensemesterModel->addPlusMinus(null, $number_displayed_past_studiensemester);
$this->_ci->StudiensemesterModel->addSelect("studiensemester_kurzbz AS name");
$this->_ci->StudiensemesterModel->addSelect("FORMAT(" . $this->_ci->StudiensemesterModel->escape($pathTemplate) . ", studiensemester_kurzbz) AS path", false);
$this->_ci->StudiensemesterModel->addSelect("FORMAT(" . $this->_ci->StudiensemesterModel->escape($linkTemplate) . ", studiensemester_kurzbz) AS link", false);
$this->_ci->StudiensemesterModel->addSelect($this->_ci->StudiensemesterModel->escape($vars['studiengang_kz']) . " AS stg_kz", false);
$this->_ci->StudiensemesterModel->addOrder('ende');
$result = $this->_ci->StudiensemesterModel->load();
return getData($result) ?: [];
}
}
@@ -0,0 +1,43 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH . 'traits/menu/Stg/Prestudent/StdsemTrait.php');
/**
*
*/
trait PrestudentTrait
{
use StdsemTrait;
protected function initPrestudent()
{
$name = 'Prestudent'; // TODO(chris): translate
return [
'children' => [ 'stdsem' ],
'name' => $name,
'vars' => [
'no_sem_reload' => true
]
];
}
}
@@ -0,0 +1,72 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
trait GroupTrait
{
protected function initGroup()
{
return [
'identifiers' => ['gruppe_kurzbz'],
'build' => 'getGroup'
];
}
protected function getGroup($vars, $pathTemplate, $linkTemplate)
{
// TODO(chris): permission on stg
// TODO(chris): check vars
$this->_ci->load->model('organisation/Gruppe_model', 'GruppeModel');
$this->_ci->GruppeModel->addDistinct();
$this->_ci->GruppeModel->addSelect("FORMAT(" . $this->_ci->GruppeModel->escape($pathTemplate) . ", gruppe_kurzbz) AS path", false);
$this->_ci->GruppeModel->addSelect("FORMAT(" . $this->_ci->GruppeModel->escape($linkTemplate) . ", gruppe_kurzbz) AS link", false);
$this->_ci->GruppeModel->addSelect("CONCAT(gruppe_kurzbz, ' (', bezeichnung, ')') AS name", false);
$this->_ci->GruppeModel->addSelect("TRUE AS leaf", false);
$this->_ci->GruppeModel->addSelect('sort');
$this->_ci->GruppeModel->addSelect('gruppe_kurzbz');
$this->_ci->GruppeModel->addSelect($this->_ci->GruppeModel->escape($vars['studiengang_kz']) . '::integer AS stg_kz', false);
$this->_ci->GruppeModel->addSelect("ARRAY['link-strict', 'student-collection'] AS droplink");
$this->_ci->GruppeModel->addOrder('sort');
$this->_ci->GruppeModel->addOrder('gruppe_kurzbz');
$where = [
'studiengang_kz' => $vars['studiengang_kz'],
'semester' => $vars['semester'],
'lehre' => true,
'sichtbar' => true,
'aktiv' => true,
'direktinskription' => false
];
if (isset($vars['org_form']))
$where['orgform_kurzbz'] = $vars['org_form'];
$result = $this->_ci->GruppeModel->loadWhere($where);
return getData($result) ?: [];
}
}
@@ -0,0 +1,73 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*
*/
trait VerbandsGroupTrait
{
protected function initVerbandsGroup()
{
return [
'identifiers' => ['group'],
'build' => 'getVerbandsGroup'
];
}
protected function getVerbandsGroup($vars, $pathTemplate, $linkTemplate)
{
// TODO(chris): permission on stg
// TODO(chris): check vars
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->_ci->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
$this->_ci->StudiengangModel->addDistinct();
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($pathTemplate) . ", gruppe) AS path", false);
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($linkTemplate) . ", gruppe) AS link", false);
$this->_ci->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, verband, gruppe, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester AND verband=v.verband AND gruppe=v.gruppe ORDER BY gruppe LIMIT 1)) AS name", false);
$this->_ci->StudiengangModel->addSelect("TRUE AS leaf", false);
$this->_ci->StudiengangModel->addSelect('v.semester');
$this->_ci->StudiengangModel->addSelect('v.verband');
$this->_ci->StudiengangModel->addSelect('gruppe');
$this->_ci->StudiengangModel->addSelect($this->_ci->StudiengangModel->escape($vars['studiengang_kz']) . '::integer AS stg_kz', false);
$this->_ci->StudiengangModel->addSelect("ARRAY['link-strict', 'student-collection'] AS droplink");
$this->_ci->StudiengangModel->addOrder('gruppe');
$where = [
'v.studiengang_kz' => $vars['studiengang_kz'],
'v.semester' => $vars['semester'],
'v.verband' => $vars['verband'],
'v.gruppe !=' => '',
'v.aktiv' => true
];
if (isset($vars['org_form']) && $vars['semester']) // NOTE(chris): on semester 0 show all?
$where['v.orgform_kurzbz'] = $vars['org_form'];
$result = $this->_ci->StudiengangModel->loadWhere($where);
return getData($result) ?: [];
}
}
@@ -0,0 +1,77 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH . 'traits/menu/Stg/Semester/Verband/VerbandsGroupTrait.php');
/**
*
*/
trait VerbandTrait
{
use VerbandsGroupTrait;
protected function initVerband()
{
return [
'children' => ['VerbandsGroup' => 'group'],
'identifiers' => ['verband'],
'build' => 'getVerband'
];
}
protected function getVerband($vars, $pathTemplate, $linkTemplate)
{
// TODO(chris): permission on stg
// TODO(chris): check vars
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->_ci->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($pathTemplate) . ", verband) AS path", false);
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($linkTemplate) . ", verband) AS link", false);
$this->_ci->StudiengangModel->addSelect("CONCAT(UPPER(CONCAT(typ, kurzbz)), '-', semester, verband, (SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END FROM public.tbl_lehrverband WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester AND verband=v.verband ORDER BY gruppe LIMIT 1)) AS name", false);
$this->_ci->StudiengangModel->addSelect("CASE WHEN MAX(gruppe)='' OR MAX(gruppe)=' ' THEN TRUE ELSE FALSE END AS leaf");
$this->_ci->StudiengangModel->addSelect($this->_ci->StudiengangModel->escape($vars['semester']) . ' AS semester');
$this->_ci->StudiengangModel->addSelect('verband');
$this->_ci->StudiengangModel->addSelect($this->_ci->StudiengangModel->escape($vars['studiengang_kz']) . '::integer AS stg_kz', false);
$this->_ci->StudiengangModel->addSelect("ARRAY['link-strict', 'student-collection'] AS droplink");
$this->_ci->StudiengangModel->addOrder('verband');
$this->_ci->StudiengangModel->addGroupBy('path, link, name, verband');
$where = [
'v.studiengang_kz' => $vars['studiengang_kz'],
'v.semester' => $vars['semester'],
'v.verband !=' => '',
'v.aktiv' => true
];
if (isset($vars['org_form']) && $vars['semester']) // NOTE(chris): on semester 0 show all?
$where['v.orgform_kurzbz'] = $vars['org_form'];
$result = $this->_ci->StudiengangModel->loadWhere($where);
return getData($result) ?: [];
}
}
@@ -0,0 +1,86 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH . 'traits/menu/Stg/Semester/GroupTrait.php');
require_once(APPPATH . 'traits/menu/Stg/Semester/VerbandTrait.php');
/**
*
*/
trait SemesterTrait
{
use GroupTrait, VerbandTrait;
protected function initSemester()
{
return [
'children' => ['group', 'verband'],
'identifiers' => ['semester'],
'build' => 'getSemester'
];
}
protected function getSemester($vars, $pathTemplate, $linkTemplate)
{
// TODO(chris): permission on stg
// TODO(chris): check vars
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->_ci->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
$this->_ci->StudiengangModel->addDistinct();
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($pathTemplate) . ", semester) AS path", false);
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($linkTemplate) . ", semester) AS link", false);
$this->_ci->StudiengangModel->addSelect("CONCAT(
UPPER(CONCAT(typ, kurzbz)),
'-',
semester,
(
SELECT CASE WHEN bezeichnung IS NULL OR bezeichnung='' THEN ''::TEXT ELSE CONCAT(' (', bezeichnung, ')') END
FROM public.tbl_lehrverband
WHERE studiengang_kz=v.studiengang_kz AND semester=v.semester
ORDER BY verband, gruppe LIMIT 1
)
) AS name", false);
$this->_ci->StudiengangModel->addSelect('semester');
$this->_ci->StudiengangModel->addSelect($this->_ci->StudiengangModel->escape($vars['studiengang_kz']) . '::integer AS stg_kz', false);
$this->_ci->StudiengangModel->addSelect("ARRAY['link-strict', 'student-collection'] AS droplink");
$this->_ci->StudiengangModel->addOrder('semester');
if (isset($vars['org_form'])) {
$this->_ci->StudiengangModel->addSelect("v.orgform_kurzbz");
$this->_ci->StudiengangModel->db->group_start();
$this->_ci->StudiengangModel->db->where('v.semester', 0);
$this->_ci->StudiengangModel->db->or_where('v.orgform_kurzbz', $vars['org_form']);
$this->_ci->StudiengangModel->db->group_end();
}
$result = $this->_ci->StudiengangModel->loadWhere([
'v.studiengang_kz' => $vars['studiengang_kz'],
'v.aktiv' => true
]);
return getData($result) ?: [];
}
}
+82
View File
@@ -0,0 +1,82 @@
<?php
/**
* Copyright (C) 2026 fhcomplete.org
*
* 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 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
require_once(APPPATH . 'traits/menu/Stg/PrestudentTrait.php');
require_once(APPPATH . 'traits/menu/Stg/SemesterTrait.php');
require_once(APPPATH . 'traits/menu/Stg/OrgformTrait.php');
/**
*
*/
trait StgTrait
{
use OrgformTrait;
protected function initStg()
{
// TODO(chris): like this or with functions???
return [
// children as assoc array to rename them
'children' => ['prestudent', 'semester', 'orgform'],
#'identifiers' => 'getIdentifiersStg',
'identifiers' => ['studiengang_kz'],
'build' => 'getStg'
];
}
protected function getStg($vars, $pathTemplate, $linkTemplate)
{
$stgs = $this->_ci->permissionlib->getSTG_isEntitledFor('admin') ?: [];
$stgs = array_merge($stgs, $this->_ci->permissionlib->getSTG_isEntitledFor('assistenz') ?: []);
if (!$stgs)
return [];
$this->_ci->load->model('organisation/Studiengang_model', 'StudiengangModel');
$this->_ci->StudiengangModel->addJoin('public.tbl_lehrverband v', 'studiengang_kz');
$this->_ci->StudiengangModel->addDistinct();
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($pathTemplate) . ", v.studiengang_kz) AS path");
$this->_ci->StudiengangModel->addSelect("FORMAT(" . $this->_ci->StudiengangModel->escape($linkTemplate) . ", v.studiengang_kz) AS link");
$this->_ci->StudiengangModel->addSelect(
"CONCAT(kurzbzlang, ' (', UPPER(CONCAT(typ, kurzbz)), ') - ', tbl_studiengang.bezeichnung) AS name",
false
);
$this->_ci->StudiengangModel->addSelect("studiengang_kz AS title");
$this->_ci->StudiengangModel->addSelect("studiengang_kz AS search");
$this->_ci->StudiengangModel->addSelect('erhalter_kz');
$this->_ci->StudiengangModel->addSelect('typ');
$this->_ci->StudiengangModel->addSelect('kurzbz');
$this->_ci->StudiengangModel->addSelect('studiengang_kz');
$this->_ci->StudiengangModel->addSelect('studiengang_kz AS stg_kz');
$this->_ci->StudiengangModel->addOrder('erhalter_kz');
$this->_ci->StudiengangModel->addOrder('typ');
$this->_ci->StudiengangModel->addOrder('kurzbz');
$this->_ci->StudiengangModel->db->where_in('studiengang_kz', $stgs);
$result = $this->_ci->StudiengangModel->loadWhere(['v.aktiv' => true]);
return getData($result) ?: [];
}
}