From 933af943448aa4e05da36d3e83e042e95f08a0e3 Mon Sep 17 00:00:00 2001 From: Cris Date: Wed, 20 Nov 2024 13:55:11 +0100 Subject: [PATCH] Added checkIsTemplate method to Lehrveranstaltung Model Checks if given LV is a template (Quellkurs) --- .../education/Lehrveranstaltung_model.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/application/models/education/Lehrveranstaltung_model.php b/application/models/education/Lehrveranstaltung_model.php index 1c601a291..f7860f470 100644 --- a/application/models/education/Lehrveranstaltung_model.php +++ b/application/models/education/Lehrveranstaltung_model.php @@ -716,6 +716,28 @@ class Lehrveranstaltung_model extends DB_Model return $this->execQuery($qry); } + /** + * Check if given LV is a template (Quellkurs) + * + * @param $lehrveranstaltung_id + * @return array|stdClass|void + */ + public function checkIsTemplate($lehrveranstaltung_id) + { + $this->addSelect('lehrtyp_kurzbz, lehrveranstaltung_template_id'); + $result = $this->load($lehrveranstaltung_id); + + if (isError($result)) + return error(getError($result)); + + if (hasData($result)) + { + return success( + getData($result)[0]->lehrtyp_kurzbz === 'tpl' && + getData($result)[0]->lehrveranstaltung_template_id === null + ); + } + } /** * Get ECTS Summe pro angerechnetes Quereinstiegssemester.