From 8280ec42b0900fbb8493fa3a38403c54a8fd8909 Mon Sep 17 00:00:00 2001 From: Cristina Date: Thu, 11 Dec 2025 16:07:07 +0100 Subject: [PATCH] Added method getEntitledStgs to Studiengang_model.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Get active Studiengänge with Kuerzel by given Studiengang-Kennzahlen. Helpful to easily get Studiengänge the user is entitled for. --- .../models/organisation/Studiengang_model.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/application/models/organisation/Studiengang_model.php b/application/models/organisation/Studiengang_model.php index 02f972690..98d650e0c 100644 --- a/application/models/organisation/Studiengang_model.php +++ b/application/models/organisation/Studiengang_model.php @@ -801,4 +801,38 @@ class Studiengang_model extends DB_Model return $this->execReadOnlyQuery($qry, array($studiengang_kz, $orgform_kurzbz, $studiensemester_kurzbz)); } + + /** + * Get active Studiengänge with Kuerzel by given Studiengang-Kennzahlen. + * Helpful to easily get Studiengänge the user is entitled for. + * + * @param $studiengang_kz_arr + * @param $studiensemester_kurzbz + * @return array|stdClass|null + */ + public function getEntitledStgs($studiengang_kz_arr, $studiensemester_kurzbz) + { + if (is_numeric($studiengang_kz_arr)) + { + $studiengang_kz_arr = [$studiengang_kz_arr]; + } + + $qry = ' + SELECT + DISTINCT stg.*, UPPER(typ::varchar(1) || kurzbz) AS kuerzel + FROM + public.tbl_studiengang stg + JOIN lehre.tbl_studienordnung sto USING(studiengang_kz) + JOIN lehre.tbl_studienplan stpl USING(studienordnung_id) + JOIN lehre.tbl_studienplan_semester stplsem USING(studienplan_id) + WHERE + stg.studiengang_kz IN ? + AND stg.aktiv = TRUE + AND stplsem.studiensemester_kurzbz = ? + ORDER BY + stg.kurzbzlang + '; + + return $this->execQuery($qry, [$studiengang_kz_arr, $studiensemester_kurzbz]); + } }