fix trans removing html
This commit is contained in:
parent
fb3c4ab865
commit
cccc670c05
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2009 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* 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
|
||||
* 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 "<br>\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}', '<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 '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
@ -178,8 +183,11 @@ if ($action == 'edit')
|
||||
|
||||
// Method
|
||||
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);
|
||||
else print '<font class="error">'.$langs->trans("None").'</font>';
|
||||
if (count($listofmethods)) {
|
||||
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>';
|
||||
|
||||
// From
|
||||
@ -204,8 +212,6 @@ if ($action == 'edit')
|
||||
print '</form>';
|
||||
print '<br>';
|
||||
} 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 '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
|
||||
|
||||
@ -218,14 +224,18 @@ if ($action == 'edit')
|
||||
// Method
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_SMS_SENDMODE").'</td><td>';
|
||||
$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 '</td></tr>';
|
||||
|
||||
// From
|
||||
print '<tr class="oddeven"><td>'.$langs->trans("MAIN_MAIL_SMS_FROM", $langs->transnoentities("Undefined")).'</td>';
|
||||
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>';
|
||||
|
||||
// Autocopy to
|
||||
@ -234,7 +244,7 @@ if ($action == 'edit')
|
||||
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"));
|
||||
print '</td></tr>';
|
||||
*/
|
||||
*/
|
||||
|
||||
print '</table>';
|
||||
|
||||
@ -257,8 +267,7 @@ if ($action == 'edit')
|
||||
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&mode=init">'.$langs->trans("DoTestSend").'</a>';
|
||||
} else {
|
||||
print '<a class="butActionRefused classfortooltip" href="#">'.$langs->trans("DoTestSend").'</a>';
|
||||
@ -290,8 +299,7 @@ if ($action == 'edit')
|
||||
}*/
|
||||
|
||||
// Affichage formulaire de TEST simple
|
||||
if ($action == 'test')
|
||||
{
|
||||
if ($action == 'test') {
|
||||
print '<br>';
|
||||
print load_fiche_titre($langs->trans("DoTestSend"));
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user