fix trans removing html

This commit is contained in:
Frédéric FRANCE 2020-12-05 08:45:58 +01:00
parent fb3c4ab865
commit cccc670c05
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2009 Regis Houssin <regis.houssin@inodbox.com> * Copyright (C) 2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2020 Frédéric France <frederic.france@netlogic.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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 $cancel = GETPOST('cancel', 'alpha'); // We click on a Cancel button
if (!$user->admin) if (!$user->admin) {
accessforbidden(); accessforbidden();
}
$substitutionarrayfortest = array( $substitutionarrayfortest = array(
'__ID__' => 'TESTIdRecord', '__ID__' => 'TESTIdRecord',
'__PHONEFROM__' => 'TESTPhoneFrom', '__PHONEFROM__' => 'TESTPhoneFrom',
'__PHONETO__' => 'TESTPhoneTo', '__PHONETO__' => 'TESTPhoneTo',
'__LASTNAME__' => 'TESTLastname', '__LASTNAME__' => 'TESTLastname',
'__FIRSTNAME__' => 'TESTFirstname' '__FIRSTNAME__' => 'TESTFirstname'
); );
$action = GETPOST('action', 'aZ09'); $action = GETPOST('action', 'aZ09');
@ -48,8 +50,7 @@ $action = GETPOST('action', 'aZ09');
* Actions * 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_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); 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 * Send sms
*/ */
if ($action == 'send' && !$_POST['cancel']) if ($action == 'send' && !$_POST['cancel']) {
{
$error = 0; $error = 0;
$smsfrom = ''; $smsfrom = '';
if (!empty($_POST["fromsms"])) $smsfrom = GETPOST("fromsms", 'alphanohtml'); if (!empty($_POST["fromsms"])) {
if (empty($smsfrom)) $smsfrom = GETPOST("fromname", 'alphanohtml'); $smsfrom = GETPOST("fromsms", 'alphanohtml');
}
if (empty($smsfrom)) {
$smsfrom = GETPOST("fromname", 'alphanohtml');
}
$sendto = GETPOST("sendto", 'alphanohtml'); $sendto = GETPOST("sendto", 'alphanohtml');
$body = GETPOST('message', 'alphanohtml'); $body = GETPOST('message', 'alphanohtml');
$deliveryreceipt = GETPOST("deliveryreceipt", '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'; include_once DOL_DOCUMENT_ROOT.'/core/class/html.formsms.class.php';
$formsms = new FormSms($db); $formsms = new FormSms($db);
if (!empty($formsms->error)) if (!empty($formsms->error)) {
{
setEventMessages($formsms->error, $formsms->errors, 'errors'); setEventMessages($formsms->error, $formsms->errors, 'errors');
$action = 'test'; $action = 'test';
$error++; $error++;
} }
if (empty($body)) if (empty($body)) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Message")), null, 'errors');
$action = 'test'; $action = 'test';
$error++; $error++;
} }
if (empty($smsfrom) || !str_replace('+', '', $smsfrom)) if (empty($smsfrom) || !str_replace('+', '', $smsfrom)) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsFrom")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsFrom")), null, 'errors');
$action = 'test'; $action = 'test';
$error++; $error++;
} }
if (empty($sendto) || !str_replace('+', '', $sendto)) if (empty($sendto) || !str_replace('+', '', $sendto)) {
{
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsTo")), null, 'errors'); setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("SmsTo")), null, 'errors');
$action = 'test'; $action = 'test';
$error++; $error++;
} }
if (!$error) if (!$error) {
{
// Make substitutions into message // Make substitutions into message
complete_substitutions_array($substitutionarrayfortest, $langs); complete_substitutions_array($substitutionarrayfortest, $langs);
$body = make_substitutions($body, $substitutionarrayfortest); $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 $smsfile = new CSMSFile($sendto, $smsfrom, $body, $deliveryreceipt, $deferred, $priority, $class); // This define OvhSms->login, pass, session and account
$result = $smsfile->sendfile(); // This send SMS $result = $smsfile->sendfile(); // This send SMS
if ($result) if ($result) {
{
setEventMessages($langs->trans("SmsSuccessfulySent", $smsfrom, $sendto), null, 'mesgs'); setEventMessages($langs->trans("SmsSuccessfulySent", $smsfrom, $sendto), null, 'mesgs');
setEventMessages($smsfile->error, $smsfile->errors, 'mesgs'); setEventMessages($smsfile->error, $smsfile->errors, 'mesgs');
} else { } else {
@ -138,8 +136,12 @@ if ($action == 'send' && !$_POST['cancel'])
*/ */
$linuxlike = 1; $linuxlike = 1;
if (preg_match('/^win/i', PHP_OS)) $linuxlike = 0; if (preg_match('/^win/i', PHP_OS)) {
if (preg_match('/^mac/i', PHP_OS)) $linuxlike = 0; $linuxlike = 0;
}
if (preg_match('/^mac/i', PHP_OS)) {
$linuxlike = 0;
}
$wikihelp = 'EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms'; $wikihelp = 'EN:Setup Sms|FR:Paramétrage Sms|ES:Configuración Sms';
llxHeader('', $langs->trans("Setup"), $wikihelp); llxHeader('', $langs->trans("Setup"), $wikihelp);
@ -153,11 +155,14 @@ print "<br>\n";
$listofmethods = (is_array($conf->modules_parts['sms']) ? $conf->modules_parts['sms'] : array()); $listofmethods = (is_array($conf->modules_parts['sms']) ? $conf->modules_parts['sms'] : array());
asort($listofmethods); asort($listofmethods);
if ($action == 'edit') if (!count($listofmethods)) {
{ $descnosms = $langs->trans("NoSmsEngine", '{Dolistore}');
$form = new Form($db); $descnosms = str_replace('{Dolistore}', '<a href="http://www.dolistore.com/search.php?orderby=position&orderway=desc&search_query=smsmanager">DoliStore</a>', $descnosms);
print '<div class="warning">'.$descnosms.'</div>';
}
if (!count($listofmethods)) print '<div class="warning">'.$langs->trans("NoSmsEngine", '<a href="http://www.dolistore.com/search.php?orderby=position&orderway=desc&search_query=smsmanager">DoliStore</a>').'</div>'; if ($action == 'edit') {
$form = new Form($db);
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.newToken().'">'; print '<input type="hidden" name="token" value="'.newToken().'">';
@ -178,8 +183,11 @@ if ($action == 'edit')
// Method // Method
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_SMS_SENDMODE").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_SMS_SENDMODE").'</td><td>';
if (count($listofmethods)) print $form->selectarray('MAIN_SMS_SENDMODE', $listofmethods, $conf->global->MAIN_SMS_SENDMODE, 1); if (count($listofmethods)) {
else print '<font class="error">'.$langs->trans("None").'</font>'; print $form->selectarray('MAIN_SMS_SENDMODE', $listofmethods, $conf->global->MAIN_SMS_SENDMODE, 1);
} else {
print '<font class="error">'.$langs->trans("None").'</font>';
}
print '</td></tr>'; print '</td></tr>';
// From // From
@ -204,8 +212,6 @@ if ($action == 'edit')
print '</form>'; print '</form>';
print '<br>'; print '<br>';
} else { } else {
if (!count($listofmethods)) print '<div class="warning">'.$langs->trans("NoSmsEngine", '<a target="_blank" href="http://www.dolistore.com/search.php?orderby=position&orderway=desc&search_query=smsmanager">DoliStore</a>').'</div>';
print '<table class="noborder centpercent">'; print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
@ -218,14 +224,18 @@ if ($action == 'edit')
// Method // Method
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_SMS_SENDMODE").'</td><td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_SMS_SENDMODE").'</td><td>';
$text = $listofmethods[$conf->global->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 $text;
print '</td></tr>'; print '</td></tr>';
// From // From
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).'</td>'; print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).'</td>';
print '<td>'.$conf->global->MAIN_MAIL_SMS_FROM; print '<td>'.$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 '</td></tr>'; print '</td></tr>';
// Autocopy to // Autocopy to
@ -234,7 +244,7 @@ if ($action == 'edit')
print '<td>'.$conf->global->MAIN_MAIL_AUTOCOPY_TO; print '<td>'.$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")); if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO) && ! isValidEmail($conf->global->MAIN_MAIL_AUTOCOPY_TO)) print img_warning($langs->trans("ErrorBadEMail"));
print '</td></tr>'; print '</td></tr>';
*/ */
print '</table>'; print '</table>';
@ -257,8 +267,7 @@ if ($action == 'edit')
print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>'; print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("FeatureNotAvailableOnLinux").'">'.$langs->trans("DoTestServerAvailability").'</a>';
}*/ }*/
if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) if (count($listofmethods) && !empty($conf->global->MAIN_SMS_SENDMODE)) {
{
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>'; print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=test&amp;mode=init">'.$langs->trans("DoTestSend").'</a>';
} else { } else {
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("DoTestSend").'</a>'; print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("DoTestSend").'</a>';
@ -290,8 +299,7 @@ if ($action == 'edit')
}*/ }*/
// Affichage formulaire de TEST simple // Affichage formulaire de TEST simple
if ($action == 'test') if ($action == 'test') {
{
print '<br>'; print '<br>';
print load_fiche_titre($langs->trans("DoTestSend")); print load_fiche_titre($langs->trans("DoTestSend"));