From 2daef49e529fafa086e9c999e924fc6c94d7078a Mon Sep 17 00:00:00 2001 From: hainberg Date: Thu, 1 Aug 2019 15:34:06 +0200 Subject: [PATCH] Extended usability of Studiengang_widget [PRE-ALPHA-VERSION] Started: Extended Studiengang_widget to be used with specific given array of studiengaenge. --- application/widgets/Studiengang_widget.php | 33 ++++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/application/widgets/Studiengang_widget.php b/application/widgets/Studiengang_widget.php index a09c865f5..5515b6b82 100644 --- a/application/widgets/Studiengang_widget.php +++ b/application/widgets/Studiengang_widget.php @@ -8,15 +8,30 @@ class Studiengang_widget extends DropdownWidget $this->load->model('organisation/Studiengang_model', 'StudiengangModel'); $this->StudiengangModel->addOrder('kurzbzlang'); - $this->addSelectToModel($this->StudiengangModel, 'studiengang_kz', '\'(\' || kurzbzlang || \') \' || bezeichnung'); - - $this->setElementsArray( - $this->StudiengangModel->loadWhere(array('aktiv' => true)), - true, - 'Select a studiengang...', - 'No studiengaenge found' - ); - + $this->addSelectToModel($this->StudiengangModel, 'studiengang_kz', '\'(\' || kurzbzlang || \') \' || tbl_studiengang.bezeichnung'); + + + // If a specific array of studiengaenge is privided, set the condition to retrieve them + if (isset($widgetData['studiengang'])) + { + $condition = ' + studiengang_kz IN ('. implode(',', $widgetData['studiengang']) . ') AND + aktiv = true + '; + } + // Default: retrieve all studiengaenge + else + { + $condition = array('aktiv' => true); + } + + $this->setElementsArray( + $this->StudiengangModel->loadWhere($condition), + true, + 'Select a studiengang...', + 'No studiengaenge found' + ); + $this->loadDropDownView(); } } \ No newline at end of file