Passed
Push — develop ( 3db452...b7dcac )
by Nikolay
05:45
created
src/Core/Workers/Cron/WorkerSafeScriptsCore.php 3 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
         $this->waitFullyBooted();
43 43
 
44 44
         ReactKernel::start(
45
-            function () {
45
+            function() {
46 46
                 // Parallel execution https://github.com/recoilphp/recoil
47 47
                 try {
48 48
                     yield [
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
                 } catch (\Exception $e) {
62 62
                     global $errorLogger;
63 63
                     $errorLogger->captureException($e);
64
-                    Util::sysLogMsg(__CLASS__ . '_EXCEPTION', $e->getMessage());
64
+                    Util::sysLogMsg(__CLASS__.'_EXCEPTION', $e->getMessage());
65 65
                 }
66 66
             }
67 67
         );
@@ -69,17 +69,17 @@  discard block
 block discarded – undo
69 69
         // Modules workers
70 70
         $arrModulesWorkers = [];
71 71
         $pbxConfModules = $this->di->getShared('pbxConfModules');
72
-        foreach ($pbxConfModules as $pbxConfModule){
72
+        foreach ($pbxConfModules as $pbxConfModule) {
73 73
             $arrModulesWorkers[] = $pbxConfModule->getModuleWorkers();
74 74
         }
75 75
         $arrModulesWorkers = array_merge(...$arrModulesWorkers);
76
-        if (count($arrModulesWorkers)>0){
76
+        if (count($arrModulesWorkers) > 0) {
77 77
             ReactKernel::start(
78
-                function () use ($arrModulesWorkers){
78
+                function() use ($arrModulesWorkers){
79 79
                     // Parallel execution https://github.com/recoilphp/recoil
80 80
                     try {
81
-                        foreach ($arrModulesWorkers as $type=>$moduleWorker){
82
-                            if ($type===self::CHECK_BY_AMI){
81
+                        foreach ($arrModulesWorkers as $type=>$moduleWorker) {
82
+                            if ($type === self::CHECK_BY_AMI) {
83 83
                                 yield $this->checkWorkerAMI($moduleWorker);
84 84
                             } else {
85 85
                                 yield $this->checkWorkerBeanstalk($moduleWorker);
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
                     } catch (\Exception $e) {
89 89
                         global $errorLogger;
90 90
                         $errorLogger->captureException($e);
91
-                        Util::sysLogMsg(__CLASS__ . '_EXCEPTION', $e->getMessage());
91
+                        Util::sysLogMsg(__CLASS__.'_EXCEPTION', $e->getMessage());
92 92
                     }
93 93
                 }
94 94
             );
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
     {
107 107
         $time_start = microtime(true);
108 108
         $result = false;
109
-        $out      = [];
109
+        $out = [];
110 110
         if (Util::isSystemctl()) {
111 111
             $options = '';
112 112
         } else {
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function checkWorkerBeanstalk($workerClassName): ?Generator
141 141
     {
142
-        $WorkerPID    = Util::getPidOfProcess($workerClassName);
142
+        $WorkerPID = Util::getPidOfProcess($workerClassName);
143 143
         $result = false;
144 144
         if ($WorkerPID !== '') {
145 145
             // We had service PID, so we will ping it
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -42,7 +42,8 @@  discard block
 block discarded – undo
42 42
         $this->waitFullyBooted();
43 43
 
44 44
         ReactKernel::start(
45
-            function () {
45
+            function ()
46
+            {
46 47
                 // Parallel execution https://github.com/recoilphp/recoil
47 48
                 try {
48 49
                     yield [
@@ -75,7 +76,8 @@  discard block
 block discarded – undo
75 76
         $arrModulesWorkers = array_merge(...$arrModulesWorkers);
76 77
         if (count($arrModulesWorkers)>0){
77 78
             ReactKernel::start(
78
-                function () use ($arrModulesWorkers){
79
+                function () use ($arrModulesWorkers)
80
+                {
79 81
                     // Parallel execution https://github.com/recoilphp/recoil
80 82
                     try {
81 83
                         foreach ($arrModulesWorkers as $type=>$moduleWorker){
Please login to merge, or discard this patch.
Upper-Lower-Casing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
         }
144 144
         if (false === $result) {
145 145
             Util::restartPHPWorker($workerClassName);
146
-            Util::sysLogMsg(__CLASS__, "Service {$workerClassName} started.");
146
+            Util::sysLogMsg(__CLASS__, "service {$workerClassName} started.");
147 147
         }
148 148
         yield;
149 149
     }
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 
173 173
         if ($res_ping === false && $level < 10) {
174 174
             Util::restartPHPWorker($workerClassName);
175
-            Util::sysLogMsg(__CLASS__, "Service {$workerClassName} started.");
175
+            Util::sysLogMsg(__CLASS__, "service {$workerClassName} started.");
176 176
             // Wait 5 seconds while service will be ready to listen requests
177 177
             sleep(5);
178 178
 
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/QueueConf.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
             $q_conf .= "\n";
85 85
         }
86 86
 
87
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/queues.conf', $q_conf);
87
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/queues.conf', $q_conf);
88 88
 
89 89
     }
90 90
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         $conf = "[queue_agent_answer]\n";
140 140
         $conf .= "exten => s,1,NoOp(--- Answer Queue ---)\n\t";
141 141
         // $conf .= "same => n,AGI(cdr_connector.php,queue_answer)\n\t";
142
-        $conf .= 'same => n,Gosub(queue_answer,${EXTEN},1)' . "\n\t";
142
+        $conf .= 'same => n,Gosub(queue_answer,${EXTEN},1)'."\n\t";
143 143
         $conf .= "same => n,Return()\n\n";
144 144
 
145 145
         return $conf;
@@ -169,8 +169,8 @@  discard block
 block discarded – undo
169 169
         $conf = '';
170 170
         $db_data = $this->getQueueData();
171 171
         foreach ($db_data as $queue) {
172
-            $conf .= 'exten => _' . $queue['extension'] . ',1,Set(__ISTRANSFER=transfer_)' . " \n\t";
173
-            $conf .= 'same => n,Goto(internal,${EXTEN},1)' . " \n";
172
+            $conf .= 'exten => _'.$queue['extension'].',1,Set(__ISTRANSFER=transfer_)'." \n\t";
173
+            $conf .= 'same => n,Goto(internal,${EXTEN},1)'." \n";
174 174
         }
175 175
         $conf .= "\n";
176 176
 
@@ -191,32 +191,32 @@  discard block
 block discarded – undo
191 191
         foreach ($db_data as $queue) {
192 192
             $queue_ext_conf .= "exten => {$queue['extension']},1,NoOp(--- Start Queue ---) \n\t";
193 193
             $queue_ext_conf .= "same => n,Answer() \n\t";
194
-            $queue_ext_conf .= 'same => n,Set(__QUEUE_SRC_CHAN=${CHANNEL})' . "\n\t";
195
-            $queue_ext_conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))' . "\n\t";
196
-            $queue_ext_conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t";
194
+            $queue_ext_conf .= 'same => n,Set(__QUEUE_SRC_CHAN=${CHANNEL})'."\n\t";
195
+            $queue_ext_conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))'."\n\t";
196
+            $queue_ext_conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t";
197 197
             // $queue_ext_conf .= 'same => n,AGI(cdr_connector.php,queue_start)'."\n\t";
198
-            $queue_ext_conf .= 'same => n,Gosub(queue_start,${EXTEN},1)' . "\n\t";
198
+            $queue_ext_conf .= 'same => n,Gosub(queue_start,${EXTEN},1)'."\n\t";
199 199
 
200 200
             $options = '';
201 201
             if (isset($queue['caller_hear']) && $queue['caller_hear'] === 'ringing') {
202 202
                 $options .= 'r'; // Установить КПВ (гудки) вместо Музыки на Удержании для ожидающих в очереди
203 203
             }
204
-            $ringlength     = (trim(
204
+            $ringlength = (trim(
205 205
                     $queue['timeout_to_redirect_to_extension']
206 206
                 ) == '') ? 120 : $queue['timeout_to_redirect_to_extension'];
207 207
             $queue_ext_conf .= "same => n,Queue({$queue['uniqid']},kT{$options},,,{$ringlength},,,queue_agent_answer) \n\t";
208 208
             // Оповестим о завершении работы очереди.
209 209
             // $queue_ext_conf .= 'same => n,AGI(cdr_connector.php,queue_end)'."\n\t";
210
-            $queue_ext_conf .= 'same => n,Gosub(queue_end,${EXTEN},1)' . "\n\t";
210
+            $queue_ext_conf .= 'same => n,Gosub(queue_end,${EXTEN},1)'."\n\t";
211 211
 
212 212
             if (trim($queue['timeout_extension']) !== '') {
213 213
                 // Если по таймауту не ответили, то выполним переадресацию.
214
-                $queue_ext_conf .= 'same => n,ExecIf($["${QUEUESTATUS}" == "TIMEOUT"]?Goto(internal,' . $queue['timeout_extension'] . ',1))' . " \n\t";
214
+                $queue_ext_conf .= 'same => n,ExecIf($["${QUEUESTATUS}" == "TIMEOUT"]?Goto(internal,'.$queue['timeout_extension'].',1))'." \n\t";
215 215
             }
216 216
             if (trim($queue['redirect_to_extension_if_empty']) !== '') {
217 217
                 // Если пустая очередь, то выполним переадресацию.
218
-                $exp            = '$["${QUEUESTATUS}" == "JOINEMPTY" || "${QUEUESTATUS}" == "LEAVEEMPTY" ]';
219
-                $queue_ext_conf .= 'same => n,ExecIf(' . $exp . '?Goto(internal,' . $queue['redirect_to_extension_if_empty'] . ',1))' . " \n\t";
218
+                $exp = '$["${QUEUESTATUS}" == "JOINEMPTY" || "${QUEUESTATUS}" == "LEAVEEMPTY" ]';
219
+                $queue_ext_conf .= 'same => n,ExecIf('.$exp.'?Goto(internal,'.$queue['redirect_to_extension_if_empty'].',1))'." \n\t";
220 220
             }
221 221
             $queue_ext_conf .= "\n";
222 222
         }
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/IndicationConf.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -20,11 +20,11 @@
 block discarded – undo
20 20
 
21 21
     protected function generateConfigProtected(): void
22 22
     {
23
-        $country = 'ru';//TODO:: Добавить в интерфейс если это важная опция
23
+        $country = 'ru'; //TODO:: Добавить в интерфейс если это важная опция
24 24
         $filePath = appPath('src/Core/Asterisk/Configs/Samples/indications.conf.sample');
25 25
         $data     = file_get_contents($filePath);
26 26
         $conf     = str_replace('{country}', $country, $data);
27
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/indications.conf', $conf);
27
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/indications.conf', $conf);
28 28
     }
29 29
 
30 30
 }
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/DialplanApplicationConf.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -64,9 +64,9 @@  discard block
 block discarded – undo
64 64
         $app_data = '';
65 65
         foreach ($arr_data_app as $row) {
66 66
             if ('' === $app_data) {
67
-                $app_data .= "exten => _{$app['extension']},$row" . "\n\t";
67
+                $app_data .= "exten => _{$app['extension']},$row"."\n\t";
68 68
             } else {
69
-                $app_data .= "same => $row" . "\n\t";
69
+                $app_data .= "same => $row"."\n\t";
70 70
             }
71 71
         }
72 72
 
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
     private function generatePhpApp($app): string
82 82
     {
83 83
         $agiBinDir = $this->config->path('asterisk.astagidir');
84
-        $text_app     = "#!/usr/bin/php\n";
85
-        $text_app     .= base64_decode($app['applicationlogic']);
84
+        $text_app = "#!/usr/bin/php\n";
85
+        $text_app .= base64_decode($app['applicationlogic']);
86 86
         file_put_contents("{$agiBinDir}/{$app['uniqid']}.php", $text_app);
87 87
         chmod("{$agiBinDir}/{$app['uniqid']}.php", 0755);
88 88
 
89
-        $result = 'exten => _' . $app['extension'] . ',1,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))' . "\n\t";
90
-        $result .= 'same => n,Gosub(dial_app,${EXTEN},1)' . "\n\t";
89
+        $result = 'exten => _'.$app['extension'].',1,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))'."\n\t";
90
+        $result .= 'same => n,Gosub(dial_app,${EXTEN},1)'."\n\t";
91 91
         $result .= "same => n,AGI({$app['uniqid']}.php)\n";
92 92
 
93 93
         return $result;
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/ModulesConf.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 
19 19
     protected function generateConfigProtected(): void
20 20
     {
21
-        $conf = "[modules]\n" .
21
+        $conf = "[modules]\n".
22 22
             "autoload=no\n";
23 23
         $modules = [];
24 24
         $modules[] = [
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
                 'res_pjsip_dlg_options.so',
181 181
                 'res_security_log.so',
182 182
             ];
183
-            file_put_contents($this->config->path('asterisk.astetcdir') . '/pjproject.conf', '');
184
-            file_put_contents($this->config->path('asterisk.astetcdir') . '/sorcery.conf', '');
185
-            file_put_contents($this->config->path('asterisk.astetcdir') . '/pjsip_notify.conf', '');
183
+            file_put_contents($this->config->path('asterisk.astetcdir').'/pjproject.conf', '');
184
+            file_put_contents($this->config->path('asterisk.astetcdir').'/sorcery.conf', '');
185
+            file_put_contents($this->config->path('asterisk.astetcdir').'/pjsip_notify.conf', '');
186 186
         } else {
187 187
             $modules[] = [
188 188
                 'chan_sip.so',
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
             $conf .= $appClass->generateModulesConf();
200 200
         }
201 201
 
202
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/modules.conf', $conf);
203
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/codecs.conf', '');
202
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/modules.conf', $conf);
203
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/codecs.conf', '');
204 204
     }
205 205
 }
206 206
\ No newline at end of file
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/ExtensionsConf.php 1 patch
Spacing   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     {
25 25
         $additionalModules = $this->di->getShared('pbxConfModules');
26 26
         $conf              = "[globals] \n";
27
-        $conf              .= "TRANSFER_CONTEXT=internal-transfer; \n";
27
+        $conf .= "TRANSFER_CONTEXT=internal-transfer; \n";
28 28
         foreach ($additionalModules as $appClass) {
29 29
             $conf .= $appClass->extensionGlobals();
30 30
         }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
         // Переключатель по времени.
49 49
         $this->generateOutWorkTimes($conf);
50 50
 
51
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/extensions.conf', $conf);
51
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/extensions.conf', $conf);
52 52
     }
53 53
 
54 54
     /**
@@ -60,72 +60,72 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $extension = 'X!';
62 62
         // Контекст для AMI originate. Без него отображается не корректный CallerID.
63
-        $conf .= '[sipregistrations]' . "\n\n";
63
+        $conf .= '[sipregistrations]'."\n\n";
64 64
 
65
-        $conf .= '[messages]' . "\n" .
66
-            'exten => _' . $extension . ',1,MessageSend(sip:${EXTEN},"${CALLERID(name)}"${MESSAGE(from)})' . "\n\n";
65
+        $conf .= '[messages]'."\n".
66
+            'exten => _'.$extension.',1,MessageSend(sip:${EXTEN},"${CALLERID(name)}"${MESSAGE(from)})'."\n\n";
67 67
 
68
-        $conf .= '[internal-originate]' . " \n";
69
-        $conf .= 'exten => _' . $extension . ',1,NoOP(Hint ${HINT} exten ${EXTEN} )' . " \n";
70
-        $conf .= '; Если это originate, то скроем один CDR.' . " \n\t";
71
-        $conf .= 'same => n,ExecIf($["${pt1c_cid}x" != "x"]?Set(CALLERID(num)=${pt1c_cid}))' . " \n\t";
68
+        $conf .= '[internal-originate]'." \n";
69
+        $conf .= 'exten => _'.$extension.',1,NoOP(Hint ${HINT} exten ${EXTEN} )'." \n";
70
+        $conf .= '; Если это originate, то скроем один CDR.'." \n\t";
71
+        $conf .= 'same => n,ExecIf($["${pt1c_cid}x" != "x"]?Set(CALLERID(num)=${pt1c_cid}))'." \n\t";
72 72
 
73
-        $conf .= 'same => n,ExecIf($["${CUT(CHANNEL,\;,2)}" == "2"]?Set(__PT1C_SIP_HEADER=${SIPADDHEADER}))' . " \n\t";
74
-        $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Set(ADDITIONAL_PEER=&Local/${peer_mobile}@outgoing/n))' . " \n\t";
73
+        $conf .= 'same => n,ExecIf($["${CUT(CHANNEL,\;,2)}" == "2"]?Set(__PT1C_SIP_HEADER=${SIPADDHEADER}))'." \n\t";
74
+        $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Set(ADDITIONAL_PEER=&Local/${peer_mobile}@outgoing/n))'." \n\t";
75 75
 
76 76
         // Описываем возможность прыжка в пользовательский sub контекст.
77
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t";
78
-        $conf .= 'same => n,Dial(Local/${EXTEN}@internal-users/n${ADDITIONAL_PEER},60,TteKkHhb(originate_create_chan,s,1))' . " \n\n";
77
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t";
78
+        $conf .= 'same => n,Dial(Local/${EXTEN}@internal-users/n${ADDITIONAL_PEER},60,TteKkHhb(originate_create_chan,s,1))'." \n\n";
79 79
 
80
-        $conf .= '[macro-dial_answer]' . "\n";
80
+        $conf .= '[macro-dial_answer]'."\n";
81 81
         // $conf.= 'exten => s,1,AGI(cdr_connector.php,${ISTRANSFER}dial_answer)'."\n\n";
82
-        $conf .= 'exten => s,1,Gosub(${ISTRANSFER}dial_answer,${EXTEN},1)' . "\n\n";
83
-
84
-        $conf .= '[originate_create_chan]' . " \n";
85
-        $conf .= 'exten => s,1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t";
86
-        $conf .= 'same => n,return' . " \n\n";
87
-
88
-        $conf .= '[dial_create_chan]' . " \n";
89
-        $conf .= 'exten => s,1,Gosub(lua_${ISTRANSFER}dial_create_chan,${EXTEN},1)' . "\n\t";
90
-        $conf .= 'same => n,Set(pt1c_is_dst=1)' . " \n\t";
91
-        $conf .= 'same => n,ExecIf($["${PT1C_SIP_HEADER}x" != "x"]?Set(PJSIP_HEADER(add,${CUT(PT1C_SIP_HEADER,:,1)})=${CUT(PT1C_SIP_HEADER,:,2)}))' . " \n\t";
92
-        $conf .= 'same => n,Set(__PT1C_SIP_HEADER=${UNDEFINED})' . " \n\t";
93
-        $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . " \n\t";
94
-        $conf .= 'same => n,return' . " \n\n";
95
-
96
-        $conf .= '[hangup_handler]' . "\n";
97
-        $conf .= 'exten => s,1,NoOp(--- hangup - ${CHANNEL} ---)' . "\n\t";
98
-        $conf .= 'same => n,Gosub(hangup_chan,${EXTEN},1)' . "\n\t";
99
-
100
-        $conf .= 'same => n,return' . "\n\n";
101
-
102
-        $conf .= '[set_orign_chan]' . "\n";
103
-        $conf .= 'exten => s,1,Wait(0.2)' . "\n\t";
104
-        $conf .= 'same => n,Set(pl=${IF($["${CHANNEL:-1}" == "1"]?2:1)})' . "\n\t";
105
-        $conf .= 'same => n,Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)})' . "\n\t";
106
-        $conf .= 'same => n,ExecIf($[ "${orign_chan}x" == "x" ]?Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},FROM_CHAN)}))' . "\n\t";
107
-        $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN}x" != "x" ]?Set(__QUEUE_SRC_CHAN=${orign_chan}))' . "\n\t";
108
-        $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN:0:5}" == "Local" ]?Set(__QUEUE_SRC_CHAN=${FROM_CHAN}))' . "\n\t";
109
-        $conf .= 'same => n,ExecIf($[ "${FROM_CHAN}x" == "x" ]?Set(__FROM_CHAN=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)}))' . "\n\t";
110
-        $conf .= 'same => n,return' . "\n\n";
111
-
112
-        $conf .= '[playback]' . "\n";
113
-        $conf .= 'exten => s,1,Playback(hello_demo,noanswer)' . "\n\t";
114
-        $conf .= 'same => n,ExecIf($["${SRC_BRIDGE_CHAN}x" == "x"]?Wait(30))' . "\n\t";
115
-        $conf .= 'same => n,Wait(0.3)' . "\n\t";
116
-        $conf .= 'same => n,Bridge(${SRC_BRIDGE_CHAN},kKTthH)' . "\n\n";
117
-
118
-        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\n";
82
+        $conf .= 'exten => s,1,Gosub(${ISTRANSFER}dial_answer,${EXTEN},1)'."\n\n";
83
+
84
+        $conf .= '[originate_create_chan]'." \n";
85
+        $conf .= 'exten => s,1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t";
86
+        $conf .= 'same => n,return'." \n\n";
87
+
88
+        $conf .= '[dial_create_chan]'." \n";
89
+        $conf .= 'exten => s,1,Gosub(lua_${ISTRANSFER}dial_create_chan,${EXTEN},1)'."\n\t";
90
+        $conf .= 'same => n,Set(pt1c_is_dst=1)'." \n\t";
91
+        $conf .= 'same => n,ExecIf($["${PT1C_SIP_HEADER}x" != "x"]?Set(PJSIP_HEADER(add,${CUT(PT1C_SIP_HEADER,:,1)})=${CUT(PT1C_SIP_HEADER,:,2)}))'." \n\t";
92
+        $conf .= 'same => n,Set(__PT1C_SIP_HEADER=${UNDEFINED})'." \n\t";
93
+        $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'." \n\t";
94
+        $conf .= 'same => n,return'." \n\n";
95
+
96
+        $conf .= '[hangup_handler]'."\n";
97
+        $conf .= 'exten => s,1,NoOp(--- hangup - ${CHANNEL} ---)'."\n\t";
98
+        $conf .= 'same => n,Gosub(hangup_chan,${EXTEN},1)'."\n\t";
99
+
100
+        $conf .= 'same => n,return'."\n\n";
101
+
102
+        $conf .= '[set_orign_chan]'."\n";
103
+        $conf .= 'exten => s,1,Wait(0.2)'."\n\t";
104
+        $conf .= 'same => n,Set(pl=${IF($["${CHANNEL:-1}" == "1"]?2:1)})'."\n\t";
105
+        $conf .= 'same => n,Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)})'."\n\t";
106
+        $conf .= 'same => n,ExecIf($[ "${orign_chan}x" == "x" ]?Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},FROM_CHAN)}))'."\n\t";
107
+        $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN}x" != "x" ]?Set(__QUEUE_SRC_CHAN=${orign_chan}))'."\n\t";
108
+        $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN:0:5}" == "Local" ]?Set(__QUEUE_SRC_CHAN=${FROM_CHAN}))'."\n\t";
109
+        $conf .= 'same => n,ExecIf($[ "${FROM_CHAN}x" == "x" ]?Set(__FROM_CHAN=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)}))'."\n\t";
110
+        $conf .= 'same => n,return'."\n\n";
111
+
112
+        $conf .= '[playback]'."\n";
113
+        $conf .= 'exten => s,1,Playback(hello_demo,noanswer)'."\n\t";
114
+        $conf .= 'same => n,ExecIf($["${SRC_BRIDGE_CHAN}x" == "x"]?Wait(30))'."\n\t";
115
+        $conf .= 'same => n,Wait(0.3)'."\n\t";
116
+        $conf .= 'same => n,Bridge(${SRC_BRIDGE_CHAN},kKTthH)'."\n\n";
117
+
118
+        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\n";
119 119
 
120 120
         // TODO / Добавление / удаление префиксов на входящий callerid.
121
-        $conf .= '[add-trim-prefix-clid]' . "\n";
122
-        $conf .= 'exten => _.!,1,NoOp(--- Incoming call from ${CALLERID(num)} ---)' . "\n\t";
123
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t";
121
+        $conf .= '[add-trim-prefix-clid]'."\n";
122
+        $conf .= 'exten => _.!,1,NoOp(--- Incoming call from ${CALLERID(num)} ---)'."\n\t";
123
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t";
124 124
         // Отсекаем "+".
125 125
         // $conf.= 'same => n,ExecIf( $["${CALLERID(num):0:1}" == "+"]?Set(CALLERID(num)=${CALLERID(num):1}))'."\n\t";
126 126
         // Отсекаем "7" и добавляем "8".
127 127
         // $conf.= 'same => n,ExecIf( $["${REGEX("^7[0-9]+" ${CALLERID(num)})}" == "1"]?Set(CALLERID(num)=8${CALLERID(num):1}))'."\n\t";
128
-        $conf .= 'same => n,return' . "\n\n";
128
+        $conf .= 'same => n,return'."\n\n";
129 129
     }
130 130
 
131 131
     /**
@@ -144,63 +144,63 @@  discard block
 block discarded – undo
144 144
         }
145 145
         $conf .= "\n";
146 146
         $conf .= "[internal-num-undefined] \n";
147
-        $conf .= 'exten => _' . $extension . ',1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t";
148
-        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . "\n\t";
147
+        $conf .= 'exten => _'.$extension.',1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t";
148
+        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'."\n\t";
149 149
         $conf .= "same => n,Playback(pbx-invalid,noanswer) \n\n";
150 150
 
151 151
         $conf .= "[internal-fw]\n";
152
-        $conf .= 'exten => _' . $extension . ',1,NoOp(DIALSTATUS - ${DIALSTATUS})' . "\n\t";
152
+        $conf .= 'exten => _'.$extension.',1,NoOp(DIALSTATUS - ${DIALSTATUS})'."\n\t";
153 153
         // CANCEL - вызов был отменен, к примеру *0, не нужно дальше искать адресат.
154
-        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CANCEL"]?Hangup())' . "\n\t";
154
+        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CANCEL"]?Hangup())'."\n\t";
155 155
         // BUSY - занято. К примру абонент завершил вызов или DND.
156
-        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "BUSY"]?Set(dstatus=FW_BUSY))' . "\n\t";
156
+        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "BUSY"]?Set(dstatus=FW_BUSY))'."\n\t";
157 157
         // CHANUNAVAIL - канал не доступен. К примеру телефон не зарегистрирован или не отвечает.
158
-        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CHANUNAVAIL"]?Set(dstatus=FW_UNAV))' . "\n\t";
158
+        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CHANUNAVAIL"]?Set(dstatus=FW_UNAV))'."\n\t";
159 159
         // NOANSWER - не ответили по таймауту.
160
-        $conf .= 'same => n,ExecIf($["${dstatus}x" == "x"]?Set(dstatus=FW))' . "\n\t";
161
-        $conf .= 'same => n,Set(fw=${DB(${dstatus}/${EXTEN})})' . "\n\t";
162
-        $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Set(__pt1c_UNIQUEID=${UNDEFINED})' . "\n\t";
163
-        $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Goto(internal,${fw},1))' . "\n\t";
164
-        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . "\n\t";
165
-        $conf .= 'same => n,Hangup() ' . "\n\n";
160
+        $conf .= 'same => n,ExecIf($["${dstatus}x" == "x"]?Set(dstatus=FW))'."\n\t";
161
+        $conf .= 'same => n,Set(fw=${DB(${dstatus}/${EXTEN})})'."\n\t";
162
+        $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Set(__pt1c_UNIQUEID=${UNDEFINED})'."\n\t";
163
+        $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Goto(internal,${fw},1))'."\n\t";
164
+        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'."\n\t";
165
+        $conf .= 'same => n,Hangup() '."\n\n";
166 166
 
167 167
         $conf .= "[all_peers]\n";
168
-        $conf .= 'include => internal-hints' . "\n";
169
-        $conf .= 'exten => failed,1,Hangup()' . "\n";
168
+        $conf .= 'include => internal-hints'."\n";
169
+        $conf .= 'exten => failed,1,Hangup()'."\n";
170 170
 
171
-        $conf .= 'exten => _.!,1,ExecIf($[ "${EXTEN}" == "h" ]?Hangup())' . "\n\t";
172
-        $conf .= 'same => n,Set(__FROM_CHAN=${CHANNEL})' . "\n\t";
173
-        $conf .= 'same => n,ExecIf($["${OLD_LINKEDID}x" == "x"]?Set(__OLD_LINKEDID=${CDR(linkedid)}))' . "\n\t";
174
-        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))' . "\n\t";
175
-        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))' . "\n\t";
171
+        $conf .= 'exten => _.!,1,ExecIf($[ "${EXTEN}" == "h" ]?Hangup())'."\n\t";
172
+        $conf .= 'same => n,Set(__FROM_CHAN=${CHANNEL})'."\n\t";
173
+        $conf .= 'same => n,ExecIf($["${OLD_LINKEDID}x" == "x"]?Set(__OLD_LINKEDID=${CDR(linkedid)}))'."\n\t";
174
+        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))'."\n\t";
175
+        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))'."\n\t";
176 176
 
177
-        $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(num)=${FROM_PEER}))' . "\n\t";
178
-        $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(name)=${FROM_PEER}))' . "\n\t";
177
+        $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(num)=${FROM_PEER}))'."\n\t";
178
+        $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(name)=${FROM_PEER}))'."\n\t";
179 179
 
180
-        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local" && "${FROM_PEER}x" == "x"]?Set(__FROM_PEER=${CALLERID(num)}))' . "\n\t";
181
-        $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t";
182
-        $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)' . "\n\t";
180
+        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local" && "${FROM_PEER}x" == "x"]?Set(__FROM_PEER=${CALLERID(num)}))'."\n\t";
181
+        $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t";
182
+        $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)'."\n\t";
183 183
 
184 184
         // Описываем возможность прыжка в пользовательский sub контекст.
185
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t";
185
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t";
186 186
 
187
-        $conf .= 'same => n,Goto(peer_${FROM_PEER},${EXTEN},1)' . "\n\n";
187
+        $conf .= 'same => n,Goto(peer_${FROM_PEER},${EXTEN},1)'."\n\n";
188 188
 
189 189
         $pickupexten = $this->mikoPBXConfig->getPickupExten();
190
-        $conf        .= 'exten => _' . $pickupexten . $extension . ',1,Set(PICKUPEER=' . $technology . '/${FILTER(0-9,${EXTEN:2})})' . "\n\t";
191
-        $conf        .= 'same => n,Set(pt1c_dnid=${EXTEN})' . "\n\t";
192
-        $conf        .= 'same => n,PickupChan(${PICKUPEER})' . "\n\t";
193
-        $conf        .= 'same => n,Hangup()' . "\n\n";
190
+        $conf        .= 'exten => _'.$pickupexten.$extension.',1,Set(PICKUPEER='.$technology.'/${FILTER(0-9,${EXTEN:2})})'."\n\t";
191
+        $conf        .= 'same => n,Set(pt1c_dnid=${EXTEN})'."\n\t";
192
+        $conf        .= 'same => n,PickupChan(${PICKUPEER})'."\n\t";
193
+        $conf        .= 'same => n,Hangup()'."\n\n";
194 194
 
195 195
         $voicemail_exten = $this->mikoPBXConfig->getVoicemailExten();
196
-        $conf            .= 'exten => ' . $voicemail_exten . ',1,NoOp(NOTICE, Dialing out from ${CALLERID(all)} to VoiceMail)' . "\n\t";
197
-        $conf            .= 'same => n,VoiceMailMain(admin@voicemailcontext,s)' . "\n\t";
198
-        $conf            .= 'same => n,Hangup()' . "\n\n";
196
+        $conf            .= 'exten => '.$voicemail_exten.',1,NoOp(NOTICE, Dialing out from ${CALLERID(all)} to VoiceMail)'."\n\t";
197
+        $conf            .= 'same => n,VoiceMailMain(admin@voicemailcontext,s)'."\n\t";
198
+        $conf            .= 'same => n,Hangup()'."\n\n";
199 199
 
200 200
         $conf .= "[voice_mail_peer] \n";
201
-        $conf .= 'exten => voicemail,1,Answer()' . "\n\t";
202
-        $conf .= 'same => n,VoiceMail(admin@voicemailcontext)' . "\n\t";
203
-        $conf .= 'same => n,Hangup()' . "\n\n";
201
+        $conf .= 'exten => voicemail,1,Answer()'."\n\t";
202
+        $conf .= 'same => n,VoiceMail(admin@voicemailcontext)'."\n\t";
203
+        $conf .= 'same => n,Hangup()'."\n\n";
204 204
 
205 205
         // Контекст для внутренних вызовов.
206 206
         $conf .= "[internal] \n";
@@ -213,51 +213,51 @@  discard block
 block discarded – undo
213 213
             $conf .= $appClass->extensionGenInternal();
214 214
         }
215 215
 
216
-        $conf .= 'exten => i,1,NoOp(-- INVALID NUMBER --)' . "\n\t";
217
-        $conf .= 'same => n,Set(DIALSTATUS=INVALID_NUMBER)' . "\n\t";
218
-        $conf .= 'same => n,Playback(privacy-incorrect,noanswer)' . "\n\t";
219
-        $conf .= 'same => n,Hangup()' . "\n";
216
+        $conf .= 'exten => i,1,NoOp(-- INVALID NUMBER --)'."\n\t";
217
+        $conf .= 'same => n,Set(DIALSTATUS=INVALID_NUMBER)'."\n\t";
218
+        $conf .= 'same => n,Playback(privacy-incorrect,noanswer)'."\n\t";
219
+        $conf .= 'same => n,Hangup()'."\n";
220 220
 
221
-        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\n";
221
+        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\n";
222 222
 
223 223
         $conf .= "[internal-incoming]\n";
224
-        $conf .= 'exten => _.!,1,ExecIf($["${MASTER_CHANNEL(M_TIMEOUT)}x" != "x"]?Set(TIMEOUT(absolute)=${MASTER_CHANNEL(M_TIMEOUT)}))' . " \n\t";
225
-        $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT_CHANNEL)=${CHANNEL})' . " \n\t";
226
-        $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT)=${EMPTY_VAR})' . " \n\t";
227
-        $conf .= 'same => n,Goto(internal,${EXTEN},1)' . " \n\n";
224
+        $conf .= 'exten => _.!,1,ExecIf($["${MASTER_CHANNEL(M_TIMEOUT)}x" != "x"]?Set(TIMEOUT(absolute)=${MASTER_CHANNEL(M_TIMEOUT)}))'." \n\t";
225
+        $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT_CHANNEL)=${CHANNEL})'." \n\t";
226
+        $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT)=${EMPTY_VAR})'." \n\t";
227
+        $conf .= 'same => n,Goto(internal,${EXTEN},1)'." \n\n";
228 228
 
229 229
         $conf .= "[internal-users] \n";
230
-        $conf .= 'exten => _' . $extension . ',1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . " \n\t";
231
-        $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Set(SIPADDHEADER01=${EMPTY_VAR})' . " \n\t";
232
-        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))' . " \n\t";
230
+        $conf .= 'exten => _'.$extension.',1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'." \n\t";
231
+        $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Set(SIPADDHEADER01=${EMPTY_VAR})'." \n\t";
232
+        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))'." \n\t";
233 233
 
234
-        $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)' . "\n\t";
234
+        $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)'."\n\t";
235 235
         // Проверим, существует ли такой пир.
236 236
 
237
-        $conf .= 'same => n,ExecIf($["${PJSIP_ENDPOINT(${EXTEN},auth)}x" == "x"]?Goto(internal-num-undefined,${EXTEN},1))' . " \n\t";
238
-        $conf .= 'same => n,ExecIf($["${DEVICE_STATE(' . $technology . '/${EXTEN})}" == "BUSY"]?Set(DIALSTATUS=BUSY))' . " \n\t";
239
-        $conf .= 'same => n,GotoIf($["${DEVICE_STATE(' . $technology . '/${EXTEN})}" == "BUSY"]?fw_start)' . " \n\t";
237
+        $conf .= 'same => n,ExecIf($["${PJSIP_ENDPOINT(${EXTEN},auth)}x" == "x"]?Goto(internal-num-undefined,${EXTEN},1))'." \n\t";
238
+        $conf .= 'same => n,ExecIf($["${DEVICE_STATE('.$technology.'/${EXTEN})}" == "BUSY"]?Set(DIALSTATUS=BUSY))'." \n\t";
239
+        $conf .= 'same => n,GotoIf($["${DEVICE_STATE('.$technology.'/${EXTEN})}" == "BUSY"]?fw_start)'." \n\t";
240 240
 
241 241
         // Как долго звонить пиру.
242
-        $conf .= 'same => n,Set(ringlength=${DB(FW_TIME/${EXTEN})})' . " \n\t";
243
-        $conf .= 'same => n,ExecIf($["${ringlength}x" == "x" || "${QUEUE_SRC_CHAN}x" != "x"]?Set(ringlength=600))' . " \n\t";
242
+        $conf .= 'same => n,Set(ringlength=${DB(FW_TIME/${EXTEN})})'." \n\t";
243
+        $conf .= 'same => n,ExecIf($["${ringlength}x" == "x" || "${QUEUE_SRC_CHAN}x" != "x"]?Set(ringlength=600))'." \n\t";
244 244
 
245
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1) ' . " \n\t";
245
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1) '." \n\t";
246 246
         // Совершаем вызов пира.
247 247
 
248
-        $conf .= 'same => n,Set(DST_CONTACT=${PJSIP_DIAL_CONTACTS(${EXTEN})})' . " \n\t";
249
-        $conf .= 'same => n,ExecIf($["${DST_CONTACT}x" != "x"]?Dial(${DST_CONTACT},${ringlength},TtekKHhU(${ISTRANSFER}dial_answer)b(${ISTRANSFER}dial_create_chan,s,1)):Set(DIALSTATUS=CHANUNAVAIL))' . " \n\t";
248
+        $conf .= 'same => n,Set(DST_CONTACT=${PJSIP_DIAL_CONTACTS(${EXTEN})})'." \n\t";
249
+        $conf .= 'same => n,ExecIf($["${DST_CONTACT}x" != "x"]?Dial(${DST_CONTACT},${ringlength},TtekKHhU(${ISTRANSFER}dial_answer)b(${ISTRANSFER}dial_create_chan,s,1)):Set(DIALSTATUS=CHANUNAVAIL))'." \n\t";
250 250
 
251
-        $conf .= 'same => n(fw_start),NoOp(dial_hangup)' . " \n\t";
251
+        $conf .= 'same => n(fw_start),NoOp(dial_hangup)'." \n\t";
252 252
 
253 253
         // QUEUE_SRC_CHAN - установлена, если вызов сервершен агенту очереди.
254 254
         // Проверяем нужна ли переадресация
255 255
         $expression = '$["${DIALSTATUS}" != "ANSWER" && "${QUEUE_SRC_CHAN}x" == "x"]';
256
-        $conf       .= 'same => n,ExecIf(' . $expression . '?Goto(internal-fw,${EXTEN},1))' . " \n\t";
257
-        $conf       .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . " \n\t";
258
-        $conf       .= 'same => n,Hangup()' . "\n\n";
256
+        $conf       .= 'same => n,ExecIf('.$expression.'?Goto(internal-fw,${EXTEN},1))'." \n\t";
257
+        $conf       .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'." \n\t";
258
+        $conf       .= 'same => n,Hangup()'."\n\n";
259 259
 
260
-        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\n";
260
+        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\n";
261 261
     }
262 262
 
263 263
     /**
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
     private function generateInternalTransfer(&$conf): void
269 269
     {
270 270
         $additionalModules = $this->di->getShared('pbxConfModules');
271
-        $conf              .= "[internal-transfer] \n";
271
+        $conf .= "[internal-transfer] \n";
272 272
 
273 273
         foreach ($additionalModules as $appClass) {
274 274
             $conf .= $appClass->getIncludeInternalTransfer();
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
         foreach ($additionalModules as $appClass) {
278 278
             $conf .= $appClass->extensionGenInternalTransfer();
279 279
         }
280
-        $conf .= 'exten => h,1,Gosub(transfer_dial_hangup,${EXTEN},1)' . "\n\n";
280
+        $conf .= 'exten => h,1,Gosub(transfer_dial_hangup,${EXTEN},1)'."\n\n";
281 281
     }
282 282
 
283 283
     /**
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
     private function generateSipHints(&$conf): void
289 289
     {
290 290
         $additionalModules = $this->di->getShared('pbxConfModules');
291
-        $conf              .= "[internal-hints] \n";
291
+        $conf .= "[internal-hints] \n";
292 292
         foreach ($additionalModules as $appClass) {
293 293
             $conf .= $appClass->extensionGenHints();
294 294
         }
@@ -303,16 +303,16 @@  discard block
 block discarded – undo
303 303
     private function generateOutContextPeers(&$conf): void
304 304
     {
305 305
         $additionalModules = $this->di->getShared('pbxConfModules');
306
-        $conf              .= "[outgoing] \n";
306
+        $conf .= "[outgoing] \n";
307 307
 
308
-        $conf .= 'exten => _+.!,1,NoOp(Strip + sign from number and convert it to 00)' . " \n\t";
309
-        $conf .= 'same => n,Set(ADDPLUS=00);' . " \n\t";
310
-        $conf .= 'same => n,Goto(${CONTEXT},${EXTEN:1},1);' . " \n\n";
311
-        $conf .= 'exten => _X!,1,NoOp(Start outgoing calling...)' . " \n\t";
312
-        $conf .= 'same => n,Ringing()' . " \n\t";
308
+        $conf .= 'exten => _+.!,1,NoOp(Strip + sign from number and convert it to 00)'." \n\t";
309
+        $conf .= 'same => n,Set(ADDPLUS=00);'." \n\t";
310
+        $conf .= 'same => n,Goto(${CONTEXT},${EXTEN:1},1);'." \n\n";
311
+        $conf .= 'exten => _X!,1,NoOp(Start outgoing calling...)'." \n\t";
312
+        $conf .= 'same => n,Ringing()'." \n\t";
313 313
 
314 314
         // Описываем возможность прыжка в пользовательский sub контекст.
315
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t";
315
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t";
316 316
 
317 317
         /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $routs */
318 318
         /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $rout */
@@ -324,63 +324,63 @@  discard block
 block discarded – undo
324 324
             if ($technology !== '') {
325 325
                     $rout_data                       = $rout->toArray();
326 326
                     $rout_data['technology']         = $technology;
327
-                    $id_dialplan                     = $rout_data['providerid'] . '-' . $rout_data['id'] . '-outgoing';
327
+                    $id_dialplan                     = $rout_data['providerid'].'-'.$rout_data['id'].'-outgoing';
328 328
                     $provider_contexts[$id_dialplan] = $rout_data;
329
-                    $conf                            .= $this->generateOutgoingRegexPattern($rout_data);
329
+                    $conf .= $this->generateOutgoingRegexPattern($rout_data);
330 330
                     break;
331 331
             }
332 332
         }
333
-        $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Hangup())' . " \n\t";
334
-        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${BLINDTRANSFER}x" != "x" && "${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t";
335
-        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . " \n\t";
333
+        $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Hangup())'." \n\t";
334
+        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${BLINDTRANSFER}x" != "x" && "${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t";
335
+        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'." \n\t";
336 336
         // $conf.= 'same => n,ExecIf($["${ROUTFOUND}x" == "x"]?AGI(cdr_connector.php,dial))'." \n\t";
337
-        $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" == "x"]?Gosub(dial,${EXTEN},1))' . "\n\t";
337
+        $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" == "x"]?Gosub(dial,${EXTEN},1))'."\n\t";
338 338
 
339
-        $conf .= 'same => n,Playback(silence/2,noanswer)' . " \n\t";
340
-        $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" != "x"]?Playback(followme/sorry,noanswer):Playback(cannot-complete-as-dialed,noanswer))' . " \n\t";
341
-        $conf .= 'same => n,Hangup()' . " \n\n";
339
+        $conf .= 'same => n,Playback(silence/2,noanswer)'." \n\t";
340
+        $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" != "x"]?Playback(followme/sorry,noanswer):Playback(cannot-complete-as-dialed,noanswer))'." \n\t";
341
+        $conf .= 'same => n,Hangup()'." \n\n";
342 342
         // $conf.= 'exten => h,1,AGI(cdr_connector.php,${ISTRANSFER}dial_hangup)'."\n";
343
-        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t";
343
+        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t";
344 344
 
345 345
         foreach ($provider_contexts as $id_dialplan => $rout) {
346 346
             $conf .= "\n[{$id_dialplan}]\n";
347 347
             if (isset($rout['trimfrombegin']) && $rout['trimfrombegin'] > 0) {
348 348
                 // $exten_var = '${ADDPLUS}${EXTEN:'.$rout['trimfrombegin'].'}';
349
-                $exten_var    = '${EXTEN:' . $rout['trimfrombegin'] . '}';
350
-                $change_exten = 'same => n,ExecIf($["${EXTEN}" != "${number}"]?Goto(${CONTEXT},${number},$[${PRIORITY} + 1]))' . "\n\t";
349
+                $exten_var    = '${EXTEN:'.$rout['trimfrombegin'].'}';
350
+                $change_exten = 'same => n,ExecIf($["${EXTEN}" != "${number}"]?Goto(${CONTEXT},${number},$[${PRIORITY} + 1]))'."\n\t";
351 351
             } else {
352 352
                 $exten_var    = '${ADDPLUS}${EXTEN}';
353 353
                 $change_exten = '';
354 354
             }
355
-            $conf .= 'exten => _X!,1,Set(number=' . $rout['prepend'] . $exten_var . ')' . "\n\t";
355
+            $conf .= 'exten => _X!,1,Set(number='.$rout['prepend'].$exten_var.')'."\n\t";
356 356
             $conf .= $change_exten;
357 357
             foreach ($additionalModules as $appClass) {
358 358
                 $conf .= $appClass->generateOutRoutContext($rout);
359 359
             }
360
-            $conf .= 'same => n,ExecIf($["${number}x" == "x"]?Hangup())' . "\n\t";
361
-            $conf .= 'same => n,Set(ROUTFOUND=1)' . "\n\t";
362
-            $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)' . "\n\t";
360
+            $conf .= 'same => n,ExecIf($["${number}x" == "x"]?Hangup())'."\n\t";
361
+            $conf .= 'same => n,Set(ROUTFOUND=1)'."\n\t";
362
+            $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)'."\n\t";
363 363
 
364
-            $conf .= 'same => n,ExecIf($["${EXTERNALPHONE}" == "${EXTEN}"]?Set(DOPTIONS=tk))' . "\n\t";
364
+            $conf .= 'same => n,ExecIf($["${EXTERNALPHONE}" == "${EXTEN}"]?Set(DOPTIONS=tk))'."\n\t";
365 365
 
366 366
             // Описываем возможность прыжка в пользовательский sub контекст.
367
-            $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(' . $rout['providerid'] . '-outgoing-custom,${EXTEN},1)}" == "1"]?' . $rout['providerid'] . '-outgoing-custom,${EXTEN},1)' . "\n\t";
367
+            $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS('.$rout['providerid'].'-outgoing-custom,${EXTEN},1)}" == "1"]?'.$rout['providerid'].'-outgoing-custom,${EXTEN},1)'."\n\t";
368 368
 
369 369
             $technology = SIPConf::getTechnology();
370 370
             if ($rout['technology'] === IAXConf::TYPE_IAX2) {
371
-                $conf .= 'same => n,Dial(' . $rout['technology'] . '/' . $rout['providerid'] . '/${number},600,${DOPTIONS}TKM(dial_answer)b(dial_create_chan,s,1))' . "\n\t";
371
+                $conf .= 'same => n,Dial('.$rout['technology'].'/'.$rout['providerid'].'/${number},600,${DOPTIONS}TKM(dial_answer)b(dial_create_chan,s,1))'."\n\t";
372 372
             } else {
373
-                $conf .= 'same => n,Dial(' . $rout['technology'] . '/${number}@' . $rout['providerid'] . ',600,${DOPTIONS}TKU(dial_answer)b(dial_create_chan,s,1))' . "\n\t";
373
+                $conf .= 'same => n,Dial('.$rout['technology'].'/${number}@'.$rout['providerid'].',600,${DOPTIONS}TKU(dial_answer)b(dial_create_chan,s,1))'."\n\t";
374 374
             }
375 375
             foreach ($additionalModules as $appClass) {
376 376
                 $conf .= $appClass->generateOutRoutAfterDialContext($rout);
377 377
             }
378
-            $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(' . $rout['providerid'] . '-outgoing-after-dial-custom,${EXTEN}),1}" == "1"]?' . $rout['providerid'] . '-outgoing-after-dial-custom,${EXTEN},1)' . "\n\t";
378
+            $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS('.$rout['providerid'].'-outgoing-after-dial-custom,${EXTEN}),1}" == "1"]?'.$rout['providerid'].'-outgoing-after-dial-custom,${EXTEN},1)'."\n\t";
379 379
 
380
-            $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t";
381
-            $conf .= 'same => n,ExecIf($["${DIALSTATUS}" = "ANSWER"]?Hangup())' . "\n\t";
382
-            $conf .= 'same => n,Set(pt1c_UNIQUEID=${EMPTY_VALUE})' . "\n\t";
383
-            $conf .= 'same => n,return' . "\n";
380
+            $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t";
381
+            $conf .= 'same => n,ExecIf($["${DIALSTATUS}" = "ANSWER"]?Hangup())'."\n\t";
382
+            $conf .= 'same => n,Set(pt1c_UNIQUEID=${EMPTY_VALUE})'."\n\t";
383
+            $conf .= 'same => n,return'."\n";
384 384
         }
385 385
     }
386 386
 
@@ -396,14 +396,14 @@  discard block
 block discarded – undo
396 396
         $conf        = '';
397 397
         $restnumbers = '';
398 398
         if (isset($rout['restnumbers']) && $rout['restnumbers'] > 0) {
399
-            $restnumbers = "[0-9]{" . $rout['restnumbers'] . "}$";
399
+            $restnumbers = "[0-9]{".$rout['restnumbers']."}$";
400 400
         } elseif ($rout['restnumbers'] == 0) {
401 401
             $restnumbers = "$";
402 402
         } elseif ($rout['restnumbers'] == -1) {
403 403
             $restnumbers = "";
404 404
         }
405 405
         $numberbeginswith = $rout['numberbeginswith'];
406
-        $conf             .= 'same => n,ExecIf($["${REGEX("^' . $numberbeginswith . $restnumbers . '" ${EXTEN})}" == "1"]?Gosub(' . $rout['providerid'] . '-' . $rout['id'] . '-outgoing,${EXTEN},1))' . " \n\t";
406
+        $conf .= 'same => n,ExecIf($["${REGEX("^'.$numberbeginswith.$restnumbers.'" ${EXTEN})}" == "1"]?Gosub('.$rout['providerid'].'-'.$rout['id'].'-outgoing,${EXTEN},1))'." \n\t";
407 407
 
408 408
         return $conf;
409 409
     }
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
         $conf              .= self::generateIncomingContextPeers('none', '', '');
421 421
         $conf              .= "[public-direct-dial] \n";
422 422
         foreach ($additionalModules as $appClass) {
423
-            if ($appClass instanceof $this){
423
+            if ($appClass instanceof $this) {
424 424
                 continue;
425 425
             }
426 426
             $appClass->generatePublicContext($conf);
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
         $conf              = '';
451 451
         $dialplan          = [];
452 452
         $di = Di::getDefault();
453
-        if ($di===null){
453
+        if ($di === null) {
454 454
             return '';
455 455
         }
456 456
         $additionalModules = $di->getShared('pbxConfModules');
@@ -505,17 +505,17 @@  discard block
 block discarded – undo
505 505
             if (empty($rout_data)) {
506 506
                 $ext_prefix = ('none' === $provider) ? '' : '_';
507 507
                 $rout_data  .= "exten => {$ext_prefix}{$rout_number},1,NoOp(--- Incoming call ---)\n\t";
508
-                $rout_data  .= 'same => n,Set(CHANNEL(language)=' . $lang . ')' . "\n\t";
509
-                $rout_data  .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t";
510
-                $rout_data  .= 'same => n,Set(__FROM_DID=${EXTEN})' . "\n\t";
511
-                $rout_data  .= 'same => n,Set(__FROM_CHAN=${CHANNEL})' . "\n\t";
508
+                $rout_data  .= 'same => n,Set(CHANNEL(language)='.$lang.')'."\n\t";
509
+                $rout_data  .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t";
510
+                $rout_data  .= 'same => n,Set(__FROM_DID=${EXTEN})'."\n\t";
511
+                $rout_data  .= 'same => n,Set(__FROM_CHAN=${CHANNEL})'."\n\t";
512 512
 
513 513
                 // Установка имени пира.
514
-                $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))' . "\n\t";
515
-                $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Set(__FROM_PEER=${CALLERID(num)}))' . "\n\t";
514
+                $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))'."\n\t";
515
+                $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Set(__FROM_PEER=${CALLERID(num)}))'."\n\t";
516 516
 
517 517
                 // TODO / Подмена входящего callerid.
518
-                $rout_data .= 'same => n,Gosub(add-trim-prefix-clid,${EXTEN},1)' . "\n\t";
518
+                $rout_data .= 'same => n,Gosub(add-trim-prefix-clid,${EXTEN},1)'."\n\t";
519 519
 
520 520
                 if ($additionalModules) {
521 521
                     foreach ($additionalModules as $appClass) {
@@ -524,28 +524,28 @@  discard block
 block discarded – undo
524 524
                 }
525 525
 
526 526
                 // Перехват на ответственного.
527
-                $rout_data .= 'same => n,UserEvent(Interception,CALLERID: ${CALLERID(num)},chan1c: ${CHANNEL},FROM_DID: ${FROM_DID})' . "\n\t";
527
+                $rout_data .= 'same => n,UserEvent(Interception,CALLERID: ${CALLERID(num)},chan1c: ${CHANNEL},FROM_DID: ${FROM_DID})'."\n\t";
528 528
                 // Проверим распискние для входящих внешних звонков.
529 529
                 $rout_data .= 'same => n,Gosub(check-out-work-time,${EXTEN},1)';
530 530
                 // Описываем возможность прыжка в пользовательский sub контекст.
531
-                $rout_data .= " \n\t" . 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)';
531
+                $rout_data .= " \n\t".'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)';
532 532
             }
533 533
 
534
-            if ( ! empty($rout['extension'])) {
534
+            if (!empty($rout['extension'])) {
535 535
                 $rout_data = rtrim($rout_data);
536 536
                 // Обязательно проверяем "DIALSTATUS", в случае с парковой через AMI вызова это необходимо.
537 537
                 // При ответе может отработать следующий приоритет.
538
-                if ( ! isset($rout_data_dial[$rout_number])) {
538
+                if (!isset($rout_data_dial[$rout_number])) {
539 539
                     $rout_data_dial[$rout_number] = '';
540 540
                 }
541 541
 
542
-                $dial_command                 = " \n\t" . 'same => n,' . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Dial(Local/{$rout['extension']}@internal-incoming/n,{$timeout},TKg));";
543
-                $rout_data_dial[$rout_number] .= " \n\t" . "same => n,Set(M_TIMEOUT={$timeout})";
542
+                $dial_command = " \n\t".'same => n,'.'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?'."Dial(Local/{$rout['extension']}@internal-incoming/n,{$timeout},TKg));";
543
+                $rout_data_dial[$rout_number] .= " \n\t"."same => n,Set(M_TIMEOUT={$timeout})";
544 544
                 $rout_data_dial[$rout_number] .= $dial_command;
545 545
 
546 546
                 if (is_array($provider)) {
547 547
                     $key = $provider[$rout['provider']] ?? '';
548
-                    if ( ! isset($rout_data_dial[$key])) {
548
+                    if (!isset($rout_data_dial[$key])) {
549 549
                         $rout_data_dial[$key] = '';
550 550
                     }
551 551
                     if (empty($number)) {
@@ -556,9 +556,9 @@  discard block
 block discarded – undo
556 556
         }
557 557
 
558 558
         if (is_string($login)) {
559
-            $add_login_pattern = ! empty($login);
559
+            $add_login_pattern = !empty($login);
560 560
             foreach ($data as $rout) {
561
-                if ( ! $add_login_pattern) {
561
+                if (!$add_login_pattern) {
562 562
                     break;
563 563
                 } // Логин не заполнен, обработка не требуется.
564 564
                 $is_num = preg_match_all('/^\d+$/m', $login, $matches, PREG_SET_ORDER, 0);
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
             if ($add_login_pattern && array_key_exists('X!', $rout_data_dial) && isset($dialplan['X!'])) {
579 579
                 $dialplan[$login]       = str_replace('_X!,1', "{$login},1", $dialplan['X!']);
580 580
                 $rout_data_dial[$login] = $rout_data_dial['X!'];
581
-            }elseif($add_login_pattern === true && $need_def_rout === true && count($data) === 1){
581
+            }elseif ($add_login_pattern === true && $need_def_rout === true && count($data) === 1) {
582 582
                 // Только маршрут "По умолчанию".
583 583
                 $dialplan[$login]       = str_replace('_X!,1', "{$login},1", $dialplan['X!']);
584 584
             }
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
         }
590 590
 
591 591
         foreach ($dialplan as $key => &$dpln) {
592
-            if ( ! array_key_exists($key, $rout_data_dial)) {
592
+            if (!array_key_exists($key, $rout_data_dial)) {
593 593
                 continue;
594 594
             }
595 595
             $dpln = rtrim($dpln);
@@ -598,28 +598,28 @@  discard block
 block discarded – undo
598 598
         unset($dpln);
599 599
 
600 600
         $uniqid = is_string($provider) ? $provider : $uniqid;
601
-        $conf   .= "\n" . "[{$uniqid}-incoming]\n";
601
+        $conf .= "\n"."[{$uniqid}-incoming]\n";
602 602
         foreach ($dialplan as $dpln) {
603
-            $conf .= $dpln . "\n";
603
+            $conf .= $dpln."\n";
604 604
             if (null == $default_action && 'none' !== $provider) {
605 605
                 continue;
606 606
             }
607 607
             if ('extension' === $default_action->action) {
608 608
                 // Обязательно проверяем "DIALSTATUS", в случае с парковой через AMI вызова это необходимо.
609 609
                 // При ответе может отработать следующий приоритет.
610
-                $conf .= "\t" . 'same => n,Set(M_TIMEOUT=0)' . "\n";
611
-                $conf .= "\t" . "same => n," . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Dial(Local/{$default_action->extension}@internal/n,,TKg)); default action" . "\n";
610
+                $conf .= "\t".'same => n,Set(M_TIMEOUT=0)'."\n";
611
+                $conf .= "\t"."same => n,".'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?'."Dial(Local/{$default_action->extension}@internal/n,,TKg)); default action"."\n";
612 612
 
613 613
                 if ($additionalModules) {
614 614
                     foreach ($additionalModules as $appClass) {
615 615
                         $conf .= $appClass->generateIncomingRoutAfterDialContext($uniqid);
616 616
                     }
617 617
                 }
618
-                $conf .= " \t" . 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-after-dial-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-after-dial-custom,${EXTEN},1)' . "\n";
618
+                $conf .= " \t".'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-after-dial-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-after-dial-custom,${EXTEN},1)'."\n";
619 619
             } elseif ('busy' === $default_action->action) {
620
-                $conf .= "\t" . "same => n,Busy()" . "\n";
620
+                $conf .= "\t"."same => n,Busy()"."\n";
621 621
             }
622
-            $conf .= "\t" . "same => n,Hangup()" . "\n";
622
+            $conf .= "\t"."same => n,Hangup()"."\n";
623 623
         }
624 624
 
625 625
         return $conf;
@@ -635,10 +635,10 @@  discard block
 block discarded – undo
635 635
     private function generateOutWorkTimes(&$conf): string
636 636
     {
637 637
         $conf .= "\n\n[playback-exit]\n";
638
-        $conf .= 'exten => _.!,1,NoOp(check time)' . "\n\t";
639
-        $conf .= 'same => n,Gosub(dial_outworktimes,${EXTEN},1)' . "\n\t";
640
-        $conf .= 'same => n,Playback(${filename})' . "\n\t";
641
-        $conf .= 'same => n,Hangup()' . "\n\n";
638
+        $conf .= 'exten => _.!,1,NoOp(check time)'."\n\t";
639
+        $conf .= 'same => n,Gosub(dial_outworktimes,${EXTEN},1)'."\n\t";
640
+        $conf .= 'same => n,Playback(${filename})'."\n\t";
641
+        $conf .= 'same => n,Hangup()'."\n\n";
642 642
 
643 643
         $conf .= "[check-out-work-time]\n";
644 644
         $conf .= "exten => _.!,1,NoOp(check time)\n\t";
@@ -650,7 +650,7 @@  discard block
 block discarded – undo
650 650
         $now_year = 1 * date('Y', time());
651 651
         foreach ($data as $out_data) {
652 652
             /** @var \MikoPBX\Common\Models\OutWorkTimes $out_data */
653
-            if ( ! empty($out_data->date_from) && ! empty($out_data->date_to)) {
653
+            if (!empty($out_data->date_from) && !empty($out_data->date_to)) {
654 654
                 $year_from = 1 * date('Y', $out_data->date_from);
655 655
                 $year_to   = 1 * date('Y', $out_data->date_to);
656 656
                 if ($now_year < $year_from || $now_year > $year_to) {
@@ -691,9 +691,9 @@  discard block
 block discarded – undo
691 691
             } else {
692 692
                 $mdays  = strtolower(date("j", $date_from));
693 693
                 $months = strtolower(date("M", $date_from));
694
-                if ( ! empty($date_to)) {
695
-                    $mdays  .= "-" . strtolower(date("j", $date_to));
696
-                    $months .= "-" . strtolower(date("M", $date_to));
694
+                if (!empty($date_to)) {
695
+                    $mdays  .= "-".strtolower(date("j", $date_to));
696
+                    $months .= "-".strtolower(date("M", $date_to));
697 697
                 }
698 698
             }
699 699
 
@@ -706,12 +706,12 @@  discard block
 block discarded – undo
706 706
                 $res           = SoundFiles::findFirst($out_data->audio_message_id);
707 707
                 $audio_message = ($res === null) ? '' : Util::trimExtensionForFile($res->path);
708 708
 
709
-                $conf_out_set_var .= "[work-time-set-var-{$out_data->id}]\n" .
710
-                    'exten => _.!,1,Set(filename=' . $audio_message . ')' . "\n\t" .
711
-                    'same => n,Goto(playback-exit,${EXTEN},1)' . "\n\n";
709
+                $conf_out_set_var .= "[work-time-set-var-{$out_data->id}]\n".
710
+                    'exten => _.!,1,Set(filename='.$audio_message.')'."\n\t".
711
+                    'same => n,Goto(playback-exit,${EXTEN},1)'."\n\n";
712 712
 
713 713
                 $appname = 'ExecIfTime';
714
-                $appdata = 'Goto(work-time-set-var-' . $out_data->id . ',${EXTEN},1)';
714
+                $appdata = 'Goto(work-time-set-var-'.$out_data->id.',${EXTEN},1)';
715 715
             }
716 716
             $conf .= "same => n,{$appname}($times,$weekdays,$mdays,$months?{$appdata})\n\t";
717 717
         }
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/SIPConf.php 1 patch
Spacing   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
         $conf .= $this->generateProvidersPj();
46 46
         $conf .= $this->generatePeersPj();
47 47
 
48
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/pjsip.conf', $conf);
48
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/pjsip.conf', $conf);
49 49
 
50 50
 
51 51
         $db = new AstDB();
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
                 continue;
175 175
             }
176 176
             $sub = new SubnetCalculator($lan_config['ipaddr'], $lan_config['subnet']);
177
-            $net = $sub->getNetworkPortion() . '/' . $lan_config['subnet'];
177
+            $net = $sub->getNetworkPortion().'/'.$lan_config['subnet'];
178 178
             if ($if_data['topology'] === 'private' && in_array($net, $subnets, true) === false) {
179 179
                 $subnets[] = $net;
180 180
             }
@@ -192,27 +192,27 @@  discard block
 block discarded – undo
192 192
             }
193 193
         }
194 194
 
195
-        $conf = "[general] \n" .
196
-            "disable_multi_domain=on\n" .
197
-            "transport = udp \n\n" .
198
-
199
-            "[global] \n" .
200
-            "type = global\n" .
201
-            "user_agent = mikopbx\n\n" .
202
-
203
-            "[anonymous]\n" .
204
-            "type = endpoint\n" .
205
-            "allow = alaw\n" .
206
-            "allow = ulaw\n" .
207
-            "allow = g722\n" .
208
-            "allow = gsm\n" .
209
-            "allow = g726\n" .
210
-            "timers = no\n" .
211
-            "context = public-direct-dial\n\n" .
212
-
213
-            "[transport-udp]\n" .
214
-            "type = transport\n" .
215
-            "protocol = udp\n" .
195
+        $conf = "[general] \n".
196
+            "disable_multi_domain=on\n".
197
+            "transport = udp \n\n".
198
+
199
+            "[global] \n".
200
+            "type = global\n".
201
+            "user_agent = mikopbx\n\n".
202
+
203
+            "[anonymous]\n".
204
+            "type = endpoint\n".
205
+            "allow = alaw\n".
206
+            "allow = ulaw\n".
207
+            "allow = g722\n".
208
+            "allow = gsm\n".
209
+            "allow = g726\n".
210
+            "timers = no\n".
211
+            "context = public-direct-dial\n\n".
212
+
213
+            "[transport-udp]\n".
214
+            "type = transport\n".
215
+            "protocol = udp\n".
216 216
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n";
217 217
 
218 218
         if ($topology === 'private') {
@@ -220,21 +220,21 @@  discard block
 block discarded – undo
220 220
                 $conf .= "local_net={$net}\n";
221 221
             }
222 222
 
223
-            if ( ! empty($exthostname)) {
223
+            if (!empty($exthostname)) {
224 224
                 $parts = explode(':', $exthostname);
225
-                $conf  .= 'external_media_address=' . $parts[0] . "\n";
226
-                $conf  .= 'external_signaling_address=' . $parts[0] . "\n";
227
-                $conf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
228
-            } elseif ( ! empty($extipaddr)) {
225
+                $conf  .= 'external_media_address='.$parts[0]."\n";
226
+                $conf  .= 'external_signaling_address='.$parts[0]."\n";
227
+                $conf  .= 'external_signaling_port='.($parts[1] ?? '5060');
228
+            } elseif (!empty($extipaddr)) {
229 229
                 $parts = explode(':', $extipaddr);
230
-                $conf  .= 'external_media_address=' . $parts[0] . "\n";
231
-                $conf  .= 'external_signaling_address=' . $parts[0] . "\n";
232
-                $conf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
230
+                $conf  .= 'external_media_address='.$parts[0]."\n";
231
+                $conf  .= 'external_signaling_address='.$parts[0]."\n";
232
+                $conf  .= 'external_signaling_port='.($parts[1] ?? '5060');
233 233
             }
234 234
         }
235 235
 
236 236
         $varEtcPath = $this->config->path('core.varEtcPath');
237
-        file_put_contents($varEtcPath . '/topology_hash', md5($topology . $exthostname . $extipaddr));
237
+        file_put_contents($varEtcPath.'/topology_hash', md5($topology.$exthostname.$extipaddr));
238 238
         $conf .= "\n";
239 239
 
240 240
         return $conf;
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
         $conf        = '';
252 252
         $reg_strings = '';
253 253
         $prov_config = '';
254
-        if ($this->data_providers===null){
254
+        if ($this->data_providers === null) {
255 255
             $this->getSettings();
256 256
         }
257 257
         foreach ($this->data_providers as $provider) {
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 
261 261
             $need_register = $provider['noregister'] !== '1';
262 262
             if ($need_register) {
263
-                $options     = [
263
+                $options = [
264 264
                     'type'     => 'auth',
265 265
                     'username' => $provider['username'],
266 266
                     'password' => $provider['secret'],
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
                 $reg_strings .= "[REG-AUTH-{$provider['uniqid']}]\n";
269 269
                 $reg_strings .= Util::overrideConfigurationArray($options, $manual_attributes, 'registration-auth');
270 270
 
271
-                $options     = [
271
+                $options = [
272 272
                     'type'           => 'registration',
273 273
                     'transport'      => 'transport-udp',
274 274
                     'outbound_auth'  => "REG-AUTH-{$provider['uniqid']}",
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
             }
285 285
 
286 286
             if ('1' !== $provider['receive_calls_without_auth']) {
287
-                $options     = [
287
+                $options = [
288 288
                     'type'     => 'auth',
289 289
                     'username' => $provider['username'],
290 290
                     'password' => $provider['secret'],
@@ -294,7 +294,7 @@  discard block
 block discarded – undo
294 294
             }
295 295
 
296 296
             $defaultuser = (trim($provider['defaultuser']) === '') ? $provider['username'] : $provider['defaultuser'];
297
-            if ( ! empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
297
+            if (!empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
298 298
                 $contact = "sip:$defaultuser@{$provider['host']}:{$port}";
299 299
             } else {
300 300
                 $contact = "sip:{$provider['host']}:{$port}";
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
             $prov_config .= "[{$provider['uniqid']}]\n";
311 311
             $prov_config .= Util::overrideConfigurationArray($options, $manual_attributes, 'aor');
312 312
 
313
-            $options     = [
313
+            $options = [
314 314
                 'type'     => 'identify',
315 315
                 'endpoint' => $provider['uniqid'],
316 316
                 'match'    => $provider['host'],
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
      */
374 374
     public function generatePeersPj(): string
375 375
     {
376
-        if ($this->data_peers===null){
376
+        if ($this->data_peers === null) {
377 377
             $this->getSettings();
378 378
         }
379 379
         $lang              = $this->generalSettings['PBXLanguage'];
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
             $language = (trim($language) === '') ? 'en-en' : $language;
388 388
 
389 389
             $calleridname = (trim($peer['calleridname']) === '') ? $peer['extension'] : $peer['calleridname'];
390
-            $busylevel    = (trim($peer['busylevel']) === '') ? '1' : '' . $peer['busylevel'];
390
+            $busylevel    = (trim($peer['busylevel']) === '') ? '1' : ''.$peer['busylevel'];
391 391
 
392 392
             $options = [
393 393
                 'type'     => 'auth',
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
             'bind'  => ['id' => $uniqid],
542 542
             'order' => 'priority',
543 543
         ];
544
-        $codecs     = SipCodecs::find($filter);
544
+        $codecs = SipCodecs::find($filter);
545 545
         foreach ($codecs as $codec_data) {
546 546
             $arr_codecs[] = $codec_data->codec;
547 547
         }
@@ -571,8 +571,8 @@  discard block
 block discarded – undo
571 571
             // Получим используемые кодеки.
572 572
             $arr_data['codecs'] = $this->getCodecs($sip_peer->uniqid);
573 573
 
574
-            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host . $sip_peer->port);
575
-            if ( ! isset($this->contexts_data[$context_id])) {
574
+            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host.$sip_peer->port);
575
+            if (!isset($this->contexts_data[$context_id])) {
576 576
                 $this->contexts_data[$context_id] = [];
577 577
             }
578 578
             $this->contexts_data[$context_id][$sip_peer->uniqid] = $sip_peer->username;
@@ -591,7 +591,7 @@  discard block
 block discarded – undo
591 591
      */
592 592
     private function getOutRoutes(): array
593 593
     {
594
-        if ($this->data_peers===null){
594
+        if ($this->data_peers === null) {
595 595
             $this->getSettings();
596 596
         }
597 597
         /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $rout */
@@ -626,7 +626,7 @@  discard block
 block discarded – undo
626 626
      */
627 627
     public function extensionGenContexts(): string
628 628
     {
629
-        if ($this->data_peers===null){
629
+        if ($this->data_peers === null) {
630 630
             $this->getSettings();
631 631
         }
632 632
         // Генерация внутреннего номерного плана.
@@ -644,8 +644,8 @@  discard block
 block discarded – undo
644 644
             $contexts_data = $this->contexts_data[$provider['context_id']];
645 645
             if (count($contexts_data) === 1) {
646 646
                 $conf .= ExtensionsConf::generateIncomingContextPeers($provider['uniqid'], $provider['username'], '');
647
-            } elseif ( ! in_array($provider['context_id'], $contexts, true)) {
648
-                $conf       .= ExtensionsConf::generateIncomingContextPeers(
647
+            } elseif (!in_array($provider['context_id'], $contexts, true)) {
648
+                $conf .= ExtensionsConf::generateIncomingContextPeers(
649 649
                     $contexts_data,
650 650
                     null,
651 651
                     $provider['context_id']
@@ -664,7 +664,7 @@  discard block
 block discarded – undo
664 664
      */
665 665
     public function extensionGenHints(): string
666 666
     {
667
-        if ($this->data_peers===null){
667
+        if ($this->data_peers === null) {
668 668
             $this->getSettings();
669 669
         }
670 670
         $conf = '';
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
 
678 678
     public function extensionGenInternal(): string
679 679
     {
680
-        if ($this->data_peers===null){
680
+        if ($this->data_peers === null) {
681 681
             $this->getSettings();
682 682
         }
683 683
         // Генерация внутреннего номерного плана.
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 
693 693
     public function extensionGenInternalTransfer(): string
694 694
     {
695
-        if ($this->data_peers===null){
695
+        if ($this->data_peers === null) {
696 696
             $this->getSettings();
697 697
         }
698 698
         // Генерация внутреннего номерного плана.
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/ChanDahdiConf.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,11 +18,11 @@
 block discarded – undo
18 18
 
19 19
     protected function generateConfigProtected(): void
20 20
     {
21
-        $conf = "[trunkgroups]\n" .
22
-            "[channels]\n" .
21
+        $conf = "[trunkgroups]\n".
22
+            "[channels]\n".
23 23
             "";
24 24
 
25
-        file_put_contents($this->config->path('asterisk.astetcdir') . '/chan_dahdi.conf', $conf);
25
+        file_put_contents($this->config->path('asterisk.astetcdir').'/chan_dahdi.conf', $conf);
26 26
     }
27 27
 
28 28
 }
29 29
\ No newline at end of file
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/IAXConf.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
         $conf .= $this->generateGeneral();
30 30
         $conf .= $this->generateProviders();
31 31
 
32
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/iax.conf', $conf);
33
-        file_put_contents($this->config->path('asterisk.astetcdir') . '/iaxprov.conf', "[default]\ncodec=alaw\n");
32
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/iax.conf', $conf);
33
+        file_put_contents($this->config->path('asterisk.astetcdir').'/iaxprov.conf', "[default]\ncodec=alaw\n");
34 34
     }
35 35
 
36 36
 
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
      */
100 100
     private function getProviders(): array
101 101
     {
102
-        $data_providers =[];
102
+        $data_providers = [];
103 103
         // Получим настройки всех аккаунтов.
104
-        $arrIaxProviders              = Iax::find("disabled IS NULL OR disabled = '0'");
104
+        $arrIaxProviders = Iax::find("disabled IS NULL OR disabled = '0'");
105 105
         foreach ($arrIaxProviders as $peer) {
106 106
             /** @var \MikoPBX\Common\Models\Iax $peer */
107 107
             $arr_data = $peer->toArray();
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                 'bind'  => ['id' => $peer->uniqid],
117 117
                 'order' => 'priority',
118 118
             ];
119
-            $codecs             = IaxCodecs::find($filter);
119
+            $codecs = IaxCodecs::find($filter);
120 120
             foreach ($codecs as $ob_codec) {
121 121
                 $arr_data['codecs'][] = $ob_codec->codec;
122 122
             }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
     private function generateGeneral(): string
153 153
     {
154 154
         $iax_port = (trim($this->generalSettings['IAXPort']) !== '') ? $this->generalSettings['IAXPort'] : '4569';
155
-        $conf     = '[general]' . "\n";
155
+        $conf     = '[general]'."\n";
156 156
         // $conf .= "context=public-direct-dial \n";
157 157
         $conf .= "bindport={$iax_port}\n";
158 158
         $conf .= "bindaddr=0.0.0.0\n";
@@ -212,12 +212,12 @@  discard block
 block discarded – undo
212 212
                 $secret = (trim($provider['secret']) == '') ? '' : ":{$provider['secret']}";
213 213
                 $host   = $provider['host'];
214 214
                 // $port	   = (trim($provider['port']) =='')?'':":{$provider['port']}";
215
-                $port        = '';
215
+                $port = '';
216 216
                 $reg_strings .= "register => {$user}{$secret}@{$host}{$port} \n";
217 217
             }
218 218
         }
219 219
 
220
-        return $reg_strings . "\n" . $prov_config;
220
+        return $reg_strings."\n".$prov_config;
221 221
     }
222 222
 
223 223
 }
Please login to merge, or discard this patch.