From a5b3f0ed88219ea817c8aa496ac334384a810bc9 Mon Sep 17 00:00:00 2001 From: Paolo Date: Thu, 13 Jun 2019 14:09:56 +0200 Subject: [PATCH] - Moved constants EMAIL_KONTAKT_TYPE and SENT_INFO_NEWLINE from config/constants.php to MessageLib - Added function parseTemplate to helper helpers/hlp_common_helper.php - Changed method getMessages of model models/system/Recipient_model.php - Changed views/templates/mailHTML.php and views/templates/mailTXT.php --- application/config/constants.php | 5 ----- application/helpers/hlp_common_helper.php | 14 +++++++++++++- application/models/system/Recipient_model.php | 16 +++------------- application/views/templates/mailHTML.php | 6 +++--- application/views/templates/mailTXT.php | 8 ++++++-- 5 files changed, 25 insertions(+), 24 deletions(-) diff --git a/application/config/constants.php b/application/config/constants.php index e1c5906c3..ce917b5a3 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -125,11 +125,6 @@ define('EMAIL_CONFIG_INDEX', 'mail'); | Messaging system constants |-------------------------------------------------------------------------- */ -// Email kontakt type -define('EMAIL_KONTAKT_TYPE', 'email'); -// tbl_msg_recipient->sentInfo separator -define('SENT_INFO_NEWLINE', '\n'); - // Message statuses define('MSG_STATUS_UNREAD', 0); define('MSG_STATUS_READ', 1); diff --git a/application/helpers/hlp_common_helper.php b/application/helpers/hlp_common_helper.php index 45a36914c..025834ed2 100644 --- a/application/helpers/hlp_common_helper.php +++ b/application/helpers/hlp_common_helper.php @@ -241,7 +241,7 @@ function isDateWorkingDay($date, $days = null) } /** - * Parse the given given text using the given data parameter + * Parse the given text using the given data parameter * Use the CI parser which performs simple text substitution for pseudo-variable */ function parseText($text, $data) @@ -251,3 +251,15 @@ function parseText($text, $data) return $ci->parser->parse_string($text, $data, true); } + +/** + * Parse the given template using the given data parameter + * Use the CI parser which performs simple text substitution for pseudo-variable + */ +function parseTemplate($template, $data) +{ + $ci =& get_instance(); // get CI instance + $ci->load->library('parser'); // Loads CI parser library + + return $ci->parser->parse($template, $data, true); +} diff --git a/application/models/system/Recipient_model.php b/application/models/system/Recipient_model.php index 654a9a883..74a1c3256 100644 --- a/application/models/system/Recipient_model.php +++ b/application/models/system/Recipient_model.php @@ -205,7 +205,7 @@ class Recipient_model extends DB_Model * @param limit specifies the number of messages to get * @param message_id specifies a single message */ - public function getMessages($kontaktType, $sent, $limit = null, $message_id = null) + public function getMessages($kontaktType, $limit = 1, $message_id = null) { $query = 'SELECT mm.message_id, ks.kontakt as sender, @@ -239,17 +239,7 @@ class Recipient_model extends DB_Model $parametersArray = array($kontaktType, $kontaktType); - if (is_null($sent) || $sent == '') - { - $query .= ' WHERE mr.sent IS NULL'; - } - else - { - array_push($parametersArray, $sent); - $query .= ' WHERE mr.sent = ?'; - } - - if (!is_null($message_id)) + if (is_numeric($message_id)) { array_push($parametersArray, $message_id); $query .= ' AND mm.message_id = ?'; @@ -257,7 +247,7 @@ class Recipient_model extends DB_Model $query .= ' ORDER BY mr.insertamum ASC'; - if (!is_null($limit)) + if (is_numeric($limit)) { $query .= ' LIMIT ?'; array_push($parametersArray, $limit); diff --git a/application/views/templates/mailHTML.php b/application/views/templates/mailHTML.php index c2e072f68..32d544c5a 100644 --- a/application/views/templates/mailHTML.php +++ b/application/views/templates/mailHTML.php @@ -1,12 +1,12 @@ - This is not the email template, this is a tribute + Notification of personal message reception
-

Neue Nachricht vorhanden

+

A new message is available

diff --git a/application/views/templates/mailTXT.php b/application/views/templates/mailTXT.php index cd55aeb06..09634e6ae 100644 --- a/application/views/templates/mailTXT.php +++ b/application/views/templates/mailTXT.php @@ -1,3 +1,7 @@ -Follow the following link to read the message. +Notification of personal message reception -{href} \ No newline at end of file +A new message is available + +Click here to view the message + +{href}