From b45c93f254681490ebad0cedf83e3b9e84c0aa64 Mon Sep 17 00:00:00 2001 From: Pepijn Over Date: Mon, 28 Jul 2014 09:46:48 +0200 Subject: [PATCH] issue #113: only send test sms if user has a mobile no --- src/lang/bg_BG.lang.php | 1 + src/lang/da_DK.lang.php | 1 + src/lang/de_DE.lang.php | 1 + src/lang/en_US.lang.php | 1 + src/lang/es_ES.lang.php | 1 + src/lang/fr_FR.lang.php | 1 + src/lang/it_IT.lang.php | 1 + src/lang/ko_KR.lang.php | 1 + src/lang/nl_NL.lang.php | 3 ++- src/lang/pt_BR.lang.php | 1 + src/lang/ru_RU.lang.php | 1 + src/lang/zh_CN.lang.php | 1 + .../Config/Controller/ConfigController.class.php | 12 ++++++++---- 13 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/lang/bg_BG.lang.php b/src/lang/bg_BG.lang.php index 881c56b3..d2594220 100644 --- a/src/lang/bg_BG.lang.php +++ b/src/lang/bg_BG.lang.php @@ -225,6 +225,7 @@ $sm_lang = array( 'email_error' => 'Възникна грешка при изпращането на тесовия имейл', 'sms_sent' => 'Тестовото SMS съобщение е изпратеното успешно.', 'sms_error' => 'Възникна грешка при изпращането на тестовия SMS', + 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.', ), // За нов ред в имейл съобщението, моля използвайте тага
'notifications' => array( diff --git a/src/lang/da_DK.lang.php b/src/lang/da_DK.lang.php index fdb91614..d556a284 100644 --- a/src/lang/da_DK.lang.php +++ b/src/lang/da_DK.lang.php @@ -225,6 +225,7 @@ $sm_lang = array( 'email_error' => 'Fejl ved afsendelse af email', 'sms_sent' => 'Sms sendt', 'sms_error' => 'Fejl ved afsendelse af SMS', + 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/de_DE.lang.php b/src/lang/de_DE.lang.php index 90eb0d97..adf5f496 100644 --- a/src/lang/de_DE.lang.php +++ b/src/lang/de_DE.lang.php @@ -225,6 +225,7 @@ $sm_lang = array( 'email_error' => 'Error in email sending', 'sms_sent' => 'Sms sent', 'sms_error' => 'Error in sms sending', + 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/en_US.lang.php b/src/lang/en_US.lang.php index 5eb63be9..d05c81ac 100644 --- a/src/lang/en_US.lang.php +++ b/src/lang/en_US.lang.php @@ -225,6 +225,7 @@ $sm_lang = array( 'email_error' => 'Error in email sending', 'sms_sent' => 'Sms sent', 'sms_error' => 'Error in sms sending', + 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/es_ES.lang.php b/src/lang/es_ES.lang.php index 29e27105..b3c19d5b 100644 --- a/src/lang/es_ES.lang.php +++ b/src/lang/es_ES.lang.php @@ -223,6 +223,7 @@ $sm_lang = array( 'email_error' => 'Error in email sending', 'sms_sent' => 'Sms sent', 'sms_error' => 'Error in sms sending', + 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/fr_FR.lang.php b/src/lang/fr_FR.lang.php index 4de4f9f8..e35a6f62 100644 --- a/src/lang/fr_FR.lang.php +++ b/src/lang/fr_FR.lang.php @@ -224,6 +224,7 @@ $sm_lang = array( 'email_error' => 'Erreur lors de l\'envoie de l\'email', 'sms_sent' => 'Sms envoyé', 'sms_error' => 'Erreur lors de l\'envoie du sms', + 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/it_IT.lang.php b/src/lang/it_IT.lang.php index 7721365f..d11ca077 100644 --- a/src/lang/it_IT.lang.php +++ b/src/lang/it_IT.lang.php @@ -223,6 +223,7 @@ $sm_lang = array( 'email_error' => 'Error in email sending', 'sms_sent' => 'Sms sent', 'sms_error' => 'Error in sms sending', + 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/ko_KR.lang.php b/src/lang/ko_KR.lang.php index fd186ca8..3fbcb2ca 100644 --- a/src/lang/ko_KR.lang.php +++ b/src/lang/ko_KR.lang.php @@ -223,6 +223,7 @@ $sm_lang = array( 'email_error' => 'Error in email sending', 'sms_sent' => 'Sms sent', 'sms_error' => 'Error in sms sending', + 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/nl_NL.lang.php b/src/lang/nl_NL.lang.php index fccc7f73..7bd1d21c 100644 --- a/src/lang/nl_NL.lang.php +++ b/src/lang/nl_NL.lang.php @@ -200,7 +200,7 @@ $sm_lang = array( 'log_email' => 'Log emails verstuurd bij het script?', 'log_sms' => 'Log sms berichten verstuurd bij het script?', 'updated' => 'De configuratie is gewijzigd.', - 'nochanges' => 'The configuration didn\'t change.', + 'nochanges' => 'De configuratie is ongewijzigd.', 'tab_email' => 'Email', 'tab_sms' => 'SMS', 'tab_log' => 'Log', @@ -224,6 +224,7 @@ $sm_lang = array( 'email_error' => 'Er is een fout opgetreden tijdens het verzenden', 'sms_sent' => 'SMS verzonden', 'sms_error' => 'Er is een fout opgetreden tijdens het verzenden', + 'sms_error_nomobile' => 'Kan test SMS niet verzenden: er is geen telefoonnummer ingevuld in je profiel.', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/pt_BR.lang.php b/src/lang/pt_BR.lang.php index a8b412ad..fc436eea 100644 --- a/src/lang/pt_BR.lang.php +++ b/src/lang/pt_BR.lang.php @@ -225,6 +225,7 @@ $sm_lang = array( 'email_error' => 'Error in email sending', 'sms_sent' => 'Sms sent', 'sms_error' => 'Error in sms sending', + 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/ru_RU.lang.php b/src/lang/ru_RU.lang.php index 9fb5add1..eefd430d 100644 --- a/src/lang/ru_RU.lang.php +++ b/src/lang/ru_RU.lang.php @@ -225,6 +225,7 @@ $sm_lang = array( 'email_error' => 'Ошибка при отправке email', 'sms_sent' => 'Sms отправлено', 'sms_error' => 'Ошибка при отправке sms', + 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/lang/zh_CN.lang.php b/src/lang/zh_CN.lang.php index 4f312245..7da4897a 100644 --- a/src/lang/zh_CN.lang.php +++ b/src/lang/zh_CN.lang.php @@ -224,6 +224,7 @@ $sm_lang = array( 'email_error' => 'Error in email sending', 'sms_sent' => 'Sms sent', 'sms_error' => 'Error in sms sending', + 'sms_error_nomobile' => 'Unable to send test SMS: no valid phone number found in your profile.', ), // for newlines in the email messages use
'notifications' => array( diff --git a/src/psm/Module/Config/Controller/ConfigController.class.php b/src/psm/Module/Config/Controller/ConfigController.class.php index 10d8ee23..f072f242 100644 --- a/src/psm/Module/Config/Controller/ConfigController.class.php +++ b/src/psm/Module/Config/Controller/ConfigController.class.php @@ -210,11 +210,15 @@ class ConfigController extends AbstractController { $sms = psm_build_sms(); if($sms) { $user = $this->user->getUser(); - $sms->addRecipients($user->mobile); - if($sms->sendSMS(psm_get_lang('config', 'test_message'))) { - $this->addMessage(psm_get_lang('config', 'sms_sent'), 'success'); + if(empty($user->mobile)) { + $this->addMessage(psm_get_lang('config', 'sms_error_nomobile'), 'error'); } else { - $this->addMessage(psm_get_lang('config', 'sms_error'), 'error'); + $sms->addRecipients($user->mobile); + if($sms->sendSMS(psm_get_lang('config', 'test_message'))) { + $this->addMessage(psm_get_lang('config', 'sms_sent'), 'success'); + } else { + $this->addMessage(psm_get_lang('config', 'sms_error'), 'error'); + } } } }