From cccc670c05c7d7a7948940c7ef2b9799a38f7e61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 5 Dec 2020 08:45:58 +0100 Subject: [PATCH] fix trans removing html --- htdocs/admin/sms.php | 92 ++++++++++++++++++++++++-------------------- 1 file changed, 50 insertions(+), 42 deletions(-) diff --git a/htdocs/admin/sms.php b/htdocs/admin/sms.php index 823d4804121..fd1bcb69bdb 100644 --- a/htdocs/admin/sms.php +++ b/htdocs/admin/sms.php @@ -2,6 +2,7 @@ /* Copyright (C) 2007-2011 Laurent Destailleur * Copyright (C) 2009 Regis Houssin * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2020 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -30,15 +31,16 @@ $langs->loadLangs(array("companies", "admin", "products", "sms", "other", "error $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button -if (!$user->admin) -accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $substitutionarrayfortest = array( -'__ID__' => 'TESTIdRecord', -'__PHONEFROM__' => 'TESTPhoneFrom', -'__PHONETO__' => 'TESTPhoneTo', -'__LASTNAME__' => 'TESTLastname', -'__FIRSTNAME__' => 'TESTFirstname' + '__ID__' => 'TESTIdRecord', + '__PHONEFROM__' => 'TESTPhoneFrom', + '__PHONETO__' => 'TESTPhoneTo', + '__LASTNAME__' => 'TESTLastname', + '__FIRSTNAME__' => 'TESTFirstname' ); $action = GETPOST('action', 'aZ09'); @@ -48,8 +50,7 @@ $action = GETPOST('action', 'aZ09'); * Actions */ -if ($action == 'update' && !$cancel) -{ +if ($action == 'update' && !$cancel) { dolibarr_set_const($db, "MAIN_DISABLE_ALL_SMS", GETPOST("MAIN_DISABLE_ALL_SMS", 'alphanohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SMS_SENDMODE", GETPOST("MAIN_SMS_SENDMODE", 'alphanohtml'), 'chaine', 0, '', $conf->entity); @@ -64,13 +65,16 @@ if ($action == 'update' && !$cancel) /* * Send sms */ -if ($action == 'send' && !$_POST['cancel']) -{ +if ($action == 'send' && !$_POST['cancel']) { $error = 0; $smsfrom = ''; - if (!empty($_POST["fromsms"])) $smsfrom = GETPOST("fromsms", 'alphanohtml'); - if (empty($smsfrom)) $smsfrom = GETPOST("fromname", 'alphanohtml'); + if (!empty($_POST["fromsms"])) { + $smsfrom = GETPOST("fromsms", 'alphanohtml'); + } + if (empty($smsfrom)) { + $smsfrom = GETPOST("fromname", 'alphanohtml'); + } $sendto = GETPOST("sendto", 'alphanohtml'); $body = GETPOST('message', 'alphanohtml'); $deliveryreceipt = GETPOST("deliveryreceipt", 'alphanohtml'); @@ -83,32 +87,27 @@ if ($action == 'send' && !$_POST['cancel']) include_once DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php'; $formsms = new FormSms($db); - if (!empty($formsms->error)) - { + if (!empty($formsms->error)) { setEventMessages($formsms->error, $formsms->errors, 'errors'); $action = 'test'; $error++; } - if (empty($body)) - { + if (empty($body)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); $action = 'test'; $error++; } - if (empty($smsfrom) || !str_replace('+', '', $smsfrom)) - { + if (empty($smsfrom) || !str_replace('+', '', $smsfrom)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsFrom")), null, 'errors'); $action = 'test'; $error++; } - if (empty($sendto) || !str_replace('+', '', $sendto)) - { + if (empty($sendto) || !str_replace('+', '', $sendto)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsTo")), null, 'errors'); $action = 'test'; $error++; } - if (!$error) - { + if (!$error) { // Make substitutions into message complete_substitutions_array($substitutionarrayfortest, $langs); $body = make_substitutions($body, $substitutionarrayfortest); @@ -118,8 +117,7 @@ if ($action == 'send' && !$_POST['cancel']) $smsfile = new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class); // This define OvhSms->login, pass, session and account $result = $smsfile->sendfile(); // This send SMS - if ($result) - { + if ($result) { setEventMessages($langs->trans("SmsSuccessfulySent", $smsfrom, $sendto), null, 'mesgs'); setEventMessages($smsfile->error, $smsfile->errors, 'mesgs'); } else { @@ -138,8 +136,12 @@ if ($action == 'send' && !$_POST['cancel']) */ $linuxlike = 1; -if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; -if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; +if (preg_match('/^win/i', PHP_OS)) { + $linuxlike = 0; +} +if (preg_match('/^mac/i', PHP_OS)) { + $linuxlike = 0; +} $wikihelp = 'EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms'; llxHeader('', $langs->trans("Setup"), $wikihelp); @@ -153,11 +155,14 @@ print "
\n"; $listofmethods = (is_array($conf->modules_parts['sms']) ? $conf->modules_parts['sms'] : array()); asort($listofmethods); -if ($action == 'edit') -{ - $form = new Form($db); +if (!count($listofmethods)) { + $descnosms = $langs->trans("NoSmsEngine", '{Dolistore}'); + $descnosms = str_replace('{Dolistore}', 'DoliStore', $descnosms); + print '
'.$descnosms.'
'; +} - if (!count($listofmethods)) print '
'.$langs->trans("NoSmsEngine", 'DoliStore').'
'; +if ($action == 'edit') { + $form = new Form($db); print '
'; print ''; @@ -178,8 +183,11 @@ if ($action == 'edit') // Method print ''.$langs->trans("MAIN_SMS_SENDMODE").''; - if (count($listofmethods)) print $form->selectarray('MAIN_SMS_SENDMODE', $listofmethods, $conf->global->MAIN_SMS_SENDMODE, 1); - else print ''.$langs->trans("None").''; + if (count($listofmethods)) { + print $form->selectarray('MAIN_SMS_SENDMODE', $listofmethods, $conf->global->MAIN_SMS_SENDMODE, 1); + } else { + print ''.$langs->trans("None").''; + } print ''; // From @@ -204,8 +212,6 @@ if ($action == 'edit') print '
'; print '
'; } else { - if (!count($listofmethods)) print '
'.$langs->trans("NoSmsEngine", 'DoliStore').'
'; - print ''; print ''; @@ -218,14 +224,18 @@ if ($action == 'edit') // Method print ''; // From print ''; print ''; // Autocopy to @@ -234,7 +244,7 @@ if ($action == 'edit') print ''; - */ + */ print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_SMS_SENDMODE").''; $text = $listofmethods[$conf->global->MAIN_SMS_SENDMODE]; - if (empty($text)) $text = $langs->trans("Undefined").' '.img_warning(); + if (empty($text)) { + $text = $langs->trans("Undefined").' '.img_warning(); + } print $text; print '
'.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).''.$conf->global->MAIN_MAIL_SMS_FROM; - if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && !isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) print ' '.img_warning($langs->trans("ErrorBadPhone")); + if (!empty($conf->global->MAIN_MAIL_SMS_FROM) && !isValidPhone($conf->global->MAIN_MAIL_SMS_FROM)) { + print ' '.img_warning($langs->trans("ErrorBadPhone")); + } print '
'.$conf->global->MAIN_MAIL_AUTOCOPY_TO; if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) && ! isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail")); print '
'; @@ -257,8 +267,7 @@ if ($action == 'edit') print ''.$langs->trans("DoTestServerAvailability").''; }*/ - if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) - { + if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) { print ''.$langs->trans("DoTestSend").''; } else { print ''.$langs->trans("DoTestSend").''; @@ -290,8 +299,7 @@ if ($action == 'edit') }*/ // Affichage formulaire de TEST simple - if ($action == 'test') - { + if ($action == 'test') { print '
'; print load_fiche_titre($langs->trans("DoTestSend"));