From 34b6581849bbe176b51c96a08461cbbffa888ef0 Mon Sep 17 00:00:00 2001 From: Paolo Date: Wed, 26 Feb 2020 17:22:59 +0100 Subject: [PATCH] - Renamed BenutzerfunktionModel->getByPersonId to getActiveFunctionsByPersonId - BenutzerfunktionModel->getActiveFunctionsByPersonId changed query to get only active functions - Removed commented code --- application/libraries/MessageLib.php | 2 +- .../models/person/Benutzerfunktion_model.php | 16 ++++++++++------ .../views/system/messages/htmlWriteTemplate.php | 1 - application/widgets/Vorlage_widget.php | 1 - 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index f2ede9cef..b97ef4bae 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -223,7 +223,7 @@ class MessageLib $this->_ci->load->model('person/Benutzerfunktion_model', 'BenutzerfunktionModel'); // Retrieves organisation units for a user from database - $benutzer = $this->_ci->BenutzerfunktionModel->getByPersonId($sender_id); + $benutzer = $this->_ci->BenutzerfunktionModel->getActiveFunctionsByPersonId($sender_id); if (isSuccess($benutzer)) // if everything is ok { $ouArray = array(); diff --git a/application/models/person/Benutzerfunktion_model.php b/application/models/person/Benutzerfunktion_model.php index ceb427687..fb9b51c1a 100644 --- a/application/models/person/Benutzerfunktion_model.php +++ b/application/models/person/Benutzerfunktion_model.php @@ -11,16 +11,20 @@ class Benutzerfunktion_model extends DB_Model $this->dbTable = 'public.tbl_benutzerfunktion'; $this->pk = 'benutzerfunktion_id'; } - + /** * Get the Benutzerfunktion using the person_id */ - public function getByPersonId($person_id) + public function getActiveFunctionsByPersonId($person_id) { - // Join with the table - $this->addJoin('public.tbl_benutzer', 'uid'); - - return $this->loadWhere(array('person_id' => $person_id)); + $query = 'SELECT bf.* + FROM public.tbl_benutzerfunktion bf + JOIN public.tbl_benutzer b USING (uid) + WHERE b.person_id = ? + AND (bf.datum_von IS NULL OR bf.datum_von <= now()) + AND (bf.datum_bis IS NULL OR bf.datum_bis >= now())'; + + return $this->execQuery($query, array($person_id)); } /** diff --git a/application/views/system/messages/htmlWriteTemplate.php b/application/views/system/messages/htmlWriteTemplate.php index bb031a370..575e9ea07 100644 --- a/application/views/system/messages/htmlWriteTemplate.php +++ b/application/views/system/messages/htmlWriteTemplate.php @@ -139,7 +139,6 @@ 'Dropdown_widget', array('elements' => success($recipientsArray), 'emptyElement' => ucfirst($this->p->t('global', 'empfaenger')).'...'), array( - /*'title' => ucfirst($this->p->t('global', 'empfaenger')).': ',*/ 'name' => 'recipients[]', 'id' => 'recipients' ) diff --git a/application/widgets/Vorlage_widget.php b/application/widgets/Vorlage_widget.php index 1c05db9e3..9ec13250f 100644 --- a/application/widgets/Vorlage_widget.php +++ b/application/widgets/Vorlage_widget.php @@ -63,7 +63,6 @@ class Vorlage_widget extends DropdownWidget FROM tbl_vorlagestudiengang vs INNER JOIN tbl_vorlage v USING(vorlage_kurzbz) ) templates'; $alias = 'templates'; - //$fields = array("templates.vorlage_kurzbz AS id", "UPPER(templates.oe_kurzbz) || ' - ' || templates.bezeichnung || ' - V' || templates.version AS description"); $fields = array("templates.vorlage_kurzbz AS id", "templates.bezeichnung AS description"); $where = 'templates.aktiv = TRUE AND templates.subject IS NOT NULL