From 50b26ce7624d4eaf88202bb0cee030cf13d72875 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 16 Nov 2017 16:41:20 +0100 Subject: [PATCH] Changed method getOERoot of MessageToken_model and method redirectByToken of controller to retrive the correct root of the organisation unit tree --- application/controllers/Redirect.php | 21 ++++++------------ .../models/system/MessageToken_model.php | 22 +++++++++++-------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/application/controllers/Redirect.php b/application/controllers/Redirect.php index ffe135003..660709b6f 100644 --- a/application/controllers/Redirect.php +++ b/application/controllers/Redirect.php @@ -53,22 +53,15 @@ class Redirect extends FHC_Controller if ($oe_kurzbz != null && $oe_kurzbz != '') { $organisationRoot = null; + $getOERoot = $this->MessageTokenModel->getOERoot($oe_kurzbz); - if ($getOERoot) // If no errors occurred + if (isSuccess($getOERoot)) // If no errors occurred { - // If data are present - if (is_array($getOERoot->result()) && count($getOERoot->result()) > 0) - { - $organisationseinheit = $getOERoot->result()[0]; - if ($organisationseinheit->oe_kurzbz == null) - { - show_error('No organisation unit present in the message'); - } - else - { - $organisationRoot = $organisationseinheit->oe_kurzbz; - } - } + $organisationRoot = $getOERoot->retval; + } + else + { + show_error('No organisation unit present in the message'); } $addonAufnahmeUrls = $this->config->item('addons_aufnahme_url'); diff --git a/application/models/system/MessageToken_model.php b/application/models/system/MessageToken_model.php index 9e62af6e9..24b9f05ca 100644 --- a/application/models/system/MessageToken_model.php +++ b/application/models/system/MessageToken_model.php @@ -237,17 +237,21 @@ class MessageToken_model extends CI_Model if ($result) // If no errors occurred { // If data are present - if (is_array($result->result()) && count($result->result()) > 0) + if (is_array($result->result()) + && count($result->result()) > 0 + && is_object($result->result()[0]) + && isset($result->result()[0]->oe_kurzbz)) { - $organisationseinheit = $result->result()[0]; - - // If this organisationseinheit has a parent - if ($organisationseinheit->oe_parent_kurzbz != null) - { - // looks for the parent - $result = $this->getOERoot($organisationseinheit->oe_parent_kurzbz); - } + return success($result->result()[0]->oe_kurzbz); } + else + { + return error(); + } + } + else + { + return error($this->db->error()); } return $result;