Passed
Branch develop (1da827)
by Портнов
08:21 queued 03:02
created
src/Core/Workers/WorkerRemoveOldRecords.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     public function start($argv): void
20 20
     {
21 21
         $varEtcDir = $this->di->getShared('config')->path('core.varEtcDir');
22
-        $filename   = "{$varEtcDir}/storage_device";
22
+        $filename = "{$varEtcDir}/storage_device";
23 23
         if (file_exists($filename)) {
24 24
             $mount_point = file_get_contents($filename);
25 25
         } else {
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
             $out
55 55
         );
56 56
         foreach ($out as $dir_info) {
57
-            if ( ! is_dir($dir_info)) {
57
+            if (!is_dir($dir_info)) {
58 58
                 echo 'error';
59 59
                 continue;
60 60
             }
Please login to merge, or discard this patch.
src/Core/Workers/WorkerBase.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             file_put_contents($this->getPidFile(), $activeProcesses);
48 48
         } else {
49 49
             $pidFilesDir = dirname($this->getPidFile());
50
-            $pidFile     = $pidFilesDir . '/' . pathinfo($this->getPidFile(), PATHINFO_BASENAME);
50
+            $pidFile     = $pidFilesDir.'/'.pathinfo($this->getPidFile(), PATHINFO_BASENAME);
51 51
             // Delete old PID files
52 52
             $rm = Util::which('rm');
53 53
             Processes::mwExec("{$rm} -rf {$pidFile}*");
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function pingCallBack(BeanstalkClient $message): void
87 87
     {
88
-        $message->reply(json_encode($message->getBody() . ':pong'));
88
+        $message->reply(json_encode($message->getBody().':pong'));
89 89
     }
90 90
 
91 91
     /**
Please login to merge, or discard this patch.
src/Core/System/Processes.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
     {
28 28
         $killallPath = Util::which('killall');
29 29
 
30
-        return self::mwExec($killallPath . ' ' . escapeshellarg($procName));
30
+        return self::mwExec($killallPath.' '.escapeshellarg($procName));
31 31
     }
32 32
 
33 33
     /**
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
         }
136 136
         $currentProcCount = count($processes);
137 137
 
138
-        if ( ! class_exists($className)) {
138
+        if (!class_exists($className)) {
139 139
             return;
140 140
         }
141 141
         $workerObject    = new $className();
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                     $countProc4Kill = $neededProcCount - $currentProcCount;
178 178
                     // Send SIGUSR1 command to them
179 179
                     while ($countProc4Kill >= 0) {
180
-                        if ( ! isset($processes[$countProc4Kill])) {
180
+                        if (!isset($processes[$countProc4Kill])) {
181 181
                             break;
182 182
                         }
183 183
                         // Kill old processes with timeout, maybe it is soft restart and worker die without any help
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
 
208 208
         $name       = addslashes($name);
209 209
         $filter_cmd = '';
210
-        if ( ! empty($exclude)) {
211
-            $filter_cmd = "| $path_grep -v " . escapeshellarg($exclude);
210
+        if (!empty($exclude)) {
211
+            $filter_cmd = "| $path_grep -v ".escapeshellarg($exclude);
212 212
         }
213 213
         $out = [];
214 214
         self::mwExec(
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
         $rmPath    = Util::which('rm');
234 234
         $sleepPath = Util::which('sleep');
235 235
         if ($sleep_time > 0) {
236
-            $filename = '/tmp/' . time() . '_noop.sh';
236
+            $filename = '/tmp/'.time().'_noop.sh';
237 237
             file_put_contents($filename, "{$sleepPath} {$sleep_time}; {$command}; {$rmPath} -rf {$filename}");
238 238
             $noop_command = "{$nohupPath} {$shPath} {$filename} > {$out_file} 2>&1 &";
239 239
         } else {
Please login to merge, or discard this patch.
src/Core/Asterisk/agi-bin/cdr_connector.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -32,14 +32,14 @@  discard block
 block discarded – undo
32 32
     $orign_chan     = $agi->get_variable("orign_chan", true);
33 33
     $id             = $agi->get_variable("pt1c_UNIQUEID", true);
34 34
     $IS_ORGNT       = $agi->get_variable("IS_ORGNT", true);
35
-    if ($id == '' || ! empty($QUEUE_SRC_CHAN)) {
35
+    if ($id == '' || !empty($QUEUE_SRC_CHAN)) {
36 36
         // Если это вызов на агента очереди !empty($QUEUE_SRC_CHAN).
37 37
         // Если это новый вызов $id == ''.
38
-        $id = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
38
+        $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
39 39
     }
40 40
     // Канал, AGI скрипта.
41 41
     $channel  = $agi->request['agi_channel'];
42
-    $is_local = ! (stripos($channel, 'local/') === false);
42
+    $is_local = !(stripos($channel, 'local/') === false);
43 43
     if ($QUEUE_SRC_CHAN != '' && $is_local) {
44 44
         // Это LOCAL, Переопределим на исходный.
45 45
         $channel = $QUEUE_SRC_CHAN;
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     }
55 55
 
56 56
     $data['action'] = "$action";
57
-    if ( ! empty($IS_ORGNT)) {
57
+    if (!empty($IS_ORGNT)) {
58 58
         $dst_num            = $agi->request['agi_callerid'];
59 59
         $src_num            = $agi->request['agi_extension'];
60 60
         $data['dialstatus'] = 'ORIGINATE';
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
         $num     = substr($agi->request['agi_channel'], $p_start, $p_end);
66 66
 
67 67
         $p_start  = strpos($agi->request['agi_channel'], ';');
68
-        $dst_chan = substr($agi->request['agi_channel'], 0, $p_start) . ';1';
68
+        $dst_chan = substr($agi->request['agi_channel'], 0, $p_start).';1';
69 69
 
70
-        $id               = substr($agi->request['agi_uniqueid'], 0, 16) . '_' . $num . '_' . $IS_ORGNT;
70
+        $id               = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$num.'_'.$IS_ORGNT;
71 71
         $data['dst_chan'] = $dst_chan;
72 72
     } else {
73 73
         $src_num = $agi->request['agi_callerid'];
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
     $data['agi_channel']  = $agi->request['agi_channel'];
85 85
     $data['did']          = $agi->get_variable("FROM_DID", true);
86 86
     $data['from_account'] = $from_account;
87
-    $data['IS_ORGNT']     = ! empty($IS_ORGNT);
87
+    $data['IS_ORGNT']     = !empty($IS_ORGNT);
88 88
 
89 89
     $agi->set_variable("__pt1c_UNIQUEID", "$id");
90 90
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
     }
116 116
 
117 117
     $IS_ORGNT = $agi->get_variable("IS_ORGNT", true);
118
-    if ( ! empty($IS_ORGNT)) {
118
+    if (!empty($IS_ORGNT)) {
119 119
         // Вероятно необходимо переопределить искать по двум ID.
120 120
         // Применимо только для Originate, когда в качестве звонящего используем два канала
121 121
         // мобильный и внутренний номер.
122 122
         $peer_mobile = $agi->get_variable("peer_mobile", true);
123
-        if ( ! empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
124
-            $id             = substr($agi->request['agi_uniqueid'], 0, 16) . '_' . $peer_mobile . '_' . $IS_ORGNT;
123
+        if (!empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
124
+            $id             = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$peer_mobile.'_'.$IS_ORGNT;
125 125
             $data['org_id'] = $id;
126 126
         }
127 127
     }
@@ -154,22 +154,22 @@  discard block
 block discarded – undo
154 154
     $data['BRIDGEPEER']      = $agi->get_variable("FROM_CHAN", true);
155 155
 
156 156
     $IS_ORGNT = $agi->get_variable("IS_ORGNT", true);
157
-    if ( ! empty($IS_ORGNT)) {
157
+    if (!empty($IS_ORGNT)) {
158 158
         // Вероятно необходимо переопределить ID.
159 159
         // Применимо только для Originate, когда в качестве звонящего используем два канала
160 160
         // мобильный и внутренний номер.
161 161
         $peer_mobile = $agi->get_variable("peer_mobile", true);
162
-        if ( ! empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
163
-            $id             = substr($agi->request['agi_uniqueid'], 0, 16) . '_' . $peer_mobile . '_' . $IS_ORGNT;
162
+        if (!empty($peer_mobile) && stripos($id, $peer_mobile) === false) {
163
+            $id             = substr($agi->request['agi_uniqueid'], 0, 16).'_'.$peer_mobile.'_'.$IS_ORGNT;
164 164
             $data['org_id'] = $id;
165 165
         }
166 166
     }
167 167
 
168
-    if ( ! empty($data['ENDCALLONANSWER'])) {
168
+    if (!empty($data['ENDCALLONANSWER'])) {
169 169
         $agi->set_variable("__ENDCALLONANSWER", "");
170 170
     }
171 171
 
172
-    $PICKUPEER     = trim('' . $agi->get_variable("PICKUPEER", true));
172
+    $PICKUPEER     = trim(''.$agi->get_variable("PICKUPEER", true));
173 173
     $data['dnid']  = $agi->request['agi_dnid'];
174 174
     $mikoPBXConfig = new MikoPBXConfig();
175 175
     $pickupexten   = $mikoPBXConfig->getGeneralSettings('PBXFeaturePickupExten');
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
         // Очищаем переменную канала. Больше не требуется.
185 185
         $agi->set_variable("PICKUPEER", "");
186 186
         $data['old_id'] = $id;
187
-        $data['id']     = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
187
+        $data['id']     = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
188 188
     }
189 189
     $agi->set_variable("__pt1c_UNIQUEID", "$id");
190 190
 
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     $data['linkedid']    = $agi->get_variable("CHANNEL(linkedid)", true);
212 212
     $data['did']         = $agi->get_variable("FROM_DID", true);
213 213
 
214
-    $data['agi_threadid'] = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
214
+    $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
215 215
 
216 216
     return $data;
217 217
 }
@@ -227,12 +227,12 @@  discard block
 block discarded – undo
227 227
 function Event_transfer_dial($agi, $action)
228 228
 {
229 229
     $now = Util::getNowDate();
230
-    $id  = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
230
+    $id  = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
231 231
 
232 232
     // Пытаемся определить канал.
233 233
     $TRANSFERERNAME = $agi->get_variable("TRANSFERERNAME", true);
234 234
     $QUEUE_SRC_CHAN = $agi->get_variable("QUEUE_SRC_CHAN", true);
235
-    $is_local       = ! (stripos($TRANSFERERNAME, 'local/') === false);
235
+    $is_local       = !(stripos($TRANSFERERNAME, 'local/') === false);
236 236
     if ($QUEUE_SRC_CHAN != '' && $is_local) {
237 237
         // Это LOCAL, Переопределим на исходный.
238 238
         $channel = $QUEUE_SRC_CHAN;
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
     $data                = [];
249 249
     $data['action']      = "$action";
250
-    $data['agi_channel'] = $channel;// $agi->request['agi_channel'];
250
+    $data['agi_channel'] = $channel; // $agi->request['agi_channel'];
251 251
     $data['linkedid']    = $agi->get_variable("CHANNEL(linkedid)", true);
252 252
     $data['src_chan']    = $channel;
253 253
     $data['did']         = $agi->get_variable("FROM_DID", true);
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
     $data['did']          = $agi->get_variable("FROM_DID", true);
322 322
     $data['action']       = "$action";
323 323
     $data['agi_channel']  = $agi->request['agi_channel'];
324
-    $data['agi_threadid'] = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
324
+    $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
325 325
 
326 326
     $pos = stripos($data['agi_channel'], 'local/');
327 327
     if ($pos === false) {
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
     $data                 = [];
351 351
     $data['action']       = "$action";
352 352
     $data['did']          = $agi->get_variable("FROM_DID", true);
353
-    $data['agi_threadid'] = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
353
+    $data['agi_threadid'] = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
354 354
 
355 355
     $data['linkedid']   = $agi->get_variable("CHANNEL(linkedid)", true);
356 356
     $data['dialstatus'] = $agi->get_variable("DIALSTATUS", true);
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
     $agi->set_variable("pt1c_PARK_CHAN", $park_row['ParkeeChannel']);
386 386
 
387 387
     // Сбор данных для генерации CDR.
388
-    $id      = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
388
+    $id      = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
389 389
     $channel = $agi->request['agi_channel'];
390 390
     $agi->set_variable("__pt1c_UNIQUEID", "$id");
391 391
     $data                 = [];
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
         $data['src_chan'] = $channel;
404 404
         $data['src_num']  = $agi->request['agi_callerid'];
405 405
         $data['dst_num']  = $agi->request['agi_extension'];
406
-        $data['dst_chan'] = 'Park:' . $agi->request['agi_extension'];
406
+        $data['dst_chan'] = 'Park:'.$agi->request['agi_extension'];
407 407
     } elseif (true === $park_row['pt1c_is_dst']) {
408 408
         $data['src_chan'] = $channel;
409 409
         $data['dst_chan'] = $park_row['ParkeeChannel'];
@@ -419,11 +419,11 @@  discard block
 block discarded – undo
419 419
     if (trim($park_row['ParkingDuration']) !== '') {
420 420
         $time_start           = date("Y-m-d H:i:s", time() - 1 * ($park_row['ParkingDuration']));
421 421
         $data_parking         = [
422
-            'UNIQUEID' => $id . '_' . Util::generateRandomString(3),
422
+            'UNIQUEID' => $id.'_'.Util::generateRandomString(3),
423 423
             'src_chan' => $park_row['ParkeeChannel'],
424 424
             'src_num'  => $park_row['ParkeeCallerIDNum'],
425 425
             'dst_num'  => $park_row['ParkingSpace'],
426
-            'dst_chan' => 'Park:' . $park_row['ParkingSpace'],
426
+            'dst_chan' => 'Park:'.$park_row['ParkingSpace'],
427 427
             'start'    => $time_start,
428 428
             'answer'   => $time_start,
429 429
             'endtime'  => $now,
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 function Event_unpark_call_timeout($agi, $action)
449 449
 {
450 450
     $now = Util::getNowDate();
451
-    $id  = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
451
+    $id  = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
452 452
     // PARKER=SIP/206
453 453
     $PARKING_DURATION = $agi->get_variable("PARKING_DURATION", true);
454 454
     $PARKING_DURATION = ($PARKING_DURATION == '') ? 45 : $PARKING_DURATION;
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
         'src_chan' => $agi->request['agi_channel'], // $agi->get_variable("PARKER", true), // ???
461 461
         'src_num'  => $agi->request['agi_callerid'],
462 462
         'dst_num'  => $PARKING_SPACE,
463
-        'dst_chan' => 'Park:' . $PARKING_SPACE,
463
+        'dst_chan' => 'Park:'.$PARKING_SPACE,
464 464
         'start'    => $time_start,
465 465
         'answer'   => $time_start,
466 466
         'endtime'  => $now,
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
     ];
473 473
 
474 474
 
475
-    $id2 = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
475
+    $id2 = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
476 476
     $agi->set_variable("__pt1c_UNIQUEID", "$id2");
477 477
 
478 478
     return $data;
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
     $id         = $agi->get_variable("pt1c_UNIQUEID", true);
494 494
     $ISTRANSFER = $agi->get_variable("ISTRANSFER", true);
495 495
 
496
-    if (empty($id) || ! empty($ISTRANSFER)) {
497
-        $id         = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
496
+    if (empty($id) || !empty($ISTRANSFER)) {
497
+        $id         = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
498 498
         $time_start = $now;
499 499
     }
500 500
 
@@ -503,7 +503,7 @@  discard block
 block discarded – undo
503 503
         // 'src_chan' => $agi->request['agi_channel'],
504 504
         // 'src_num'  => $agi->request['agi_callerid'],
505 505
         'dst_num'  => $agi->request['agi_extension'],
506
-        'dst_chan' => 'Queue:' . $agi->request['agi_extension'],
506
+        'dst_chan' => 'Queue:'.$agi->request['agi_extension'],
507 507
         // 'answer'   => $time_start,
508 508
         // 'end'  	   => $now,
509 509
         'did'      => $agi->get_variable("FROM_DID", true),
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         'UNIQUEID' => $id,
512 512
         'linkedid' => $agi->get_variable("CHANNEL(linkedid)", true),
513 513
     ];
514
-    if ( ! empty($time_start)) {
514
+    if (!empty($time_start)) {
515 515
         $data['src_chan'] = $agi->get_variable("QUEUE_SRC_CHAN", true);
516 516
         $data['src_num']  = $agi->request['agi_callerid'];
517 517
         $data['start']    = $time_start;
@@ -519,7 +519,7 @@  discard block
 block discarded – undo
519 519
         $data['transfer'] = '0';
520 520
         $agi->set_variable("__pt1c_q_UNIQUEID", "$id");
521 521
     }
522
-    if ( ! empty($ISTRANSFER)) {
522
+    if (!empty($ISTRANSFER)) {
523 523
         $data['transfer'] = '1';
524 524
     } else {
525 525
         $data['transfer'] = '0';
@@ -590,7 +590,7 @@  discard block
 block discarded – undo
590 590
 
591 591
     $is_conf   = ($agi->get_variable('CALLERID(num)', true) === 'Conference_Room');
592 592
     $not_local = (stripos($agi->request['agi_channel'], 'local/') === false);
593
-    if ($not_local && ! $is_conf) {
593
+    if ($not_local && !$is_conf) {
594 594
         $am         = Util::getAstManager();
595 595
         $res        = $am->meetMeCollectInfo($exten, ['conf_1c']);
596 596
         $callid     = $agi->request['agi_callerid'];
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
     }
629 629
 
630 630
     if (empty($id)) {
631
-        $id = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
631
+        $id = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
632 632
     }
633 633
 
634 634
     $recordingfile = CdrDb::MeetMeSetRecFilename($id);
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
         'src_chan'      => $agi->request['agi_channel'],
638 638
         'src_num'       => $src_num,
639 639
         'dst_num'       => $dst_num,
640
-        'dst_chan'      => 'MeetMe:' . $mikoidconf,
640
+        'dst_chan'      => 'MeetMe:'.$mikoidconf,
641 641
         'start'         => $time_start,
642 642
         'answer'        => $time_start,
643 643
         'recordingfile' => "{$recordingfile}.mp3",
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
     $lamePath = Util::which('lame');
680 680
     $nicePath = Util::which('nice');
681 681
     $chmodPath = Util::which('chmod');
682
-    $command               = "{$nicePath} -n 19 {$lamePath} -b 32 --silent \"{$recordingfile}.wav\" \"{$recordingfile}.mp3\" && {$chmodPath} o+r \"{$recordingfile}.mp3\"";
682
+    $command = "{$nicePath} -n 19 {$lamePath} -b 32 --silent \"{$recordingfile}.wav\" \"{$recordingfile}.mp3\" && {$chmodPath} o+r \"{$recordingfile}.mp3\"";
683 683
     Processes::mwExecBg($command);
684 684
 
685 685
     return $data;
@@ -695,14 +695,14 @@  discard block
 block discarded – undo
695 695
  */
696 696
 function Event_dial_app($agi, $action)
697 697
 {
698
-    $id        = $agi->request['agi_uniqueid'] . '_' . Util::generateRandomString();
698
+    $id        = $agi->request['agi_uniqueid'].'_'.Util::generateRandomString();
699 699
     $extension = $agi->get_variable("APPEXTEN", true);
700 700
     if (empty($extension)) {
701 701
         $extension = $agi->request['agi_extension'];
702 702
     }
703 703
 
704 704
     $data             = Event_dial($agi, $action);
705
-    $data['dst_chan'] = 'App:' . $extension;
705
+    $data['dst_chan'] = 'App:'.$extension;
706 706
     $data['dst_num']  = $extension;
707 707
     $data['is_app']   = 1;
708 708
     $data['UNIQUEID'] = $id;
@@ -743,5 +743,5 @@  discard block
 block discarded – undo
743 743
     $result = $func_name($agi, $action);
744 744
     // Оповещение без задержек.
745 745
     $data = base64_encode(json_encode($result));
746
-    $agi->exec("UserEvent", "CdrConnector,AgiData:" . base64_encode(json_encode($result)));
746
+    $agi->exec("UserEvent", "CdrConnector,AgiData:".base64_encode(json_encode($result)));
747 747
 }
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/SIPConf.php 2 patches
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -55,15 +55,15 @@  discard block
 block discarded – undo
55 55
         $conf .= $this->generateProvidersPj();
56 56
         $conf .= $this->generatePeersPj();
57 57
 
58
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/pjsip.conf', $conf);
58
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/pjsip.conf', $conf);
59 59
         $pjConf = '[log_mappings]'."\n".
60 60
             'type=log_mappings'."\n".
61 61
             'asterisk_error = 0'."\n".
62 62
             'asterisk_warning = 2'."\n".
63 63
             'asterisk_debug = 1,3,4,5,6'."\n\n";
64 64
 
65
-        file_put_contents($this->config->path('asterisk.astetcdir') . '/pjproject.conf', $pjConf);
66
-        file_put_contents($this->config->path('asterisk.astetcdir') . '/sorcery.conf', '');
65
+        file_put_contents($this->config->path('asterisk.astetcdir').'/pjproject.conf', $pjConf);
66
+        file_put_contents($this->config->path('asterisk.astetcdir').'/sorcery.conf', '');
67 67
 
68 68
         $db = new AstDB();
69 69
         foreach ($this->data_peers as $peer) {
@@ -84,13 +84,13 @@  discard block
 block discarded – undo
84 84
      */
85 85
     private function generateGeneralPj(): string
86 86
     {
87
-        $lang    = $this->generalSettings['PBXLanguage'];
87
+        $lang = $this->generalSettings['PBXLanguage'];
88 88
         [$topology, $extipaddr, $exthostname, $subnets] = $this->getTopologyData();
89 89
 
90 90
         $codecs = $this->getCodecs();
91 91
         $codecConf = '';
92
-        foreach ($codecs as $codec){
93
-            $codecConf.= "allow = {$codec}\n";
92
+        foreach ($codecs as $codec) {
93
+            $codecConf .= "allow = {$codec}\n";
94 94
         }
95 95
 
96 96
         $pbxVersion = PbxSettings::getValueByKey('PBXVersion');
@@ -99,50 +99,50 @@  discard block
 block discarded – undo
99 99
             foreach ($subnets as $net) {
100 100
                 $natConf .= "local_net={$net}\n";
101 101
             }
102
-            if ( ! empty($exthostname)) {
102
+            if (!empty($exthostname)) {
103 103
                 $parts = explode(':', $exthostname);
104
-                $natConf  .= 'external_media_address=' . $parts[0] . "\n";
105
-                $natConf  .= 'external_signaling_address=' . $parts[0] . "\n";
106
-                $natConf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
107
-            } elseif ( ! empty($extipaddr)) {
104
+                $natConf  .= 'external_media_address='.$parts[0]."\n";
105
+                $natConf  .= 'external_signaling_address='.$parts[0]."\n";
106
+                $natConf  .= 'external_signaling_port='.($parts[1] ?? '5060');
107
+            } elseif (!empty($extipaddr)) {
108 108
                 $parts = explode(':', $extipaddr);
109
-                $natConf  .= 'external_media_address=' . $parts[0] . "\n";
110
-                $natConf  .= 'external_signaling_address=' . $parts[0] . "\n";
111
-                $natConf  .= 'external_signaling_port=' . ($parts[1] ?? '5060');
109
+                $natConf  .= 'external_media_address='.$parts[0]."\n";
110
+                $natConf  .= 'external_signaling_address='.$parts[0]."\n";
111
+                $natConf  .= 'external_signaling_port='.($parts[1] ?? '5060');
112 112
             }
113 113
         }
114 114
 
115
-        $conf = "[general] \n" .
116
-            "disable_multi_domain=on\n" .
117
-            "transport = udp \n\n" .
115
+        $conf = "[general] \n".
116
+            "disable_multi_domain=on\n".
117
+            "transport = udp \n\n".
118 118
 
119
-            "[global] \n" .
120
-            "type = global\n" .
121
-            "endpoint_identifier_order=username,ip,anonymous\n" .
122
-            "user_agent = mikopbx-{$pbxVersion}\n\n" .
119
+            "[global] \n".
120
+            "type = global\n".
121
+            "endpoint_identifier_order=username,ip,anonymous\n".
122
+            "user_agent = mikopbx-{$pbxVersion}\n\n".
123 123
 
124
-            "[anonymous]\n" .
125
-            "type = endpoint\n" .
124
+            "[anonymous]\n".
125
+            "type = endpoint\n".
126 126
             $codecConf.
127 127
             "language={$lang}\n".
128
-            "timers = no\n" .
128
+            "timers = no\n".
129 129
             "context = public-direct-dial\n\n".
130 130
 
131
-            "[transport-udp]\n" .
132
-            "type = transport\n" .
133
-            "protocol = udp\n" .
131
+            "[transport-udp]\n".
132
+            "type = transport\n".
133
+            "protocol = udp\n".
134 134
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n".
135 135
             "{$natConf}\n\n".
136 136
 
137
-            "[transport-tcp]\n" .
138
-            "type = transport\n" .
139
-            "protocol = tcp\n" .
137
+            "[transport-tcp]\n".
138
+            "type = transport\n".
139
+            "protocol = tcp\n".
140 140
             "bind=0.0.0.0:{$this->generalSettings['SIPPort']}\n".
141 141
             "{$natConf}\n\n".
142 142
             '';
143 143
 
144 144
         $varEtcDir = $this->config->path('core.varEtcDir');
145
-        file_put_contents($varEtcDir . '/topology_hash', md5($topology . $exthostname . $extipaddr. $this->generalSettings['SIPPort']));
145
+        file_put_contents($varEtcDir.'/topology_hash', md5($topology.$exthostname.$extipaddr.$this->generalSettings['SIPPort']));
146 146
         $conf .= "\n";
147 147
 
148 148
         return $conf;
@@ -154,19 +154,19 @@  discard block
 block discarded – undo
154 154
      * @return bool
155 155
      */
156 156
     public function needAsteriskRestart():bool{
157
-        $di     = Di::getDefault();
157
+        $di = Di::getDefault();
158 158
         if ($di === null) {
159 159
             return false;
160 160
         }
161
-        $mikoPBXConfig  = new MikoPBXConfig();
161
+        $mikoPBXConfig = new MikoPBXConfig();
162 162
         [$topology, $extipaddr, $exthostname] = $this->getTopologyData();
163 163
 
164 164
         $generalSettings = $mikoPBXConfig->getGeneralSettings();
165
-        $now_hadh = md5($topology . $exthostname . $extipaddr. $generalSettings['SIPPort']);
166
-        $old_hash   = '';
165
+        $now_hadh = md5($topology.$exthostname.$extipaddr.$generalSettings['SIPPort']);
166
+        $old_hash = '';
167 167
         $varEtcDir = $di->getShared('config')->path('core.varEtcDir');
168
-        if (file_exists($varEtcDir . '/topology_hash')) {
169
-            $old_hash = file_get_contents($varEtcDir . '/topology_hash');
168
+        if (file_exists($varEtcDir.'/topology_hash')) {
169
+            $old_hash = file_get_contents($varEtcDir.'/topology_hash');
170 170
         }
171 171
 
172 172
         return $old_hash !== $now_hadh;
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
             }
191 191
             try {
192 192
                 $sub = new SubnetCalculator($lan_config['ipaddr'], $lan_config['subnet']);
193
-            }catch (\Throwable $e){
193
+            } catch (\Throwable $e) {
194 194
                 Util::sysLogMsg(self::class, $e->getMessage());
195 195
                 continue;
196 196
             }
197
-            $net = $sub->getNetworkPortion() . '/' . $lan_config['subnet'];
197
+            $net = $sub->getNetworkPortion().'/'.$lan_config['subnet'];
198 198
             if ($if_data['topology'] === 'private' && in_array($net, $subnets, true) === false) {
199 199
                 $subnets[] = $net;
200 200
             }
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
         $conf        = '';
233 233
         $reg_strings = '';
234 234
         $prov_config = '';
235
-        if ($this->data_providers===null){
235
+        if ($this->data_providers === null) {
236 236
             $this->getSettings();
237 237
         }
238 238
         $additionalModules = $this->di->getShared('pbxConfModules');
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
      */
264 264
     private function generateProviderRegistrationAuth(array $provider, array $additionalModules, array $manual_attributes): string{
265 265
         $conf = '';
266
-        if($provider['noregister'] === '1'){
266
+        if ($provider['noregister'] === '1') {
267 267
             return $conf;
268 268
         }
269
-        $options     = [
269
+        $options = [
270 270
             'type'     => 'registration-auth',
271 271
             'username' => $provider['username'],
272 272
             'password' => $provider['secret'],
@@ -289,10 +289,10 @@  discard block
 block discarded – undo
289 289
      */
290 290
     private function generateProviderRegistration(array $provider, array $additionalModules, array $manual_attributes): string{
291 291
         $conf = '';
292
-        if($provider['noregister'] === '1'){
292
+        if ($provider['noregister'] === '1') {
293 293
             return $conf;
294 294
         }
295
-        $options     = [
295
+        $options = [
296 296
             'type'                        => 'registration',
297 297
             'outbound_auth'               => "REG-AUTH-{$provider['uniqid']}",
298 298
             'contact_user'                => $provider['username'],
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
         if ('1' === $provider['receive_calls_without_auth']) {
325 325
             return $conf;
326 326
         }
327
-        $options     = [
327
+        $options = [
328 328
             'type'     => 'endpoint-auth',
329 329
             'username' => $provider['username'],
330 330
             'password' => $provider['secret'],
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
     private function generateProviderAor(array $provider, array $additionalModules, array $manual_attributes): string{
349 349
         $conf = '';
350 350
         $defaultuser = (trim($provider['defaultuser']) === '') ? $provider['username'] : $provider['defaultuser'];
351
-        if ( ! empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
351
+        if (!empty($defaultuser) && '1' !== $provider['receive_calls_without_auth']) {
352 352
             $contact = "sip:$defaultuser@{$provider['host']}:{$provider['port']}";
353 353
         } else {
354 354
             $contact = "sip:{$provider['host']}:{$provider['port']}";
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
             'minimum_expiration' => $this->generalSettings['SIPMinExpiry'],
362 362
             'default_expiration' => $this->generalSettings['SIPDefaultExpiry'],
363 363
         ];
364
-        if($provider['qualify'] === '1'){
364
+        if ($provider['qualify'] === '1') {
365 365
             $options['qualify_frequency'] = $provider['qualifyfreq'];
366 366
             $options['qualify_timeout']   = '3.0';
367 367
         }
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
      */
437 437
     private function generateProviderIdentify(array $provider, array $additionalModules, array $manual_attributes): string{
438 438
         $conf = '';
439
-        $options     = [
439
+        $options = [
440 440
             'type'     => 'identify',
441 441
             'endpoint' => $provider['uniqid'],
442 442
             'match'    => $provider['host'],
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
             'pl-pl' => 'pl',
469 469
             'pt-br' => 'pt',
470 470
         ];
471
-        $toneZone = $settings[$lang]??'';
472
-        if(!empty($toneZone)){
471
+        $toneZone = $settings[$lang] ?? '';
472
+        if (!empty($toneZone)) {
473 473
             $options['inband_progress'] = 'yes';
474 474
             $options['tone_zone'] = $toneZone;
475 475
         }
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
      */
484 484
     public function generatePeersPj(): string
485 485
     {
486
-        if ($this->data_peers===null){
486
+        if ($this->data_peers === null) {
487 487
             $this->getSettings();
488 488
         }
489 489
         $lang              = $this->generalSettings['PBXLanguage'];
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
         $language = (trim($language) === '') ? 'en-en' : $language;
579 579
 
580 580
         $calleridname = (trim($peer['calleridname']) === '') ? $peer['extension'] : $peer['calleridname'];
581
-        $busylevel = (trim($peer['busylevel']) === '') ? '1' : '' . $peer['busylevel'];
581
+        $busylevel = (trim($peer['busylevel']) === '') ? '1' : ''.$peer['busylevel'];
582 582
 
583 583
         $dtmfmode = ($peer['dtmfmode'] === 'rfc2833') ? 'rfc4733' : $peer['dtmfmode'];
584 584
         $options = [
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
             'conditions'=>'disabled="0"',
705 705
             'order' => 'type, priority',
706 706
         ];
707
-        $codecs     = Codecs::find($filter);
707
+        $codecs = Codecs::find($filter);
708 708
         foreach ($codecs as $codec_data) {
709 709
             $arr_codecs[] = $codec_data->name;
710 710
         }
@@ -734,8 +734,8 @@  discard block
 block discarded – undo
734 734
             // Получим используемые кодеки.
735 735
             $arr_data['codecs'] = $this->getCodecs();
736 736
 
737
-            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host . $sip_peer->port);
738
-            if ( ! isset($this->contexts_data[$context_id])) {
737
+            $context_id = preg_replace("/[^a-z\d]/iu", '', $sip_peer->host.$sip_peer->port);
738
+            if (!isset($this->contexts_data[$context_id])) {
739 739
                 $this->contexts_data[$context_id] = [];
740 740
             }
741 741
             $this->contexts_data[$context_id][$sip_peer->uniqid] = $sip_peer->username;
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
      */
755 755
     private function getOutRoutes(): array
756 756
     {
757
-        if ($this->data_peers===null){
757
+        if ($this->data_peers === null) {
758 758
             $this->getSettings();
759 759
         }
760 760
         /** @var OutgoingRoutingTable $rout */
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
      */
790 790
     public function extensionGenContexts(): string
791 791
     {
792
-        if ($this->data_peers===null){
792
+        if ($this->data_peers === null) {
793 793
             $this->getSettings();
794 794
         }
795 795
         // Генерация внутреннего номерного плана.
@@ -807,8 +807,8 @@  discard block
 block discarded – undo
807 807
             $contexts_data = $this->contexts_data[$provider['context_id']];
808 808
             if (count($contexts_data) === 1) {
809 809
                 $conf .= ExtensionsConf::generateIncomingContextPeers($provider['uniqid'], $provider['username'], '');
810
-            } elseif ( ! in_array($provider['context_id'], $contexts, true)) {
811
-                $conf       .= ExtensionsConf::generateIncomingContextPeers(
810
+            } elseif (!in_array($provider['context_id'], $contexts, true)) {
811
+                $conf .= ExtensionsConf::generateIncomingContextPeers(
812 812
                     $contexts_data,
813 813
                     null,
814 814
                     $provider['context_id']
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
      */
828 828
     public function extensionGenHints(): string
829 829
     {
830
-        if ($this->data_peers===null){
830
+        if ($this->data_peers === null) {
831 831
             $this->getSettings();
832 832
         }
833 833
         $conf = '';
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
 
841 841
     public function extensionGenInternal(): string
842 842
     {
843
-        if ($this->data_peers===null){
843
+        if ($this->data_peers === null) {
844 844
             $this->getSettings();
845 845
         }
846 846
         // Генерация внутреннего номерного плана.
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 
856 856
     public function extensionGenInternalTransfer(): string
857 857
     {
858
-        if ($this->data_peers===null){
858
+        if ($this->data_peers === null) {
859 859
             $this->getSettings();
860 860
         }
861 861
         // Генерация внутреннего номерного плана.
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -190,7 +190,7 @@
 block discarded – undo
190 190
             }
191 191
             try {
192 192
                 $sub = new SubnetCalculator($lan_config['ipaddr'], $lan_config['subnet']);
193
-            }catch (\Throwable $e){
193
+            } catch (\Throwable $e){
194 194
                 Util::sysLogMsg(self::class, $e->getMessage());
195 195
                 continue;
196 196
             }
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/ExtensionsConf.php 1 patch
Spacing   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@  discard block
 block discarded – undo
26 26
         $additionalModules = $this->di->getShared('pbxConfModules');
27 27
         $conf = "[globals] \n".
28 28
                 "TRANSFER_CONTEXT=internal-transfer; \n";
29
-        if($this->generalSettings['PBXRecordCalls'] === '1'){
30
-            $conf.="MONITOR_DIR=".Storage::getMonitorDir()." \n";
31
-            $conf.="MONITOR_STEREO=".$this->generalSettings['PBXSplitAudioThread']." \n";
29
+        if ($this->generalSettings['PBXRecordCalls'] === '1') {
30
+            $conf .= "MONITOR_DIR=".Storage::getMonitorDir()." \n";
31
+            $conf .= "MONITOR_STEREO=".$this->generalSettings['PBXSplitAudioThread']." \n";
32 32
         }
33 33
         foreach ($additionalModules as $appClass) {
34 34
             $addition = $appClass->extensionGlobals();
35
-            if (!empty($addition)){
36
-                $conf .=$appClass->confBlockWithComments($addition);
35
+            if (!empty($addition)) {
36
+                $conf .= $appClass->confBlockWithComments($addition);
37 37
             }
38 38
         }
39 39
         $conf .= "\n";
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         // Переключатель по времени.
57 57
         $this->generateOutWorkTimes($conf);
58 58
 
59
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/extensions.conf', $conf);
59
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/extensions.conf', $conf);
60 60
     }
61 61
 
62 62
     /**
@@ -68,68 +68,68 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $extension = 'X!';
70 70
         // Контекст для AMI originate. Без него отображается не корректный CallerID.
71
-        $conf .= '[sipregistrations]' . "\n\n";
71
+        $conf .= '[sipregistrations]'."\n\n";
72 72
 
73
-        $conf .= '[messages]' . "\n" .
74
-            'exten => _' . $extension . ',1,MessageSend(sip:${EXTEN},"${CALLERID(name)}"${MESSAGE(from)})' . "\n\n";
73
+        $conf .= '[messages]'."\n".
74
+            'exten => _'.$extension.',1,MessageSend(sip:${EXTEN},"${CALLERID(name)}"${MESSAGE(from)})'."\n\n";
75 75
 
76
-        $conf .= '[internal-originate]' . " \n";
77
-        $conf .= 'exten => _' . $extension . ',1,NoOP(Hint ${HINT} exten ${EXTEN} )' . " \n";
78
-        $conf .= '; Если это originate, то скроем один CDR.' . " \n\t";
79
-        $conf .= 'same => n,ExecIf($["${pt1c_cid}x" != "x"]?Set(CALLERID(num)=${pt1c_cid}))' . " \n\t";
76
+        $conf .= '[internal-originate]'." \n";
77
+        $conf .= 'exten => _'.$extension.',1,NoOP(Hint ${HINT} exten ${EXTEN} )'." \n";
78
+        $conf .= '; Если это originate, то скроем один CDR.'." \n\t";
79
+        $conf .= 'same => n,ExecIf($["${pt1c_cid}x" != "x"]?Set(CALLERID(num)=${pt1c_cid}))'." \n\t";
80 80
 
81
-        $conf .= 'same => n,ExecIf($["${CUT(CHANNEL,\;,2)}" == "2"]?Set(__PT1C_SIP_HEADER=${SIPADDHEADER}))' . " \n\t";
82
-        $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Set(ADDITIONAL_PEER=&Local/${peer_mobile}@outgoing/n))' . " \n\t";
81
+        $conf .= 'same => n,ExecIf($["${CUT(CHANNEL,\;,2)}" == "2"]?Set(__PT1C_SIP_HEADER=${SIPADDHEADER}))'." \n\t";
82
+        $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Set(ADDITIONAL_PEER=&Local/${peer_mobile}@outgoing/n))'." \n\t";
83 83
 
84 84
         // Описываем возможность прыжка в пользовательский sub контекст.
85
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t";
86
-        $conf .= 'same => n,Dial(Local/${EXTEN}@internal-users/n${ADDITIONAL_PEER},60,cTteKkHhb(originate_create_chan,s,1))' . " \n\n";
87
-
88
-        $conf .= '[originate_create_chan]' . " \n";
89
-        $conf .= 'exten => s,1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t";
90
-        $conf .= 'same => n,return' . " \n\n";
91
-
92
-        $conf .= '[dial_create_chan]' . " \n";
93
-        $conf .= 'exten => s,1,Gosub(lua_${ISTRANSFER}dial_create_chan,${EXTEN},1)' . "\n\t";
94
-        $conf .= 'same => n,Set(pt1c_is_dst=1)' . " \n\t";
95
-        $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";
96
-        $conf .= 'same => n,Set(__PT1C_SIP_HEADER=${UNDEFINED})' . " \n\t";
97
-        $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . " \n\t";
98
-        $conf .= 'same => n,return' . " \n\n";
99
-
100
-        $conf .= '[hangup_handler]' . "\n";
101
-        $conf .= 'exten => s,1,NoOp(--- hangup - ${CHANNEL} ---)' . "\n\t";
102
-        $conf .= 'same => n,Gosub(hangup_chan,${EXTEN},1)' . "\n\t";
103
-
104
-        $conf .= 'same => n,return' . "\n\n";
105
-
106
-        $conf .= '[set_orign_chan]' . "\n";
107
-        $conf .= 'exten => s,1,Wait(0.2)' . "\n\t";
108
-        $conf .= 'same => n,Set(pl=${IF($["${CHANNEL:-1}" == "1"]?2:1)})' . "\n\t";
109
-        $conf .= 'same => n,Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)})' . "\n\t";
110
-        $conf .= 'same => n,ExecIf($[ "${orign_chan}x" == "x" ]?Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},FROM_CHAN)}))' . "\n\t";
111
-        $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN}x" != "x" ]?Set(__QUEUE_SRC_CHAN=${orign_chan}))' . "\n\t";
112
-        $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN:0:5}" == "Local" ]?Set(__QUEUE_SRC_CHAN=${FROM_CHAN}))' . "\n\t";
113
-        $conf .= 'same => n,ExecIf($[ "${FROM_CHAN}x" == "x" ]?Set(__FROM_CHAN=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)}))' . "\n\t";
114
-        $conf .= 'same => n,return' . "\n\n";
115
-
116
-        $conf .= '[playback]' . "\n";
117
-        $conf .= 'exten => s,1,Playback(hello_demo,noanswer)' . "\n\t";
118
-        $conf .= 'same => n,ExecIf($["${SRC_BRIDGE_CHAN}x" == "x"]?Wait(30))' . "\n\t";
119
-        $conf .= 'same => n,Wait(0.3)' . "\n\t";
120
-        $conf .= 'same => n,Bridge(${SRC_BRIDGE_CHAN},kKTthH)' . "\n\n";
121
-
122
-        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\n";
85
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t";
86
+        $conf .= 'same => n,Dial(Local/${EXTEN}@internal-users/n${ADDITIONAL_PEER},60,cTteKkHhb(originate_create_chan,s,1))'." \n\n";
87
+
88
+        $conf .= '[originate_create_chan]'." \n";
89
+        $conf .= 'exten => s,1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t";
90
+        $conf .= 'same => n,return'." \n\n";
91
+
92
+        $conf .= '[dial_create_chan]'." \n";
93
+        $conf .= 'exten => s,1,Gosub(lua_${ISTRANSFER}dial_create_chan,${EXTEN},1)'."\n\t";
94
+        $conf .= 'same => n,Set(pt1c_is_dst=1)'." \n\t";
95
+        $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";
96
+        $conf .= 'same => n,Set(__PT1C_SIP_HEADER=${UNDEFINED})'." \n\t";
97
+        $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'." \n\t";
98
+        $conf .= 'same => n,return'." \n\n";
99
+
100
+        $conf .= '[hangup_handler]'."\n";
101
+        $conf .= 'exten => s,1,NoOp(--- hangup - ${CHANNEL} ---)'."\n\t";
102
+        $conf .= 'same => n,Gosub(hangup_chan,${EXTEN},1)'."\n\t";
103
+
104
+        $conf .= 'same => n,return'."\n\n";
105
+
106
+        $conf .= '[set_orign_chan]'."\n";
107
+        $conf .= 'exten => s,1,Wait(0.2)'."\n\t";
108
+        $conf .= 'same => n,Set(pl=${IF($["${CHANNEL:-1}" == "1"]?2:1)})'."\n\t";
109
+        $conf .= 'same => n,Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)})'."\n\t";
110
+        $conf .= 'same => n,ExecIf($[ "${orign_chan}x" == "x" ]?Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},FROM_CHAN)}))'."\n\t";
111
+        $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN}x" != "x" ]?Set(__QUEUE_SRC_CHAN=${orign_chan}))'."\n\t";
112
+        $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN:0:5}" == "Local" ]?Set(__QUEUE_SRC_CHAN=${FROM_CHAN}))'."\n\t";
113
+        $conf .= 'same => n,ExecIf($[ "${FROM_CHAN}x" == "x" ]?Set(__FROM_CHAN=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)}))'."\n\t";
114
+        $conf .= 'same => n,return'."\n\n";
115
+
116
+        $conf .= '[playback]'."\n";
117
+        $conf .= 'exten => s,1,Playback(hello_demo,noanswer)'."\n\t";
118
+        $conf .= 'same => n,ExecIf($["${SRC_BRIDGE_CHAN}x" == "x"]?Wait(30))'."\n\t";
119
+        $conf .= 'same => n,Wait(0.3)'."\n\t";
120
+        $conf .= 'same => n,Bridge(${SRC_BRIDGE_CHAN},kKTthH)'."\n\n";
121
+
122
+        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\n";
123 123
 
124 124
         // TODO / Добавление / удаление префиксов на входящий callerid.
125
-        $conf .= '[add-trim-prefix-clid]' . "\n";
126
-        $conf .= 'exten => _.!,1,NoOp(--- Incoming call from ${CALLERID(num)} ---)' . "\n\t";
127
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t";
125
+        $conf .= '[add-trim-prefix-clid]'."\n";
126
+        $conf .= 'exten => _.!,1,NoOp(--- Incoming call from ${CALLERID(num)} ---)'."\n\t";
127
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t";
128 128
         // Отсекаем "+".
129 129
         // $conf.= 'same => n,ExecIf( $["${CALLERID(num):0:1}" == "+"]?Set(CALLERID(num)=${CALLERID(num):1}))'."\n\t";
130 130
         // Отсекаем "7" и добавляем "8".
131 131
         // $conf.= 'same => n,ExecIf( $["${REGEX("^7[0-9]+" ${CALLERID(num)})}" == "1"]?Set(CALLERID(num)=8${CALLERID(num):1}))'."\n\t";
132
-        $conf .= 'same => n,return' . "\n\n";
132
+        $conf .= 'same => n,return'."\n\n";
133 133
     }
134 134
 
135 135
     /**
@@ -145,136 +145,136 @@  discard block
 block discarded – undo
145 145
         $additionalModules = $this->di->getShared('pbxConfModules');
146 146
         foreach ($additionalModules as $appClass) {
147 147
             $addition = $appClass->extensionGenContexts();
148
-            if (!empty($addition)){
149
-                $conf .=$appClass->confBlockWithComments($addition);
148
+            if (!empty($addition)) {
149
+                $conf .= $appClass->confBlockWithComments($addition);
150 150
             }
151 151
         }
152 152
         $conf .= "\n";
153 153
         $conf .= "[internal-num-undefined] \n";
154
-        $conf .= 'exten => _' . $extension . ',1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t";
155
-        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . "\n\t";
154
+        $conf .= 'exten => _'.$extension.',1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t";
155
+        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'."\n\t";
156 156
         $conf .= "same => n,Playback(pbx-invalid,noanswer) \n\n";
157 157
 
158 158
         $conf .= "[internal-fw]\n";
159
-        $conf .= 'exten => _' . $extension . ',1,NoOp(DIALSTATUS - ${DIALSTATUS})' . "\n\t";
159
+        $conf .= 'exten => _'.$extension.',1,NoOp(DIALSTATUS - ${DIALSTATUS})'."\n\t";
160 160
         // CANCEL - вызов был отменен, к примеру *0, не нужно дальше искать адресат.
161
-        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CANCEL"]?Hangup())' . "\n\t";
161
+        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CANCEL"]?Hangup())'."\n\t";
162 162
         // BUSY - занято. К примру абонент завершил вызов или DND.
163
-        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "BUSY"]?Set(dstatus=FW_BUSY))' . "\n\t";
163
+        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "BUSY"]?Set(dstatus=FW_BUSY))'."\n\t";
164 164
         // CHANUNAVAIL - канал не доступен. К примеру телефон не зарегистрирован или не отвечает.
165
-        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CHANUNAVAIL"]?Set(dstatus=FW_UNAV))' . "\n\t";
165
+        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CHANUNAVAIL"]?Set(dstatus=FW_UNAV))'."\n\t";
166 166
         // NOANSWER - не ответили по таймауту.
167
-        $conf .= 'same => n,ExecIf($["${dstatus}x" == "x"]?Set(dstatus=FW))' . "\n\t";
168
-        $conf .= 'same => n,Set(fw=${DB(${dstatus}/${EXTEN})})' . "\n\t";
169
-        $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Set(__pt1c_UNIQUEID=${UNDEFINED})' . "\n\t";
170
-        $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Goto(internal,${fw},1))' . "\n\t";
171
-        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . "\n\t";
172
-        $conf .= 'same => n,Hangup() ' . "\n\n";
167
+        $conf .= 'same => n,ExecIf($["${dstatus}x" == "x"]?Set(dstatus=FW))'."\n\t";
168
+        $conf .= 'same => n,Set(fw=${DB(${dstatus}/${EXTEN})})'."\n\t";
169
+        $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Set(__pt1c_UNIQUEID=${UNDEFINED})'."\n\t";
170
+        $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Goto(internal,${fw},1))'."\n\t";
171
+        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'."\n\t";
172
+        $conf .= 'same => n,Hangup() '."\n\n";
173 173
 
174 174
         $conf .= "[all_peers]\n";
175
-        $conf .= 'include => internal-hints' . "\n";
176
-        $conf .= 'exten => failed,1,Hangup()' . "\n";
175
+        $conf .= 'include => internal-hints'."\n";
176
+        $conf .= 'exten => failed,1,Hangup()'."\n";
177 177
 
178
-        $conf .= 'exten => _.!,1,ExecIf($[ "${EXTEN}" == "h" ]?Hangup())' . "\n\t";
178
+        $conf .= 'exten => _.!,1,ExecIf($[ "${EXTEN}" == "h" ]?Hangup())'."\n\t";
179 179
         // Фильтр спецсимволов. Разершаем только цифры.
180
-        $conf .= 'same => n,Set(cleanNumber=${FILTER(\*\#1234567890,${EXTEN})})' . "\n\t";
181
-        $conf .= 'same => n,ExecIf($["${EXTEN}" != "${cleanNumber}"]?Goto(${CONTEXT},${cleanNumber},$[${PRIORITY} + 1]))' . "\n\t";
180
+        $conf .= 'same => n,Set(cleanNumber=${FILTER(\*\#1234567890,${EXTEN})})'."\n\t";
181
+        $conf .= 'same => n,ExecIf($["${EXTEN}" != "${cleanNumber}"]?Goto(${CONTEXT},${cleanNumber},$[${PRIORITY} + 1]))'."\n\t";
182 182
 
183
-        $conf .= 'same => n,Set(__FROM_CHAN=${CHANNEL})' . "\n\t";
184
-        $conf .= 'same => n,ExecIf($["${OLD_LINKEDID}x" == "x"]?Set(__OLD_LINKEDID=${CHANNEL(linkedid)}))' . "\n\t";
185
-        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))' . "\n\t";
186
-        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))' . "\n\t";
183
+        $conf .= 'same => n,Set(__FROM_CHAN=${CHANNEL})'."\n\t";
184
+        $conf .= 'same => n,ExecIf($["${OLD_LINKEDID}x" == "x"]?Set(__OLD_LINKEDID=${CHANNEL(linkedid)}))'."\n\t";
185
+        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))'."\n\t";
186
+        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))'."\n\t";
187 187
 
188
-        $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(num)=${FROM_PEER}))' . "\n\t";
189
-        $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(name)=${FROM_PEER}))' . "\n\t";
188
+        $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(num)=${FROM_PEER}))'."\n\t";
189
+        $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(name)=${FROM_PEER}))'."\n\t";
190 190
 
191
-        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local" && "${FROM_PEER}x" == "x"]?Set(__FROM_PEER=${CALLERID(num)}))' . "\n\t";
192
-        $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t";
193
-        $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)' . "\n\t";
191
+        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local" && "${FROM_PEER}x" == "x"]?Set(__FROM_PEER=${CALLERID(num)}))'."\n\t";
192
+        $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t";
193
+        $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)'."\n\t";
194 194
 
195 195
         // Описываем возможность прыжка в пользовательский sub контекст.
196
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t";
196
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t";
197 197
 
198
-        $conf .= 'same => n,Goto(peer_${FROM_PEER},${EXTEN},1)' . "\n\n";
198
+        $conf .= 'same => n,Goto(peer_${FROM_PEER},${EXTEN},1)'."\n\n";
199 199
 
200
-        $pickupexten =  $this->generalSettings['PBXFeaturePickupExten'];
201
-        $conf        .= 'exten => _' . $pickupexten . $extension . ',1,Set(PICKUPEER=' . $technology . '/${FILTER(0-9,${EXTEN:2})})' . "\n\t";
202
-        $conf        .= 'same => n,Set(pt1c_dnid=${EXTEN})' . "\n\t";
203
-        $conf        .= 'same => n,PickupChan(${PICKUPEER})' . "\n\t";
204
-        $conf        .= 'same => n,Hangup()' . "\n\n";
200
+        $pickupexten = $this->generalSettings['PBXFeaturePickupExten'];
201
+        $conf        .= 'exten => _'.$pickupexten.$extension.',1,Set(PICKUPEER='.$technology.'/${FILTER(0-9,${EXTEN:2})})'."\n\t";
202
+        $conf        .= 'same => n,Set(pt1c_dnid=${EXTEN})'."\n\t";
203
+        $conf        .= 'same => n,PickupChan(${PICKUPEER})'."\n\t";
204
+        $conf        .= 'same => n,Hangup()'."\n\n";
205 205
 
206 206
         $voicemail_exten = $this->generalSettings['VoicemailExten'];
207
-        $conf            .= 'exten => ' . $voicemail_exten . ',1,NoOp(NOTICE, Dialing out from ${CALLERID(all)} to VoiceMail)' . "\n\t";
208
-        $conf            .= 'same => n,VoiceMailMain(admin@voicemailcontext,s)' . "\n\t";
209
-        $conf            .= 'same => n,Hangup()' . "\n\n";
207
+        $conf            .= 'exten => '.$voicemail_exten.',1,NoOp(NOTICE, Dialing out from ${CALLERID(all)} to VoiceMail)'."\n\t";
208
+        $conf            .= 'same => n,VoiceMailMain(admin@voicemailcontext,s)'."\n\t";
209
+        $conf            .= 'same => n,Hangup()'."\n\n";
210 210
 
211 211
         $conf .= "[voice_mail_peer] \n";
212
-        $conf .= 'exten => voicemail,1,Answer()' . "\n\t";
213
-        $conf .= 'same => n,VoiceMail(admin@voicemailcontext)' . "\n\t";
214
-        $conf .= 'same => n,Hangup()' . "\n\n";
212
+        $conf .= 'exten => voicemail,1,Answer()'."\n\t";
213
+        $conf .= 'same => n,VoiceMail(admin@voicemailcontext)'."\n\t";
214
+        $conf .= 'same => n,Hangup()'."\n\n";
215 215
 
216 216
         // Контекст для внутренних вызовов.
217 217
         $conf .= "[internal] \n";
218 218
 
219 219
         foreach ($additionalModules as $appClass) {
220 220
             $addition = $appClass->getIncludeInternal();
221
-            if (!empty($addition)){
222
-                $conf .=$appClass->confBlockWithComments($addition);
221
+            if (!empty($addition)) {
222
+                $conf .= $appClass->confBlockWithComments($addition);
223 223
             }
224 224
         }
225 225
 
226 226
         foreach ($additionalModules as $appClass) {
227 227
             $addition = $appClass->extensionGenInternal();
228
-            if (!empty($addition)){
229
-                $conf .=$appClass->confBlockWithComments($addition);
228
+            if (!empty($addition)) {
229
+                $conf .= $appClass->confBlockWithComments($addition);
230 230
             }
231 231
         }
232 232
 
233
-        $conf .= 'exten => i,1,NoOp(-- INVALID NUMBER --)' . "\n\t";
234
-        $conf .= 'same => n,Set(DIALSTATUS=INVALID_NUMBER)' . "\n\t";
235
-        $conf .= 'same => n,Playback(privacy-incorrect,noanswer)' . "\n\t";
236
-        $conf .= 'same => n,Hangup()' . "\n";
233
+        $conf .= 'exten => i,1,NoOp(-- INVALID NUMBER --)'."\n\t";
234
+        $conf .= 'same => n,Set(DIALSTATUS=INVALID_NUMBER)'."\n\t";
235
+        $conf .= 'same => n,Playback(privacy-incorrect,noanswer)'."\n\t";
236
+        $conf .= 'same => n,Hangup()'."\n";
237 237
 
238
-        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\n";
238
+        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\n";
239 239
 
240 240
         $conf .= "[internal-incoming]\n";
241
-        $conf .= 'exten => _.!,1,ExecIf($["${MASTER_CHANNEL(M_TIMEOUT)}x" != "x"]?Set(TIMEOUT(absolute)=${MASTER_CHANNEL(M_TIMEOUT)}))' . " \n\t";
242
-        $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT_CHANNEL)=${CHANNEL})' . " \n\t";
243
-        $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT)=${EMPTY_VAR})' . " \n\t";
244
-        $conf .= 'same => n,Goto(internal,${EXTEN},1)' . " \n\n";
241
+        $conf .= 'exten => _.!,1,ExecIf($["${MASTER_CHANNEL(M_TIMEOUT)}x" != "x"]?Set(TIMEOUT(absolute)=${MASTER_CHANNEL(M_TIMEOUT)}))'." \n\t";
242
+        $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT_CHANNEL)=${CHANNEL})'." \n\t";
243
+        $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT)=${EMPTY_VAR})'." \n\t";
244
+        $conf .= 'same => n,Goto(internal,${EXTEN},1)'." \n\n";
245 245
 
246 246
         $conf .= "[internal-users] \n";
247
-        $conf .= 'exten => _' . $extension . ',1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . " \n\t";
248
-        $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Set(SIPADDHEADER01=${EMPTY_VAR})' . " \n\t";
249
-        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))' . " \n\t";
247
+        $conf .= 'exten => _'.$extension.',1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'." \n\t";
248
+        $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Set(SIPADDHEADER01=${EMPTY_VAR})'." \n\t";
249
+        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))'." \n\t";
250 250
 
251
-        $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)' . "\n\t";
251
+        $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)'."\n\t";
252 252
         // Проверим, существует ли такой пир.
253 253
 
254
-        $conf .= 'same => n,ExecIf($["${PJSIP_ENDPOINT(${EXTEN},auth)}x" == "x"]?Goto(internal-num-undefined,${EXTEN},1))' . " \n\t";
255
-        $conf .= 'same => n,ExecIf($["${DEVICE_STATE(' . $technology . '/${EXTEN})}" == "BUSY"]?Set(DIALSTATUS=BUSY))' . " \n\t";
256
-        $conf .= 'same => n,GotoIf($["${DEVICE_STATE(' . $technology . '/${EXTEN})}" == "BUSY"]?fw_start)' . " \n\t";
254
+        $conf .= 'same => n,ExecIf($["${PJSIP_ENDPOINT(${EXTEN},auth)}x" == "x"]?Goto(internal-num-undefined,${EXTEN},1))'." \n\t";
255
+        $conf .= 'same => n,ExecIf($["${DEVICE_STATE('.$technology.'/${EXTEN})}" == "BUSY"]?Set(DIALSTATUS=BUSY))'." \n\t";
256
+        $conf .= 'same => n,GotoIf($["${DEVICE_STATE('.$technology.'/${EXTEN})}" == "BUSY"]?fw_start)'." \n\t";
257 257
 
258 258
         // Как долго звонить пиру.
259
-        $conf .= 'same => n,Set(ringlength=${DB(FW_TIME/${EXTEN})})' . " \n\t";
260
-        $conf .= 'same => n,ExecIf($["${ringlength}x" == "x"]?Set(ringlength=600))' . " \n\t";
261
-        $conf .= 'same => n,ExecIf($["${QUEUE_SRC_CHAN}x" != "x" && "${ISTRANSFER}x" == "x"]?Set(ringlength=600))' . " \n\t";
259
+        $conf .= 'same => n,Set(ringlength=${DB(FW_TIME/${EXTEN})})'." \n\t";
260
+        $conf .= 'same => n,ExecIf($["${ringlength}x" == "x"]?Set(ringlength=600))'." \n\t";
261
+        $conf .= 'same => n,ExecIf($["${QUEUE_SRC_CHAN}x" != "x" && "${ISTRANSFER}x" == "x"]?Set(ringlength=600))'." \n\t";
262 262
 
263
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1) ' . " \n\t";
263
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1) '." \n\t";
264 264
         // Совершаем вызов пира.
265
-        $conf .= 'same => n,Set(DST_CONTACT=${PJSIP_DIAL_CONTACTS(${EXTEN})})' . " \n\t";
266
-        $conf .= 'same => n,ExecIf($["${FIELDQTY(DST_CONTACT,&)}" != "1"]?Set(__PT1C_SIP_HEADER=${EMPTY_VAR}))' . " \n\t";
267
-        $conf .= 'same => n,ExecIf($["${DST_CONTACT}x" != "x"]?Dial(${DST_CONTACT},${ringlength},cTtekKHhU(${ISTRANSFER}dial_answer)b(dial_create_chan,s,1)):Set(DIALSTATUS=CHANUNAVAIL))' . " \n\t";
268
-        $conf .= 'same => n(fw_start),NoOp(dial_hangup)' . " \n\t";
265
+        $conf .= 'same => n,Set(DST_CONTACT=${PJSIP_DIAL_CONTACTS(${EXTEN})})'." \n\t";
266
+        $conf .= 'same => n,ExecIf($["${FIELDQTY(DST_CONTACT,&)}" != "1"]?Set(__PT1C_SIP_HEADER=${EMPTY_VAR}))'." \n\t";
267
+        $conf .= 'same => n,ExecIf($["${DST_CONTACT}x" != "x"]?Dial(${DST_CONTACT},${ringlength},cTtekKHhU(${ISTRANSFER}dial_answer)b(dial_create_chan,s,1)):Set(DIALSTATUS=CHANUNAVAIL))'." \n\t";
268
+        $conf .= 'same => n(fw_start),NoOp(dial_hangup)'." \n\t";
269 269
 
270 270
         // QUEUE_SRC_CHAN - установлена, если вызов сервершен агенту очереди.
271 271
         // Проверяем нужна ли переадресация
272
-        $conf       .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${ISTRANSFER}x" != "x"]?Goto(internal-fw,${EXTEN},1))' . " \n\t";
273
-        $conf       .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${QUEUE_SRC_CHAN}x" == "x"]?Goto(internal-fw,${EXTEN},1))' . " \n\t";
274
-        $conf       .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . " \n\t";
275
-        $conf       .= 'same => n,Hangup()' . "\n\n";
272
+        $conf       .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${ISTRANSFER}x" != "x"]?Goto(internal-fw,${EXTEN},1))'." \n\t";
273
+        $conf       .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${QUEUE_SRC_CHAN}x" == "x"]?Goto(internal-fw,${EXTEN},1))'." \n\t";
274
+        $conf       .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'." \n\t";
275
+        $conf       .= 'same => n,Hangup()'."\n\n";
276 276
 
277
-        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\n";
277
+        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\n";
278 278
     }
279 279
 
280 280
     /**
@@ -285,22 +285,22 @@  discard block
 block discarded – undo
285 285
     private function generateInternalTransfer(&$conf): void
286 286
     {
287 287
         $additionalModules = $this->di->getShared('pbxConfModules');
288
-        $conf              .= "[internal-transfer] \n";
288
+        $conf .= "[internal-transfer] \n";
289 289
 
290 290
         foreach ($additionalModules as $appClass) {
291
-            $addition= $appClass->getIncludeInternalTransfer();
292
-            if (!empty($addition)){
293
-                $conf .=$appClass->confBlockWithComments($addition);
291
+            $addition = $appClass->getIncludeInternalTransfer();
292
+            if (!empty($addition)) {
293
+                $conf .= $appClass->confBlockWithComments($addition);
294 294
             }
295 295
         }
296 296
 
297 297
         foreach ($additionalModules as $appClass) {
298
-            $addition= $appClass->extensionGenInternalTransfer();
299
-            if (!empty($addition)){
300
-                $conf .=$appClass->confBlockWithComments($addition);
298
+            $addition = $appClass->extensionGenInternalTransfer();
299
+            if (!empty($addition)) {
300
+                $conf .= $appClass->confBlockWithComments($addition);
301 301
             }
302 302
         }
303
-        $conf .= 'exten => h,1,Gosub(transfer_dial_hangup,${EXTEN},1)' . "\n\n";
303
+        $conf .= 'exten => h,1,Gosub(transfer_dial_hangup,${EXTEN},1)'."\n\n";
304 304
     }
305 305
 
306 306
     /**
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
     private function generateSipHints(&$conf): void
312 312
     {
313 313
         $additionalModules = $this->di->getShared('pbxConfModules');
314
-        $conf              .= "[internal-hints] \n";
314
+        $conf .= "[internal-hints] \n";
315 315
         foreach ($additionalModules as $appClass) {
316 316
             $addition = $appClass->extensionGenHints();
317
-            if (!empty($addition)){
318
-                $conf .=$appClass->confBlockWithComments($addition);
317
+            if (!empty($addition)) {
318
+                $conf .= $appClass->confBlockWithComments($addition);
319 319
             }
320 320
         }
321 321
         $conf .= "\n\n";
@@ -329,16 +329,16 @@  discard block
 block discarded – undo
329 329
     private function generateOutContextPeers(&$conf): void
330 330
     {
331 331
         $additionalModules = $this->di->getShared('pbxConfModules');
332
-        $conf              .= "[outgoing] \n";
332
+        $conf .= "[outgoing] \n";
333 333
 
334
-        $conf .= 'exten => _+.!,1,NoOp(Strip + sign from number and convert it to +)' . " \n\t";
335
-        $conf .= 'same => n,Set(ADDPLUS=+);' . " \n\t";
336
-        $conf .= 'same => n,Goto(${CONTEXT},${EXTEN:1},1);' . " \n\n";
337
-        $conf .= 'exten => _X!,1,NoOp(Start outgoing calling...)' . " \n\t";
338
-        $conf .= 'same => n,Ringing()' . " \n\t";
334
+        $conf .= 'exten => _+.!,1,NoOp(Strip + sign from number and convert it to +)'." \n\t";
335
+        $conf .= 'same => n,Set(ADDPLUS=+);'." \n\t";
336
+        $conf .= 'same => n,Goto(${CONTEXT},${EXTEN:1},1);'." \n\n";
337
+        $conf .= 'exten => _X!,1,NoOp(Start outgoing calling...)'." \n\t";
338
+        $conf .= 'same => n,Ringing()'." \n\t";
339 339
 
340 340
         // Описываем возможность прыжка в пользовательский sub контекст.
341
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t";
341
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t";
342 342
 
343 343
         /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $routs */
344 344
         /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $rout */
@@ -350,66 +350,66 @@  discard block
 block discarded – undo
350 350
             if ($technology !== '') {
351 351
                     $rout_data                       = $rout->toArray();
352 352
                     $rout_data['technology']         = $technology;
353
-                    $id_dialplan                     = $rout_data['providerid'] . '-' . $rout_data['id'] . '-outgoing';
353
+                    $id_dialplan                     = $rout_data['providerid'].'-'.$rout_data['id'].'-outgoing';
354 354
                     $provider_contexts[$id_dialplan] = $rout_data;
355
-                    $conf                            .= $this->generateOutgoingRegexPattern($rout_data);
355
+                    $conf .= $this->generateOutgoingRegexPattern($rout_data);
356 356
                     continue;
357 357
             }
358 358
         }
359
-        $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Hangup())' . " \n\t";
360
-        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${BLINDTRANSFER}x" != "x" && "${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t";
361
-        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . " \n\t";
362
-        $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" == "x"]?Gosub(dial,${EXTEN},1))' . "\n\t";
359
+        $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Hangup())'." \n\t";
360
+        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${BLINDTRANSFER}x" != "x" && "${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t";
361
+        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'." \n\t";
362
+        $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" == "x"]?Gosub(dial,${EXTEN},1))'."\n\t";
363 363
 
364
-        $conf .= 'same => n,Playback(silence/2,noanswer)' . " \n\t";
365
-        $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" != "x"]?Playback(followme/sorry,noanswer):Playback(cannot-complete-as-dialed,noanswer))' . " \n\t";
366
-        $conf .= 'same => n,Hangup()' . " \n\n";
367
-        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t";
364
+        $conf .= 'same => n,Playback(silence/2,noanswer)'." \n\t";
365
+        $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" != "x"]?Playback(followme/sorry,noanswer):Playback(cannot-complete-as-dialed,noanswer))'." \n\t";
366
+        $conf .= 'same => n,Hangup()'." \n\n";
367
+        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t";
368 368
 
369 369
         foreach ($provider_contexts as $id_dialplan => $rout) {
370 370
             $conf .= "\n[{$id_dialplan}]\n";
371 371
             if (isset($rout['trimfrombegin']) && $rout['trimfrombegin'] > 0) {
372 372
                 // $exten_var = '${ADDPLUS}${EXTEN:'.$rout['trimfrombegin'].'}';
373
-                $exten_var    = '${EXTEN:' . $rout['trimfrombegin'] . '}';
374
-                $change_exten = 'same => n,ExecIf($["${EXTEN}" != "${number}"]?Goto(${CONTEXT},${number},$[${PRIORITY} + 1]))' . "\n\t";
373
+                $exten_var    = '${EXTEN:'.$rout['trimfrombegin'].'}';
374
+                $change_exten = 'same => n,ExecIf($["${EXTEN}" != "${number}"]?Goto(${CONTEXT},${number},$[${PRIORITY} + 1]))'."\n\t";
375 375
             } else {
376 376
                 $exten_var    = '${ADDPLUS}${EXTEN}';
377 377
                 $change_exten = '';
378 378
             }
379
-            $conf .= 'exten => _X!,1,Set(number=' . $rout['prepend'] . $exten_var . ')' . "\n\t";
379
+            $conf .= 'exten => _X!,1,Set(number='.$rout['prepend'].$exten_var.')'."\n\t";
380 380
             $conf .= $change_exten;
381 381
             foreach ($additionalModules as $appClass) {
382 382
                 $addition = $appClass->generateOutRoutContext($rout);
383
-                if (!empty($addition)){
384
-                    $conf .=$appClass->confBlockWithComments($addition);
383
+                if (!empty($addition)) {
384
+                    $conf .= $appClass->confBlockWithComments($addition);
385 385
                 }
386 386
             }
387
-            $conf .= 'same => n,ExecIf($["${number}x" == "x"]?Hangup())' . "\n\t";
388
-            $conf .= 'same => n,Set(ROUTFOUND=1)' . "\n\t";
389
-            $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)' . "\n\t";
387
+            $conf .= 'same => n,ExecIf($["${number}x" == "x"]?Hangup())'."\n\t";
388
+            $conf .= 'same => n,Set(ROUTFOUND=1)'."\n\t";
389
+            $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)'."\n\t";
390 390
 
391
-            $conf .= 'same => n,ExecIf($["${EXTERNALPHONE}" == "${EXTEN}"]?Set(DOPTIONS=tk))' . "\n\t";
391
+            $conf .= 'same => n,ExecIf($["${EXTERNALPHONE}" == "${EXTEN}"]?Set(DOPTIONS=tk))'."\n\t";
392 392
 
393 393
             // Описываем возможность прыжка в пользовательский sub контекст.
394
-            $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(' . $rout['providerid'] . '-outgoing-custom,${EXTEN},1)}" == "1"]?' . $rout['providerid'] . '-outgoing-custom,${EXTEN},1)' . "\n\t";
394
+            $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS('.$rout['providerid'].'-outgoing-custom,${EXTEN},1)}" == "1"]?'.$rout['providerid'].'-outgoing-custom,${EXTEN},1)'."\n\t";
395 395
 
396 396
             if ($rout['technology'] === IAXConf::TYPE_IAX2) {
397
-                $conf .= 'same => n,Dial(' . $rout['technology'] . '/' . $rout['providerid'] . '/${number},600,${DOPTIONS}TKU(${ISTRANSFER}dial_answer)b(dial_create_chan,s,1))' . "\n\t";
397
+                $conf .= 'same => n,Dial('.$rout['technology'].'/'.$rout['providerid'].'/${number},600,${DOPTIONS}TKU(${ISTRANSFER}dial_answer)b(dial_create_chan,s,1))'."\n\t";
398 398
             } else {
399
-                $conf .= 'same => n,Dial(' . $rout['technology'] . '/${number}@' . $rout['providerid'] . ',600,${DOPTIONS}TKU(${ISTRANSFER}dial_answer)b(dial_create_chan,s,1))' . "\n\t";
399
+                $conf .= 'same => n,Dial('.$rout['technology'].'/${number}@'.$rout['providerid'].',600,${DOPTIONS}TKU(${ISTRANSFER}dial_answer)b(dial_create_chan,s,1))'."\n\t";
400 400
             }
401 401
             foreach ($additionalModules as $appClass) {
402 402
                 $addition = $appClass->generateOutRoutAfterDialContext($rout);
403
-                if (!empty($addition)){
404
-                    $conf .=$appClass->confBlockWithComments($addition);
403
+                if (!empty($addition)) {
404
+                    $conf .= $appClass->confBlockWithComments($addition);
405 405
                 }
406 406
             }
407
-            $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";
407
+            $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";
408 408
 
409
-            $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t";
410
-            $conf .= 'same => n,ExecIf($["${DIALSTATUS}" = "ANSWER"]?Hangup())' . "\n\t";
411
-            $conf .= 'same => n,Set(pt1c_UNIQUEID=${EMPTY_VALUE})' . "\n\t";
412
-            $conf .= 'same => n,return' . "\n";
409
+            $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t";
410
+            $conf .= 'same => n,ExecIf($["${DIALSTATUS}" = "ANSWER"]?Hangup())'."\n\t";
411
+            $conf .= 'same => n,Set(pt1c_UNIQUEID=${EMPTY_VALUE})'."\n\t";
412
+            $conf .= 'same => n,return'."\n";
413 413
         }
414 414
     }
415 415
 
@@ -425,14 +425,14 @@  discard block
 block discarded – undo
425 425
         $conf        = '';
426 426
         $restnumbers = '';
427 427
         if (isset($rout['restnumbers']) && $rout['restnumbers'] > 0) {
428
-            $restnumbers = "[0-9]{" . $rout['restnumbers'] . "}$";
428
+            $restnumbers = "[0-9]{".$rout['restnumbers']."}$";
429 429
         } elseif ($rout['restnumbers'] == 0) {
430 430
             $restnumbers = "$";
431 431
         } elseif ($rout['restnumbers'] == -1) {
432 432
             $restnumbers = "";
433 433
         }
434 434
         $numberbeginswith = $rout['numberbeginswith'];
435
-        $conf             .= 'same => n,ExecIf($["${REGEX("^' . $numberbeginswith . $restnumbers . '" ${EXTEN})}" == "1"]?Gosub(' . $rout['providerid'] . '-' . $rout['id'] . '-outgoing,${EXTEN},1))' . " \n\t";
435
+        $conf .= 'same => n,ExecIf($["${REGEX("^'.$numberbeginswith.$restnumbers.'" ${EXTEN})}" == "1"]?Gosub('.$rout['providerid'].'-'.$rout['id'].'-outgoing,${EXTEN},1))'." \n\t";
436 436
 
437 437
         return $conf;
438 438
     }
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
         $conf              .= self::generateIncomingContextPeers('none', '', '');
450 450
         $conf              .= "[public-direct-dial] \n";
451 451
         foreach ($additionalModules as $appClass) {
452
-            if ($appClass instanceof $this){
452
+            if ($appClass instanceof $this) {
453 453
                 continue;
454 454
             }
455 455
             $appClass->generatePublicContext($conf);
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
         $conf              = '';
480 480
         $dialplan          = [];
481 481
         $di = Di::getDefault();
482
-        if ($di===null){
482
+        if ($di === null) {
483 483
             return '';
484 484
         }
485 485
         $additionalModules = $di->getShared('pbxConfModules');
@@ -535,55 +535,55 @@  discard block
 block discarded – undo
535 535
             if (empty($rout_data)) {
536 536
                 $ext_prefix = ('none' === $provider) ? '' : '_';
537 537
                 $rout_data  .= "exten => {$ext_prefix}{$rout_number},1,NoOp(--- Incoming call ---)\n\t";
538
-                $rout_data  .= 'same => n,Set(CHANNEL(language)=' . $lang . ')' . "\n\t";
539
-                $rout_data  .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t";
540
-                $rout_data  .= 'same => n,Set(__FROM_DID=${EXTEN})' . "\n\t";
541
-                $rout_data  .= 'same => n,Set(__FROM_CHAN=${CHANNEL})' . "\n\t";
538
+                $rout_data  .= 'same => n,Set(CHANNEL(language)='.$lang.')'."\n\t";
539
+                $rout_data  .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t";
540
+                $rout_data  .= 'same => n,Set(__FROM_DID=${EXTEN})'."\n\t";
541
+                $rout_data  .= 'same => n,Set(__FROM_CHAN=${CHANNEL})'."\n\t";
542 542
 
543 543
                 // Установка имени пира.
544
-                $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))' . "\n\t";
545
-                $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Set(__FROM_PEER=${CALLERID(num)}))' . "\n\t";
544
+                $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))'."\n\t";
545
+                $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Set(__FROM_PEER=${CALLERID(num)}))'."\n\t";
546 546
 
547 547
                 // TODO / Подмена входящего callerid.
548
-                $rout_data .= 'same => n,Gosub(add-trim-prefix-clid,${EXTEN},1)' . "\n\t";
548
+                $rout_data .= 'same => n,Gosub(add-trim-prefix-clid,${EXTEN},1)'."\n\t";
549 549
 
550 550
                 foreach ($additionalModules as $appClass) {
551 551
                      $addition = $appClass->generateIncomingRoutBeforeDial($rout_number);
552
-                     if (!empty($addition)){
553
-                         $rout_data .=$appClass->confBlockWithComments($addition);
552
+                     if (!empty($addition)) {
553
+                         $rout_data .= $appClass->confBlockWithComments($addition);
554 554
                      }
555 555
                  }
556 556
 
557 557
                 // Перехват на ответственного.
558
-                $rout_data .= 'same => n,UserEvent(Interception,CALLERID: ${CALLERID(num)},chan1c: ${CHANNEL},FROM_DID: ${FROM_DID})' . "\n\t";
558
+                $rout_data .= 'same => n,UserEvent(Interception,CALLERID: ${CALLERID(num)},chan1c: ${CHANNEL},FROM_DID: ${FROM_DID})'."\n\t";
559 559
                 // Проверим распискние для входящих внешних звонков.
560 560
                 $rout_data .= 'same => n,Gosub(check-out-work-time,${EXTEN},1)';
561 561
                 // Описываем возможность прыжка в пользовательский sub контекст.
562
-                $rout_data .= " \n\t" . 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)';
562
+                $rout_data .= " \n\t".'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)';
563 563
             }
564 564
 
565
-            if ( ! empty($rout['extension'])) {
565
+            if (!empty($rout['extension'])) {
566 566
                 $rout_data = rtrim($rout_data);
567 567
                 // Обязательно проверяем "DIALSTATUS", в случае с парковой через AMI вызова это необходимо.
568 568
                 // При ответе может отработать следующий приоритет.
569
-                if ( ! isset($rout_data_dial[$rout_number])) {
569
+                if (!isset($rout_data_dial[$rout_number])) {
570 570
                     $rout_data_dial[$rout_number] = '';
571 571
                 }
572 572
 
573
-                if(in_array($rout['extension'], $confExtensions, true)){
573
+                if (in_array($rout['extension'], $confExtensions, true)) {
574 574
                     // Это конференция. Тут не требуется обработка таймаута ответа.
575 575
                     // Вызов будет отвечен сразу конференцией.
576
-                    $dial_command = " \n\t" . 'same => n,' . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Goto(internal,{$rout['extension']},1));";
576
+                    $dial_command = " \n\t".'same => n,'.'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?'."Goto(internal,{$rout['extension']},1));";
577 577
                     $rout_data_dial[$rout_number] .= "";
578
-                }else{
579
-                    $dial_command                 = " \n\t" . 'same => n,' . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Dial(Local/{$rout['extension']}@internal-incoming/n,{$timeout},cTKg));";
580
-                    $rout_data_dial[$rout_number] .= " \n\t" . "same => n,Set(M_TIMEOUT={$timeout})";
578
+                } else {
579
+                    $dial_command = " \n\t".'same => n,'.'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?'."Dial(Local/{$rout['extension']}@internal-incoming/n,{$timeout},cTKg));";
580
+                    $rout_data_dial[$rout_number] .= " \n\t"."same => n,Set(M_TIMEOUT={$timeout})";
581 581
                 }
582 582
                 $rout_data_dial[$rout_number] .= $dial_command;
583 583
 
584 584
                 if (is_array($provider)) {
585 585
                     $key = $provider[$rout['provider']] ?? '';
586
-                    if ( ! isset($rout_data_dial[$key])) {
586
+                    if (!isset($rout_data_dial[$key])) {
587 587
                         $rout_data_dial[$key] = '';
588 588
                     }
589 589
                     if (empty($number)) {
@@ -594,9 +594,9 @@  discard block
 block discarded – undo
594 594
         }
595 595
 
596 596
         if (is_string($login)) {
597
-            $add_login_pattern = ! empty($login);
597
+            $add_login_pattern = !empty($login);
598 598
             foreach ($data as $rout) {
599
-                if ( ! $add_login_pattern) {
599
+                if (!$add_login_pattern) {
600 600
                     break;
601 601
                 } // Логин не заполнен, обработка не требуется.
602 602
                 $is_num = preg_match_all('/^\d+$/m', $login, $matches, PREG_SET_ORDER, 0);
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
             if ($add_login_pattern && array_key_exists('X!', $rout_data_dial) && isset($dialplan['X!'])) {
617 617
                 $dialplan[$login]       = str_replace('_X!,1', "{$login},1", $dialplan['X!']);
618 618
                 $rout_data_dial[$login] = $rout_data_dial['X!'];
619
-            }elseif($add_login_pattern === true && $need_def_rout === true && count($data) === 1){
619
+            }elseif ($add_login_pattern === true && $need_def_rout === true && count($data) === 1) {
620 620
                 // Только маршрут "По умолчанию".
621 621
                 $dialplan[$login]       = str_replace('_X!,1', "{$login},1", $dialplan['X!']);
622 622
             }
@@ -627,7 +627,7 @@  discard block
 block discarded – undo
627 627
         }
628 628
 
629 629
         foreach ($dialplan as $key => &$dpln) {
630
-            if ( ! array_key_exists($key, $rout_data_dial)) {
630
+            if (!array_key_exists($key, $rout_data_dial)) {
631 631
                 continue;
632 632
             }
633 633
             $dpln = rtrim($dpln);
@@ -636,34 +636,34 @@  discard block
 block discarded – undo
636 636
         unset($dpln);
637 637
 
638 638
         $uniqid = is_string($provider) ? $provider : $uniqid;
639
-        $conf   .= "\n" . "[{$uniqid}-incoming]\n";
639
+        $conf .= "\n"."[{$uniqid}-incoming]\n";
640 640
         foreach ($dialplan as $dpln) {
641
-            $conf .= $dpln . "\n";
641
+            $conf .= $dpln."\n";
642 642
             if (null === $default_action && 'none' !== $provider) {
643 643
                 continue;
644 644
             }
645 645
             if ('extension' === $default_action->action) {
646 646
                 // Обязательно проверяем "DIALSTATUS", в случае с парковой через AMI вызова это необходимо.
647 647
                 // При ответе может отработать следующий приоритет.
648
-                $conf .= "\t" . 'same => n,Set(M_TIMEOUT=0)' . "\n";
649
-                if(in_array($default_action->extension, $confExtensions, true)){
648
+                $conf .= "\t".'same => n,Set(M_TIMEOUT=0)'."\n";
649
+                if (in_array($default_action->extension, $confExtensions, true)) {
650 650
                     // Это конференция. Тут не требуется обработка таймаута ответа.
651 651
                     // Вызов будет отвечен сразу конференцией.
652
-                    $conf .= "\t" . "same => n," . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Goto(internal,{$default_action->extension},1)); default action" . "\n";
653
-                }else {
654
-                    $conf .= "\t" . "same => n," . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Dial(Local/{$default_action->extension}@internal/n,,cTKg)); default action" . "\n";
652
+                    $conf .= "\t"."same => n,".'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?'."Goto(internal,{$default_action->extension},1)); default action"."\n";
653
+                } else {
654
+                    $conf .= "\t"."same => n,".'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?'."Dial(Local/{$default_action->extension}@internal/n,,cTKg)); default action"."\n";
655 655
                 }
656 656
                 foreach ($additionalModules as $appClass) {
657 657
                     $addition = $appClass->generateIncomingRoutAfterDialContext($uniqid);
658
-                    if (!empty($addition)){
659
-                         $conf .=$appClass->confBlockWithComments($addition);
658
+                    if (!empty($addition)) {
659
+                         $conf .= $appClass->confBlockWithComments($addition);
660 660
                     }
661 661
                 }
662
-                $conf .= " \t" . 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-after-dial-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-after-dial-custom,${EXTEN},1)' . "\n";
662
+                $conf .= " \t".'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-after-dial-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-after-dial-custom,${EXTEN},1)'."\n";
663 663
             } elseif ('busy' === $default_action->action) {
664
-                $conf .= "\t" . "same => n,Busy()" . "\n";
664
+                $conf .= "\t"."same => n,Busy()"."\n";
665 665
             }
666
-            $conf .= "\t" . "same => n,Hangup()" . "\n";
666
+            $conf .= "\t"."same => n,Hangup()"."\n";
667 667
         }
668 668
 
669 669
         return $conf;
@@ -679,10 +679,10 @@  discard block
 block discarded – undo
679 679
     private function generateOutWorkTimes(&$conf): string
680 680
     {
681 681
         $conf .= "\n\n[playback-exit]\n";
682
-        $conf .= 'exten => _.!,1,NoOp(check time)' . "\n\t";
683
-        $conf .= 'same => n,Gosub(dial_outworktimes,${EXTEN},1)' . "\n\t";
684
-        $conf .= 'same => n,Playback(${filename})' . "\n\t";
685
-        $conf .= 'same => n,Hangup()' . "\n\n";
682
+        $conf .= 'exten => _.!,1,NoOp(check time)'."\n\t";
683
+        $conf .= 'same => n,Gosub(dial_outworktimes,${EXTEN},1)'."\n\t";
684
+        $conf .= 'same => n,Playback(${filename})'."\n\t";
685
+        $conf .= 'same => n,Hangup()'."\n\n";
686 686
 
687 687
         $conf .= "[check-out-work-time]\n";
688 688
         $conf .= "exten => _.!,1,NoOp(check time)\n\t";
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
         $now_year = 1 * date('Y', time());
695 695
         foreach ($data as $out_data) {
696 696
             /** @var \MikoPBX\Common\Models\OutWorkTimes $out_data */
697
-            if ( ! empty($out_data->date_from) && ! empty($out_data->date_to)) {
698
-                $year_from = 1 * date('Y', (int)$out_data->date_from);
699
-                $year_to   = 1 * date('Y', (int)$out_data->date_to);
697
+            if (!empty($out_data->date_from) && !empty($out_data->date_to)) {
698
+                $year_from = 1 * date('Y', (int) $out_data->date_from);
699
+                $year_to   = 1 * date('Y', (int) $out_data->date_to);
700 700
                 if ($now_year < $year_from || $now_year > $year_to) {
701 701
                     // Правило не актуально для текущего года.
702 702
                     continue;
@@ -733,11 +733,11 @@  discard block
 block discarded – undo
733 733
                 $mdays  = '*';
734 734
                 $months = '*';
735 735
             } else {
736
-                $mdays  = strtolower(date("j", (int)$date_from));
737
-                $months = strtolower(date("M", (int)$date_from));
738
-                if ( ! empty($date_to)) {
739
-                    $mdays  .= "-" . strtolower(date("j", (int)$date_to));
740
-                    $months .= "-" . strtolower(date("M", (int)$date_to));
736
+                $mdays  = strtolower(date("j", (int) $date_from));
737
+                $months = strtolower(date("M", (int) $date_from));
738
+                if (!empty($date_to)) {
739
+                    $mdays  .= "-".strtolower(date("j", (int) $date_to));
740
+                    $months .= "-".strtolower(date("M", (int) $date_to));
741 741
                 }
742 742
             }
743 743
 
@@ -750,12 +750,12 @@  discard block
 block discarded – undo
750 750
                 $res           = SoundFiles::findFirst($out_data->audio_message_id);
751 751
                 $audio_message = ($res === null) ? '' : Util::trimExtensionForFile($res->path);
752 752
 
753
-                $conf_out_set_var .= "[work-time-set-var-{$out_data->id}]\n" .
754
-                    'exten => _.!,1,Set(filename=' . $audio_message . ')' . "\n\t" .
755
-                    'same => n,Goto(playback-exit,${EXTEN},1)' . "\n\n";
753
+                $conf_out_set_var .= "[work-time-set-var-{$out_data->id}]\n".
754
+                    'exten => _.!,1,Set(filename='.$audio_message.')'."\n\t".
755
+                    'same => n,Goto(playback-exit,${EXTEN},1)'."\n\n";
756 756
 
757 757
                 $appname = 'ExecIfTime';
758
-                $appdata = 'Goto(work-time-set-var-' . $out_data->id . ',${EXTEN},1)';
758
+                $appdata = 'Goto(work-time-set-var-'.$out_data->id.',${EXTEN},1)';
759 759
             }
760 760
             $conf .= "same => n,{$appname}($times,$weekdays,$mdays,$months?{$appdata})\n\t";
761 761
         }
@@ -781,10 +781,10 @@  discard block
 block discarded – undo
781 781
         if ($provider !== null) {
782 782
             if ($provider->type === 'SIP') {
783 783
                 $account    = Sip::findFirst('disabled="0" AND uniqid = "'.$uniqueID.'"');
784
-                $technology = ($account === null)?'':SIPConf::getTechnology();
784
+                $technology = ($account === null) ? '' : SIPConf::getTechnology();
785 785
             } elseif ($provider->type === 'IAX') {
786 786
                 $account    = Iax::findFirst('disabled="0" AND uniqid = "'.$uniqueID.'"');
787
-                $technology = ($account === null)?'':'IAX2';
787
+                $technology = ($account === null) ? '' : 'IAX2';
788 788
             }
789 789
         }
790 790
 
Please login to merge, or discard this patch.