Merge branch 'master' into feature/76981-missing-mailing-lists

This commit is contained in:
Harald Bamberger
2026-07-08 14:15:40 +02:00
182 changed files with 14334 additions and 5045 deletions
+2 -1
View File
@@ -1657,7 +1657,7 @@ class AntragLib
$result = $this->_ci->StudierendenantragModel->loadWithStatusWhere($where);
if (isError($result))
return $result;
return $result;
if (!hasData($result))
return error($this->_ci->p->t('studierendenantrag', "error_no_antrag_found", ['id' => $studierendenantrag_id]));
@@ -1709,6 +1709,7 @@ class AntragLib
$result->statustyp = $antrag->statustyp;
$result->status_insertvon = $antrag->status_insertvon;
$result->grund = $antrag->grund;
$result->status_grund = $antrag->status_grund;
$result->studierendenantrag_id = $antrag->studierendenantrag_id;
$result->typ = $antrag->typ;
$result->datum = $antrag->datum;
+31 -7
View File
@@ -40,13 +40,16 @@ class StundenplanLib
* @return stdClass
* @access public
*/
public function getEventsUser($start, $end)
public function getEventsUser($start, $end, $uid = null)
{
$this->_ci =& get_instance();
$this->_ci->load->model('ressource/Mitarbeiter_model', 'MitarbeiterModel');
$uid = getAuthUID();
if (!$uid) {
$uid = getAuthUID();
}
if (is_null($uid))
return error("No UID");
@@ -217,7 +220,7 @@ class StundenplanLib
* @param string $ort_kurzbz
* @return stdClass
*/
public function getReservierungen($start_date, $end_date, $ort_kurzbz = '')
public function getReservierungen($start_date, $end_date, $ort_kurzbz = '', $uid = null)
{
$this->_ci =& get_instance();
@@ -228,14 +231,14 @@ class StundenplanLib
$this->_ci->load->model('ressource/Reservierung_model', 'ReservierungModel');
$this->_ci->load->model('ressource/Stundenplan_model', 'StundenplanModel');
$is_mitarbeiter = getData($this->_ci->MitarbeiterModel->isMitarbeiter(getAuthUID()));
$is_mitarbeiter = getData($this->_ci->MitarbeiterModel->isMitarbeiter($uid ?? getAuthUID()));
if ($is_mitarbeiter && empty($ort_kurzbz)) {
// request for personal lvplan show only reservations of logged in user
$reservierungen = $this->_ci->ReservierungModel->getReservierungenMitarbeiter($start_date, $end_date);
$reservierungen = $this->_ci->ReservierungModel->getReservierungenMitarbeiter($start_date, $end_date, $uid);
} else {
// querying the reservierungen
$reservierungen = $this->_ci->ReservierungModel->getReservierungen($start_date, $end_date, $ort_kurzbz);
$reservierungen = $this->_ci->ReservierungModel->getReservierungen($start_date, $end_date, $ort_kurzbz, $uid);
}
if (isError($reservierungen))
@@ -357,7 +360,10 @@ class StundenplanLib
if (isError($ort_content_object)) {
return error(getData($ort_content_object));
}
$ort_content_object = getData($ort_content_object)[0];
$ort_content_object_data = getData($ort_content_object);
$ort_content_object = (is_array($ort_content_object_data) && count($ort_content_object_data) > 0)
? $ort_content_object_data[0]
: null;
if($ort_content_object) {
$item->ort_content_id = $ort_content_object->content_id;
}
@@ -445,6 +451,24 @@ class StundenplanLib
return success($ferienEventsFlattened);
}
public function getEventsStgOrg( $start, $end, $stg_kz, $sem, $verband, $gruppe)
{
$this->_ci =& get_instance();
$this->_ci->load->model('ressource/Stundenplan_model', 'StundenplanModel');
$stundenplan_data = $this->_ci->StundenplanModel->getStundenplanStudiengang($start, $end, $stg_kz, $sem, $verband, $gruppe);
if (isError($stundenplan_data))
return $stundenplan_data;
$stundenplan_data = getData($stundenplan_data) ?? [];
$function_error = $this->expandObjectInformation($stundenplan_data);
if ($function_error)
return $function_error;
return success($stundenplan_data);
}
// start of the private functions ########################################################################################################
// function used to sort an array of studiensemester strings
@@ -37,7 +37,9 @@ class DashboardLib
public function getDashboardByKurzbz($dashboard_kurzbz)
{
$result = $this->_ci->DashboardModel->getDashboardByKurzbz($dashboard_kurzbz);
$result = $this->_ci->DashboardModel->loadWhere([
'dashboard_kurzbz' => $dashboard_kurzbz
]);
if (hasData($result))
{
@@ -47,17 +49,21 @@ class DashboardLib
return null;
}
public function getMergedConfig($dashboard_id, $uid)
public function getMergedUserConfig($dashboard_id, $uid)
{
$defaultconfig = $this->getDefaultConfig($dashboard_id);
$userconfig = $this->getUserConfig($dashboard_id, $uid);
$defaultconfig = $this->getUserBaseConfig($dashboard_id);
$userconfig = $this->getUserOverrideConfig($dashboard_id, $uid);
$mergedconfig = array_replace_recursive($defaultconfig, $userconfig);
$sourceconfig = array_map(function ($value) {
return ['source' => $value['source']];
}, $defaultconfig);
$mergedconfig = array_replace_recursive($defaultconfig, $userconfig, $sourceconfig);
return $mergedconfig;
}
public function getDefaultConfig($dashboard_id)
protected function getUserBaseConfig($dashboard_id)
{
$funktion_kurzbzs = [];
$rights = $this->_ci->permissionlib->getAccessRights();
@@ -87,7 +93,11 @@ class DashboardLib
$preset = json_decode($presetobj->preset, true);
if (null !== $preset)
{
$defaultconfig = array_replace_recursive($defaultconfig, $preset);
$preset = array_map(function ($value) use ($presetobj) {
$value['source'] = $presetobj->funktion_kurzbz ?: self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL;
return $value;
}, $preset);
$defaultconfig = array_merge_recursive($defaultconfig, $preset);
}
}
}
@@ -95,7 +105,7 @@ class DashboardLib
return $defaultconfig;
}
public function getUserConfig($dashboard_id, $uid)
protected function getUserOverrideConfig($dashboard_id, $uid)
{
$res_userconfig = $this->_ci->DashboardOverrideModel->getOverride($dashboard_id, $uid);
@@ -124,7 +134,7 @@ class DashboardLib
$emptyoverride = new stdClass();
$emptyoverride->dashboard_id = $dashboard->dashboard_id;
$emptyoverride->uid = $uid;
$emptyoverride->override = '{"' . self::USEROVERRIDE_SECTION . '": {"widgets":{}}, "custom": { "widgets" : {}}}';
$emptyoverride->override = '[]';
return $emptyoverride;
}
@@ -143,8 +153,7 @@ class DashboardLib
$emptypreset = new stdClass();
$emptypreset->dashboard_id = $dashboard->dashboard_id;
$emptypreset->funktion_kurzbz = $funktion_kurzbz;
$section = ($funktion_kurzbz !== null) ? $funktion_kurzbz : self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL;
$emptypreset->preset = '{"' . $section . '": { "widgets" : {}},"custom": { "widgets" : {}}}';
$emptypreset->preset = '[]';
return $emptypreset;
}
@@ -209,44 +218,4 @@ class DashboardLib
return $result;
}
public function addWidgetsToWidgets(&$widgets, $dashboard_kurzbz, $section, $addwigets)
{
foreach ($addwigets as $widget)
{
if(!isset($widget['widgetid']))
{
$widget['widgetid'] = $this->generateWidgetId($dashboard_kurzbz);
}
$this->addWidgetToWidgets($widgets, $section, $widget, $widget['widgetid']);
}
}
public function addWidgetToWidgets(&$widgets, $section, $widget, $widgetid)
{
$section = ($section !== null) ? $section : self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL;
if (!isset($widgets[$section]) || !isset($widgets[$section]["widgets"]) || !is_array($widgets[$section]))
{
$widgets[$section] = array();
$widgets[$section]["widgets"] = array();
}
$widgets[$section]["widgets"][$widgetid] = $widget;
}
public function removeWidgetFromWidgets(&$widgets, $section, $widgetid)
{
$section = ($section !== null) ? $section : self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL;
if (isset($widgets[$section]) && isset($widgets[$section]["widgets"][$widgetid]))
{
unset($widgets[$section]["widgets"][$widgetid]);
if(empty($widgets[$section]["widgets"]) && $section !== self::USEROVERRIDE_SECTION) {
unset($widgets[$section]);
}
return true;
}
else {
return false;
}
}
}
@@ -0,0 +1,363 @@
<?php
/**
* Copyright (C) 2025 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');
/**
* This generates a list of students and or prestudents used for Studierendenverwaltung
*/
class StudentListLib
{
private $_ci; // Code igniter instance
private $_allowedStgs = [];
private $_selects = [];
private $_joins = [];
/**
* Gets the CI instance, loads model and prepares default values
*
* @param array $params
*
* @return void
*/
public function __construct($params = null)
{
$this->_ci =& get_instance(); // get code igniter instance
$this->_ci->load->model('crm/Prestudent_model', 'PrestudentModel');
if (isset($params['allowedStgs']))
$this->_allowedStgs = $params['allowedStgs'];
// Add default SELECTs
$this->addSelect("b.uid");
if (defined('STV_TAGS_ENABLED') && STV_TAGS_ENABLED)
$this->addSelect('tag_data_agg.tags');
$this->addSelect('titelpre');
$this->addSelect('nachname');
$this->addSelect('vorname');
$this->addSelect('wahlname');
$this->addSelect('vornamen');
$this->addSelect('titelpost');
$this->addSelect('ersatzkennzeichen');
$this->addSelect('gebdatum');
$this->addSelect('geschlecht');
$this->addSelect('foto');
$this->addSelect('foto_sperre');
$this->addSelect('v.semester');
$this->addSelect('v.verband');
$this->addSelect('v.gruppe');
$this->addSelect("statusofsemester"); // Will be replaced later
$this->addSelect('UPPER(stg.typ || stg.kurzbz) AS studiengang');
$this->addSelect('tbl_prestudent.studiengang_kz');
$this->addSelect('stg.bezeichnung AS stg_bezeichnung');
$this->addSelect("s.matrikelnr");
$this->addSelect('p.person_id');
$this->addSelect('pls.status_kurzbz AS status');
$this->addSelect('pls.datum AS status_datum');
$this->addSelect('pls.bestaetigtam AS status_bestaetigung');
$this->addSelect(
"(SELECT kontakt FROM public.tbl_kontakt WHERE kontakttyp='email' AND person_id=p.person_id AND zustellung LIMIT 1) AS mail_privat",
false
);
$this->addSelect("
CASE WHEN b.uid IS NOT NULL AND b.uid<>''
THEN CONCAT(b.uid, '@', " . $this->_ci->PrestudentModel->escape(DOMAIN) . ")
ELSE '' END AS mail_intern", false);
$this->addSelect('p.anmerkung AS anmerkungen');
$this->addSelect('tbl_prestudent.anmerkung');
$this->addSelect('pls.orgform_kurzbz');
$this->addSelect('aufmerksamdurch_kurzbz');
$this->addSelect(
"(SELECT rt_gesamtpunkte AS punkte FROM public.tbl_prestudent WHERE prestudent_id=ps.prestudent_id) AS punkte",
false
);
$this->addSelect('tbl_prestudent.aufnahmegruppe_kurzbz');
$this->addSelect('tbl_prestudent.dual');
$this->addSelect('p.matr_nr');
$this->addSelect('sp.bezeichnung AS studienplan_bezeichnung');
$this->addSelect('tbl_prestudent.prestudent_id');
$this->addSelect("(
SELECT count(*)
FROM (
SELECT *, public.get_rolle_prestudent(pss.prestudent_id, NULL) AS laststatus
FROM public.tbl_prestudent pss
JOIN public.tbl_prestudentstatus USING (prestudent_id)
WHERE person_id = p.person_id
AND studiensemester_kurzbz = (
SELECT studiensemester_kurzbz
FROM public.tbl_prestudentstatus
WHERE prestudent_id = tbl_prestudent.prestudent_id
AND status_kurzbz = 'Interessent'
LIMIT 1
)
AND status_kurzbz = 'Interessent'
) prest
WHERE laststatus NOT IN ('Abbrecher', 'Abgewiesener', 'Absolvent')
AND priorisierung <= tbl_prestudent.priorisierung
) || ' (' || COALESCE(tbl_prestudent.priorisierung::text, ' '::text) || ')' AS priorisierung_relativ", false); // TODO(chris): overwrite in fetchStudents
$this->addSelect('mentor');
$this->addSelect('b.aktiv AS bnaktiv');
$this->addSelect('unruly');
// Add default JOINs
$this->addJoin('public.tbl_studiengang stg', 'studiengang_kz', 'LEFT');
$this->addJoin('public.tbl_person p', 'person_id');
$this->addJoin('public.tbl_student s', 'prestudent_id', 'LEFT'); // TODO(chris): overwrite in fetchStudents
$this->addJoin('public.tbl_prestudentstatus pls', '
pls.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, NULL)
AND pls.prestudent_id=tbl_prestudent.prestudent_id
AND pls.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, NULL)
AND pls.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, NULL)', 'LEFT');
$this->addJoin('lehre.tbl_studienplan sp', 'studienplan_id', 'LEFT');
$this->addJoin('public.tbl_benutzer b', 's.student_uid=b.uid', 'LEFT');
$this->addJoin("v", "", ""); // Will be replaced later
$this->addJoin("ps", "", ""); // Will be replaced later
if (defined('STV_TAGS_ENABLED') && STV_TAGS_ENABLED) {
$this->_ci->load->config('stv');
$tags = $this->_ci->config->item('stv_prestudent_tags');
$whereTags = '';
if (is_array($tags) && !isEmptyArray($tags)) {
$tags = array_keys($tags);
foreach ($tags as $key => $tag) {
$tags[$key] = $this->_ci->PrestudentModel->escape($tag);
}
$whereTags = " AND nt.typ_kurzbz IN (" . implode(",", $tags) . ")";
}
$subQueryTag = "(
SELECT
tag.prestudent_id,
COALESCE(json_agg(tag ORDER BY tag.done), '[]'::json) AS tags
FROM (
SELECT DISTINCT ON (n.notiz_id)
n.notiz_id AS id,
nt.typ_kurzbz,
array_to_json(nt.bezeichnung_mehrsprachig)->>0 AS beschreibung,
n.text AS notiz,
nt.style,
n.erledigt AS done,
nz.prestudent_id
FROM public.tbl_notizzuordnung AS nz
JOIN public.tbl_notiz AS n ON nz.notiz_id = n.notiz_id
JOIN public.tbl_notiz_typ AS nt ON n.typ = nt.typ_kurzbz " . $whereTags . "
) AS tag
GROUP BY tag.prestudent_id
) AS tag_data_agg";
$this->addJoin($subQueryTag, 'tag_data_agg.prestudent_id = tbl_prestudent.prestudent_id', 'LEFT');
}
}
//------------------------------------------------------------------------------------------------------------------
// Public methods
/**
* Adds a SELECT statement to the query.
*
* @param string|array $select
* @param boolean $escape (optional)
*
* @return void
*/
public function addSelect($select, $escape = true)
{
if (is_array($select)) {
foreach ($select as $s)
$this->addSelect($s, $escape);
return;
}
$alias = $this->getAliasFromSelect($select);
$this->_selects[$alias] = [$select, $escape];
}
/**
* Joins a table to the query.
*
* @param string $table
* @param string $cond
* @param string $type (optional)
* @param string $position (optional)
*
* @return void
*/
public function addJoin($table, $cond, $type = '', $position = 'end')
{
$alias = $this->getAliasFromTable($table);
if ($position == 'end') {
return $this->_joins[$alias] = [$table, $cond, $type];
}
if ($position == 'start') {
return $this->_joins = [$alias => [$table, $cond, $type]] + $this->_joins;
}
if (substr($position, 0, 7) == 'before_') {
$ref = substr($position, 7);
$index = 0;
} elseif (substr($position, 0, 6) == 'after_') {
$ref = substr($position, 6);
$index = 1;
} else {
return $this->addJoin($table, $cond, $type);
}
if (!isset($this->_joins[$ref]))
return $this->addJoin($table, $cond, $type);
$key_indeces = array_flip(array_keys($this->_joins));
$index += $key_indeces[$ref];
if (!$index)
return $this->addJoin($table, $cond, $type, 'start');
$front_part = array_slice($this->_joins, 0, $index, true);
$back_part = array_slice($this->_joins, $index, null, true);
if (isset($front_part[$alias])) {
unset($front_part[$alias]);
}
$this->_joins = $front_part + [$alias => [$table, $cond, $type]] + $back_part;
}
/**
* Adds a WHERE clause to the query.
*
* @param string|array $key
* @param string|array $value
* @param boolean $escape
*
* @return void
*/
public function addWhere($key, $value = null, $escape = true)
{
if (!is_array($key) && is_array($value)) {
$this->_ci->PrestudentModel->db->where_in($key, $value, $escape);
} else {
$this->_ci->PrestudentModel->db->where($key, $value, $escape);
}
}
/**
* Adds a OR WHERE clause to the query.
*
* @param string|array $key
* @param string|array $value
* @param boolean $escape
*
* @return void
*/
public function addOrWhere($key, $value = null, $escape = true)
{
if (!is_array($key) && is_array($value)) {
$this->_ci->PrestudentModel->db->or_where_in($key, $value, $escape);
} else {
$this->_ci->PrestudentModel->db->or_where($key, $value, $escape);
}
}
/**
* Generates the query and executes it.
*
* @param string|null $studiensemester_kurzbz
*
* @return stdClass result of the query
*/
public function execute($studiensemester_kurzbz)
{
$stdsemEsc = $studiensemester_kurzbz ? $this->_ci->PrestudentModel->escape($studiensemester_kurzbz) : 'NULL';
$this->addSelect(
"public.get_rolle_prestudent(
public.tbl_prestudent.prestudent_id,
" . $this->_ci->PrestudentModel->escape($studiensemester_kurzbz) . "
) AS statusofsemester"
);
$this->addJoin(
'public.tbl_studentlehrverband v',
'v.student_uid=s.student_uid AND v.studiensemester_kurzbz' . ($studiensemester_kurzbz ? '=' . $stdsemEsc : ' IS NULL'),
'LEFT'
);
$this->addJoin(
'public.tbl_prestudentstatus ps',
'ps.status_kurzbz=public.get_rolle_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')
AND ps.prestudent_id=tbl_prestudent.prestudent_id
AND ps.studiensemester_kurzbz=public.get_stdsem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')
AND ps.ausbildungssemester=public.get_absem_prestudent(tbl_prestudent.prestudent_id, ' . $stdsemEsc . ')
',
'LEFT'
);
$this->addWhere('tbl_prestudent.studiengang_kz', $this->_allowedStgs);
foreach ($this->_joins as $join)
$this->_ci->PrestudentModel->addJoin($join[0], $join[1], $join[2]);
foreach ($this->_selects as $select)
$this->_ci->PrestudentModel->addSelect($select[0], $select[1]);
$this->_ci->PrestudentModel->addOrder('nachname');
$this->_ci->PrestudentModel->addOrder('vorname');
return $this->_ci->PrestudentModel->load();
}
//------------------------------------------------------------------------------------------------------------------
// Protected methods
/**
* Get alias of a table or select statement
*
* @param string $select
*
* @return string
*/
final protected function getAliasFromSelect($select)
{
if (strpos($select, ' ') !== false) {
return trim(strrchr($select, ' '));
}
if (strpos($select, '.') !== false) {
return substr(strrchr($select, '.'), 1);
}
return $select;
}
/**
* Get alias of a table or select statement
*
* @param string|array $table
*
* @return string|array
*/
final protected function getAliasFromTable($table)
{
if (strpos($table, ' ') !== false) {
return trim(strrchr($table, ' '));
}
return $table;
}
}
@@ -40,7 +40,9 @@ abstract class AbstractBestandteil implements IValidation
if( is_bool($new_value) && ($old_value !== $new_value) ) {
$this->modifiedcolumns[$columnname] = $columnname;
} else if($old_value != $new_value) {
} else if(is_null($old_value) xor is_null($new_value)) {
$this->modifiedcolumns[$columnname] = $columnname;
} else if($old_value != $new_value) {
$this->modifiedcolumns[$columnname] = $columnname;
}
}
@@ -137,19 +137,25 @@ EOTXT;
return parent::__toString() . $txt;
}
/* public function validate()
public function validate()
{
if( !(filter_var($this->tage, FILTER_VALIDATE_INT,
array(
'options' => array(
'min_range' => 1,
'max_range' => 50
)
)
)) ) {
$this->validationerrors[] = 'Urlaubsanspruch muss eine Tagesanzahl im Bereich 1 bis 50 sein.';
$value = $this->vordienstzeit;
if ($value === null || $value === '') {
$result = null; // allow null value
} else {
$result = filter_var($value, FILTER_VALIDATE_INT, [
'options' => [
'min_range' => 0,
'max_range' => 100
]
]);
if ($result === false) {
$this->validationerrors[] = 'Vordienstjahre muss eine ganze Zahl (0 bis 100) enthalten oder leer sein.';
}
}
return parent::validate();
} */
}
}