From 13f418c7d677c883fd286a18080220f043a23af5 Mon Sep 17 00:00:00 2001 From: boffart <> Date: Thu, 8 Aug 2024 14:45:14 +0300 Subject: [PATCH] =?UTF-8?q?#734=20=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=D0=BB=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D0=BA=D1=83=20indications.conf=20=D1=81=D0=B8=D0=BD=D1=85?= =?UTF-8?q?=D1=80=D0=BE=D0=BD=D0=B8=D0=B7=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BB=20=D1=81=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D0=BD?= =?UTF-8?q?=D1=8B=D0=BC=20=D1=8F=D0=B7=D1=8B=D0=BA=D0=BE=D0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Core/Asterisk/Configs/IndicationConf.php | 24 ++++++-- src/Core/Asterisk/Configs/SIPConf.php | 16 +----- .../Configs/Samples/indications.conf.sample | 56 ------------------- src/Core/System/PBX.php | 8 +++ 4 files changed, 28 insertions(+), 76 deletions(-) diff --git a/src/Core/Asterisk/Configs/IndicationConf.php b/src/Core/Asterisk/Configs/IndicationConf.php index b07ea4ee1..a3a111c32 100644 --- a/src/Core/Asterisk/Configs/IndicationConf.php +++ b/src/Core/Asterisk/Configs/IndicationConf.php @@ -20,6 +20,8 @@ namespace MikoPBX\Core\Asterisk\Configs; +use MikoPBX\Common\Models\PbxSettings; +use MikoPBX\Common\Models\PbxSettingsConstants; use MikoPBX\Core\System\Util; use function MikoPBX\Common\Config\appPath; @@ -32,8 +34,21 @@ */ class IndicationConf extends AsteriskConfigClass { - // The module hook applying priority - public int $priority = 1000; + public const LANG_ZONE_MAP = [ + 'ru-ru' => 'ru', + 'en-en' => 'us', + 'en-gb' => 'uk', + 'de-de' => 'de', + 'da-dk' => 'dk', + 'es-es' => 'es', + 'gr-gr' => 'gr', + 'fr-ca' => 'fr', + 'it-it' => 'it', + 'ja-jp' => 'jp', + 'nl-nl' => 'nl', + 'pl-pl' => 'pl', + 'pt-br' => 'pt', + ]; protected string $description = 'indications.conf'; @@ -44,13 +59,12 @@ class IndicationConf extends AsteriskConfigClass */ protected function generateConfigProtected(): void { - $country = 'ru'; // TODO: Add to the interface if it's an important option + $lang = PbxSettings::getValueByKey(PbxSettingsConstants::PBX_LANGUAGE); + $country = self::LANG_ZONE_MAP[$lang] ?? 'ru'; $filePath = appPath('src/Core/Asterisk/Configs/Samples/indications.conf.sample'); $data = file_get_contents($filePath); $conf = str_replace('{country}', $country, $data); - // Write the configuration content to the file Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/indications.conf', $conf); } - } \ No newline at end of file diff --git a/src/Core/Asterisk/Configs/SIPConf.php b/src/Core/Asterisk/Configs/SIPConf.php index c57474b68..ab6ccdc63 100644 --- a/src/Core/Asterisk/Configs/SIPConf.php +++ b/src/Core/Asterisk/Configs/SIPConf.php @@ -1127,21 +1127,7 @@ public static function getContextId(string $name, string $port):string */ public static function getToneZone(array &$options, string $lang): void { - $settings = [ - 'ru-ru' => 'ru', - 'en-gb' => 'uk', - 'de-de' => 'de', - 'da-dk' => 'dk', - 'es-es' => 'es', - 'gr-gr' => 'gr', - 'fr-ca' => 'fr', - 'it-it' => 'it', - 'ja-jp' => 'jp', - 'nl-nl' => 'nl', - 'pl-pl' => 'pl', - 'pt-br' => 'pt', - ]; - $toneZone = $settings[$lang] ?? ''; + $toneZone = IndicationConf::LANG_ZONE_MAP[$lang] ?? ''; if ( ! empty($toneZone)) { $options['inband_progress'] = 'yes'; $options['tone_zone'] = $toneZone; diff --git a/src/Core/Asterisk/Configs/Samples/indications.conf.sample b/src/Core/Asterisk/Configs/Samples/indications.conf.sample index c5c63615f..85d73b008 100644 --- a/src/Core/Asterisk/Configs/Samples/indications.conf.sample +++ b/src/Core/Asterisk/Configs/Samples/indications.conf.sample @@ -1,62 +1,6 @@ -; -; indications.conf -; -; Configuration file for location specific tone indications -; - -; -; NOTE: -; When adding countries to this file, please keep them in alphabetical -; order according to the 2-character country codes! -; -; The [general] category is for certain global variables. -; All other categories are interpreted as location specific indications -; - [general] country={country} - -; [example] -; description = string -; The full name of your country, in English. -; ringcadence = num[,num]* -; List of durations the physical bell rings. -; dial = tonelist -; Set of tones to be played when one picks up the hook. -; busy = tonelist -; Set of tones played when the receiving end is busy. -; congestion = tonelist -; Set of tones played when there is some congestion (on the network?) -; callwaiting = tonelist -; Set of tones played when there is a call waiting in the background. -; dialrecall = tonelist -; Not well defined; many phone systems play a recall dial tone after hook -; flash. -; record = tonelist -; Set of tones played when call recording is in progress. -; info = tonelist -; Set of tones played with special information messages (e.g., "number is -; out of service") -; name = tonelist -; Every other variable will be available as a shortcut for the "PlayList" command -; but will not be used automatically by Asterisk. -; -; -; The tonelist itself is defined by a comma-separated sequence of elements. -; Each element consist of a frequency (f) with an optional duration (in ms) -; attached to it (f/duration). The frequency component may be a mixture of two -; frequencies (f1+f2) or a frequency modulated by another frequency (f1*f2). -; The implicit modulation depth is fixed at 90%, though. -; If the list element starts with a !, that element is NOT repeated, -; therefore, only if all elements start with !, the tonelist is time-limited, -; all others will repeat indefinitely. -; -; concisely: -; element = [!]freq[+|*freq2][/duration] -; tonelist = element[,element]* -; - [at] description = Austria ringcadence = 1000,5000 diff --git a/src/Core/System/PBX.php b/src/Core/System/PBX.php index 8f12b3472..7934c96ae 100644 --- a/src/Core/System/PBX.php +++ b/src/Core/System/PBX.php @@ -35,6 +35,7 @@ FeaturesConf, HttpConf, IAXConf, + IndicationConf, ManagerConf, ModulesConf, MusicOnHoldConf, @@ -163,6 +164,9 @@ public static function coreReload(): void $asteriskConf = new AsteriskConf(); $asteriskConf->generateConfig(); + $indicationConf = new IndicationConf(); + $indicationConf->generateConfig(); + $arr_out = []; $asteriskPath = Util::which('asterisk'); Processes::mwExec("{$asteriskPath} -rx 'core reload'", $arr_out); @@ -175,6 +179,10 @@ public static function coreRestart(): void { $asteriskConf = new AsteriskConf(); $asteriskConf->generateConfig(); + + $indicationConf = new IndicationConf(); + $indicationConf->generateConfig(); + $asteriskPath = Util::which('asterisk'); Processes::mwExec("{$asteriskPath} -rx 'core restart now'"); }