Passed
Push — master ( 6427d5...5783a1 )
by Nikolay
13:52 queued 05:42
created
src/Core/Workers/WorkerCallEvents.php 1 patch
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function MixMonitor($channel, $file_name = null, $sub_dir = null, $full_name = null, $onlySetVar = false): string
41 41
     {
42
-        $resFile = $this->mixMonitorChannels[$channel]??'';
43
-        if($resFile !== ''){
42
+        $resFile = $this->mixMonitorChannels[$channel] ?? '';
43
+        if ($resFile !== '') {
44 44
             return $resFile;
45 45
         }
46
-        $resFile           = '';
46
+        $resFile = '';
47 47
         $file_name = str_replace('/', '_', $file_name);
48 48
         if ($this->record_calls) {
49
-            if ( ! file_exists($full_name)) {
49
+            if (!file_exists($full_name)) {
50 50
                 $monitor_dir = Storage::getMonitorDir();
51 51
                 if ($sub_dir === null) {
52 52
                     $sub_dir = date('Y/m/d/H/');
@@ -62,21 +62,21 @@  discard block
 block discarded – undo
62 62
                 $options = 'ab';
63 63
             }
64 64
             $nicePath   = Util::which('nice');
65
-            $wav2mp3Path= Util::which('wav2mp3.sh');
65
+            $wav2mp3Path = Util::which('wav2mp3.sh');
66 66
 
67 67
             $arr = $this->am->GetChannels(false);
68
-            if(!in_array($channel, $arr, true)){
68
+            if (!in_array($channel, $arr, true)) {
69 69
                 CdrDb::LogEvent("MixMonitor: Channel {$channel} not found.");
70 70
                 return '';
71 71
             }
72 72
             $srcFile = "{$f}.wav";
73 73
             $resFile = "{$f}.mp3";
74 74
             $command = "{$nicePath} -n 19 {$wav2mp3Path} '{$f}'";
75
-            if($onlySetVar){
75
+            if ($onlySetVar) {
76 76
                 $this->am->SetVar($channel, 'MIX_FILE_NAME', $srcFile);
77
-                $this->am->SetVar($channel, 'MIX_CMD',       $command);
78
-                $this->am->SetVar($channel, 'MIX_OPTIONS',   $options);
79
-            }else{
77
+                $this->am->SetVar($channel, 'MIX_CMD', $command);
78
+                $this->am->SetVar($channel, 'MIX_OPTIONS', $options);
79
+            } else {
80 80
                 $res        = $this->am->MixMonitor($channel, $srcFile, $options, $command);
81 81
                 $res['cmd'] = "MixMonitor($channel, $file_name)";
82 82
                 CdrDb::LogEvent(json_encode($res));
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
      */
96 96
     public function StopMixMonitor($channel): void
97 97
     {
98
-        if(isset($this->mixMonitorChannels[$channel])){
98
+        if (isset($this->mixMonitorChannels[$channel])) {
99 99
             unset($this->mixMonitorChannels[$channel]);
100
-        }else{
100
+        } else {
101 101
             return;
102 102
         }
103 103
         if ($this->record_calls) {
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
         foreach ($m_data as $row) {
138 138
             $row->writeAttribute('endtime', $data['start']);
139 139
             $res = $row->update();
140
-            if ( ! $res) {
140
+            if (!$res) {
141 141
                 Util::sysLogMsg('Action_app_end', implode(' ', $row->getMessages()));
142 142
             }
143 143
         }
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
             // мобильный и внутренний номер.
157 157
             $filter = [
158 158
                 '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:org_id:) AND endtime = ""',
159
-                'bind' => ['UNIQUEID' => $data['UNIQUEID'], 'org_id' => $data['org_id'],],
159
+                'bind' => ['UNIQUEID' => $data['UNIQUEID'], 'org_id' => $data['org_id'], ],
160 160
             ];
161 161
         } else {
162 162
             $filter = [
@@ -173,14 +173,14 @@  discard block
 block discarded – undo
173 173
         /** @var CallDetailRecordsTmp $row */
174 174
         $m_data = CallDetailRecordsTmp::find($filter);
175 175
         foreach ($m_data as $row) {
176
-            if ( ! is_object($row)) {
176
+            if (!is_object($row)) {
177 177
                 continue;
178 178
             }
179 179
             ///
180 180
             // Проверим, если более одного канала SIP/256 при входящем.
181 181
             $column_chan_name = ('ORIGINATE' === $row->dialstatus) ? 'src_chan' : 'dst_chan';
182 182
 
183
-            if ( ! empty($row->$column_chan_name) && $data['dst_chan'] !== $row->$column_chan_name) {
183
+            if (!empty($row->$column_chan_name) && $data['dst_chan'] !== $row->$column_chan_name) {
184 184
                 if ($row_create) {
185 185
                     continue;
186 186
                 }
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
                     $new_row->writeAttribute($attribute, $value);
195 195
                 }
196 196
                 $new_row->writeAttribute($column_chan_name, $data['dst_chan']);
197
-                $new_row->writeAttribute('UNIQUEID', $data['UNIQUEID'] . '_' . $data['dst_chan']);
197
+                $new_row->writeAttribute('UNIQUEID', $data['UNIQUEID'].'_'.$data['dst_chan']);
198 198
                 // Подмена $row;
199 199
                 $row        = $new_row;
200 200
                 $row_create = true;
@@ -207,8 +207,8 @@  discard block
 block discarded – undo
207 207
                 // При оригинации меняется местами srs_chan в поле dst_chan.
208 208
                 $row->writeAttribute('src_chan', $data['dst_chan']);
209 209
             } else {
210
-                if ( ! $rec_start) {
211
-                    $data['recordingfile'] = $this->MixMonitor($data['dst_chan'], $row->UNIQUEID,null, $row->recordingfile,true);
210
+                if (!$rec_start) {
211
+                    $data['recordingfile'] = $this->MixMonitor($data['dst_chan'], $row->UNIQUEID, null, $row->recordingfile, true);
212 212
                     $row->writeAttribute('recordingfile', $data['recordingfile']);
213 213
                     $rec_start = true;
214 214
                 }
@@ -216,14 +216,14 @@  discard block
 block discarded – undo
216 216
                 $row->writeAttribute('dst_chan', $data['dst_chan']);
217 217
             }
218 218
 
219
-            if (isset($data['to_account']) && ! empty($data['to_account'])) {
219
+            if (isset($data['to_account']) && !empty($data['to_account'])) {
220 220
                 $row->writeAttribute($account_col, $data['to_account']);
221 221
             }
222
-            if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) {
222
+            if (isset($data['dst_call_id']) && !empty($data['dst_call_id'])) {
223 223
                 $row->writeAttribute('dst_call_id', $data['dst_call_id']);
224 224
             }
225 225
             $res = $row->save();
226
-            if ( ! $res) {
226
+            if (!$res) {
227 227
                 Util::sysLogMsg('Action_dial_create_chan', implode(' ', $row->getMessages()));
228 228
             }
229 229
         }
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
             // Событие возникает, когда мы пытаемся перехватить вызов на соседний телефон.
244 244
             $filter = [
245 245
                 'UNIQUEID=:UNIQUEID:',
246
-                'bind' => ['UNIQUEID' => $data['old_id'],],
246
+                'bind' => ['UNIQUEID' => $data['old_id'], ],
247 247
             ];
248 248
             /** @var CallDetailRecordsTmp $m_data */
249 249
             $m_data = CallDetailRecordsTmp::find($filter);
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
                 $new_data['dst_chan']       = $data['agi_channel'];
258 258
                 $new_data['dst_num']        = $data['dst_num'];
259 259
                 $new_data['UNIQUEID']       = $data['id'];
260
-                $new_data['recordingfile']  = $this->MixMonitor($new_data['dst_chan'],  'pickup_'.$new_data['UNIQUEID']);
260
+                $new_data['recordingfile']  = $this->MixMonitor($new_data['dst_chan'], 'pickup_'.$new_data['UNIQUEID']);
261 261
 
262 262
                 unset($new_data['id']);
263 263
                 unset($new_data['end']);
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
                 $this->am->UserEvent('CdrConnector', ['AgiData' => $AgiData]);
271 271
             }
272 272
         } else {
273
-            if ( ! empty($data['ENDCALLONANSWER'])) {
273
+            if (!empty($data['ENDCALLONANSWER'])) {
274 274
                 // Переменная ENDCALLONANSWER устанавливается при начале работы умной маршуртизации.
275 275
                 // Как только произошел ответ на вызов, отметим вызов на приложение как завершенный.
276 276
                 $filter = [
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
                     $row->writeAttribute('endtime', $data['answer']);
288 288
                     $row->writeAttribute('is_app', 1);
289 289
                     $res = $row->save();
290
-                    if ( ! $res) {
290
+                    if (!$res) {
291 291
                         Util::sysLogMsg('ENDCALLONANSWER', implode(' ', $row->getMessages()));
292 292
                     }
293 293
                 }
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
                     '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:UNIQUEID_CHAN:) AND answer = "" AND endtime = ""',
310 310
                     'bind' => [
311 311
                         'UNIQUEID'      => $data['id'],
312
-                        'UNIQUEID_CHAN' => $data['id'] . '_' . $data['agi_channel'],
312
+                        'UNIQUEID_CHAN' => $data['id'].'_'.$data['agi_channel'],
313 313
                     ],
314 314
                 ];
315 315
             }
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
                         continue;
323 323
                     }
324 324
                     // Найдем все прочие CDR по данному originate и отметим как завершенные.
325
-                    $filter      = [
325
+                    $filter = [
326 326
                         'linkedid=:linkedid: AND endtime <> "" AND src_chan <> :src_chan:',
327 327
                         'bind' => [
328 328
                             'linkedid' => $row->linkedid,
@@ -336,7 +336,7 @@  discard block
 block discarded – undo
336 336
                             $orgn_row->writeAttribute('endtime', $data['answer']);
337 337
                         }
338 338
                         $orgn_row->writeAttribute('dst_chan', '');
339
-                        $orgn_row->writeAttribute('UNIQUEID', $data['id'] . '_' . $orgn_row->src_chan);
339
+                        $orgn_row->writeAttribute('UNIQUEID', $data['id'].'_'.$orgn_row->src_chan);
340 340
                         $orgn_row->update();
341 341
                     }
342 342
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
                     $row->writeAttribute('answer', $data['answer']);
350 350
                 }
351 351
                 $res = $row->save();
352
-                if ( ! $res) {
352
+                if (!$res) {
353 353
                     Util::sysLogMsg('Action_dial_answer', implode(' ', $row->getMessages()));
354 354
                 }
355 355
             }
@@ -375,10 +375,10 @@  discard block
 block discarded – undo
375 375
         $this->hangupChanCheckSipTrtansfer($data, $channels);
376 376
 
377 377
         // Очистим память.
378
-        if(isset($this->checkChanHangupTransfer[$data['agi_channel']])){
378
+        if (isset($this->checkChanHangupTransfer[$data['agi_channel']])) {
379 379
             unset($this->checkChanHangupTransfer[$data['agi_channel']]);
380 380
         }
381
-        if(isset($this->mixMonitorChannels[$data['agi_channel']])){
381
+        if (isset($this->mixMonitorChannels[$data['agi_channel']])) {
382 382
             unset($this->mixMonitorChannels[$data['agi_channel']]);
383 383
         }
384 384
     }
@@ -390,24 +390,24 @@  discard block
 block discarded – undo
390 390
      */
391 391
     private function hangupChanCheckSipTrtansfer($data, $channels):void{
392 392
         $not_local = (stripos($data['agi_channel'], 'local/') === false);
393
-        if($not_local === false || $data['OLD_LINKEDID'] !== $data['linkedid']) {
393
+        if ($not_local === false || $data['OLD_LINKEDID'] !== $data['linkedid']) {
394 394
             return;
395 395
         }
396 396
         $active_chans = $this->am->GetChannels(false);
397 397
         // Намек на SIP трансфер.
398 398
         foreach ($channels as $data_chan) {
399
-            if ( ! in_array($data_chan['chan'], $active_chans, true)) {
399
+            if (!in_array($data_chan['chan'], $active_chans, true)) {
400 400
                 // Вызов уже завершен. Не интересно.
401 401
                 continue;
402 402
             }
403 403
             $BRIDGEPEER = $this->am->GetVar($data_chan['chan'], 'BRIDGEPEER', null, false);
404
-            if ( ! in_array($BRIDGEPEER, $active_chans, true) || !is_string($BRIDGEPEER)) {
404
+            if (!in_array($BRIDGEPEER, $active_chans, true) || !is_string($BRIDGEPEER)) {
405 405
                 // Вызов уже завершен. Не интересно.
406 406
                 continue;
407 407
             }
408 408
 
409 409
             $linkedid = $this->am->GetVar($data_chan['chan'], 'CDR(linkedid)', null, false);
410
-            if ( empty($linkedid) || $linkedid === $data['linkedid']) {
410
+            if (empty($linkedid) || $linkedid === $data['linkedid']) {
411 411
                 continue;
412 412
             }
413 413
 
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
             $n_data['start']         = date('Y-m-d H:i:s');
421 421
             $n_data['answer']        = date('Y-m-d H:i:s');
422 422
             $n_data['linkedid']      = $linkedid;
423
-            $n_data['UNIQUEID']      = $data['linkedid'] . Util::generateRandomString();
423
+            $n_data['UNIQUEID']      = $data['linkedid'].Util::generateRandomString();
424 424
             $n_data['transfer']      = '0';
425 425
             $n_data['recordingfile'] = $this->MixMonitor($n_data['dst_chan'], $n_data['UNIQUEID']);
426 426
             $n_data['did']           = $data_chan['did'];
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
      * @param array $channels
453 453
      */
454 454
     private function hangupChanEndCalls(array $data, array &$transfer_calls, array &$channels):void{
455
-        $filter         = [
455
+        $filter = [
456 456
             'linkedid=:linkedid: AND endtime = "" AND (src_chan=:src_chan: OR dst_chan=:dst_chan:)',
457 457
             'bind' => [
458 458
                 'linkedid' => $data['linkedid'],
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
             }
470 470
             if ($row->dialstatus === 'ORIGINATE') {
471 471
                 $row->writeAttribute('dialstatus', '');
472
-                if($row->answer === ''){
473
-                    $newId = $row->linkedid.'_'.$row->src_num.'_'.substr($row->src_chan, strpos($row->src_chan,'-') +1);
472
+                if ($row->answer === '') {
473
+                    $newId = $row->linkedid.'_'.$row->src_num.'_'.substr($row->src_chan, strpos($row->src_chan, '-') + 1);
474 474
                     $row->writeAttribute('UNIQUEID', $newId);
475 475
                 }
476 476
             }
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
                 $row->writeAttribute('dialstatus', $data['dialstatus']);
484 484
             }
485 485
             $res = $row->update();
486
-            if ( ! $res) {
486
+            if (!$res) {
487 487
                 Util::sysLogMsg('Action_hangup_chan', implode(' ', $row->getMessages()));
488 488
             }
489 489
 
@@ -515,14 +515,14 @@  discard block
 block discarded – undo
515 515
      */
516 516
     public function Action_CreateRowTransfer($action, $data, $calls_data = null): void
517 517
     {
518
-        if( isset($this->checkChanHangupTransfer[$data['agi_channel']]) ) {
518
+        if (isset($this->checkChanHangupTransfer[$data['agi_channel']])) {
519 519
             return;
520
-        }else{
520
+        } else {
521 521
             $this->checkChanHangupTransfer[$data['agi_channel']] = $action;
522 522
         }
523 523
 
524 524
         if (null === $calls_data) {
525
-            $filter     = [
525
+            $filter = [
526 526
                 'linkedid=:linkedid: AND endtime = "" AND transfer=1 AND (src_chan=:chan: OR dst_chan=:chan:)',
527 527
                 'bind'  => [
528 528
                     'linkedid' => $data['linkedid'],
@@ -544,8 +544,8 @@  discard block
 block discarded – undo
544 544
                     $insert_data[$fname_chan] = $row_data['dst_chan'];
545 545
                     $insert_data[$fname_num]  = $row_data['dst_num'];
546 546
                 } else {
547
-                    $fname_chan = ! isset($insert_data['src_chan']) ? 'src_chan' : 'dst_chan';
548
-                    $fname_num  = ! isset($insert_data['src_num']) ? 'src_num' : 'dst_num';
547
+                    $fname_chan = !isset($insert_data['src_chan']) ? 'src_chan' : 'dst_chan';
548
+                    $fname_num  = !isset($insert_data['src_num']) ? 'src_num' : 'dst_num';
549 549
 
550 550
                     $insert_data[$fname_chan] = $row_data['src_chan'];
551 551
                     $insert_data[$fname_num]  = $row_data['src_num'];
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
             $this->StopMixMonitor($insert_data['dst_chan']);
557 557
             $recordingfile = $this->MixMonitor(
558 558
                 $insert_data['dst_chan'],
559
-                'transfer_' . $insert_data['src_num'] . '_' . $insert_data['dst_num'] . '_' . $data['linkedid']
559
+                'transfer_'.$insert_data['src_num'].'_'.$insert_data['dst_num'].'_'.$data['linkedid']
560 560
             );
561 561
             //
562 562
             $insert_data['action']        = "{$action}_end_trasfer";
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 
579 579
             $this->insertDataToDbM($insert_data);
580 580
             CdrDb::LogEvent(json_encode($insert_data));
581
-        } elseif (empty($calls_data[0]['answer']) && count($calls_data) === 1 && ! empty($calls_data[0]['recordingfile'])) {
581
+        } elseif (empty($calls_data[0]['answer']) && count($calls_data) === 1 && !empty($calls_data[0]['recordingfile'])) {
582 582
             // Возобновление записи разговора при срыве переадресации.
583 583
             $row_data = $calls_data[0];
584 584
             $chan     = ($data['agi_channel'] === $row_data['src_chan']) ? $row_data['dst_chan'] : $row_data['src_chan'];
@@ -594,12 +594,12 @@  discard block
 block discarded – undo
594 594
             /** @var CallDetailRecordsTmp $row */
595 595
             $not_ended_cdr = null;
596 596
             $transferNotComplete = false;
597
-            foreach ($cdr as $row){
598
-                if($row->transfer === '1' && ($row->src_chan === $chan || $row->dst_chan === $chan) ){
597
+            foreach ($cdr as $row) {
598
+                if ($row->transfer === '1' && ($row->src_chan === $chan || $row->dst_chan === $chan)) {
599 599
                     $not_ended_cdr = $row;
600 600
                 }
601
-                if($row->answer === '' && $row->endtime === ''
602
-                    && ($row->src_chan === $chan || $row->dst_chan === $chan) ){
601
+                if ($row->answer === '' && $row->endtime === ''
602
+                    && ($row->src_chan === $chan || $row->dst_chan === $chan)) {
603 603
                     $transferNotComplete = true;
604 604
                 }
605 605
             }
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
      */
658 658
     public function Action_transfer_dial_create_chan($data): void
659 659
     {
660
-        $filter     = [
660
+        $filter = [
661 661
             'UNIQUEID=:UNIQUEID: AND endtime = "" AND answer = ""',
662 662
             'bind' => [
663 663
                 'UNIQUEID' => $data['transfer_UNIQUEID'],
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
         foreach ($m_data as $row) {
671 671
             ///
672 672
             // Проверим, если более одного канала SIP/256 при входящем.
673
-            if ( ! empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) {
673
+            if (!empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) {
674 674
                 if ($row_create) {
675 675
                     continue;
676 676
                 }
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
                     $new_row->writeAttribute($attribute, $value);
685 685
                 }
686 686
                 $new_row->writeAttribute('dst_chan', $data['dst_chan']);
687
-                $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'] . '_' . $data['dst_chan']);
687
+                $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'].'_'.$data['dst_chan']);
688 688
                 // $new_row->save();
689 689
                 // Подмена $row;
690 690
                 $row        = $new_row;
@@ -697,11 +697,11 @@  discard block
 block discarded – undo
697 697
 
698 698
             $row->writeAttribute('dst_chan', $data['dst_chan']);
699 699
             $row->writeAttribute('recordingfile', $data['recordingfile']);
700
-            if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) {
700
+            if (isset($data['dst_call_id']) && !empty($data['dst_call_id'])) {
701 701
                 $row->writeAttribute('dst_call_id', $data['dst_call_id']);
702 702
             }
703 703
             $res = $row->save();
704
-            if ( ! $res) {
704
+            if (!$res) {
705 705
                 Util::sysLogMsg('Action_transfer_dial_create_chan', implode(' ', $row->getMessages()));
706 706
             }
707 707
         }
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
             '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:UNIQUEID_CHAN:) AND answer = "" AND endtime = ""',
719 719
             'bind' => [
720 720
                 'UNIQUEID'      => $data['transfer_UNIQUEID'],
721
-                'UNIQUEID_CHAN' => $data['transfer_UNIQUEID'] . '_' . $data['agi_channel'],
721
+                'UNIQUEID_CHAN' => $data['transfer_UNIQUEID'].'_'.$data['agi_channel'],
722 722
             ],
723 723
         ];
724 724
 
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
         foreach ($m_data as $row) {
729 729
             $row->writeAttribute('answer', $data['answer']);
730 730
             $res = $row->save();
731
-            if ( ! $res) {
731
+            if (!$res) {
732 732
                 Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
733 733
             }
734 734
         }
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
                 // Завершим вызов в CDR.
763 763
                 $row->writeAttribute('endtime', $data['end']);
764 764
                 $row->writeAttribute('transfer', 0);
765
-                if ( ! $row->save()) {
765
+                if (!$row->save()) {
766 766
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
767 767
                 }
768 768
             }
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
                 // Ответа не было. Переадресация отменена.
798 798
                 $row->writeAttribute('endtime', $data['end']);
799 799
                 $row->writeAttribute('transfer', 0);
800
-                if ( ! $row->save()) {
800
+                if (!$row->save()) {
801 801
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
802 802
                 }
803 803
             }
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
                 $this->MixMonitor($row->src_chan, $info['filename'], $subdir);
818 818
                 // Снимем со строк признак переадресации.
819 819
                 $row->writeAttribute('transfer', 0);
820
-                if ( ! $row->save()) {
820
+                if (!$row->save()) {
821 821
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
822 822
                 }
823 823
             }
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
 
894 894
                 $f_list = $m_data->toArray();
895 895
                 foreach ($data as $attribute => $value) {
896
-                    if ( ! array_key_exists($attribute, $f_list)) {
896
+                    if (!array_key_exists($attribute, $f_list)) {
897 897
                         continue;
898 898
                     }
899 899
                     $m_data->writeAttribute($attribute, $value);
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
             $row->writeAttribute('answer', $data['answer']);
965 965
             $row->writeAttribute('endtime', $data['answer']);
966 966
             $res = $row->save();
967
-            if ( ! $res) {
967
+            if (!$res) {
968 968
                 Util::sysLogMsg('Action_queue_answer', implode(' ', $row->getMessages()));
969 969
             }
970 970
         }
@@ -993,7 +993,7 @@  discard block
 block discarded – undo
993 993
                 $row->writeAttribute('dialstatus', $data['dialstatus']);
994 994
             }
995 995
             $res = $row->save();
996
-            if ( ! $res) {
996
+            if (!$res) {
997 997
                 Util::sysLogMsg('Action_queue_end', implode(' ', $row->getMessages()));
998 998
             }
999 999
         }
@@ -1023,11 +1023,11 @@  discard block
 block discarded – undo
1023 1023
             if ($dest_chan === $row->dst_chan) {
1024 1024
                 $is_local        = (stripos($data['src_chan'], 'local/') !== false);
1025 1025
                 $is_stored_local = (stripos($row->src_chan, 'local/') !== false);
1026
-                if ($row->UNIQUEID === $data['UNIQUEID'] && $is_local && ! $is_stored_local) {
1026
+                if ($row->UNIQUEID === $data['UNIQUEID'] && $is_local && !$is_stored_local) {
1027 1027
                     $data['src_chan'] = $row->src_chan;
1028 1028
                 }
1029 1029
                 if (file_exists($row->recordingfile) || file_exists(
1030
-                        Util::trimExtensionForFile($row->recordingfile) . '.wav'
1030
+                        Util::trimExtensionForFile($row->recordingfile).'.wav'
1031 1031
                     )) {
1032 1032
                     // Переопределим путь к файлу записи разговора. Для конферецнии файл один.
1033 1033
                     $recordingfile = $row->recordingfile;
@@ -1039,7 +1039,7 @@  discard block
 block discarded – undo
1039 1039
             // Подменим ID на идентификатор конференции.
1040 1040
             $row->writeAttribute('linkedid', $data['meetme_id']);
1041 1041
             $res = $row->save();
1042
-            if ( ! $res) {
1042
+            if (!$res) {
1043 1043
                 Util::sysLogMsg('Action_hangup_chan_meetme', implode(' ', $row->getMessages()));
1044 1044
             }
1045 1045
         }
@@ -1056,11 +1056,11 @@  discard block
 block discarded – undo
1056 1056
             $row->writeAttribute('transfer', 0);
1057 1057
             $row->writeAttribute('linkedid', $data['meetme_id']);
1058 1058
 
1059
-            if ( ! empty($recordingfile)) {
1059
+            if (!empty($recordingfile)) {
1060 1060
                 $row->writeAttribute('recordingfile', $recordingfile);
1061 1061
             }
1062 1062
             $res = $row->save();
1063
-            if ( ! $res) {
1063
+            if (!$res) {
1064 1064
                 Util::sysLogMsg('Action_hangup_chan_meetme', implode(' ', $row->getMessages()));
1065 1065
             }
1066 1066
         }
@@ -1099,9 +1099,9 @@  discard block
 block discarded – undo
1099 1099
      */
1100 1100
     public function callEventsWorker($tube): void
1101 1101
     {
1102
-        $data      = json_decode($tube->getBody(), true);
1103
-        $funcName = "Action_".$data['action']??'';
1104
-        if ( method_exists($this, $funcName) ) {
1102
+        $data = json_decode($tube->getBody(), true);
1103
+        $funcName = "Action_".$data['action'] ?? '';
1104
+        if (method_exists($this, $funcName)) {
1105 1105
             $this->$funcName($data);
1106 1106
         }
1107 1107
         $tube->reply(json_encode(true));
@@ -1131,14 +1131,14 @@  discard block
 block discarded – undo
1131 1131
     public function updateDataInDbM($data): bool
1132 1132
     {
1133 1133
         if (empty($data['UNIQUEID'])) {
1134
-            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data));
1134
+            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty '.json_encode($data));
1135 1135
 
1136 1136
             return false;
1137 1137
         }
1138 1138
 
1139 1139
         $filter = [
1140 1140
             "UNIQUEID=:id:",
1141
-            'bind' => ['id' => $data['UNIQUEID'],],
1141
+            'bind' => ['id' => $data['UNIQUEID'], ],
1142 1142
         ];
1143 1143
         /** @var CallDetailRecordsTmp $m_data */
1144 1144
         $m_data = CallDetailRecordsTmp::findFirst($filter);
@@ -1147,7 +1147,7 @@  discard block
 block discarded – undo
1147 1147
         }
1148 1148
         $f_list = $m_data->toArray();
1149 1149
         foreach ($data as $attribute => $value) {
1150
-            if ( ! array_key_exists($attribute, $f_list)) {
1150
+            if (!array_key_exists($attribute, $f_list)) {
1151 1151
                 continue;
1152 1152
             }
1153 1153
             if ('UNIQUEID' == $attribute) {
@@ -1156,7 +1156,7 @@  discard block
 block discarded – undo
1156 1156
             $m_data->writeAttribute($attribute, $value);
1157 1157
         }
1158 1158
         $res = $m_data->save();
1159
-        if ( ! $res) {
1159
+        if (!$res) {
1160 1160
             Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1161 1161
         }
1162 1162
 
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
     public static function insertDataToDbM($data): bool
1197 1197
     {
1198 1198
         if (empty($data['UNIQUEID'])) {
1199
-            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data));
1199
+            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty '.json_encode($data));
1200 1200
 
1201 1201
             return false;
1202 1202
         }
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
         $m_data = CallDetailRecordsTmp::findFirst(
1207 1207
             [
1208 1208
                 "UNIQUEID=:id:",
1209
-                'bind' => ['id' => $data['UNIQUEID'],],
1209
+                'bind' => ['id' => $data['UNIQUEID'], ],
1210 1210
             ]
1211 1211
         );
1212 1212
         if ($m_data === null) {
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
         } elseif (isset($data['IS_ORGNT']) && $data['IS_ORGNT'] !== false && $data['action'] == 'dial') {
1216 1216
             if (empty($m_data->endtime)) {
1217 1217
                 // Если это оригинация dial может прийти дважды.
1218
-                if(!empty($m_data->src_num) && $m_data->src_num === $data['dst_num']){
1218
+                if (!empty($m_data->src_num) && $m_data->src_num === $data['dst_num']) {
1219 1219
                     $m_data->dst_num = $data['src_num'];
1220 1220
                     $m_data->save();
1221 1221
                 }
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
                 $new_m_data->transfer     = $data['transfer'];
1241 1241
 
1242 1242
                 $res = $new_m_data->save();
1243
-                if ( ! $res) {
1243
+                if (!$res) {
1244 1244
                     Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1245 1245
                 }
1246 1246
 
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 
1251 1251
         $f_list = $m_data->toArray();
1252 1252
         foreach ($data as $attribute => $value) {
1253
-            if ( ! array_key_exists($attribute, $f_list)) {
1253
+            if (!array_key_exists($attribute, $f_list)) {
1254 1254
                 continue;
1255 1255
             }
1256 1256
             if ($is_new === false && 'UNIQUEID' == $attribute) {
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
             $m_data->writeAttribute($attribute, $value);
1260 1260
         }
1261 1261
         $res = $m_data->save();
1262
-        if ( ! $res) {
1262
+        if (!$res) {
1263 1263
             Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1264 1264
         }
1265 1265
 
@@ -1274,12 +1274,12 @@  discard block
 block discarded – undo
1274 1274
         $q      = $tube->getBody();
1275 1275
         $filter = json_decode($q, true);
1276 1276
 
1277
-        if($this->filterNotValid($filter)){
1277
+        if ($this->filterNotValid($filter)) {
1278 1278
             $tube->reply('[]');
1279 1279
             return;
1280 1280
         }
1281 1281
 
1282
-        $res    = null;
1282
+        $res = null;
1283 1283
         try {
1284 1284
             if (isset($filter['miko_tmp_db'])) {
1285 1285
                 $res = CallDetailRecordsTmp::find($filter);
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
             }
1299 1299
             $filter['add_pack_query']['bind'][$filter['columns']] = $arr;
1300 1300
 
1301
-            if($this->filterNotValid($filter['add_pack_query'])){
1301
+            if ($this->filterNotValid($filter['add_pack_query'])) {
1302 1302
                 $tube->reply('[]');
1303 1303
                 return;
1304 1304
             }
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
         if (isset($filter['miko_result_in_file'])) {
1317 1317
             $di         = Di::getDefault();
1318 1318
             $dirsConfig = $di->getShared('config');
1319
-            $filename   = $dirsConfig->path('core.tempDir') . '/' . md5(microtime(true));
1319
+            $filename   = $dirsConfig->path('core.tempDir').'/'.md5(microtime(true));
1320 1320
             file_put_contents($filename, $res_data);
1321 1321
             Util::addRegularWWWRights($filename);
1322 1322
             $res_data = json_encode($filename);
@@ -1329,16 +1329,16 @@  discard block
 block discarded – undo
1329 1329
      * Проверка фильтра на корректность bind параметров.
1330 1330
      * @param $filter
1331 1331
      */
1332
-    private function filterNotValid($filter){
1332
+    private function filterNotValid($filter) {
1333 1333
         $haveErrors = false;
1334
-        if(isset($filter['bind'])){
1335
-            if(is_array($filter)){
1334
+        if (isset($filter['bind'])) {
1335
+            if (is_array($filter)) {
1336 1336
                 foreach ($filter['bind'] as $bindValue) {
1337
-                    if(empty($bindValue)){
1337
+                    if (empty($bindValue)) {
1338 1338
                         $haveErrors = true;
1339 1339
                     }
1340 1340
                 }
1341
-            }else{
1341
+            } else {
1342 1342
                 $haveErrors = true;
1343 1343
             }
1344 1344
         }
@@ -1347,7 +1347,7 @@  discard block
 block discarded – undo
1347 1347
 
1348 1348
     public function errorHandler($m): void
1349 1349
     {
1350
-        Util::sysLogMsg(self::class . '_ERROR', $m);
1350
+        Util::sysLogMsg(self::class.'_ERROR', $m);
1351 1351
     }
1352 1352
 }
1353 1353
 
Please login to merge, or discard this patch.
src/Core/System/BeanstalkClient.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function __construct($tube = 'default', $port = '')
38 38
     {
39
-        $this->tube        = str_replace("\\", '-', $tube);;
39
+        $this->tube        = str_replace("\\", '-', $tube); ;
40 40
         $this->job_options = ['priority' => 250, 'delay' => 0, 'ttr' => 3600];
41 41
         $this->port = $port;
42 42
         $this->reconnect();
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
     {
50 50
         $config = $this->di->get('config')->beanstalk;
51 51
         $port   = $config->port;
52
-        if(!empty($this->port) && is_numeric($this->port)){
52
+        if (!empty($this->port) && is_numeric($this->port)) {
53 53
             $port = $this->port;
54 54
         }
55 55
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
     {
127 127
         $tube = str_replace("\\", '-', $tube);
128 128
         // Change tube
129
-        if ( ! empty($tube) && $this->tube !== $tube) {
129
+        if (!empty($tube) && $this->tube !== $tube) {
130 130
             $this->queue->useTube($tube);
131 131
         }
132 132
         $job_data = serialize($job_data);
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
         }
179 179
 
180 180
         // Processing job over callable function attached in $this->subscribe
181
-        if(json_decode($job->getData(), true) !==null){
182
-            $mData =  $job->getData();
183
-        }else{
181
+        if (json_decode($job->getData(), true) !== null) {
182
+            $mData = $job->getData();
183
+        } else {
184 184
             $mData = unserialize($job->getData(), [false]);
185 185
         }
186 186
         $this->message = $mData;
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 
198 198
         try {
199 199
             $this->queue->delete($job);
200
-        }catch (\Pheanstalk\Exception\JobNotFoundException $e){
200
+        } catch (\Pheanstalk\Exception\JobNotFoundException $e) {
201 201
             // Игнорируем ошибку, задачи не существует, нечего удалять.
202
-        }catch (\Error $e){
202
+        } catch (\Error $e) {
203 203
             // Аналогично, нечего удалять.
204 204
             // Если задача и не удалена, то это будет исправлено позже при очистке.
205 205
         }
@@ -266,28 +266,28 @@  discard block
 block discarded – undo
266 266
     /**
267 267
      * Drops orphaned tasks
268 268
      */
269
-    public function cleanTube(){
269
+    public function cleanTube() {
270 270
         $tubes = $this->queue->listTubes();
271
-        foreach ($tubes as $tube){
272
-            if(strpos($tube, "INBOX_") !== 0){
271
+        foreach ($tubes as $tube) {
272
+            if (strpos($tube, "INBOX_") !== 0) {
273 273
                 continue;
274 274
             }
275 275
             try {
276 276
                 $statData = $this->queue->statsTube($tube)->getArrayCopy();
277 277
                 $watching = $statData['current-watching'];
278
-                if($watching !== '0'){
278
+                if ($watching !== '0') {
279 279
                     continue;
280 280
                 }
281 281
                 // Нужно удалить все Jobs.
282 282
                 $this->queue->watch($tube);
283
-                while (true){
283
+                while (true) {
284 284
                     $job = $this->queue->reserveWithTimeout(1);
285
-                    if($job === null){
285
+                    if ($job === null) {
286 286
                         break;
287 287
                     }
288 288
                     $this->queue->delete($job);
289 289
                 }
290
-            }catch (\Exception $e){
290
+            } catch (\Exception $e) {
291 291
                 continue;
292 292
             }
293 293
 
Please login to merge, or discard this patch.
Braces   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -83,8 +83,7 @@  discard block
 block discarded – undo
83 83
         $job_data,
84 84
         int $timeout = 10,
85 85
         int $priority = PheanstalkInterface::DEFAULT_PRIORITY
86
-    )
87
-    {
86
+    ) {
88 87
         $this->message = false;
89 88
         $inbox_tube    = uniqid('INBOX_', true);
90 89
         $this->queue->watch($inbox_tube);
@@ -180,7 +179,7 @@  discard block
 block discarded – undo
180 179
         // Processing job over callable function attached in $this->subscribe
181 180
         if(json_decode($job->getData(), true) !==null){
182 181
             $mData =  $job->getData();
183
-        }else{
182
+        } else{
184 183
             $mData = unserialize($job->getData(), [false]);
185 184
         }
186 185
         $this->message = $mData;
@@ -197,9 +196,9 @@  discard block
 block discarded – undo
197 196
 
198 197
         try {
199 198
             $this->queue->delete($job);
200
-        }catch (\Pheanstalk\Exception\JobNotFoundException $e){
199
+        } catch (\Pheanstalk\Exception\JobNotFoundException $e){
201 200
             // Игнорируем ошибку, задачи не существует, нечего удалять.
202
-        }catch (\Error $e){
201
+        } catch (\Error $e){
203 202
             // Аналогично, нечего удалять.
204 203
             // Если задача и не удалена, то это будет исправлено позже при очистке.
205 204
         }
@@ -266,7 +265,8 @@  discard block
 block discarded – undo
266 265
     /**
267 266
      * Drops orphaned tasks
268 267
      */
269
-    public function cleanTube(){
268
+    public function cleanTube()
269
+    {
270 270
         $tubes = $this->queue->listTubes();
271 271
         foreach ($tubes as $tube){
272 272
             if(strpos($tube, "INBOX_") !== 0){
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
                     }
288 288
                     $this->queue->delete($job);
289 289
                 }
290
-            }catch (\Exception $e){
290
+            } catch (\Exception $e){
291 291
                 continue;
292 292
             }
293 293
 
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/FeaturesConf.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
     protected function generateConfigProtected(): void
21 21
     {
22
-        $conf             = "[general]\n" .
23
-            "featuredigittimeout = {$this->generalSettings['PBXFeatureDigitTimeout']}\n" .
24
-            "atxfernoanswertimeout = {$this->generalSettings['PBXFeatureAtxferNoAnswerTimeout']}\n" .
25
-            "transferdigittimeout = {$this->generalSettings['PBXFeatureTransferDigitTimeout']}\n" .
26
-            "pickupexten = {$this->generalSettings['PBXFeaturePickupExten']}\n" .
27
-            "atxferabort = *0\n" .
28
-            "\n" .
29
-            "[featuremap]\n" .
30
-            "atxfer => {$this->generalSettings['PBXFeatureAttendedTransfer']}\n" .
31
-            "disconnect = *0\n" .
22
+        $conf = "[general]\n".
23
+            "featuredigittimeout = {$this->generalSettings['PBXFeatureDigitTimeout']}\n".
24
+            "atxfernoanswertimeout = {$this->generalSettings['PBXFeatureAtxferNoAnswerTimeout']}\n".
25
+            "transferdigittimeout = {$this->generalSettings['PBXFeatureTransferDigitTimeout']}\n".
26
+            "pickupexten = {$this->generalSettings['PBXFeaturePickupExten']}\n".
27
+            "atxferabort = *0\n".
28
+            "\n".
29
+            "[featuremap]\n".
30
+            "atxfer => {$this->generalSettings['PBXFeatureAttendedTransfer']}\n".
31
+            "disconnect = *0\n".
32 32
             "blindxfer => {$this->generalSettings['PBXFeatureBlindTransfer']}\n";
33 33
 
34 34
         $additionalModules = $this->di->getShared('pbxConfModules');
@@ -36,6 +36,6 @@  discard block
 block discarded – undo
36 36
             $conf .= $appClass->getFeatureMap();
37 37
         }
38 38
 
39
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/features.conf', $conf);
39
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/features.conf', $conf);
40 40
     }
41 41
 }
42 42
\ No newline at end of file
Please login to merge, or discard this patch.
src/Core/Asterisk/Configs/ExtensionsConf.php 1 patch
Spacing   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
         /** @scrutinizer ignore-call */
26 26
         $additionalModules = $this->di->getShared('pbxConfModules');
27 27
         $conf              = "[globals] \n";
28
-        $conf              .= "TRANSFER_CONTEXT=internal-transfer; \n";
28
+        $conf .= "TRANSFER_CONTEXT=internal-transfer; \n";
29 29
         foreach ($additionalModules as $appClass) {
30 30
             $addition = $appClass->extensionGlobals();
31
-            if (!empty($addition)){
32
-                $conf .=$appClass->confBlockWithComments($addition);
31
+            if (!empty($addition)) {
32
+                $conf .= $appClass->confBlockWithComments($addition);
33 33
             }
34 34
         }
35 35
         $conf .= "\n";
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         // Переключатель по времени.
53 53
         $this->generateOutWorkTimes($conf);
54 54
 
55
-        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/extensions.conf', $conf);
55
+        Util::fileWriteContent($this->config->path('asterisk.astetcdir').'/extensions.conf', $conf);
56 56
     }
57 57
 
58 58
     /**
@@ -64,68 +64,68 @@  discard block
 block discarded – undo
64 64
     {
65 65
         $extension = 'X!';
66 66
         // Контекст для AMI originate. Без него отображается не корректный CallerID.
67
-        $conf .= '[sipregistrations]' . "\n\n";
67
+        $conf .= '[sipregistrations]'."\n\n";
68 68
 
69
-        $conf .= '[messages]' . "\n" .
70
-            'exten => _' . $extension . ',1,MessageSend(sip:${EXTEN},"${CALLERID(name)}"${MESSAGE(from)})' . "\n\n";
69
+        $conf .= '[messages]'."\n".
70
+            'exten => _'.$extension.',1,MessageSend(sip:${EXTEN},"${CALLERID(name)}"${MESSAGE(from)})'."\n\n";
71 71
 
72
-        $conf .= '[internal-originate]' . " \n";
73
-        $conf .= 'exten => _' . $extension . ',1,NoOP(Hint ${HINT} exten ${EXTEN} )' . " \n";
74
-        $conf .= '; Если это originate, то скроем один CDR.' . " \n\t";
75
-        $conf .= 'same => n,ExecIf($["${pt1c_cid}x" != "x"]?Set(CALLERID(num)=${pt1c_cid}))' . " \n\t";
72
+        $conf .= '[internal-originate]'." \n";
73
+        $conf .= 'exten => _'.$extension.',1,NoOP(Hint ${HINT} exten ${EXTEN} )'." \n";
74
+        $conf .= '; Если это originate, то скроем один CDR.'." \n\t";
75
+        $conf .= 'same => n,ExecIf($["${pt1c_cid}x" != "x"]?Set(CALLERID(num)=${pt1c_cid}))'." \n\t";
76 76
 
77
-        $conf .= 'same => n,ExecIf($["${CUT(CHANNEL,\;,2)}" == "2"]?Set(__PT1C_SIP_HEADER=${SIPADDHEADER}))' . " \n\t";
78
-        $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Set(ADDITIONAL_PEER=&Local/${peer_mobile}@outgoing/n))' . " \n\t";
77
+        $conf .= 'same => n,ExecIf($["${CUT(CHANNEL,\;,2)}" == "2"]?Set(__PT1C_SIP_HEADER=${SIPADDHEADER}))'." \n\t";
78
+        $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Set(ADDITIONAL_PEER=&Local/${peer_mobile}@outgoing/n))'." \n\t";
79 79
 
80 80
         // Описываем возможность прыжка в пользовательский sub контекст.
81
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t";
82
-        $conf .= 'same => n,Dial(Local/${EXTEN}@internal-users/n${ADDITIONAL_PEER},60,cTteKkHhb(originate_create_chan,s,1))' . " \n\n";
83
-
84
-        $conf .= '[originate_create_chan]' . " \n";
85
-        $conf .= 'exten => s,1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t";
86
-        $conf .= 'same => n,return' . " \n\n";
87
-
88
-        $conf .= '[dial_create_chan]' . " \n";
89
-        $conf .= 'exten => s,1,Gosub(lua_${ISTRANSFER}dial_create_chan,${EXTEN},1)' . "\n\t";
90
-        $conf .= 'same => n,Set(pt1c_is_dst=1)' . " \n\t";
91
-        $conf .= 'same => n,ExecIf($["${PT1C_SIP_HEADER}x" != "x"]?Set(PJSIP_HEADER(add,${CUT(PT1C_SIP_HEADER,:,1)})=${CUT(PT1C_SIP_HEADER,:,2)}))' . " \n\t";
92
-        $conf .= 'same => n,Set(__PT1C_SIP_HEADER=${UNDEFINED})' . " \n\t";
93
-        $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . " \n\t";
94
-        $conf .= 'same => n,return' . " \n\n";
95
-
96
-        $conf .= '[hangup_handler]' . "\n";
97
-        $conf .= 'exten => s,1,NoOp(--- hangup - ${CHANNEL} ---)' . "\n\t";
98
-        $conf .= 'same => n,Gosub(hangup_chan,${EXTEN},1)' . "\n\t";
99
-
100
-        $conf .= 'same => n,return' . "\n\n";
101
-
102
-        $conf .= '[set_orign_chan]' . "\n";
103
-        $conf .= 'exten => s,1,Wait(0.2)' . "\n\t";
104
-        $conf .= 'same => n,Set(pl=${IF($["${CHANNEL:-1}" == "1"]?2:1)})' . "\n\t";
105
-        $conf .= 'same => n,Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)})' . "\n\t";
106
-        $conf .= 'same => n,ExecIf($[ "${orign_chan}x" == "x" ]?Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},FROM_CHAN)}))' . "\n\t";
107
-        $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN}x" != "x" ]?Set(__QUEUE_SRC_CHAN=${orign_chan}))' . "\n\t";
108
-        $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN:0:5}" == "Local" ]?Set(__QUEUE_SRC_CHAN=${FROM_CHAN}))' . "\n\t";
109
-        $conf .= 'same => n,ExecIf($[ "${FROM_CHAN}x" == "x" ]?Set(__FROM_CHAN=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)}))' . "\n\t";
110
-        $conf .= 'same => n,return' . "\n\n";
111
-
112
-        $conf .= '[playback]' . "\n";
113
-        $conf .= 'exten => s,1,Playback(hello_demo,noanswer)' . "\n\t";
114
-        $conf .= 'same => n,ExecIf($["${SRC_BRIDGE_CHAN}x" == "x"]?Wait(30))' . "\n\t";
115
-        $conf .= 'same => n,Wait(0.3)' . "\n\t";
116
-        $conf .= 'same => n,Bridge(${SRC_BRIDGE_CHAN},kKTthH)' . "\n\n";
117
-
118
-        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\n";
81
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t";
82
+        $conf .= 'same => n,Dial(Local/${EXTEN}@internal-users/n${ADDITIONAL_PEER},60,cTteKkHhb(originate_create_chan,s,1))'." \n\n";
83
+
84
+        $conf .= '[originate_create_chan]'." \n";
85
+        $conf .= 'exten => s,1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t";
86
+        $conf .= 'same => n,return'." \n\n";
87
+
88
+        $conf .= '[dial_create_chan]'." \n";
89
+        $conf .= 'exten => s,1,Gosub(lua_${ISTRANSFER}dial_create_chan,${EXTEN},1)'."\n\t";
90
+        $conf .= 'same => n,Set(pt1c_is_dst=1)'." \n\t";
91
+        $conf .= 'same => n,ExecIf($["${PT1C_SIP_HEADER}x" != "x"]?Set(PJSIP_HEADER(add,${CUT(PT1C_SIP_HEADER,:,1)})=${CUT(PT1C_SIP_HEADER,:,2)}))'." \n\t";
92
+        $conf .= 'same => n,Set(__PT1C_SIP_HEADER=${UNDEFINED})'." \n\t";
93
+        $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'." \n\t";
94
+        $conf .= 'same => n,return'." \n\n";
95
+
96
+        $conf .= '[hangup_handler]'."\n";
97
+        $conf .= 'exten => s,1,NoOp(--- hangup - ${CHANNEL} ---)'."\n\t";
98
+        $conf .= 'same => n,Gosub(hangup_chan,${EXTEN},1)'."\n\t";
99
+
100
+        $conf .= 'same => n,return'."\n\n";
101
+
102
+        $conf .= '[set_orign_chan]'."\n";
103
+        $conf .= 'exten => s,1,Wait(0.2)'."\n\t";
104
+        $conf .= 'same => n,Set(pl=${IF($["${CHANNEL:-1}" == "1"]?2:1)})'."\n\t";
105
+        $conf .= 'same => n,Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)})'."\n\t";
106
+        $conf .= 'same => n,ExecIf($[ "${orign_chan}x" == "x" ]?Set(orign_chan=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},FROM_CHAN)}))'."\n\t";
107
+        $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN}x" != "x" ]?Set(__QUEUE_SRC_CHAN=${orign_chan}))'."\n\t";
108
+        $conf .= 'same => n,ExecIf($[ "${QUEUE_SRC_CHAN:0:5}" == "Local" ]?Set(__QUEUE_SRC_CHAN=${FROM_CHAN}))'."\n\t";
109
+        $conf .= 'same => n,ExecIf($[ "${FROM_CHAN}x" == "x" ]?Set(__FROM_CHAN=${IMPORT(${CUT(CHANNEL,\;,1)}\;${pl},BRIDGEPEER)}))'."\n\t";
110
+        $conf .= 'same => n,return'."\n\n";
111
+
112
+        $conf .= '[playback]'."\n";
113
+        $conf .= 'exten => s,1,Playback(hello_demo,noanswer)'."\n\t";
114
+        $conf .= 'same => n,ExecIf($["${SRC_BRIDGE_CHAN}x" == "x"]?Wait(30))'."\n\t";
115
+        $conf .= 'same => n,Wait(0.3)'."\n\t";
116
+        $conf .= 'same => n,Bridge(${SRC_BRIDGE_CHAN},kKTthH)'."\n\n";
117
+
118
+        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\n";
119 119
 
120 120
         // TODO / Добавление / удаление префиксов на входящий callerid.
121
-        $conf .= '[add-trim-prefix-clid]' . "\n";
122
-        $conf .= 'exten => _.!,1,NoOp(--- Incoming call from ${CALLERID(num)} ---)' . "\n\t";
123
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t";
121
+        $conf .= '[add-trim-prefix-clid]'."\n";
122
+        $conf .= 'exten => _.!,1,NoOp(--- Incoming call from ${CALLERID(num)} ---)'."\n\t";
123
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t";
124 124
         // Отсекаем "+".
125 125
         // $conf.= 'same => n,ExecIf( $["${CALLERID(num):0:1}" == "+"]?Set(CALLERID(num)=${CALLERID(num):1}))'."\n\t";
126 126
         // Отсекаем "7" и добавляем "8".
127 127
         // $conf.= 'same => n,ExecIf( $["${REGEX("^7[0-9]+" ${CALLERID(num)})}" == "1"]?Set(CALLERID(num)=8${CALLERID(num):1}))'."\n\t";
128
-        $conf .= 'same => n,return' . "\n\n";
128
+        $conf .= 'same => n,return'."\n\n";
129 129
     }
130 130
 
131 131
     /**
@@ -141,136 +141,136 @@  discard block
 block discarded – undo
141 141
         $additionalModules = $this->di->getShared('pbxConfModules');
142 142
         foreach ($additionalModules as $appClass) {
143 143
             $addition = $appClass->extensionGenContexts();
144
-            if (!empty($addition)){
145
-                $conf .=$appClass->confBlockWithComments($addition);
144
+            if (!empty($addition)) {
145
+                $conf .= $appClass->confBlockWithComments($addition);
146 146
             }
147 147
         }
148 148
         $conf .= "\n";
149 149
         $conf .= "[internal-num-undefined] \n";
150
-        $conf .= 'exten => _' . $extension . ',1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t";
151
-        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . "\n\t";
150
+        $conf .= 'exten => _'.$extension.',1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t";
151
+        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'."\n\t";
152 152
         $conf .= "same => n,Playback(pbx-invalid,noanswer) \n\n";
153 153
 
154 154
         $conf .= "[internal-fw]\n";
155
-        $conf .= 'exten => _' . $extension . ',1,NoOp(DIALSTATUS - ${DIALSTATUS})' . "\n\t";
155
+        $conf .= 'exten => _'.$extension.',1,NoOp(DIALSTATUS - ${DIALSTATUS})'."\n\t";
156 156
         // CANCEL - вызов был отменен, к примеру *0, не нужно дальше искать адресат.
157
-        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CANCEL"]?Hangup())' . "\n\t";
157
+        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CANCEL"]?Hangup())'."\n\t";
158 158
         // BUSY - занято. К примру абонент завершил вызов или DND.
159
-        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "BUSY"]?Set(dstatus=FW_BUSY))' . "\n\t";
159
+        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "BUSY"]?Set(dstatus=FW_BUSY))'."\n\t";
160 160
         // CHANUNAVAIL - канал не доступен. К примеру телефон не зарегистрирован или не отвечает.
161
-        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CHANUNAVAIL"]?Set(dstatus=FW_UNAV))' . "\n\t";
161
+        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" == "CHANUNAVAIL"]?Set(dstatus=FW_UNAV))'."\n\t";
162 162
         // NOANSWER - не ответили по таймауту.
163
-        $conf .= 'same => n,ExecIf($["${dstatus}x" == "x"]?Set(dstatus=FW))' . "\n\t";
164
-        $conf .= 'same => n,Set(fw=${DB(${dstatus}/${EXTEN})})' . "\n\t";
165
-        $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Set(__pt1c_UNIQUEID=${UNDEFINED})' . "\n\t";
166
-        $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Goto(internal,${fw},1))' . "\n\t";
167
-        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . "\n\t";
168
-        $conf .= 'same => n,Hangup() ' . "\n\n";
163
+        $conf .= 'same => n,ExecIf($["${dstatus}x" == "x"]?Set(dstatus=FW))'."\n\t";
164
+        $conf .= 'same => n,Set(fw=${DB(${dstatus}/${EXTEN})})'."\n\t";
165
+        $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Set(__pt1c_UNIQUEID=${UNDEFINED})'."\n\t";
166
+        $conf .= 'same => n,ExecIf($["${fw}x" != "x"]?Goto(internal,${fw},1))'."\n\t";
167
+        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'."\n\t";
168
+        $conf .= 'same => n,Hangup() '."\n\n";
169 169
 
170 170
         $conf .= "[all_peers]\n";
171
-        $conf .= 'include => internal-hints' . "\n";
172
-        $conf .= 'exten => failed,1,Hangup()' . "\n";
171
+        $conf .= 'include => internal-hints'."\n";
172
+        $conf .= 'exten => failed,1,Hangup()'."\n";
173 173
 
174
-        $conf .= 'exten => _.!,1,ExecIf($[ "${EXTEN}" == "h" ]?Hangup())' . "\n\t";
174
+        $conf .= 'exten => _.!,1,ExecIf($[ "${EXTEN}" == "h" ]?Hangup())'."\n\t";
175 175
         // Фильтр спецсимволов. Разершаем только цифры.
176
-        $conf .= 'same => n,Set(cleanNumber=${FILTER(\*\#1234567890,${EXTEN})})' . "\n\t";
177
-        $conf .= 'same => n,ExecIf($["${EXTEN}" != "${cleanNumber}"]?Goto(${CONTEXT},${cleanNumber},$[${PRIORITY} + 1]))' . "\n\t";
176
+        $conf .= 'same => n,Set(cleanNumber=${FILTER(\*\#1234567890,${EXTEN})})'."\n\t";
177
+        $conf .= 'same => n,ExecIf($["${EXTEN}" != "${cleanNumber}"]?Goto(${CONTEXT},${cleanNumber},$[${PRIORITY} + 1]))'."\n\t";
178 178
 
179
-        $conf .= 'same => n,Set(__FROM_CHAN=${CHANNEL})' . "\n\t";
180
-        $conf .= 'same => n,ExecIf($["${OLD_LINKEDID}x" == "x"]?Set(__OLD_LINKEDID=${CDR(linkedid)}))' . "\n\t";
181
-        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))' . "\n\t";
182
-        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))' . "\n\t";
179
+        $conf .= 'same => n,Set(__FROM_CHAN=${CHANNEL})'."\n\t";
180
+        $conf .= 'same => n,ExecIf($["${OLD_LINKEDID}x" == "x"]?Set(__OLD_LINKEDID=${CDR(linkedid)}))'."\n\t";
181
+        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))'."\n\t";
182
+        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))'."\n\t";
183 183
 
184
-        $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(num)=${FROM_PEER}))' . "\n\t";
185
-        $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(name)=${FROM_PEER}))' . "\n\t";
184
+        $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(num)=${FROM_PEER}))'."\n\t";
185
+        $conf .= 'same => n,ExecIf($["${CALLERID(num)}x" == "x"]?Set(CALLERID(name)=${FROM_PEER}))'."\n\t";
186 186
 
187
-        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local" && "${FROM_PEER}x" == "x"]?Set(__FROM_PEER=${CALLERID(num)}))' . "\n\t";
188
-        $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t";
189
-        $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)' . "\n\t";
187
+        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local" && "${FROM_PEER}x" == "x"]?Set(__FROM_PEER=${CALLERID(num)}))'."\n\t";
188
+        $conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t";
189
+        $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)'."\n\t";
190 190
 
191 191
         // Описываем возможность прыжка в пользовательский sub контекст.
192
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t";
192
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t";
193 193
 
194
-        $conf .= 'same => n,Goto(peer_${FROM_PEER},${EXTEN},1)' . "\n\n";
194
+        $conf .= 'same => n,Goto(peer_${FROM_PEER},${EXTEN},1)'."\n\n";
195 195
 
196
-        $pickupexten =  $this->generalSettings['PBXFeaturePickupExten'];
197
-        $conf        .= 'exten => _' . $pickupexten . $extension . ',1,Set(PICKUPEER=' . $technology . '/${FILTER(0-9,${EXTEN:2})})' . "\n\t";
198
-        $conf        .= 'same => n,Set(pt1c_dnid=${EXTEN})' . "\n\t";
199
-        $conf        .= 'same => n,PickupChan(${PICKUPEER})' . "\n\t";
200
-        $conf        .= 'same => n,Hangup()' . "\n\n";
196
+        $pickupexten = $this->generalSettings['PBXFeaturePickupExten'];
197
+        $conf        .= 'exten => _'.$pickupexten.$extension.',1,Set(PICKUPEER='.$technology.'/${FILTER(0-9,${EXTEN:2})})'."\n\t";
198
+        $conf        .= 'same => n,Set(pt1c_dnid=${EXTEN})'."\n\t";
199
+        $conf        .= 'same => n,PickupChan(${PICKUPEER})'."\n\t";
200
+        $conf        .= 'same => n,Hangup()'."\n\n";
201 201
 
202 202
         $voicemail_exten = $this->generalSettings['VoicemailExten'];
203
-        $conf            .= 'exten => ' . $voicemail_exten . ',1,NoOp(NOTICE, Dialing out from ${CALLERID(all)} to VoiceMail)' . "\n\t";
204
-        $conf            .= 'same => n,VoiceMailMain(admin@voicemailcontext,s)' . "\n\t";
205
-        $conf            .= 'same => n,Hangup()' . "\n\n";
203
+        $conf            .= 'exten => '.$voicemail_exten.',1,NoOp(NOTICE, Dialing out from ${CALLERID(all)} to VoiceMail)'."\n\t";
204
+        $conf            .= 'same => n,VoiceMailMain(admin@voicemailcontext,s)'."\n\t";
205
+        $conf            .= 'same => n,Hangup()'."\n\n";
206 206
 
207 207
         $conf .= "[voice_mail_peer] \n";
208
-        $conf .= 'exten => voicemail,1,Answer()' . "\n\t";
209
-        $conf .= 'same => n,VoiceMail(admin@voicemailcontext)' . "\n\t";
210
-        $conf .= 'same => n,Hangup()' . "\n\n";
208
+        $conf .= 'exten => voicemail,1,Answer()'."\n\t";
209
+        $conf .= 'same => n,VoiceMail(admin@voicemailcontext)'."\n\t";
210
+        $conf .= 'same => n,Hangup()'."\n\n";
211 211
 
212 212
         // Контекст для внутренних вызовов.
213 213
         $conf .= "[internal] \n";
214 214
 
215 215
         foreach ($additionalModules as $appClass) {
216 216
             $addition = $appClass->getIncludeInternal();
217
-            if (!empty($addition)){
218
-                $conf .=$appClass->confBlockWithComments($addition);
217
+            if (!empty($addition)) {
218
+                $conf .= $appClass->confBlockWithComments($addition);
219 219
             }
220 220
         }
221 221
 
222 222
         foreach ($additionalModules as $appClass) {
223 223
             $addition = $appClass->extensionGenInternal();
224
-            if (!empty($addition)){
225
-                $conf .=$appClass->confBlockWithComments($addition);
224
+            if (!empty($addition)) {
225
+                $conf .= $appClass->confBlockWithComments($addition);
226 226
             }
227 227
         }
228 228
 
229
-        $conf .= 'exten => i,1,NoOp(-- INVALID NUMBER --)' . "\n\t";
230
-        $conf .= 'same => n,Set(DIALSTATUS=INVALID_NUMBER)' . "\n\t";
231
-        $conf .= 'same => n,Playback(privacy-incorrect,noanswer)' . "\n\t";
232
-        $conf .= 'same => n,Hangup()' . "\n";
229
+        $conf .= 'exten => i,1,NoOp(-- INVALID NUMBER --)'."\n\t";
230
+        $conf .= 'same => n,Set(DIALSTATUS=INVALID_NUMBER)'."\n\t";
231
+        $conf .= 'same => n,Playback(privacy-incorrect,noanswer)'."\n\t";
232
+        $conf .= 'same => n,Hangup()'."\n";
233 233
 
234
-        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\n";
234
+        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\n";
235 235
 
236 236
         $conf .= "[internal-incoming]\n";
237
-        $conf .= 'exten => _.!,1,ExecIf($["${MASTER_CHANNEL(M_TIMEOUT)}x" != "x"]?Set(TIMEOUT(absolute)=${MASTER_CHANNEL(M_TIMEOUT)}))' . " \n\t";
238
-        $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT_CHANNEL)=${CHANNEL})' . " \n\t";
239
-        $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT)=${EMPTY_VAR})' . " \n\t";
240
-        $conf .= 'same => n,Goto(internal,${EXTEN},1)' . " \n\n";
237
+        $conf .= 'exten => _.!,1,ExecIf($["${MASTER_CHANNEL(M_TIMEOUT)}x" != "x"]?Set(TIMEOUT(absolute)=${MASTER_CHANNEL(M_TIMEOUT)}))'." \n\t";
238
+        $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT_CHANNEL)=${CHANNEL})'." \n\t";
239
+        $conf .= 'same => n,Set(MASTER_CHANNEL(M_TIMEOUT)=${EMPTY_VAR})'." \n\t";
240
+        $conf .= 'same => n,Goto(internal,${EXTEN},1)'." \n\n";
241 241
 
242 242
         $conf .= "[internal-users] \n";
243
-        $conf .= 'exten => _' . $extension . ',1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . " \n\t";
244
-        $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Set(SIPADDHEADER01=${EMPTY_VAR})' . " \n\t";
245
-        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))' . " \n\t";
243
+        $conf .= 'exten => _'.$extension.',1,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'." \n\t";
244
+        $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Set(SIPADDHEADER01=${EMPTY_VAR})'." \n\t";
245
+        $conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Gosub(set_orign_chan,s,1))'." \n\t";
246 246
 
247
-        $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)' . "\n\t";
247
+        $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)'."\n\t";
248 248
         // Проверим, существует ли такой пир.
249 249
 
250
-        $conf .= 'same => n,ExecIf($["${PJSIP_ENDPOINT(${EXTEN},auth)}x" == "x"]?Goto(internal-num-undefined,${EXTEN},1))' . " \n\t";
251
-        $conf .= 'same => n,ExecIf($["${DEVICE_STATE(' . $technology . '/${EXTEN})}" == "BUSY"]?Set(DIALSTATUS=BUSY))' . " \n\t";
252
-        $conf .= 'same => n,GotoIf($["${DEVICE_STATE(' . $technology . '/${EXTEN})}" == "BUSY"]?fw_start)' . " \n\t";
250
+        $conf .= 'same => n,ExecIf($["${PJSIP_ENDPOINT(${EXTEN},auth)}x" == "x"]?Goto(internal-num-undefined,${EXTEN},1))'." \n\t";
251
+        $conf .= 'same => n,ExecIf($["${DEVICE_STATE('.$technology.'/${EXTEN})}" == "BUSY"]?Set(DIALSTATUS=BUSY))'." \n\t";
252
+        $conf .= 'same => n,GotoIf($["${DEVICE_STATE('.$technology.'/${EXTEN})}" == "BUSY"]?fw_start)'." \n\t";
253 253
 
254 254
         // Как долго звонить пиру.
255
-        $conf .= 'same => n,Set(ringlength=${DB(FW_TIME/${EXTEN})})' . " \n\t";
256
-        $conf .= 'same => n,ExecIf($["${ringlength}x" == "x"]?Set(ringlength=600))' . " \n\t";
257
-        $conf .= 'same => n,ExecIf($["${QUEUE_SRC_CHAN}x" != "x" && "${ISTRANSFER}x" == "x"]?Set(ringlength=600))' . " \n\t";
255
+        $conf .= 'same => n,Set(ringlength=${DB(FW_TIME/${EXTEN})})'." \n\t";
256
+        $conf .= 'same => n,ExecIf($["${ringlength}x" == "x"]?Set(ringlength=600))'." \n\t";
257
+        $conf .= 'same => n,ExecIf($["${QUEUE_SRC_CHAN}x" != "x" && "${ISTRANSFER}x" == "x"]?Set(ringlength=600))'." \n\t";
258 258
 
259
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1) ' . " \n\t";
259
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1) '." \n\t";
260 260
         // Совершаем вызов пира.
261
-        $conf .= 'same => n,Set(DST_CONTACT=${PJSIP_DIAL_CONTACTS(${EXTEN})})' . " \n\t";
262
-        $conf .= 'same => n,ExecIf($["${FIELDQTY(DST_CONTACT,&)}" != "1"]?Set(__PT1C_SIP_HEADER=${EMPTY_VAR}))' . " \n\t";
263
-        $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";
264
-        $conf .= 'same => n(fw_start),NoOp(dial_hangup)' . " \n\t";
261
+        $conf .= 'same => n,Set(DST_CONTACT=${PJSIP_DIAL_CONTACTS(${EXTEN})})'." \n\t";
262
+        $conf .= 'same => n,ExecIf($["${FIELDQTY(DST_CONTACT,&)}" != "1"]?Set(__PT1C_SIP_HEADER=${EMPTY_VAR}))'." \n\t";
263
+        $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";
264
+        $conf .= 'same => n(fw_start),NoOp(dial_hangup)'." \n\t";
265 265
 
266 266
         // QUEUE_SRC_CHAN - установлена, если вызов сервершен агенту очереди.
267 267
         // Проверяем нужна ли переадресация
268
-        $conf       .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${ISTRANSFER}x" != "x"]?Goto(internal-fw,${EXTEN},1))' . " \n\t";
269
-        $conf       .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${QUEUE_SRC_CHAN}x" == "x"]?Goto(internal-fw,${EXTEN},1))' . " \n\t";
270
-        $conf       .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . " \n\t";
271
-        $conf       .= 'same => n,Hangup()' . "\n\n";
268
+        $conf       .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${ISTRANSFER}x" != "x"]?Goto(internal-fw,${EXTEN},1))'." \n\t";
269
+        $conf       .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${QUEUE_SRC_CHAN}x" == "x"]?Goto(internal-fw,${EXTEN},1))'." \n\t";
270
+        $conf       .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'." \n\t";
271
+        $conf       .= 'same => n,Hangup()'."\n\n";
272 272
 
273
-        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\n";
273
+        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\n";
274 274
     }
275 275
 
276 276
     /**
@@ -281,22 +281,22 @@  discard block
 block discarded – undo
281 281
     private function generateInternalTransfer(&$conf): void
282 282
     {
283 283
         $additionalModules = $this->di->getShared('pbxConfModules');
284
-        $conf              .= "[internal-transfer] \n";
284
+        $conf .= "[internal-transfer] \n";
285 285
 
286 286
         foreach ($additionalModules as $appClass) {
287
-            $addition= $appClass->getIncludeInternalTransfer();
288
-            if (!empty($addition)){
289
-                $conf .=$appClass->confBlockWithComments($addition);
287
+            $addition = $appClass->getIncludeInternalTransfer();
288
+            if (!empty($addition)) {
289
+                $conf .= $appClass->confBlockWithComments($addition);
290 290
             }
291 291
         }
292 292
 
293 293
         foreach ($additionalModules as $appClass) {
294
-            $addition= $appClass->extensionGenInternalTransfer();
295
-            if (!empty($addition)){
296
-                $conf .=$appClass->confBlockWithComments($addition);
294
+            $addition = $appClass->extensionGenInternalTransfer();
295
+            if (!empty($addition)) {
296
+                $conf .= $appClass->confBlockWithComments($addition);
297 297
             }
298 298
         }
299
-        $conf .= 'exten => h,1,Gosub(transfer_dial_hangup,${EXTEN},1)' . "\n\n";
299
+        $conf .= 'exten => h,1,Gosub(transfer_dial_hangup,${EXTEN},1)'."\n\n";
300 300
     }
301 301
 
302 302
     /**
@@ -307,11 +307,11 @@  discard block
 block discarded – undo
307 307
     private function generateSipHints(&$conf): void
308 308
     {
309 309
         $additionalModules = $this->di->getShared('pbxConfModules');
310
-        $conf              .= "[internal-hints] \n";
310
+        $conf .= "[internal-hints] \n";
311 311
         foreach ($additionalModules as $appClass) {
312 312
             $addition = $appClass->extensionGenHints();
313
-            if (!empty($addition)){
314
-                $conf .=$appClass->confBlockWithComments($addition);
313
+            if (!empty($addition)) {
314
+                $conf .= $appClass->confBlockWithComments($addition);
315 315
             }
316 316
         }
317 317
         $conf .= "\n\n";
@@ -325,16 +325,16 @@  discard block
 block discarded – undo
325 325
     private function generateOutContextPeers(&$conf): void
326 326
     {
327 327
         $additionalModules = $this->di->getShared('pbxConfModules');
328
-        $conf              .= "[outgoing] \n";
328
+        $conf .= "[outgoing] \n";
329 329
 
330
-        $conf .= 'exten => _+.!,1,NoOp(Strip + sign from number and convert it to +)' . " \n\t";
331
-        $conf .= 'same => n,Set(ADDPLUS=+);' . " \n\t";
332
-        $conf .= 'same => n,Goto(${CONTEXT},${EXTEN:1},1);' . " \n\n";
333
-        $conf .= 'exten => _X!,1,NoOp(Start outgoing calling...)' . " \n\t";
334
-        $conf .= 'same => n,Ringing()' . " \n\t";
330
+        $conf .= 'exten => _+.!,1,NoOp(Strip + sign from number and convert it to +)'." \n\t";
331
+        $conf .= 'same => n,Set(ADDPLUS=+);'." \n\t";
332
+        $conf .= 'same => n,Goto(${CONTEXT},${EXTEN:1},1);'." \n\n";
333
+        $conf .= 'exten => _X!,1,NoOp(Start outgoing calling...)'." \n\t";
334
+        $conf .= 'same => n,Ringing()'." \n\t";
335 335
 
336 336
         // Описываем возможность прыжка в пользовательский sub контекст.
337
-        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)' . "\n\t";
337
+        $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)'."\n\t";
338 338
 
339 339
         /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $routs */
340 340
         /** @var \MikoPBX\Common\Models\OutgoingRoutingTable $rout */
@@ -346,66 +346,66 @@  discard block
 block discarded – undo
346 346
             if ($technology !== '') {
347 347
                     $rout_data                       = $rout->toArray();
348 348
                     $rout_data['technology']         = $technology;
349
-                    $id_dialplan                     = $rout_data['providerid'] . '-' . $rout_data['id'] . '-outgoing';
349
+                    $id_dialplan                     = $rout_data['providerid'].'-'.$rout_data['id'].'-outgoing';
350 350
                     $provider_contexts[$id_dialplan] = $rout_data;
351
-                    $conf                            .= $this->generateOutgoingRegexPattern($rout_data);
351
+                    $conf .= $this->generateOutgoingRegexPattern($rout_data);
352 352
                     continue;
353 353
             }
354 354
         }
355
-        $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Hangup())' . " \n\t";
356
-        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${BLINDTRANSFER}x" != "x" && "${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t";
357
-        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))' . " \n\t";
358
-        $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" == "x"]?Gosub(dial,${EXTEN},1))' . "\n\t";
355
+        $conf .= 'same => n,ExecIf($["${peer_mobile}x" != "x"]?Hangup())'." \n\t";
356
+        $conf .= 'same => n,ExecIf($["${DIALSTATUS}" != "ANSWER" && "${BLINDTRANSFER}x" != "x" && "${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t";
357
+        $conf .= 'same => n,ExecIf($["${BLINDTRANSFER}x" != "x"]?AGI(check_redirect.php,${BLINDTRANSFER}))'." \n\t";
358
+        $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" == "x"]?Gosub(dial,${EXTEN},1))'."\n\t";
359 359
 
360
-        $conf .= 'same => n,Playback(silence/2,noanswer)' . " \n\t";
361
-        $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" != "x"]?Playback(followme/sorry,noanswer):Playback(cannot-complete-as-dialed,noanswer))' . " \n\t";
362
-        $conf .= 'same => n,Hangup()' . " \n\n";
363
-        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t";
360
+        $conf .= 'same => n,Playback(silence/2,noanswer)'." \n\t";
361
+        $conf .= 'same => n,ExecIf($["${ROUTFOUND}x" != "x"]?Playback(followme/sorry,noanswer):Playback(cannot-complete-as-dialed,noanswer))'." \n\t";
362
+        $conf .= 'same => n,Hangup()'." \n\n";
363
+        $conf .= 'exten => h,1,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t";
364 364
 
365 365
         foreach ($provider_contexts as $id_dialplan => $rout) {
366 366
             $conf .= "\n[{$id_dialplan}]\n";
367 367
             if (isset($rout['trimfrombegin']) && $rout['trimfrombegin'] > 0) {
368 368
                 // $exten_var = '${ADDPLUS}${EXTEN:'.$rout['trimfrombegin'].'}';
369
-                $exten_var    = '${EXTEN:' . $rout['trimfrombegin'] . '}';
370
-                $change_exten = 'same => n,ExecIf($["${EXTEN}" != "${number}"]?Goto(${CONTEXT},${number},$[${PRIORITY} + 1]))' . "\n\t";
369
+                $exten_var    = '${EXTEN:'.$rout['trimfrombegin'].'}';
370
+                $change_exten = 'same => n,ExecIf($["${EXTEN}" != "${number}"]?Goto(${CONTEXT},${number},$[${PRIORITY} + 1]))'."\n\t";
371 371
             } else {
372 372
                 $exten_var    = '${ADDPLUS}${EXTEN}';
373 373
                 $change_exten = '';
374 374
             }
375
-            $conf .= 'exten => _X!,1,Set(number=' . $rout['prepend'] . $exten_var . ')' . "\n\t";
375
+            $conf .= 'exten => _X!,1,Set(number='.$rout['prepend'].$exten_var.')'."\n\t";
376 376
             $conf .= $change_exten;
377 377
             foreach ($additionalModules as $appClass) {
378 378
                 $addition = $appClass->generateOutRoutContext($rout);
379
-                if (!empty($addition)){
380
-                    $conf .=$appClass->confBlockWithComments($addition);
379
+                if (!empty($addition)) {
380
+                    $conf .= $appClass->confBlockWithComments($addition);
381 381
                 }
382 382
             }
383
-            $conf .= 'same => n,ExecIf($["${number}x" == "x"]?Hangup())' . "\n\t";
384
-            $conf .= 'same => n,Set(ROUTFOUND=1)' . "\n\t";
385
-            $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)' . "\n\t";
383
+            $conf .= 'same => n,ExecIf($["${number}x" == "x"]?Hangup())'."\n\t";
384
+            $conf .= 'same => n,Set(ROUTFOUND=1)'."\n\t";
385
+            $conf .= 'same => n,Gosub(${ISTRANSFER}dial,${EXTEN},1)'."\n\t";
386 386
 
387
-            $conf .= 'same => n,ExecIf($["${EXTERNALPHONE}" == "${EXTEN}"]?Set(DOPTIONS=tk))' . "\n\t";
387
+            $conf .= 'same => n,ExecIf($["${EXTERNALPHONE}" == "${EXTEN}"]?Set(DOPTIONS=tk))'."\n\t";
388 388
 
389 389
             // Описываем возможность прыжка в пользовательский sub контекст.
390
-            $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS(' . $rout['providerid'] . '-outgoing-custom,${EXTEN},1)}" == "1"]?' . $rout['providerid'] . '-outgoing-custom,${EXTEN},1)' . "\n\t";
390
+            $conf .= 'same => n,GosubIf($["${DIALPLAN_EXISTS('.$rout['providerid'].'-outgoing-custom,${EXTEN},1)}" == "1"]?'.$rout['providerid'].'-outgoing-custom,${EXTEN},1)'."\n\t";
391 391
 
392 392
             if ($rout['technology'] === IAXConf::TYPE_IAX2) {
393
-                $conf .= 'same => n,Dial(' . $rout['technology'] . '/' . $rout['providerid'] . '/${number},600,${DOPTIONS}TKU(dial_answer)b(dial_create_chan,s,1))' . "\n\t";
393
+                $conf .= 'same => n,Dial('.$rout['technology'].'/'.$rout['providerid'].'/${number},600,${DOPTIONS}TKU(dial_answer)b(dial_create_chan,s,1))'."\n\t";
394 394
             } else {
395
-                $conf .= 'same => n,Dial(' . $rout['technology'] . '/${number}@' . $rout['providerid'] . ',600,${DOPTIONS}TKU(dial_answer)b(dial_create_chan,s,1))' . "\n\t";
395
+                $conf .= 'same => n,Dial('.$rout['technology'].'/${number}@'.$rout['providerid'].',600,${DOPTIONS}TKU(dial_answer)b(dial_create_chan,s,1))'."\n\t";
396 396
             }
397 397
             foreach ($additionalModules as $appClass) {
398 398
                 $addition = $appClass->generateOutRoutAfterDialContext($rout);
399
-                if (!empty($addition)){
400
-                    $conf .=$appClass->confBlockWithComments($addition);
399
+                if (!empty($addition)) {
400
+                    $conf .= $appClass->confBlockWithComments($addition);
401 401
                 }
402 402
             }
403
-            $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";
403
+            $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";
404 404
 
405
-            $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))' . "\n\t";
406
-            $conf .= 'same => n,ExecIf($["${DIALSTATUS}" = "ANSWER"]?Hangup())' . "\n\t";
407
-            $conf .= 'same => n,Set(pt1c_UNIQUEID=${EMPTY_VALUE})' . "\n\t";
408
-            $conf .= 'same => n,return' . "\n";
405
+            $conf .= 'same => n,ExecIf($["${ISTRANSFER}x" != "x"]?Gosub(${ISTRANSFER}dial_hangup,${EXTEN},1))'."\n\t";
406
+            $conf .= 'same => n,ExecIf($["${DIALSTATUS}" = "ANSWER"]?Hangup())'."\n\t";
407
+            $conf .= 'same => n,Set(pt1c_UNIQUEID=${EMPTY_VALUE})'."\n\t";
408
+            $conf .= 'same => n,return'."\n";
409 409
         }
410 410
     }
411 411
 
@@ -421,14 +421,14 @@  discard block
 block discarded – undo
421 421
         $conf        = '';
422 422
         $restnumbers = '';
423 423
         if (isset($rout['restnumbers']) && $rout['restnumbers'] > 0) {
424
-            $restnumbers = "[0-9]{" . $rout['restnumbers'] . "}$";
424
+            $restnumbers = "[0-9]{".$rout['restnumbers']."}$";
425 425
         } elseif ($rout['restnumbers'] == 0) {
426 426
             $restnumbers = "$";
427 427
         } elseif ($rout['restnumbers'] == -1) {
428 428
             $restnumbers = "";
429 429
         }
430 430
         $numberbeginswith = $rout['numberbeginswith'];
431
-        $conf             .= 'same => n,ExecIf($["${REGEX("^' . $numberbeginswith . $restnumbers . '" ${EXTEN})}" == "1"]?Gosub(' . $rout['providerid'] . '-' . $rout['id'] . '-outgoing,${EXTEN},1))' . " \n\t";
431
+        $conf .= 'same => n,ExecIf($["${REGEX("^'.$numberbeginswith.$restnumbers.'" ${EXTEN})}" == "1"]?Gosub('.$rout['providerid'].'-'.$rout['id'].'-outgoing,${EXTEN},1))'." \n\t";
432 432
 
433 433
         return $conf;
434 434
     }
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
         $conf              .= self::generateIncomingContextPeers('none', '', '');
446 446
         $conf              .= "[public-direct-dial] \n";
447 447
         foreach ($additionalModules as $appClass) {
448
-            if ($appClass instanceof $this){
448
+            if ($appClass instanceof $this) {
449 449
                 continue;
450 450
             }
451 451
             $appClass->generatePublicContext($conf);
@@ -475,7 +475,7 @@  discard block
 block discarded – undo
475 475
         $conf              = '';
476 476
         $dialplan          = [];
477 477
         $di = Di::getDefault();
478
-        if ($di===null){
478
+        if ($di === null) {
479 479
             return '';
480 480
         }
481 481
         $additionalModules = $di->getShared('pbxConfModules');
@@ -530,48 +530,48 @@  discard block
 block discarded – undo
530 530
             if (empty($rout_data)) {
531 531
                 $ext_prefix = ('none' === $provider) ? '' : '_';
532 532
                 $rout_data  .= "exten => {$ext_prefix}{$rout_number},1,NoOp(--- Incoming call ---)\n\t";
533
-                $rout_data  .= 'same => n,Set(CHANNEL(language)=' . $lang . ')' . "\n\t";
534
-                $rout_data  .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)' . "\n\t";
535
-                $rout_data  .= 'same => n,Set(__FROM_DID=${EXTEN})' . "\n\t";
536
-                $rout_data  .= 'same => n,Set(__FROM_CHAN=${CHANNEL})' . "\n\t";
533
+                $rout_data  .= 'same => n,Set(CHANNEL(language)='.$lang.')'."\n\t";
534
+                $rout_data  .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler,s,1)'."\n\t";
535
+                $rout_data  .= 'same => n,Set(__FROM_DID=${EXTEN})'."\n\t";
536
+                $rout_data  .= 'same => n,Set(__FROM_CHAN=${CHANNEL})'."\n\t";
537 537
 
538 538
                 // Установка имени пира.
539
-                $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))' . "\n\t";
540
-                $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Set(__FROM_PEER=${CALLERID(num)}))' . "\n\t";
539
+                $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" != "Local"]?Gosub(set_from_peer,s,1))'."\n\t";
540
+                $rout_data .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Set(__FROM_PEER=${CALLERID(num)}))'."\n\t";
541 541
 
542 542
                 // TODO / Подмена входящего callerid.
543
-                $rout_data .= 'same => n,Gosub(add-trim-prefix-clid,${EXTEN},1)' . "\n\t";
543
+                $rout_data .= 'same => n,Gosub(add-trim-prefix-clid,${EXTEN},1)'."\n\t";
544 544
 
545 545
                 foreach ($additionalModules as $appClass) {
546 546
                      $addition = $appClass->generateIncomingRoutBeforeDial($rout_number);
547
-                     if (!empty($addition)){
548
-                         $rout_data .=$appClass->confBlockWithComments($addition);
547
+                     if (!empty($addition)) {
548
+                         $rout_data .= $appClass->confBlockWithComments($addition);
549 549
                      }
550 550
                  }
551 551
 
552 552
                 // Перехват на ответственного.
553
-                $rout_data .= 'same => n,UserEvent(Interception,CALLERID: ${CALLERID(num)},chan1c: ${CHANNEL},FROM_DID: ${FROM_DID})' . "\n\t";
553
+                $rout_data .= 'same => n,UserEvent(Interception,CALLERID: ${CALLERID(num)},chan1c: ${CHANNEL},FROM_DID: ${FROM_DID})'."\n\t";
554 554
                 // Проверим распискние для входящих внешних звонков.
555 555
                 $rout_data .= 'same => n,Gosub(check-out-work-time,${EXTEN},1)';
556 556
                 // Описываем возможность прыжка в пользовательский sub контекст.
557
-                $rout_data .= " \n\t" . 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)';
557
+                $rout_data .= " \n\t".'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-custom,${EXTEN},1)';
558 558
             }
559 559
 
560
-            if ( ! empty($rout['extension'])) {
560
+            if (!empty($rout['extension'])) {
561 561
                 $rout_data = rtrim($rout_data);
562 562
                 // Обязательно проверяем "DIALSTATUS", в случае с парковой через AMI вызова это необходимо.
563 563
                 // При ответе может отработать следующий приоритет.
564
-                if ( ! isset($rout_data_dial[$rout_number])) {
564
+                if (!isset($rout_data_dial[$rout_number])) {
565 565
                     $rout_data_dial[$rout_number] = '';
566 566
                 }
567 567
 
568
-                $dial_command                 = " \n\t" . 'same => n,' . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Dial(Local/{$rout['extension']}@internal-incoming/n,{$timeout},cTKg));";
569
-                $rout_data_dial[$rout_number] .= " \n\t" . "same => n,Set(M_TIMEOUT={$timeout})";
568
+                $dial_command = " \n\t".'same => n,'.'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?'."Dial(Local/{$rout['extension']}@internal-incoming/n,{$timeout},cTKg));";
569
+                $rout_data_dial[$rout_number] .= " \n\t"."same => n,Set(M_TIMEOUT={$timeout})";
570 570
                 $rout_data_dial[$rout_number] .= $dial_command;
571 571
 
572 572
                 if (is_array($provider)) {
573 573
                     $key = $provider[$rout['provider']] ?? '';
574
-                    if ( ! isset($rout_data_dial[$key])) {
574
+                    if (!isset($rout_data_dial[$key])) {
575 575
                         $rout_data_dial[$key] = '';
576 576
                     }
577 577
                     if (empty($number)) {
@@ -582,9 +582,9 @@  discard block
 block discarded – undo
582 582
         }
583 583
 
584 584
         if (is_string($login)) {
585
-            $add_login_pattern = ! empty($login);
585
+            $add_login_pattern = !empty($login);
586 586
             foreach ($data as $rout) {
587
-                if ( ! $add_login_pattern) {
587
+                if (!$add_login_pattern) {
588 588
                     break;
589 589
                 } // Логин не заполнен, обработка не требуется.
590 590
                 $is_num = preg_match_all('/^\d+$/m', $login, $matches, PREG_SET_ORDER, 0);
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
             if ($add_login_pattern && array_key_exists('X!', $rout_data_dial) && isset($dialplan['X!'])) {
605 605
                 $dialplan[$login]       = str_replace('_X!,1', "{$login},1", $dialplan['X!']);
606 606
                 $rout_data_dial[$login] = $rout_data_dial['X!'];
607
-            }elseif($add_login_pattern === true && $need_def_rout === true && count($data) === 1){
607
+            }elseif ($add_login_pattern === true && $need_def_rout === true && count($data) === 1) {
608 608
                 // Только маршрут "По умолчанию".
609 609
                 $dialplan[$login]       = str_replace('_X!,1', "{$login},1", $dialplan['X!']);
610 610
             }
@@ -615,7 +615,7 @@  discard block
 block discarded – undo
615 615
         }
616 616
 
617 617
         foreach ($dialplan as $key => &$dpln) {
618
-            if ( ! array_key_exists($key, $rout_data_dial)) {
618
+            if (!array_key_exists($key, $rout_data_dial)) {
619 619
                 continue;
620 620
             }
621 621
             $dpln = rtrim($dpln);
@@ -624,29 +624,29 @@  discard block
 block discarded – undo
624 624
         unset($dpln);
625 625
 
626 626
         $uniqid = is_string($provider) ? $provider : $uniqid;
627
-        $conf   .= "\n" . "[{$uniqid}-incoming]\n";
627
+        $conf .= "\n"."[{$uniqid}-incoming]\n";
628 628
         foreach ($dialplan as $dpln) {
629
-            $conf .= $dpln . "\n";
629
+            $conf .= $dpln."\n";
630 630
             if (null == $default_action && 'none' !== $provider) {
631 631
                 continue;
632 632
             }
633 633
             if ('extension' === $default_action->action) {
634 634
                 // Обязательно проверяем "DIALSTATUS", в случае с парковой через AMI вызова это необходимо.
635 635
                 // При ответе может отработать следующий приоритет.
636
-                $conf .= "\t" . 'same => n,Set(M_TIMEOUT=0)' . "\n";
637
-                $conf .= "\t" . "same => n," . 'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?' . "Dial(Local/{$default_action->extension}@internal/n,,cTKg)); default action" . "\n";
636
+                $conf .= "\t".'same => n,Set(M_TIMEOUT=0)'."\n";
637
+                $conf .= "\t"."same => n,".'ExecIf($["${M_DIALSTATUS}" != "ANSWER"]?'."Dial(Local/{$default_action->extension}@internal/n,,cTKg)); default action"."\n";
638 638
 
639 639
                 foreach ($additionalModules as $appClass) {
640 640
                     $addition = $appClass->generateIncomingRoutAfterDialContext($uniqid);
641
-                    if (!empty($addition)){
642
-                         $conf .=$appClass->confBlockWithComments($addition);
641
+                    if (!empty($addition)) {
642
+                         $conf .= $appClass->confBlockWithComments($addition);
643 643
                     }
644 644
                 }
645
-                $conf .= " \t" . 'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-after-dial-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-after-dial-custom,${EXTEN},1)' . "\n";
645
+                $conf .= " \t".'same => n,GosubIf($["${DIALPLAN_EXISTS(${CONTEXT}-after-dial-custom,${EXTEN},1)}" == "1"]?${CONTEXT}-after-dial-custom,${EXTEN},1)'."\n";
646 646
             } elseif ('busy' === $default_action->action) {
647
-                $conf .= "\t" . "same => n,Busy()" . "\n";
647
+                $conf .= "\t"."same => n,Busy()"."\n";
648 648
             }
649
-            $conf .= "\t" . "same => n,Hangup()" . "\n";
649
+            $conf .= "\t"."same => n,Hangup()"."\n";
650 650
         }
651 651
 
652 652
         return $conf;
@@ -662,10 +662,10 @@  discard block
 block discarded – undo
662 662
     private function generateOutWorkTimes(&$conf): string
663 663
     {
664 664
         $conf .= "\n\n[playback-exit]\n";
665
-        $conf .= 'exten => _.!,1,NoOp(check time)' . "\n\t";
666
-        $conf .= 'same => n,Gosub(dial_outworktimes,${EXTEN},1)' . "\n\t";
667
-        $conf .= 'same => n,Playback(${filename})' . "\n\t";
668
-        $conf .= 'same => n,Hangup()' . "\n\n";
665
+        $conf .= 'exten => _.!,1,NoOp(check time)'."\n\t";
666
+        $conf .= 'same => n,Gosub(dial_outworktimes,${EXTEN},1)'."\n\t";
667
+        $conf .= 'same => n,Playback(${filename})'."\n\t";
668
+        $conf .= 'same => n,Hangup()'."\n\n";
669 669
 
670 670
         $conf .= "[check-out-work-time]\n";
671 671
         $conf .= "exten => _.!,1,NoOp(check time)\n\t";
@@ -677,9 +677,9 @@  discard block
 block discarded – undo
677 677
         $now_year = 1 * date('Y', time());
678 678
         foreach ($data as $out_data) {
679 679
             /** @var \MikoPBX\Common\Models\OutWorkTimes $out_data */
680
-            if ( ! empty($out_data->date_from) && ! empty($out_data->date_to)) {
681
-                $year_from = 1 * date('Y', (int)$out_data->date_from);
682
-                $year_to   = 1 * date('Y', (int)$out_data->date_to);
680
+            if (!empty($out_data->date_from) && !empty($out_data->date_to)) {
681
+                $year_from = 1 * date('Y', (int) $out_data->date_from);
682
+                $year_to   = 1 * date('Y', (int) $out_data->date_to);
683 683
                 if ($now_year < $year_from || $now_year > $year_to) {
684 684
                     // Правило не актуально для текущего года.
685 685
                     continue;
@@ -716,11 +716,11 @@  discard block
 block discarded – undo
716 716
                 $mdays  = '*';
717 717
                 $months = '*';
718 718
             } else {
719
-                $mdays  = strtolower(date("j", (int)$date_from));
720
-                $months = strtolower(date("M", (int)$date_from));
721
-                if ( ! empty($date_to)) {
722
-                    $mdays  .= "-" . strtolower(date("j", (int)$date_to));
723
-                    $months .= "-" . strtolower(date("M", (int)$date_to));
719
+                $mdays  = strtolower(date("j", (int) $date_from));
720
+                $months = strtolower(date("M", (int) $date_from));
721
+                if (!empty($date_to)) {
722
+                    $mdays  .= "-".strtolower(date("j", (int) $date_to));
723
+                    $months .= "-".strtolower(date("M", (int) $date_to));
724 724
                 }
725 725
             }
726 726
 
@@ -733,12 +733,12 @@  discard block
 block discarded – undo
733 733
                 $res           = SoundFiles::findFirst($out_data->audio_message_id);
734 734
                 $audio_message = ($res === null) ? '' : Util::trimExtensionForFile($res->path);
735 735
 
736
-                $conf_out_set_var .= "[work-time-set-var-{$out_data->id}]\n" .
737
-                    'exten => _.!,1,Set(filename=' . $audio_message . ')' . "\n\t" .
738
-                    'same => n,Goto(playback-exit,${EXTEN},1)' . "\n\n";
736
+                $conf_out_set_var .= "[work-time-set-var-{$out_data->id}]\n".
737
+                    'exten => _.!,1,Set(filename='.$audio_message.')'."\n\t".
738
+                    'same => n,Goto(playback-exit,${EXTEN},1)'."\n\n";
739 739
 
740 740
                 $appname = 'ExecIfTime';
741
-                $appdata = 'Goto(work-time-set-var-' . $out_data->id . ',${EXTEN},1)';
741
+                $appdata = 'Goto(work-time-set-var-'.$out_data->id.',${EXTEN},1)';
742 742
             }
743 743
             $conf .= "same => n,{$appname}($times,$weekdays,$mdays,$months?{$appdata})\n\t";
744 744
         }
@@ -764,10 +764,10 @@  discard block
 block discarded – undo
764 764
         if ($provider !== null) {
765 765
             if ($provider->type === 'SIP') {
766 766
                 $account    = Sip::findFirst('disabled="0" AND uniqid = "'.$uniqueID.'"');
767
-                $technology = ($account === null)?'':SIPConf::getTechnology();
767
+                $technology = ($account === null) ? '' : SIPConf::getTechnology();
768 768
             } elseif ($provider->type === 'IAX') {
769 769
                 $account    = Iax::findFirst('disabled="0" AND uniqid = "'.$uniqueID.'"');
770
-                $technology = ($account === null)?'':'IAX2';
770
+                $technology = ($account === null) ? '' : 'IAX2';
771 771
             }
772 772
         }
773 773
 
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("CDR(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("CDR(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("CDR(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("CDR(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
     Util::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/Workers/WorkerModelsEvents.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
     private int $timeout = 2;
106 106
     private array $arrObject;
107 107
     private array $PRIORITY_R;
108
-    protected int $maxProc=1;
108
+    protected int $maxProc = 1;
109 109
 
110 110
 
111 111
     /**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
         foreach ($additionalModules as $appClass) {
191 191
             // Проверим, зависит ли объект от измененных данных.
192 192
             $dependences = $appClass->dependenceModels();
193
-            if (in_array($called_class, $dependences)){
193
+            if (in_array($called_class, $dependences)) {
194 194
                 // Получаем новые настройки.
195 195
                 $appClass->getSettings();
196 196
             }
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                 break;
239 239
             case Codecs::class:
240 240
                 $this->modified_tables[self::R_IAX] = true;
241
-                $this->modified_tables[self::R_SIP]     = true;
241
+                $this->modified_tables[self::R_SIP] = true;
242 242
                 break;
243 243
             case IncomingRoutingTable::class:
244 244
                 $this->modified_tables[self::R_DIALPLAN] = true;
@@ -310,16 +310,16 @@  discard block
 block discarded – undo
310 310
                     $this->modified_tables[self::R_NATS]    = true;
311 311
                 }
312 312
                 if ($this->pbxSettings->itHasTimeZoneSettings()) {
313
-                    $this->modified_tables[self::R_TIMEZONE]    = true;
314
-                    $this->modified_tables[self::R_NGINX]    = true;
315
-                    $this->modified_tables[self::R_PHP_FPM]    = true;
313
+                    $this->modified_tables[self::R_TIMEZONE] = true;
314
+                    $this->modified_tables[self::R_NGINX] = true;
315
+                    $this->modified_tables[self::R_PHP_FPM] = true;
316 316
                     $this->modified_tables[self::R_REST_API_WORKER] = true;
317 317
                 }
318 318
                 if ($this->pbxSettings->itHasNTPSettings()) {
319
-                    $this->modified_tables[self::R_NTP]    = true;
319
+                    $this->modified_tables[self::R_NTP] = true;
320 320
                 }
321 321
                 if ($this->pbxSettings->itHasCallRecordSettings()) {
322
-                    $this->modified_tables[ self::R_CALL_EVENTS_WORKER]  = true;
322
+                    $this->modified_tables[self::R_CALL_EVENTS_WORKER] = true;
323 323
                 }
324 324
                 break;
325 325
             case Sip::class:
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
      */
491 491
     public function reloadNginx(): void
492 492
     {
493
-        $nginxConf  = new NginxConf();
493
+        $nginxConf = new NginxConf();
494 494
         $nginxConf->generateConf();
495 495
         $nginxConf->reStart();
496 496
     }
Please login to merge, or discard this patch.
src/AdminCabinet/Controllers/GeneralSettingsController.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function saveAction(): void
41 41
     {
42
-        if ( ! $this->request->isPost()) {
42
+        if (!$this->request->isPost()) {
43 43
             return;
44 44
         }
45 45
         $data        = $this->request->getPost();
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
                     $this->session->set('SendMetrics', $record->value);
77 77
                     break;
78 78
                 case 'PBXFeatureTransferDigitTimeout':
79
-                    $record->value = ceil((int)$data['PBXFeatureDigitTimeout']/1000);
79
+                    $record->value = ceil((int) $data['PBXFeatureDigitTimeout'] / 1000);
80 80
                     break;
81 81
                 default:
82 82
                     if (array_key_exists($key, $data)) {
@@ -94,10 +94,10 @@  discard block
 block discarded – undo
94 94
         }
95 95
 
96 96
         $codecs = json_decode($data['codecs'], true);
97
-        foreach ($codecs as $codec){
97
+        foreach ($codecs as $codec) {
98 98
            $record = Codecs::findFirstById($codec['codecId']);
99 99
            $record->priority = $codec['priority'];
100
-           $record->disabled = $codec['disabled']===true?'1':'0';
100
+           $record->disabled = $codec['disabled'] === true ? '1' : '0';
101 101
            $record->update();
102 102
         }
103 103
 
Please login to merge, or discard this patch.
src/PBXCoreREST/Lib/FirewallManagementProcessor.php 4 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -79,22 +79,22 @@
 block discarded – undo
79 79
         return $res;
80 80
     }
81 81
 
82
-     public static function getDbConnection(){
83
-         if(!file_exists(Fail2BanConf::FAIL2BAN_DB_PATH)){
84
-             return null;
85
-         }
86
-         try {
87
-             $db      = new SQLite3(Fail2BanConf::FAIL2BAN_DB_PATH);
88
-         }catch (\Exception $e){
89
-             return null;
90
-         }
91
-         $db->busyTimeout(5000);
92
-         $fail2ban = new Fail2BanConf();
93
-         if (false === $fail2ban->tableBanExists($db)) {
94
-             return null;
95
-         }
82
+        public static function getDbConnection(){
83
+            if(!file_exists(Fail2BanConf::FAIL2BAN_DB_PATH)){
84
+                return null;
85
+            }
86
+            try {
87
+                $db      = new SQLite3(Fail2BanConf::FAIL2BAN_DB_PATH);
88
+            }catch (\Exception $e){
89
+                return null;
90
+            }
91
+            $db->busyTimeout(5000);
92
+            $fail2ban = new Fail2BanConf();
93
+            if (false === $fail2ban->tableBanExists($db)) {
94
+                return null;
95
+            }
96 96
 
97
-         return $db;
97
+            return $db;
98 98
     }
99 99
 
100 100
     /**
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -28,18 +28,18 @@  discard block
 block discarded – undo
28 28
      */
29 29
     public static function fail2banUnbanAll(string $ip): PBXApiResult
30 30
     {
31
-        $ip     = trim($ip);
31
+        $ip = trim($ip);
32 32
         $res = new PBXApiResult();
33 33
         $res->processor = __METHOD__;
34 34
         $res->success = true;
35
-        if ( ! Verify::isIpAddress($ip)) {
35
+        if (!Verify::isIpAddress($ip)) {
36 36
             $res->success = false;
37
-            $res->messages[]="Not valid ip '{$ip}'.";
37
+            $res->messages[] = "Not valid ip '{$ip}'.";
38 38
         }
39
-        $fail2ban        = new Fail2BanConf();
39
+        $fail2ban = new Fail2BanConf();
40 40
         if ($fail2ban->fail2ban_enable) {
41 41
             $fail2ban = Util::which('fail2ban-client');
42
-            $res->success  = (Util::mwExec("{$fail2ban} unban {$ip}") === 0);
42
+            $res->success = (Util::mwExec("{$fail2ban} unban {$ip}") === 0);
43 43
         } else {
44 44
             $res = self::fail2banUnbanDb($ip);
45 45
         }
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $res->processor = __METHOD__;
61 61
 
62 62
         $db = self::getDbConnection();
63
-        if(!$db){
63
+        if (!$db) {
64 64
             // Таблица не существует. Бана нет.
65 65
             $res->success    = false;
66 66
             $res->messages[] = 'DB '.Fail2BanConf::FAIL2BAN_DB_PATH.' not found';
@@ -79,13 +79,13 @@  discard block
 block discarded – undo
79 79
         return $res;
80 80
     }
81 81
 
82
-     public static function getDbConnection(){
83
-         if(!file_exists(Fail2BanConf::FAIL2BAN_DB_PATH)){
82
+     public static function getDbConnection() {
83
+         if (!file_exists(Fail2BanConf::FAIL2BAN_DB_PATH)) {
84 84
              return null;
85 85
          }
86 86
          try {
87
-             $db      = new SQLite3(Fail2BanConf::FAIL2BAN_DB_PATH);
88
-         }catch (\Exception $e){
87
+             $db = new SQLite3(Fail2BanConf::FAIL2BAN_DB_PATH);
88
+         } catch (\Exception $e) {
89 89
              return null;
90 90
          }
91 91
          $db->busyTimeout(5000);
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             $ban_time = '43800';
111 111
         }
112 112
         // Добавленн фильтр по времени бана. возвращаем только адреса, которые еще НЕ разбанены.
113
-        $q = 'SELECT' . ' DISTINCT jail,ip,MAX(timeofban) AS timeofban, MAX(timeofban+' . $ban_time . ') AS timeunban FROM bans where (timeofban+' . $ban_time . ')>' . time();
113
+        $q = 'SELECT'.' DISTINCT jail,ip,MAX(timeofban) AS timeofban, MAX(timeofban+'.$ban_time.') AS timeunban FROM bans where (timeofban+'.$ban_time.')>'.time();
114 114
         if ($ip !== null) {
115 115
             $q .= " AND ip='{$ip}'";
116 116
         }
@@ -133,13 +133,13 @@  discard block
 block discarded – undo
133 133
 
134 134
         $jail_q  = ($jail === '') ? '' : "AND jail = '{$jail}'";
135 135
         $path_db = Fail2BanConf::FAIL2BAN_DB_PATH;
136
-        if(!file_exists($path_db)){
136
+        if (!file_exists($path_db)) {
137 137
             // Таблица не существует. Бана нет.
138 138
             $res->success    = false;
139 139
             $res->messages[] = "DB {$path_db} not found";
140 140
             return $res;
141 141
         }
142
-        $db      = new SQLite3($path_db);
142
+        $db = new SQLite3($path_db);
143 143
         $db->busyTimeout(3000);
144 144
         $fail2ban = new Fail2BanConf();
145 145
         if (false === $fail2ban->tableBanExists($db)) {
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             $res->success = true;
148 148
             return $res;
149 149
         }
150
-        $q = 'DELETE' . " FROM bans WHERE ip = '{$ip}' {$jail_q}";
150
+        $q = 'DELETE'." FROM bans WHERE ip = '{$ip}' {$jail_q}";
151 151
         $db->query($q);
152 152
 
153 153
         $err = $db->lastErrorMsg();
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,13 +79,14 @@
 block discarded – undo
79 79
         return $res;
80 80
     }
81 81
 
82
-     public static function getDbConnection(){
82
+     public static function getDbConnection()
83
+     {
83 84
          if(!file_exists(Fail2BanConf::FAIL2BAN_DB_PATH)){
84 85
              return null;
85 86
          }
86 87
          try {
87 88
              $db      = new SQLite3(Fail2BanConf::FAIL2BAN_DB_PATH);
88
-         }catch (\Exception $e){
89
+         } catch (\Exception $e){
89 90
              return null;
90 91
          }
91 92
          $db->busyTimeout(5000);
Please login to merge, or discard this patch.
Upper-Lower-Casing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -136,7 +136,7 @@
 block discarded – undo
136 136
         if(!file_exists($path_db)){
137 137
             // Таблица не существует. Бана нет.
138 138
             $res->success    = false;
139
-            $res->messages[] = "DB {$path_db} not found";
139
+            $res->messages[] = "db {$path_db} not found";
140 140
             return $res;
141 141
         }
142 142
         $db      = new SQLite3($path_db);
Please login to merge, or discard this patch.
src/PBXCoreREST/Lib/SystemManagementProcessor.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
         $res->data['message'] = 'In progress...';
163 163
 
164 164
 
165
-        if ( ! file_exists($tempFilename)) {
165
+        if (!file_exists($tempFilename)) {
166 166
             $res->success    = false;
167 167
             $res->messages[] = "Update file '{$tempFilename}' not found.";
168 168
 
169 169
             return $res;
170 170
         }
171 171
 
172
-        if ( ! file_exists('/var/etc/cfdevice')) {
172
+        if (!file_exists('/var/etc/cfdevice')) {
173 173
             $res->success    = false;
174 174
             $res->messages[] = "The system is not installed";
175 175
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
         $res            = new PBXApiResult();
199 199
         $res->processor = __METHOD__;
200 200
         $moduleMetadata = FilesManagementProcessor::getMetadataFromModuleFile($filePath);
201
-        if ( ! $moduleMetadata->success) {
201
+        if (!$moduleMetadata->success) {
202 202
             return $moduleMetadata;
203 203
         } else {
204 204
             $moduleUniqueID = $moduleMetadata->data['uniqid'];
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
         if (class_exists($pbxExtensionSetupClass)
238 238
             && method_exists($pbxExtensionSetupClass, 'installModule')) {
239 239
             $setup = new $pbxExtensionSetupClass($moduleUniqueID);
240
-            if ( ! $setup->installModule()) {
240
+            if (!$setup->installModule()) {
241 241
                 $res->success    = false;
242 242
                 $res->messages[] = $setup->getMessages();
243 243
             }
@@ -384,15 +384,15 @@  discard block
 block discarded – undo
384 384
             [IncomingRoutingTable::class => ''],
385 385
             [OutWorkTimes::class => ''],
386 386
             [AsteriskManagerUsers::class => ''],
387
-            [Extensions::class => 'type="' . Extensions::TYPE_IVR_MENU . '"'],  // IVR Menu
388
-            [Extensions::class => 'type="' . Extensions::TYPE_CONFERENCE . '"'],  // CONFERENCE
389
-            [Extensions::class => 'type="' . Extensions::TYPE_QUEUE . '"'],  // QUEUE
387
+            [Extensions::class => 'type="'.Extensions::TYPE_IVR_MENU.'"'], // IVR Menu
388
+            [Extensions::class => 'type="'.Extensions::TYPE_CONFERENCE.'"'], // CONFERENCE
389
+            [Extensions::class => 'type="'.Extensions::TYPE_QUEUE.'"'], // QUEUE
390 390
         ];
391 391
 
392 392
         foreach ($clearThisModels as $modelParams) {
393 393
             foreach ($modelParams as $key => $value) {
394 394
                 $records = call_user_func([$key, 'find'], $value);
395
-                if ( ! $records->delete()) {
395
+                if (!$records->delete()) {
396 396
                     $res->messages[] = $records->getMessages();
397 397
                     $res->success    = false;
398 398
                 }
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
         }
401 401
 
402 402
         // Other extensions
403
-        $parameters     = [
403
+        $parameters = [
404 404
             'conditions' => 'not number IN ({ids:array})',
405 405
             'bind'       => [
406 406
                 'ids' => [
407 407
                     '000063', // Reads back the extension
408 408
                     '000064', // 0000MILLI
409
-                    '10003246',// Echo test
409
+                    '10003246', // Echo test
410 410
                     '10000100' // Voicemail
411 411
                 ],
412 412
             ],
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
                 $stopDeleting = true;
421 421
                 continue;
422 422
             }
423
-            if ( ! $record->delete()) {
423
+            if (!$record->delete()) {
424 424
                 $deleteAttempts += 1;
425 425
             }
426 426
             if ($deleteAttempts > $countRecords * 10) {
@@ -436,12 +436,12 @@  discard block
 block discarded – undo
436 436
                 'custom' => SoundFiles::CATEGORY_CUSTOM,
437 437
             ],
438 438
         ];
439
-        $records    = SoundFiles::find($parameters);
439
+        $records = SoundFiles::find($parameters);
440 440
 
441 441
         foreach ($records as $record) {
442 442
             if (stripos($record->path, '/storage/usbdisk1/mikopbx') !== false) {
443 443
                 Util::mwExec("{$rm} -rf {$record->path}");
444
-                if ( ! $record->delete()) {
444
+                if (!$record->delete()) {
445 445
                     $res->messages[] = $record->getMessages();
446 446
                     $res->success    = false;
447 447
                 }
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
         foreach ($records as $record) {
454 454
             $moduleDir = PbxExtensionUtils::getModuleDir($record->uniqid);
455 455
             Util::mwExec("{$rm} -rf {$moduleDir}");
456
-            if ( ! $record->delete()) {
456
+            if (!$record->delete()) {
457 457
                 $res->messages[] = $record->getMessages();
458 458
                 $res->success    = false;
459 459
             }
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 
462 462
         // Delete CallRecords
463 463
         $records = CallDetailRecords::find();
464
-        if ( ! $records->delete()) {
464
+        if (!$records->delete()) {
465 465
             $res->messages[] = $records->getMessages();
466 466
             $res->success    = false;
467 467
         }
@@ -486,14 +486,14 @@  discard block
 block discarded – undo
486 486
     {
487 487
         $res            = new PBXApiResult();
488 488
         $res->processor = __METHOD__;
489
-        if ( ! file_exists($filename)) {
489
+        if (!file_exists($filename)) {
490 490
             $res->success    = false;
491 491
             $res->messages[] = "File '{$filename}' not found.";
492 492
 
493 493
             return $res;
494 494
         }
495 495
         $out          = [];
496
-        $tmp_filename = '/tmp/' . time() . "_" . basename($filename);
496
+        $tmp_filename = '/tmp/'.time()."_".basename($filename);
497 497
         if (false === copy($filename, $tmp_filename)) {
498 498
             $res->success    = false;
499 499
             $res->messages[] = "Unable to create temporary file '{$tmp_filename}'.";
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
         }
503 503
 
504 504
         // Принудительно устанавливаем расширение файла в wav.
505
-        $n_filename     = Util::trimExtensionForFile($filename) . ".wav";
506
-        $n_filename_mp3 = Util::trimExtensionForFile($filename) . ".mp3";
505
+        $n_filename     = Util::trimExtensionForFile($filename).".wav";
506
+        $n_filename_mp3 = Util::trimExtensionForFile($filename).".mp3";
507 507
         // Конвертируем файл.
508 508
         $tmp_filename = escapeshellcmd($tmp_filename);
509 509
         $n_filename   = escapeshellcmd($n_filename);
Please login to merge, or discard this patch.