diff --git a/application/controllers/ViewMessage.php b/application/controllers/ViewMessage.php index e752cc11f..fa294a4ec 100755 --- a/application/controllers/ViewMessage.php +++ b/application/controllers/ViewMessage.php @@ -57,12 +57,21 @@ class ViewMessage extends CI_Controller } $sender_id = $msg->retval[0]->sender_id; + $receiver_id = $msg->retval[0]->receiver_id; $sender = $this->MessageTokenModel->getSenderData($sender_id); + // To decide how to change the redirection + $isEmployee = $this->MessageTokenModel->isEmployee($receiver_id); + if (!is_bool($isEmployee) && isError($isEmployee)) + { + show_error($isEmployee); + } + $data = array ( 'sender_id' => $sender_id, 'sender' => $sender->retval[0], 'message' => $msg->retval[0], + 'isEmployee' => $isEmployee, 'href' => APP_ROOT . $this->config->item('redirect_view_message_url') . $token ); diff --git a/application/models/system/MessageToken_model.php b/application/models/system/MessageToken_model.php index 9e5326056..331039a7b 100755 --- a/application/models/system/MessageToken_model.php +++ b/application/models/system/MessageToken_model.php @@ -153,10 +153,13 @@ class MessageToken_model extends CI_Model p.anrede, p.titelpost, p.titelpre, - p.vornamen + p.vornamen, + m.mitarbeiter_uid FROM public.tbl_person p + LEFT JOIN public.tbl_benutzer b USING(person_id) + LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) WHERE p.person_id = ?'; - + $result = $this->db->query($sql, array($person_id)); // If no errors occurred @@ -169,4 +172,41 @@ class MessageToken_model extends CI_Model return error($this->db->error()); } } + + /** + * + */ + public function isEmployee($person_id) + { + $sql = 'SELECT m.mitarbeiter_uid + FROM public.tbl_person p + LEFT JOIN public.tbl_benutzer b USING(person_id) + LEFT JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) + WHERE p.person_id = ? + AND b.aktiv = TRUE'; + + $result = $this->db->query($sql, array($person_id)); + + // If no errors occurred + if ($result) + { + // If data are present + if (is_array($result->result()) && count($result->result()) > 0) + { + $person = $result->result()[0]; + + // If it is an employee + if ($person->mitarbeiter_uid != null) + { + return true; + } + } + + return false; + } + else + { + return error($this->db->error()); + } + } } \ No newline at end of file diff --git a/application/views/system/messageHTML.php b/application/views/system/messageHTML.php index d34b3ab94..4a2eb2f07 100755 --- a/application/views/system/messageHTML.php +++ b/application/views/system/messageHTML.php @@ -37,11 +37,18 @@ body; ?> -