From 88fc901bf7a3383fa447e62911bd38243d8d5ac2 Mon Sep 17 00:00:00 2001 From: Paolo Date: Fri, 6 Mar 2020 16:56:27 +0100 Subject: [PATCH 1/3] - Added new config entry ou_function_whitelist in message.php - Added new constant CFG_OU_FUNCTION_WHITELIST in library MessageLib - MessageLib->getOeKurzbz now filters out organization units based on config entry ou_function_whitelist - Removed redundant templates in Vorlage_widget --- application/config/message.php | 2 + application/libraries/MessageLib.php | 10 ++- .../Organisationseinheit_model.php | 14 ++-- application/widgets/Vorlage_widget.php | 65 +++++++++++++------ 4 files changed, 62 insertions(+), 29 deletions(-) diff --git a/application/config/message.php b/application/config/message.php index 35d34124b..3a9629279 100644 --- a/application/config/message.php +++ b/application/config/message.php @@ -18,6 +18,8 @@ $config['ou_receivers'] = array('ass'); $config['ou_receivers_no_notice'] = array('infocenter'); // Organization units that will not send the notice email to the internal account, but to the private one $config['ou_receivers_private'] = array('eac', 'ewu', 'scs'); +// +$config['ou_function_whitelist'] = array('ass', 'Leitung'); $config['message_redirect_url'] = array(); $config['message_redirect_url']['fallback'] = site_url('system/messages/ViewMessage/writeReply'); diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index b97ef4bae..fd2051f48 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -15,6 +15,7 @@ class MessageLib const CFG_OU_RECEIVERS = 'ou_receivers'; const CFG_OU_RECEIVERS_NO_NOTICE = 'ou_receivers_no_notice'; const CFG_OU_RECEIVERS_PRIVATE = 'ou_receivers_private'; + const CFG_OU_FUNCTION_WHITELIST = 'ou_function_whitelist'; const CFG_REDIRECT_VIEW_MESSAGE_URL = 'redirect_view_message_url'; // Templates names @@ -229,7 +230,14 @@ class MessageLib $ouArray = array(); // Copies organisation units in $ouArray array - foreach (getData($benutzer) as $val) $ouArray[] = $val->oe_kurzbz; + foreach (getData($benutzer) as $val) + { + // If the function is in the white list then get the organisation unit + if (in_array($val->funktion_kurzbz, $this->_ci->config->item(self::CFG_OU_FUNCTION_WHITELIST))) + { + $ouArray[] = $val->oe_kurzbz; + } + } return success($ouArray); } diff --git a/application/models/organisation/Organisationseinheit_model.php b/application/models/organisation/Organisationseinheit_model.php index 3efc8472a..6439bc8d6 100644 --- a/application/models/organisation/Organisationseinheit_model.php +++ b/application/models/organisation/Organisationseinheit_model.php @@ -125,12 +125,12 @@ class Organisationseinheit_model extends DB_Model public function getChilds($oe_kurzbz, $includeinactive = false) { $query = " - WITH RECURSIVE oes(oe_kurzbz, oe_parent_kurzbz) as + WITH RECURSIVE oes(oe_kurzbz, oe_parent_kurzbz) as ( - SELECT oe_kurzbz, oe_parent_kurzbz FROM public.tbl_organisationseinheit + SELECT oe_kurzbz, oe_parent_kurzbz FROM public.tbl_organisationseinheit WHERE oe_kurzbz=? %s UNION ALL - SELECT o.oe_kurzbz, o.oe_parent_kurzbz FROM public.tbl_organisationseinheit o, oes + SELECT o.oe_kurzbz, o.oe_parent_kurzbz FROM public.tbl_organisationseinheit o, oes WHERE o.oe_parent_kurzbz=oes.oe_kurzbz %s ) SELECT oe_kurzbz @@ -150,12 +150,12 @@ class Organisationseinheit_model extends DB_Model public function getParents($oe_kurzbz, $includeinactive = false) { $query= - "WITH RECURSIVE oes(oe_kurzbz, oe_parent_kurzbz) as + "WITH RECURSIVE oes(oe_kurzbz, oe_parent_kurzbz) as ( - SELECT oe_kurzbz, oe_parent_kurzbz FROM public.tbl_organisationseinheit + SELECT oe_kurzbz, oe_parent_kurzbz FROM public.tbl_organisationseinheit WHERE oe_kurzbz=? %s UNION ALL - SELECT o.oe_kurzbz, o.oe_parent_kurzbz FROM public.tbl_organisationseinheit o, oes + SELECT o.oe_kurzbz, o.oe_parent_kurzbz FROM public.tbl_organisationseinheit o, oes WHERE o.oe_kurzbz=oes.oe_parent_kurzbz %s ) SELECT oe_kurzbz @@ -177,7 +177,7 @@ class Organisationseinheit_model extends DB_Model { $condition = ' oe_kurzbz = ( - SELECT + SELECT oe_parent_kurzbz FROM public.tbl_organisationseinheit diff --git a/application/widgets/Vorlage_widget.php b/application/widgets/Vorlage_widget.php index 9ec13250f..2ba685edc 100644 --- a/application/widgets/Vorlage_widget.php +++ b/application/widgets/Vorlage_widget.php @@ -11,9 +11,9 @@ class Vorlage_widget extends DropdownWidget $vorlage = null; // If the user is an admin - if ($idAdmin === true) + if ($idAdmin) { - // Get all the vorlage with mimetype = text/html + // Get all the vorlage with mimetype = text/html $vorlage = $this->_getAllHTMLVorlage(); } else @@ -39,7 +39,7 @@ class Vorlage_widget extends DropdownWidget private function _getAllHTMLVorlage() { $this->load->model('system/Vorlage_model', 'VorlageModel'); - $this->VorlageModel->addOrder('vorlage_kurzbz'); + $this->VorlageModel->addOrder('bezeichnung'); $this->addSelectToModel($this->VorlageModel, 'vorlage_kurzbz', 'bezeichnung'); @@ -59,15 +59,31 @@ class Vorlage_widget extends DropdownWidget $vorlage = success(array()); // Default value $table = '( - SELECT v.vorlage_kurzbz, v.bezeichnung, vs.version, vs.oe_kurzbz, vs.aktiv, vs.subject, vs.text, v.mimetype - FROM tbl_vorlagestudiengang vs INNER JOIN tbl_vorlage v USING(vorlage_kurzbz) + SELECT v.vorlage_kurzbz, + v.bezeichnung, + vs.version, + vs.oe_kurzbz, + vs.aktiv, + vs.subject, + vs.text, + v.mimetype + FROM tbl_vorlagestudiengang vs + JOIN tbl_vorlage v USING(vorlage_kurzbz) ) templates'; + $alias = 'templates'; - $fields = array("templates.vorlage_kurzbz AS id", "templates.bezeichnung AS description"); + + $fields = array( + 'templates.vorlage_kurzbz AS id', + 'templates.bezeichnung || \' (\' || UPPER(templates.oe_kurzbz) || \')\' AS description' + ); + $where = 'templates.aktiv = TRUE - AND templates.subject IS NOT NULL - AND templates.text IS NOT NULL - AND templates.mimetype = \'text/html\''; + AND templates.subject IS NOT NULL + AND templates.text IS NOT NULL + AND templates.mimetype = \'text/html\' + GROUP BY 1, 2, 3'; + $order_by = 'description ASC'; if (!is_array($oe_kurzbz)) @@ -99,30 +115,37 @@ class Vorlage_widget extends DropdownWidget if (hasData($tmpVorlage)) { // If it's the first vorlage copy it - if (count($vorlage->retval) == 0) + if (!hasData($vorlage)) { - for ($j = 0; $j < count($tmpVorlage->retval); $j++) + for ($j = 0; $j < count(getData($tmpVorlage)); $j++) { - if ($tmpVorlage->retval[$j]->id != '') + if (getData($tmpVorlage)[$j]->id != '') { - array_push($vorlage->retval, $tmpVorlage->retval[$j]); + array_push($vorlage->retval, getData($tmpVorlage)[$j]); } } } - else // checks for duplicates, if it's not already present push it into the array $vorlage->retval + else // checks for duplicates, if it's not already present push it into the array getData($vorlage) { - for ($i = 0; $i < count($vorlage->retval); $i++) + for ($j = 0; $j < count(getData($tmpVorlage)); $j++) { - for ($j = 0; $j < count($tmpVorlage->retval); $j++) + $found = false; + $currentTmpVorlageData = null; + + for ($i = 0; $i < count(getData($vorlage)); $i++) { - if ($tmpVorlage->retval[$j]->id != '' - && $vorlage->retval[$i]->_pk != $tmpVorlage->retval[$j]->_pk - && $vorlage->retval[$i]->_ppk != $tmpVorlage->retval[$j]->_ppk - && $vorlage->retval[$i]->_jtpk != $tmpVorlage->retval[$j]->_jtpk) + $currentTmpVorlageData = getData($tmpVorlage)[$j]; + + if (getData($vorlage)[$i]->_pk == getData($tmpVorlage)[$j]->_pk + && getData($vorlage)[$i]->_ppk == getData($tmpVorlage)[$j]->_ppk + && getData($vorlage)[$i]->_jtpk == getData($tmpVorlage)[$j]->_jtpk) { - array_push($vorlage->retval, $tmpVorlage->retval[$j]); + $found = true; + break; } } + + if (!$found && $currentTmpVorlageData->id != '') array_push($vorlage->retval, $currentTmpVorlageData); } } } From 9bb4e2507a2056fdede0f4c7ac39f7fd56fccdd9 Mon Sep 17 00:00:00 2001 From: Paolo Date: Mon, 9 Mar 2020 13:41:17 +0100 Subject: [PATCH 2/3] - Added two new functions to config entry ou_function_whitelist - Fixed Vorlage_widget to retrieve univocally templates --- application/config/message.php | 2 +- application/widgets/Vorlage_widget.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/application/config/message.php b/application/config/message.php index 3a9629279..8232cdfb7 100644 --- a/application/config/message.php +++ b/application/config/message.php @@ -19,7 +19,7 @@ $config['ou_receivers_no_notice'] = array('infocenter'); // Organization units that will not send the notice email to the internal account, but to the private one $config['ou_receivers_private'] = array('eac', 'ewu', 'scs'); // -$config['ou_function_whitelist'] = array('ass', 'Leitung'); +$config['ou_function_whitelist'] = array('ass', 'Leitung', 'fachzuordnung', 'oezuordnung'); $config['message_redirect_url'] = array(); $config['message_redirect_url']['fallback'] = site_url('system/messages/ViewMessage/writeReply'); diff --git a/application/widgets/Vorlage_widget.php b/application/widgets/Vorlage_widget.php index 2ba685edc..f1898eb09 100644 --- a/application/widgets/Vorlage_widget.php +++ b/application/widgets/Vorlage_widget.php @@ -136,7 +136,8 @@ class Vorlage_widget extends DropdownWidget { $currentTmpVorlageData = getData($tmpVorlage)[$j]; - if (getData($vorlage)[$i]->_pk == getData($tmpVorlage)[$j]->_pk + if (getData($vorlage)[$i]->id == getData($tmpVorlage)[$j]->id + && getData($vorlage)[$i]->_pk == getData($tmpVorlage)[$j]->_pk && getData($vorlage)[$i]->_ppk == getData($tmpVorlage)[$j]->_ppk && getData($vorlage)[$i]->_jtpk == getData($tmpVorlage)[$j]->_jtpk) { @@ -145,7 +146,10 @@ class Vorlage_widget extends DropdownWidget } } - if (!$found && $currentTmpVorlageData->id != '') array_push($vorlage->retval, $currentTmpVorlageData); + if (!$found && $currentTmpVorlageData->id != '') + { + array_push($vorlage->retval, $currentTmpVorlageData); + } } } } From 0ba7d3fc9473f34bd0b42d5e89bae74d704410ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Wed, 25 Mar 2020 14:58:21 +0100 Subject: [PATCH 3/3] Profil zeigt Infotext an wenn der Notfallkontakt fehlt --- cis/private/profile/index.php | 6 ++++++ locale/de-AT/profil.php | 2 ++ locale/en-US/profil.php | 2 ++ 3 files changed, 10 insertions(+) diff --git a/cis/private/profile/index.php b/cis/private/profile/index.php index 17593ec15..3117aec55 100644 --- a/cis/private/profile/index.php +++ b/cis/private/profile/index.php @@ -427,6 +427,7 @@ if (!$ansicht) usort($kontakt->result, "sortKontakt"); echo ''; + $has_notfallkontakt = false; foreach($kontakt->result as $k) { if ($k->kontakttyp != 'firmenhandy' && $k->kontakttyp != 'hidden') @@ -441,6 +442,8 @@ if (!$ansicht) echo ''; echo ''; echo ''; + if ($k->kontakttyp == 'notfallkontakt') + $has_notfallkontakt = true; } /* if ($k->zustellung === TRUE) @@ -462,6 +465,9 @@ if (!$ansicht) } */ } + if (!$has_notfallkontakt) + echo ''; + echo '
'.$k->anmerkung.''.$zustellung.'
'.$p->t('profil/notfallkontakt').''.$p->t('profil/notfallkontaktBekanntgeben').'
'; } diff --git a/locale/de-AT/profil.php b/locale/de-AT/profil.php index 074379601..b8dcadcdd 100644 --- a/locale/de-AT/profil.php +++ b/locale/de-AT/profil.php @@ -84,4 +84,6 @@ $this->phrasen['profil/gueltigbis']='Gültig bis'; $this->phrasen['profil/wochenstunden']='Wochenstunden'; $this->phrasen['profil/vertragsstunden']='Vertragsstunden'; $this->phrasen['profil/zukuenftigeFunktionen']='Zukünftige Funktionen'; +$this->phrasen['profil/notfallkontakt']='Notfallkontakt'; +$this->phrasen['profil/notfallkontaktBekanntgeben']='Bitte geben Sie einen Notfallkontakt bekannt!'; ?> diff --git a/locale/en-US/profil.php b/locale/en-US/profil.php index 660936381..e94f180cd 100644 --- a/locale/en-US/profil.php +++ b/locale/en-US/profil.php @@ -82,4 +82,6 @@ $this->phrasen['profil/gueltigbis']='Valid to'; $this->phrasen['profil/wochenstunden']='week hours'; $this->phrasen['profil/vertragsstunden']='contract hours'; $this->phrasen['profil/zukuenftigeFunktionen']='Future functions'; +$this->phrasen['profil/notfallkontakt']='Emergency contact'; +$this->phrasen['profil/notfallkontaktBekanntgeben']='Please provide an emergency contact!'; ?>