From d08eb75b5a2129899c6db8ed25e508fb9c1c1a73 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 5 Jul 2018 12:13:02 +0200 Subject: [PATCH] Adapted MessageLib, PhrasesLib and UDFLib to use the function getUserLanguage from language_helper --- application/libraries/MessageLib.php | 12 ++++-------- application/libraries/PhrasesLib.php | 17 ++--------------- application/libraries/UDFLib.php | 8 ++++---- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 8d04b9824..ce03fe6dc 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -268,7 +268,7 @@ class MessageLib } /** - * sendMessageVorlage() - sends new internal message using a template + * Sends new internal message using a template */ public function sendMessageVorlage($sender_id, $receiver_id, $vorlage_kurzbz, $oe_kurzbz, $data, $relationmessage_id = null, $orgform_kurzbz = null, $multiPartMime = true) { @@ -298,16 +298,12 @@ class MessageLib { $receiver_id = $receivers->retval[$i]->person_id; + // Checks if the receiver exists $result = $this->ci->PersonModel->load($receiver_id); if (hasData($result)) { - // Set the language with the global value - $sprache = DEFAULT_LANGUAGE; - // If the receiver has a prefered language use this - if (isset($result->retval[0]->sprache) && $result->retval[0]->sprache != '') - { - $sprache = $result->retval[0]->sprache; - } + // Retrives the language of the logged user + $sprache = getUserLanguage(); // Loads template data $result = $this->ci->vorlagelib->loadVorlagetext($vorlage_kurzbz, $oe_kurzbz, $orgform_kurzbz, $sprache); diff --git a/application/libraries/PhrasesLib.php b/application/libraries/PhrasesLib.php index 93250379b..88e79b467 100644 --- a/application/libraries/PhrasesLib.php +++ b/application/libraries/PhrasesLib.php @@ -242,21 +242,8 @@ class PhrasesLib $categories = array($categories); } - // Use the given language if present, otherwise retrives the language for the logged user - $language = DEFAULT_LANGUAGE; - if (count($parameters) == 2 && !isEmptyString($parameters[1]) && is_string($parameters[1])) - { - $language = $parameters[1]; - } - // Checks if the user is authenticated to retrive the users's language - // NOTE: this library could be called when the user is not logged in the system - // so this is why is checked if the function getAuthUID exists - elseif (function_exists('getAuthUID')) - { - $this->_ci->load->model('person/Person_model', 'PersonModel'); - - $language = $this->_ci->PersonModel->getLanguage(getAuthUID()); - } + // Retrives the language of the logged user + $language = getUserLanguage(count($parameters) == 2 ? $parameters[1] : null); // If only categories is not an empty array then loads phrases if (count($categories) > 0) $this->_setPhrases($categories, $language); diff --git a/application/libraries/UDFLib.php b/application/libraries/UDFLib.php index eeb546ae3..1e46eaade 100644 --- a/application/libraries/UDFLib.php +++ b/application/libraries/UDFLib.php @@ -711,7 +711,7 @@ class UDFLib || isset($jsonSchema->{UDFLib::TITLE}) || isset($jsonSchema->{UDFLib::PLACEHOLDER})) { - // Loads PhrasesLib + // Loads phrases library $this->_ci->load->library('PhrasesLib'); // If is set the label property in the json schema @@ -720,7 +720,7 @@ class UDFLib // Load the related phrase $tmpResult = $this->_ci->phraseslib->getPhrases( UDFLib::PHRASES_APP_NAME, - DEFAULT_LANGUAGE, + getUserLanguage(), $jsonSchema->{UDFLib::LABEL}, null, null, @@ -738,7 +738,7 @@ class UDFLib // Load the related phrase $tmpResult = $this->_ci->phraseslib->getPhrases( UDFLib::PHRASES_APP_NAME, - DEFAULT_LANGUAGE, + getUserLanguage(), $jsonSchema->{UDFLib::TITLE}, null, null, @@ -756,7 +756,7 @@ class UDFLib // Load the related phrase $tmpResult = $this->_ci->phraseslib->getPhrases( UDFLib::PHRASES_APP_NAME, - DEFAULT_LANGUAGE, + getUserLanguage(), $jsonSchema->{UDFLib::PLACEHOLDER}, null, null,