diff --git a/application/controllers/ViewMessage.php b/application/controllers/ViewMessage.php index fa294a4ec..48c0a09f1 100644 --- a/application/controllers/ViewMessage.php +++ b/application/controllers/ViewMessage.php @@ -33,7 +33,7 @@ class ViewMessage extends CI_Controller // Load model MessageToken_model, not calling the authentication system $this->load->model('system/MessageToken_model', 'MessageTokenModel'); } - + /** * Using the MessageTokenModel instead of MessageLib to allow * viewing the message without prompting the login @@ -50,32 +50,37 @@ class ViewMessage extends CI_Controller if (is_array($msg->retval) && count($msg->retval) > 0) { $setReadMessageStatusByToken = $this->MessageTokenModel->setReadMessageStatusByToken($token); - + if (isError($setReadMessageStatusByToken)) { show_error($msg->$setReadMessageStatusByToken); } - + $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); } - + + if($this->config->item('redirect_view_message_url') != '') + $href = APP_ROOT . $this->config->item('redirect_view_message_url') . $token; + else + $href = ''; + $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 + 'href' => $href ); - + $this->load->view('system/messageHTML.php', $data); } } -} \ No newline at end of file +} diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 3b5f8093b..3cbd18e24 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -426,14 +426,14 @@ class MessageLib if ((!is_null($result->retval[$i]->receiver) && $result->retval[$i]->receiver != '') || (!is_null($result->retval[$i]->employeecontact) && $result->retval[$i]->employeecontact != '')) { - $href = $this->ci->config->item('message_server').$this->ci->config->item('message_html_view_url').$result->retval[0]->token; + $href = $this->ci->config->item('message_server').$this->ci->config->item('message_html_view_url').$result->retval[$i]->token; // Using a template for the html email body $body = $this->ci->parser->parse( 'templates/mailHTML', array( 'href' => $href, - 'subject' => $result->retval[0]->subject, - 'body' => $result->retval[0]->body + 'subject' => $result->retval[$i]->subject, + 'body' => $result->retval[$i]->body ), true ); @@ -447,8 +447,8 @@ class MessageLib 'templates/mailTXT', array( 'href' => $href, - 'subject' => $result->retval[0]->subject, - 'body' => $result->retval[0]->body + 'subject' => $result->retval[$i]->subject, + 'body' => $result->retval[$i]->body ), true ); @@ -457,11 +457,11 @@ class MessageLib $this->ci->loglib->logError('Error while parsing the mail template'); } - // If the sender kontakt does not exist, then system-sender is used if empty + // If the sender is not an employee, then system-sender is used if empty $sender = ''; - if (!is_null($result->retval[0]->sender) && $result->retval[0]->sender != '') + if (!is_null($result->retval[0]->senderemployeecontact) && $result->retval[0]->senderemployeecontact != '') { - $sender = $result->retval[0]->sender; + $sender = $result->retval[0]->senderemployeecontact.'@'.DOMAIN; } $receiverContact = $result->retval[$i]->receiver; @@ -606,11 +606,11 @@ class MessageLib $bodyMsg = $altBody = $body; } - // If the sender kontakt does not exist, then system-sender is used if empty + // If the sender is not an employee, then system-sender is used if empty $sender = ''; - if (!is_null($result->retval[0]->sender) && $result->retval[0]->sender != '') + if (!is_null($result->retval[0]->senderemployeecontact) && $result->retval[0]->senderemployeecontact != '') { - $sender = $result->retval[0]->sender; + $sender = $result->retval[0]->senderemployeecontact.'@'.DOMAIN; } $receiverContact = $result->retval[0]->receiver; diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 40ef39f65..b9e170fbf 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -261,6 +261,7 @@ class Recipient_model extends DB_Model ks.kontakt as sender, kr.kontakt as receiver, mu.mitarbeiter_uid as employeeContact, + ms.mitarbeiter_uid as senderemployeeContact, mr.person_id as receiver_id, mr.token, mm.subject, @@ -278,7 +279,13 @@ class Recipient_model extends DB_Model m.mitarbeiter_uid FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) WHERE b.aktiv = TRUE - ) mu ON (mu.person_id = mr.person_id)'; + ) mu ON (mu.person_id = mr.person_id) + LEFT JOIN ( + SELECT b.person_id, + m.mitarbeiter_uid + FROM public.tbl_benutzer b INNER JOIN public.tbl_mitarbeiter m ON(b.uid = m.mitarbeiter_uid) + WHERE b.aktiv = TRUE + ) ms ON (ms.person_id = mm.person_id)'; $parametersArray = array($kontaktType, $kontaktType); diff --git a/application/views/system/messageHTML.php b/application/views/system/messageHTML.php index 4a2eb2f07..6a1d509ba 100644 --- a/application/views/system/messageHTML.php +++ b/application/views/system/messageHTML.php @@ -27,7 +27,8 @@ - + +
Message: @@ -38,7 +39,7 @@ @@ -48,7 +49,7 @@ + ?>