From 9df9ec8f4153aa92c6336b95a460b23c0fa178f6 Mon Sep 17 00:00:00 2001 From: bison-paolo Date: Wed, 12 Oct 2016 13:45:06 +0200 Subject: [PATCH] - MessageLib: Better error messages when sending messages - Added a new constant for the messaging system - Added a new phrase for the messaging system --- application/config/message.php | 1 + application/language/de-AT/message_lang.php | 3 ++- application/language/en-US/message_lang.php | 3 ++- application/libraries/MessageLib.php | 18 ++++++++++++++++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/application/config/message.php b/application/config/message.php index 4caa2ca71..970c383f3 100644 --- a/application/config/message.php +++ b/application/config/message.php @@ -50,6 +50,7 @@ define('MSG_ERR_BODY_EMPTY', 41); define('MSG_ERR_TEMPLATE_NOT_FOUND', 42); define('MSG_ERR_DELIVERY_MESSAGE', 43); define('MSG_ERR_CONTACT_NOT_FOUND', 44); +define('MSG_ERR_OU_CONTACTS_NOT_FOUND', 45); define('MSG_ERR_INVALID_USER_ID', 100); define('MSG_ERR_INVALID_MSG_ID', 101); diff --git a/application/language/de-AT/message_lang.php b/application/language/de-AT/message_lang.php index dd5cb55cf..02f98c1b7 100644 --- a/application/language/de-AT/message_lang.php +++ b/application/language/de-AT/message_lang.php @@ -24,4 +24,5 @@ $lang['message_' . MSG_STATUS_UPDATE] = 'Status updated'; $lang['message_' . MSG_PARTICIPANT_ADDED] = 'Participant added'; $lang['message_' . MSG_ERR_PARTICIPANT_EXISTS] = 'User is already participating in this thread'; $lang['message_' . MSG_ERR_PARTICIPANT_NONSYSTEM] = 'This user id is not in the system'; -$lang['message_' . MSG_PARTICIPANT_REMOVED] = 'Participant removed from thread'; \ No newline at end of file +$lang['message_' . MSG_PARTICIPANT_REMOVED] = 'Participant removed from thread'; +$lang['message_' . MSG_ERR_OU_CONTACTS_NOT_FOUND] = 'No receivers found for this organization unit'; \ No newline at end of file diff --git a/application/language/en-US/message_lang.php b/application/language/en-US/message_lang.php index dd5cb55cf..02f98c1b7 100644 --- a/application/language/en-US/message_lang.php +++ b/application/language/en-US/message_lang.php @@ -24,4 +24,5 @@ $lang['message_' . MSG_STATUS_UPDATE] = 'Status updated'; $lang['message_' . MSG_PARTICIPANT_ADDED] = 'Participant added'; $lang['message_' . MSG_ERR_PARTICIPANT_EXISTS] = 'User is already participating in this thread'; $lang['message_' . MSG_ERR_PARTICIPANT_NONSYSTEM] = 'This user id is not in the system'; -$lang['message_' . MSG_PARTICIPANT_REMOVED] = 'Participant removed from thread'; \ No newline at end of file +$lang['message_' . MSG_PARTICIPANT_REMOVED] = 'Participant removed from thread'; +$lang['message_' . MSG_ERR_OU_CONTACTS_NOT_FOUND] = 'No receivers found for this organization unit'; \ No newline at end of file diff --git a/application/libraries/MessageLib.php b/application/libraries/MessageLib.php index 13c16507e..52ded9de9 100644 --- a/application/libraries/MessageLib.php +++ b/application/libraries/MessageLib.php @@ -217,6 +217,12 @@ class MessageLib // If everything went ok if (is_object($receivers) && $receivers->error == EXIT_SUCCESS && is_array($receivers->retval)) { + // If no receivers were found for this organization unit + if (count($receivers->retval) == 0) + { + $result = $this->_error($receivers->retval, MSG_ERR_OU_CONTACTS_NOT_FOUND); + } + // Looping on receivers for ($i = 0; $i < count($receivers->retval); $i++) { @@ -341,8 +347,16 @@ class MessageLib // If everything went ok if (is_object($receivers) && $receivers->error == EXIT_SUCCESS && is_array($receivers->retval)) { - // Load reveiver data to get its relative language - $this->ci->load->model('person/Person_model', 'PersonModel'); + // If no receivers were found for this organization unit + if (count($receivers->retval) == 0) + { + $result = $this->_error($receivers->retval, MSG_ERR_OU_CONTACTS_NOT_FOUND); + } + else + { + // Load reveiver data to get its relative language + $this->ci->load->model('person/Person_model', 'PersonModel'); + } // Looping on receivers for ($i = 0; $i < count($receivers->retval); $i++)