Add a setting to force gsm alphabet conversion
This commit is contained in:
parent
fdbc6a0878
commit
59d3e28489
|
@ -14,8 +14,7 @@
|
|||
"symfony/yaml": "^5.0",
|
||||
"phpmailer/phpmailer": "^6.1",
|
||||
"xantios/mimey": ">=2.1",
|
||||
"kreait/firebase-php": "^5.14"
|
||||
},
|
||||
"require-dev": {
|
||||
"kreait/firebase-php": "^5.14",
|
||||
"benmorel/gsm-charset-converter": "^0.3.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -601,6 +601,11 @@ use Monolog\Logger;
|
|||
continue;
|
||||
}
|
||||
|
||||
// If we must force GSM 7 alphabet
|
||||
if ((int) ($users_settings[$id_user]['force_gsm_alphabet'] ?? false))
|
||||
{
|
||||
$text = Tool::convert_to_gsm0338($text);
|
||||
}
|
||||
|
||||
/*
|
||||
Choose phone if no phone defined for message
|
||||
|
|
|
@ -11,6 +11,8 @@
|
|||
|
||||
namespace controllers\internals;
|
||||
|
||||
use BenMorel\GsmCharsetConverter\Converter;
|
||||
|
||||
/**
|
||||
* Some tools frequently used.
|
||||
* Not a standard controller as it's not linked to a model in any way.
|
||||
|
@ -412,4 +414,17 @@ namespace controllers\internals;
|
|||
|
||||
return "{$scheme}{$user}{$pass}{$host}{$port}{$path}{$query}{$fragment}";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transform an UTF-8 string into a valid GSM 7 string (GSM 03.38), remplacing invalid chars with best equivalent whenever possible
|
||||
*
|
||||
* @param string $text : Input text to convert into gsm string
|
||||
* @return string : An UTF-8 string with GSM alphabet only
|
||||
*/
|
||||
public static function convert_to_gsm0338(string $text): string
|
||||
{
|
||||
$converter = new Converter();
|
||||
return $converter->cleanUpUtf8String($text, true, '?');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,12 @@ namespace controllers\publics;
|
|||
$result = $this->internal_templating->render($template, $data);
|
||||
$return = $result;
|
||||
|
||||
// If we must force GSM 7 alphabet
|
||||
if ((int) ($_SESSION['user']['settings']['force_gsm_alphabet'] ?? false))
|
||||
{
|
||||
$return['result'] = \controllers\internals\Tool::convert_to_gsm0338($return['result']);
|
||||
}
|
||||
|
||||
if (!trim($result['result']))
|
||||
{
|
||||
$return['result'] = 'Message vide, il ne sera pas envoyé.';
|
||||
|
|
|
@ -82,6 +82,7 @@
|
|||
'alert_quota_limit_reached' => 1,
|
||||
'alert_quota_limit_close' => 0.9,
|
||||
'hide_menus' => '',
|
||||
'force_gsm_alphabet' => 0,
|
||||
],
|
||||
];
|
||||
|
||||
|
|
|
@ -54,6 +54,25 @@
|
|||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><i class="fa fa-font fa-fw"></i> Alphabet SMS optimisé</h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<form action="<?php echo \descartes\Router::url('Setting', 'update', ['setting_name' => 'force_gsm_alphabet', 'csrf' => $_SESSION['csrf']]); ?>" method="POST">
|
||||
<div class="form-group">
|
||||
<label>Optimiser la taille des SMS en remplaçant les caractères spéciaux par leur équivalent GSM 7-bit : </label>
|
||||
<select name="setting_value" class="form-control">
|
||||
<option value="0">Non</option>
|
||||
<option value="1" <?php echo $_SESSION['user']['settings']['force_gsm_alphabet'] ? 'selected' : ''; ?>>Oui</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<button class="btn btn-success">Mettre à jour les données</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><i class="fa fa-picture-o fa-fw"></i> Support des MMS</h4>
|
||||
|
|
Loading…
Reference in New Issue