@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function modifyAction(string $uniqid): void |
59 | 59 | { |
60 | - $menuSettings = "AdditionalMenuItem{$uniqid}"; |
|
60 | + $menuSettings = "additionalmenuitem{$uniqid}"; |
|
61 | 61 | $unCamelizedControllerName = Text::uncamelize($uniqid, '-'); |
62 | 62 | $previousMenuSettings = PbxSettings::findFirstByKey($menuSettings); |
63 | 63 | $this->view->showAtMainMenu = $previousMenuSettings !== false; |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'href' => $this->url->get($unCamelizedControllerName), |
70 | 70 | 'group' => '', |
71 | 71 | 'iconClass' => 'puzzle piece', |
72 | - 'caption' => "Breadcrumb$uniqid", |
|
72 | + 'caption' => "breadcrumb$uniqid", |
|
73 | 73 | 'showAtSidebar' => false, |
74 | 74 | ]; |
75 | 75 | $previousMenuSettings->value = json_encode($value); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $options = json_decode($previousMenuSettings->value, true); |
78 | 78 | $this->view->form = new PbxExtensionModuleSettingsForm($previousMenuSettings, $options); |
79 | 79 | $this->view->title = $this->translation->_('ext_SettingsForModule') . ' ' . $this->translation->_( |
80 | - "Breadcrumb$uniqid" |
|
80 | + "breadcrumb$uniqid" |
|
81 | 81 | ); |
82 | 82 | $this->view->submitMode = null; |
83 | 83 | $this->view->indexUrl = $unCamelizedControllerName; |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | $result = []; |
129 | 129 | $modules = PbxExtensionModules::getEnabledModulesArray(); |
130 | 130 | foreach ($modules as $module) { |
131 | - $menuSettings = "AdditionalMenuItem{$module['uniqid']}"; |
|
131 | + $menuSettings = "additionalmenuitem{$module['uniqid']}"; |
|
132 | 132 | $previousMenuSettings = PbxSettings::findFirstByKey($menuSettings); |
133 | 133 | if ($previousMenuSettings !== null) { |
134 | 134 | $result['items'][] = json_decode($previousMenuSettings->value, true); |
@@ -83,7 +83,7 @@ |
||
83 | 83 | $modules = PbxExtensionModules::getEnabledModulesArray(); |
84 | 84 | foreach ($modules as $value) { |
85 | 85 | $class_name = str_replace('Module', '', $value['uniqid']); |
86 | - $full_class_name = "\\Modules\\{$value['uniqid']}\\Lib\\{$class_name}Conf"; |
|
86 | + $full_class_name = "\\Modules\\{$value['uniqid']}\\Lib\\{$class_name}conf"; |
|
87 | 87 | if (class_exists($full_class_name)) { |
88 | 88 | $object = new $full_class_name(); |
89 | 89 | if ($object instanceof ConfigClass){ |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | { |
91 | 91 | if(isset($this->mixMonitorChannels[$channel])){ |
92 | 92 | unset($this->mixMonitorChannels[$channel]); |
93 | - }else{ |
|
93 | + } else{ |
|
94 | 94 | return; |
95 | 95 | } |
96 | 96 | if ($this->record_calls) { |
@@ -1319,7 +1319,8 @@ discard block |
||
1319 | 1319 | * |
1320 | 1320 | * @return bool |
1321 | 1321 | */ |
1322 | - private function filterNotValid($filter){ |
|
1322 | + private function filterNotValid($filter) |
|
1323 | + { |
|
1323 | 1324 | $haveErrors = false; |
1324 | 1325 | if(isset($filter['bind'])){ |
1325 | 1326 | if(is_array($filter)){ |
@@ -1328,7 +1329,7 @@ discard block |
||
1328 | 1329 | $haveErrors = true; |
1329 | 1330 | } |
1330 | 1331 | } |
1331 | - }else{ |
|
1332 | + } else{ |
|
1332 | 1333 | $haveErrors = true; |
1333 | 1334 | } |
1334 | 1335 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | */ |
35 | 35 | public function MixMonitor($channel, $file_name = null, $sub_dir = null, $full_name = null): string |
36 | 36 | { |
37 | - $resFile = $this->mixMonitorChannels[$channel]??''; |
|
38 | - if($resFile !== ''){ |
|
37 | + $resFile = $this->mixMonitorChannels[$channel] ?? ''; |
|
38 | + if ($resFile !== '') { |
|
39 | 39 | return $resFile; |
40 | 40 | } |
41 | 41 | $resFile = ''; |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | if ($this->record_calls) { |
44 | 44 | [$f, $options] = $this->setMonitorFilenameOptions($full_name, $sub_dir, $file_name); |
45 | 45 | $arr = $this->am->GetChannels(false); |
46 | - if(!in_array($channel, $arr, true)){ |
|
46 | + if (!in_array($channel, $arr, true)) { |
|
47 | 47 | return ''; |
48 | 48 | } |
49 | 49 | $srcFile = "{$f}.wav"; |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function StopMixMonitor($channel): void |
87 | 87 | { |
88 | - if(isset($this->mixMonitorChannels[$channel])){ |
|
88 | + if (isset($this->mixMonitorChannels[$channel])) { |
|
89 | 89 | unset($this->mixMonitorChannels[$channel]); |
90 | - }else{ |
|
90 | + } else { |
|
91 | 91 | return; |
92 | 92 | } |
93 | 93 | if ($this->record_calls) { |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | foreach ($m_data as $row) { |
126 | 126 | $row->writeAttribute('endtime', $data['start']); |
127 | 127 | $res = $row->update(); |
128 | - if ( ! $res) { |
|
128 | + if (!$res) { |
|
129 | 129 | Util::sysLogMsg('Action_app_end', implode(' ', $row->getMessages())); |
130 | 130 | } |
131 | 131 | } |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | // мобильный и внутренний номер. |
145 | 145 | $filter = [ |
146 | 146 | '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:org_id:) AND endtime = ""', |
147 | - 'bind' => ['UNIQUEID' => $data['UNIQUEID'], 'org_id' => $data['org_id'],], |
|
147 | + 'bind' => ['UNIQUEID' => $data['UNIQUEID'], 'org_id' => $data['org_id'], ], |
|
148 | 148 | ]; |
149 | 149 | } else { |
150 | 150 | $filter = [ |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | /** @var CallDetailRecordsTmp $row */ |
161 | 161 | $m_data = CallDetailRecordsTmp::find($filter); |
162 | 162 | foreach ($m_data as $row) { |
163 | - if ( ! is_object($row)) { |
|
163 | + if (!is_object($row)) { |
|
164 | 164 | continue; |
165 | 165 | } |
166 | 166 | /// |
167 | 167 | // Проверим, если более одного канала SIP/256 при входящем. |
168 | 168 | $column_chan_name = ('ORIGINATE' === $row->dialstatus) ? 'src_chan' : 'dst_chan'; |
169 | 169 | |
170 | - if ( ! empty($row->$column_chan_name) && $data['dst_chan'] !== $row->$column_chan_name) { |
|
170 | + if (!empty($row->$column_chan_name) && $data['dst_chan'] !== $row->$column_chan_name) { |
|
171 | 171 | if ($row_create) { |
172 | 172 | continue; |
173 | 173 | } |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $new_row->writeAttribute($attribute, $value); |
182 | 182 | } |
183 | 183 | $new_row->writeAttribute($column_chan_name, $data['dst_chan']); |
184 | - $new_row->writeAttribute('UNIQUEID', $data['UNIQUEID'] . '_' . $data['dst_chan']); |
|
184 | + $new_row->writeAttribute('UNIQUEID', $data['UNIQUEID'].'_'.$data['dst_chan']); |
|
185 | 185 | // Подмена $row; |
186 | 186 | $row = $new_row; |
187 | 187 | $row_create = true; |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | $row->writeAttribute('dst_chan', $data['dst_chan']); |
198 | 198 | } |
199 | 199 | |
200 | - if (isset($data['to_account']) && ! empty($data['to_account'])) { |
|
200 | + if (isset($data['to_account']) && !empty($data['to_account'])) { |
|
201 | 201 | $row->writeAttribute($account_col, $data['to_account']); |
202 | 202 | } |
203 | - if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) { |
|
203 | + if (isset($data['dst_call_id']) && !empty($data['dst_call_id'])) { |
|
204 | 204 | $row->writeAttribute('dst_call_id', $data['dst_call_id']); |
205 | 205 | } |
206 | 206 | $res = $row->save(); |
207 | - if ( ! $res) { |
|
207 | + if (!$res) { |
|
208 | 208 | Util::sysLogMsg('Action_dial_create_chan', implode(' ', $row->getMessages())); |
209 | 209 | } |
210 | 210 | } |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | // Событие возникает, когда мы пытаемся перехватить вызов на соседний телефон. |
225 | 225 | $filter = [ |
226 | 226 | 'UNIQUEID=:UNIQUEID:', |
227 | - 'bind' => ['UNIQUEID' => $data['old_id'],], |
|
227 | + 'bind' => ['UNIQUEID' => $data['old_id'], ], |
|
228 | 228 | ]; |
229 | 229 | /** @var CallDetailRecordsTmp $m_data */ |
230 | 230 | $m_data = CallDetailRecordsTmp::find($filter); |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | $new_data['dst_chan'] = $data['agi_channel']; |
239 | 239 | $new_data['dst_num'] = $data['dst_num']; |
240 | 240 | $new_data['UNIQUEID'] = $data['id']; |
241 | - $new_data['recordingfile'] = $this->MixMonitor($new_data['dst_chan'], 'pickup_'.$new_data['UNIQUEID']); |
|
241 | + $new_data['recordingfile'] = $this->MixMonitor($new_data['dst_chan'], 'pickup_'.$new_data['UNIQUEID']); |
|
242 | 242 | |
243 | 243 | unset($new_data['id'], $new_data['end']); |
244 | 244 | self::insertDataToDbM($new_data); |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | $this->am->UserEvent('CdrConnector', ['AgiData' => $AgiData]); |
251 | 251 | } |
252 | 252 | } else { |
253 | - if ( ! empty($data['ENDCALLONANSWER'])) { |
|
253 | + if (!empty($data['ENDCALLONANSWER'])) { |
|
254 | 254 | // Переменная ENDCALLONANSWER устанавливается при начале работы умной маршуртизации. |
255 | 255 | // Как только произошел ответ на вызов, отметим вызов на приложение как завершенный. |
256 | 256 | $filter = [ |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | $row->writeAttribute('endtime', $data['answer']); |
268 | 268 | $row->writeAttribute('is_app', 1); |
269 | 269 | $res = $row->save(); |
270 | - if ( ! $res) { |
|
270 | + if (!$res) { |
|
271 | 271 | Util::sysLogMsg('ENDCALLONANSWER', implode(' ', $row->getMessages())); |
272 | 272 | } |
273 | 273 | } |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:UNIQUEID_CHAN:) AND answer = "" AND endtime = ""', |
290 | 290 | 'bind' => [ |
291 | 291 | 'UNIQUEID' => $data['id'], |
292 | - 'UNIQUEID_CHAN' => $data['id'] . '_' . $data['agi_channel'], |
|
292 | + 'UNIQUEID_CHAN' => $data['id'].'_'.$data['agi_channel'], |
|
293 | 293 | ], |
294 | 294 | ]; |
295 | 295 | } |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | continue; |
303 | 303 | } |
304 | 304 | // Найдем все прочие CDR по данному originate и отметим как завершенные. |
305 | - $filter = [ |
|
305 | + $filter = [ |
|
306 | 306 | 'linkedid=:linkedid: AND endtime <> "" AND src_chan <> :src_chan:', |
307 | 307 | 'bind' => [ |
308 | 308 | 'linkedid' => $row->linkedid, |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | $orgn_row->writeAttribute('endtime', $data['answer']); |
317 | 317 | } |
318 | 318 | $orgn_row->writeAttribute('dst_chan', ''); |
319 | - $orgn_row->writeAttribute('UNIQUEID', $data['id'] . '_' . $orgn_row->src_chan); |
|
319 | + $orgn_row->writeAttribute('UNIQUEID', $data['id'].'_'.$orgn_row->src_chan); |
|
320 | 320 | $orgn_row->update(); |
321 | 321 | } |
322 | 322 | |
@@ -328,13 +328,13 @@ discard block |
||
328 | 328 | } |
329 | 329 | |
330 | 330 | $row->writeAttribute('answer', $data['answer']); |
331 | - $recFile = $data['recordingfile']??''; |
|
332 | - if(!empty($recFile)){ |
|
331 | + $recFile = $data['recordingfile'] ?? ''; |
|
332 | + if (!empty($recFile)) { |
|
333 | 333 | $this->mixMonitorChannels[$data['agi_channel']] = $recFile; |
334 | 334 | $row->writeAttribute('recordingfile', $recFile); |
335 | 335 | } |
336 | 336 | $res = $row->save(); |
337 | - if ( !$res) { |
|
337 | + if (!$res) { |
|
338 | 338 | Util::sysLogMsg('Action_dial_answer', implode(' ', $row->getMessages())); |
339 | 339 | } |
340 | 340 | } |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | $this->hangupChanCheckSipTrtansfer($data, $channels); |
361 | 361 | |
362 | 362 | // Очистим память. |
363 | - if(isset($this->checkChanHangupTransfer[$data['agi_channel']])){ |
|
363 | + if (isset($this->checkChanHangupTransfer[$data['agi_channel']])) { |
|
364 | 364 | unset($this->checkChanHangupTransfer[$data['agi_channel']]); |
365 | 365 | } |
366 | - if(isset($this->mixMonitorChannels[$data['agi_channel']])){ |
|
366 | + if (isset($this->mixMonitorChannels[$data['agi_channel']])) { |
|
367 | 367 | unset($this->mixMonitorChannels[$data['agi_channel']]); |
368 | 368 | } |
369 | 369 | } |
@@ -375,24 +375,24 @@ discard block |
||
375 | 375 | */ |
376 | 376 | private function hangupChanCheckSipTrtansfer($data, $channels):void{ |
377 | 377 | $not_local = (stripos($data['agi_channel'], 'local/') === false); |
378 | - if($not_local === false || $data['OLD_LINKEDID'] !== $data['linkedid']) { |
|
378 | + if ($not_local === false || $data['OLD_LINKEDID'] !== $data['linkedid']) { |
|
379 | 379 | return; |
380 | 380 | } |
381 | 381 | $active_chans = $this->am->GetChannels(false); |
382 | 382 | // Намек на SIP трансфер. |
383 | 383 | foreach ($channels as $data_chan) { |
384 | - if ( ! in_array($data_chan['chan'], $active_chans, true)) { |
|
384 | + if (!in_array($data_chan['chan'], $active_chans, true)) { |
|
385 | 385 | // Вызов уже завершен. Не интересно. |
386 | 386 | continue; |
387 | 387 | } |
388 | 388 | $BRIDGEPEER = $this->am->GetVar($data_chan['chan'], 'BRIDGEPEER', null, false); |
389 | - if ( ! in_array($BRIDGEPEER, $active_chans, true) || !is_string($BRIDGEPEER)) { |
|
389 | + if (!in_array($BRIDGEPEER, $active_chans, true) || !is_string($BRIDGEPEER)) { |
|
390 | 390 | // Вызов уже завершен. Не интересно. |
391 | 391 | continue; |
392 | 392 | } |
393 | 393 | |
394 | 394 | $linkedid = $this->am->GetVar($data_chan['chan'], 'CHANNEL(linkedid)', null, false); |
395 | - if ( empty($linkedid) || $linkedid === $data['linkedid']) { |
|
395 | + if (empty($linkedid) || $linkedid === $data['linkedid']) { |
|
396 | 396 | continue; |
397 | 397 | } |
398 | 398 | |
@@ -405,7 +405,7 @@ discard block |
||
405 | 405 | $n_data['start'] = date('Y-m-d H:i:s'); |
406 | 406 | $n_data['answer'] = date('Y-m-d H:i:s'); |
407 | 407 | $n_data['linkedid'] = $linkedid; |
408 | - $n_data['UNIQUEID'] = $data['linkedid'] . Util::generateRandomString(); |
|
408 | + $n_data['UNIQUEID'] = $data['linkedid'].Util::generateRandomString(); |
|
409 | 409 | $n_data['transfer'] = '0'; |
410 | 410 | $n_data['recordingfile'] = $this->MixMonitor($n_data['dst_chan'], $n_data['UNIQUEID']); |
411 | 411 | $n_data['did'] = $data_chan['did']; |
@@ -437,7 +437,7 @@ discard block |
||
437 | 437 | * @param array $channels |
438 | 438 | */ |
439 | 439 | private function hangupChanEndCalls(array $data, array &$transfer_calls, array &$channels):void{ |
440 | - $filter = [ |
|
440 | + $filter = [ |
|
441 | 441 | 'linkedid=:linkedid: AND endtime = "" AND (src_chan=:src_chan: OR dst_chan=:dst_chan:)', |
442 | 442 | 'bind' => [ |
443 | 443 | 'linkedid' => $data['linkedid'], |
@@ -454,8 +454,8 @@ discard block |
||
454 | 454 | } |
455 | 455 | if ($row->dialstatus === 'ORIGINATE') { |
456 | 456 | $row->writeAttribute('dialstatus', ''); |
457 | - if($row->answer === ''){ |
|
458 | - $newId = $row->linkedid.'_'.$row->src_num.'_'.substr($row->src_chan, strpos($row->src_chan,'-') +1); |
|
457 | + if ($row->answer === '') { |
|
458 | + $newId = $row->linkedid.'_'.$row->src_num.'_'.substr($row->src_chan, strpos($row->src_chan, '-') + 1); |
|
459 | 459 | $row->writeAttribute('UNIQUEID', $newId); |
460 | 460 | } |
461 | 461 | } |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | $row->writeAttribute('dialstatus', $data['dialstatus']); |
469 | 469 | } |
470 | 470 | $res = $row->update(); |
471 | - if ( ! $res) { |
|
471 | + if (!$res) { |
|
472 | 472 | Util::sysLogMsg('Action_hangup_chan', implode(' ', $row->getMessages())); |
473 | 473 | } |
474 | 474 | |
@@ -500,14 +500,14 @@ discard block |
||
500 | 500 | */ |
501 | 501 | public function Action_CreateRowTransfer($action, $data, $calls_data = null): void |
502 | 502 | { |
503 | - if( isset($this->checkChanHangupTransfer[$data['agi_channel']]) ) { |
|
503 | + if (isset($this->checkChanHangupTransfer[$data['agi_channel']])) { |
|
504 | 504 | return; |
505 | 505 | } |
506 | 506 | |
507 | 507 | $this->checkChanHangupTransfer[$data['agi_channel']] = $action; |
508 | 508 | |
509 | 509 | if (null === $calls_data) { |
510 | - $filter = [ |
|
510 | + $filter = [ |
|
511 | 511 | 'linkedid=:linkedid: AND endtime = "" AND transfer=1 AND (src_chan=:chan: OR dst_chan=:chan:)', |
512 | 512 | 'bind' => [ |
513 | 513 | 'linkedid' => $data['linkedid'], |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | $insert_data[$fname_chan] = $row_data['dst_chan']; |
530 | 530 | $insert_data[$fname_num] = $row_data['dst_num']; |
531 | 531 | } else { |
532 | - $fname_chan = ! isset($insert_data['src_chan']) ? 'src_chan' : 'dst_chan'; |
|
533 | - $fname_num = ! isset($insert_data['src_num']) ? 'src_num' : 'dst_num'; |
|
532 | + $fname_chan = !isset($insert_data['src_chan']) ? 'src_chan' : 'dst_chan'; |
|
533 | + $fname_num = !isset($insert_data['src_num']) ? 'src_num' : 'dst_num'; |
|
534 | 534 | |
535 | 535 | $insert_data[$fname_chan] = $row_data['src_chan']; |
536 | 536 | $insert_data[$fname_num] = $row_data['src_num']; |
@@ -541,7 +541,7 @@ discard block |
||
541 | 541 | $this->StopMixMonitor($insert_data['dst_chan']); |
542 | 542 | $recordingfile = $this->MixMonitor( |
543 | 543 | $insert_data['dst_chan'], |
544 | - 'transfer_' . $insert_data['src_num'] . '_' . $insert_data['dst_num'] . '_' . $data['linkedid'] |
|
544 | + 'transfer_'.$insert_data['src_num'].'_'.$insert_data['dst_num'].'_'.$data['linkedid'] |
|
545 | 545 | ); |
546 | 546 | // |
547 | 547 | $insert_data['action'] = "{$action}_end_trasfer"; |
@@ -562,7 +562,7 @@ discard block |
||
562 | 562 | $this->am->UserEvent('CdrConnector', ['AgiData' => $AgiData]); |
563 | 563 | |
564 | 564 | self::insertDataToDbM($insert_data); |
565 | - } elseif (empty($calls_data[0]['answer']) && count($calls_data) === 1 && ! empty($calls_data[0]['recordingfile'])) { |
|
565 | + } elseif (empty($calls_data[0]['answer']) && count($calls_data) === 1 && !empty($calls_data[0]['recordingfile'])) { |
|
566 | 566 | // Возобновление записи разговора при срыве переадресации. |
567 | 567 | $row_data = $calls_data[0]; |
568 | 568 | $chan = ($data['agi_channel'] === $row_data['src_chan']) ? $row_data['dst_chan'] : $row_data['src_chan']; |
@@ -578,12 +578,12 @@ discard block |
||
578 | 578 | /** @var CallDetailRecordsTmp $row */ |
579 | 579 | $not_ended_cdr = null; |
580 | 580 | $transferNotComplete = false; |
581 | - foreach ($cdr as $row){ |
|
582 | - if($row->transfer === '1' && ($row->src_chan === $chan || $row->dst_chan === $chan) ){ |
|
581 | + foreach ($cdr as $row) { |
|
582 | + if ($row->transfer === '1' && ($row->src_chan === $chan || $row->dst_chan === $chan)) { |
|
583 | 583 | $not_ended_cdr = $row; |
584 | 584 | } |
585 | - if($row->answer === '' && $row->endtime === '' |
|
586 | - && ($row->src_chan === $chan || $row->dst_chan === $chan) ){ |
|
585 | + if ($row->answer === '' && $row->endtime === '' |
|
586 | + && ($row->src_chan === $chan || $row->dst_chan === $chan)) { |
|
587 | 587 | $transferNotComplete = true; |
588 | 588 | } |
589 | 589 | } |
@@ -661,7 +661,7 @@ discard block |
||
661 | 661 | */ |
662 | 662 | public function Action_transfer_dial_create_chan($data): void |
663 | 663 | { |
664 | - $filter = [ |
|
664 | + $filter = [ |
|
665 | 665 | 'UNIQUEID=:UNIQUEID: AND endtime = "" AND answer = ""', |
666 | 666 | 'bind' => [ |
667 | 667 | 'UNIQUEID' => $data['transfer_UNIQUEID'], |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | foreach ($m_data as $row) { |
675 | 675 | /// |
676 | 676 | // Проверим, если более одного канала SIP/256 при входящем. |
677 | - if ( ! empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) { |
|
677 | + if (!empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) { |
|
678 | 678 | if ($row_create) { |
679 | 679 | continue; |
680 | 680 | } |
@@ -688,7 +688,7 @@ discard block |
||
688 | 688 | $new_row->writeAttribute($attribute, $value); |
689 | 689 | } |
690 | 690 | $new_row->writeAttribute('dst_chan', $data['dst_chan']); |
691 | - $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'] . '_' . $data['dst_chan']); |
|
691 | + $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'].'_'.$data['dst_chan']); |
|
692 | 692 | // $new_row->save(); |
693 | 693 | // Подмена $row; |
694 | 694 | $row = $new_row; |
@@ -700,11 +700,11 @@ discard block |
||
700 | 700 | |
701 | 701 | $row->writeAttribute('dst_chan', $data['dst_chan']); |
702 | 702 | $row->writeAttribute('recordingfile', $data['recordingfile']); |
703 | - if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) { |
|
703 | + if (isset($data['dst_call_id']) && !empty($data['dst_call_id'])) { |
|
704 | 704 | $row->writeAttribute('dst_call_id', $data['dst_call_id']); |
705 | 705 | } |
706 | 706 | $res = $row->save(); |
707 | - if ( ! $res) { |
|
707 | + if (!$res) { |
|
708 | 708 | Util::sysLogMsg('Action_transfer_dial_create_chan', implode(' ', $row->getMessages())); |
709 | 709 | } |
710 | 710 | } |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:UNIQUEID_CHAN:) AND answer = "" AND endtime = ""', |
722 | 722 | 'bind' => [ |
723 | 723 | 'UNIQUEID' => $data['transfer_UNIQUEID'], |
724 | - 'UNIQUEID_CHAN' => $data['transfer_UNIQUEID'] . '_' . $data['agi_channel'], |
|
724 | + 'UNIQUEID_CHAN' => $data['transfer_UNIQUEID'].'_'.$data['agi_channel'], |
|
725 | 725 | ], |
726 | 726 | ]; |
727 | 727 | |
@@ -730,13 +730,13 @@ discard block |
||
730 | 730 | $m_data = CallDetailRecordsTmp::find($filter); |
731 | 731 | foreach ($m_data as $row) { |
732 | 732 | $row->writeAttribute('answer', $data['answer']); |
733 | - $recFile = $data['recordingfile']??''; |
|
734 | - if(!empty($recFile)){ |
|
733 | + $recFile = $data['recordingfile'] ?? ''; |
|
734 | + if (!empty($recFile)) { |
|
735 | 735 | $this->mixMonitorChannels[$data['agi_channel']] = $recFile; |
736 | 736 | $row->writeAttribute('recordingfile', $recFile); |
737 | 737 | } |
738 | 738 | $res = $row->save(); |
739 | - if ( !$res) { |
|
739 | + if (!$res) { |
|
740 | 740 | Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages())); |
741 | 741 | } |
742 | 742 | } |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | // Завершим вызов в CDR. |
771 | 771 | $row->writeAttribute('endtime', $data['end']); |
772 | 772 | $row->writeAttribute('transfer', 0); |
773 | - if ( ! $row->save()) { |
|
773 | + if (!$row->save()) { |
|
774 | 774 | Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages())); |
775 | 775 | } |
776 | 776 | } |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | // Ответа не было. Переадресация отменена. |
806 | 806 | $row->writeAttribute('endtime', $data['end']); |
807 | 807 | $row->writeAttribute('transfer', 0); |
808 | - if ( ! $row->save()) { |
|
808 | + if (!$row->save()) { |
|
809 | 809 | Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages())); |
810 | 810 | } |
811 | 811 | } |
@@ -825,7 +825,7 @@ discard block |
||
825 | 825 | $this->MixMonitor($row->dst_chan, $info['filename'], $subdir); |
826 | 826 | // Снимем со строк признак переадресации. |
827 | 827 | $row->writeAttribute('transfer', 0); |
828 | - if ( ! $row->save()) { |
|
828 | + if (!$row->save()) { |
|
829 | 829 | Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages())); |
830 | 830 | } |
831 | 831 | } |
@@ -901,7 +901,7 @@ discard block |
||
901 | 901 | |
902 | 902 | $f_list = $m_data->toArray(); |
903 | 903 | foreach ($data as $attribute => $value) { |
904 | - if ( ! array_key_exists($attribute, $f_list)) { |
|
904 | + if (!array_key_exists($attribute, $f_list)) { |
|
905 | 905 | continue; |
906 | 906 | } |
907 | 907 | $m_data->writeAttribute($attribute, $value); |
@@ -972,7 +972,7 @@ discard block |
||
972 | 972 | $row->writeAttribute('answer', $data['answer']); |
973 | 973 | $row->writeAttribute('endtime', $data['answer']); |
974 | 974 | $res = $row->save(); |
975 | - if ( ! $res) { |
|
975 | + if (!$res) { |
|
976 | 976 | Util::sysLogMsg('Action_queue_answer', implode(' ', $row->getMessages())); |
977 | 977 | } |
978 | 978 | } |
@@ -1001,7 +1001,7 @@ discard block |
||
1001 | 1001 | $row->writeAttribute('dialstatus', $data['dialstatus']); |
1002 | 1002 | } |
1003 | 1003 | $res = $row->save(); |
1004 | - if ( ! $res) { |
|
1004 | + if (!$res) { |
|
1005 | 1005 | Util::sysLogMsg('Action_queue_end', implode(' ', $row->getMessages())); |
1006 | 1006 | } |
1007 | 1007 | } |
@@ -1031,11 +1031,11 @@ discard block |
||
1031 | 1031 | if ($dest_chan === $row->dst_chan) { |
1032 | 1032 | $is_local = (stripos($data['src_chan'], 'local/') !== false); |
1033 | 1033 | $is_stored_local = (stripos($row->src_chan, 'local/') !== false); |
1034 | - if ($row->UNIQUEID === $data['UNIQUEID'] && $is_local && ! $is_stored_local) { |
|
1034 | + if ($row->UNIQUEID === $data['UNIQUEID'] && $is_local && !$is_stored_local) { |
|
1035 | 1035 | $data['src_chan'] = $row->src_chan; |
1036 | 1036 | } |
1037 | 1037 | if (file_exists($row->recordingfile) || file_exists( |
1038 | - Util::trimExtensionForFile($row->recordingfile) . '.wav' |
|
1038 | + Util::trimExtensionForFile($row->recordingfile).'.wav' |
|
1039 | 1039 | )) { |
1040 | 1040 | // Переопределим путь к файлу записи разговора. Для конферецнии файл один. |
1041 | 1041 | $recordingfile = $row->recordingfile; |
@@ -1047,7 +1047,7 @@ discard block |
||
1047 | 1047 | // Подменим ID на идентификатор конференции. |
1048 | 1048 | $row->writeAttribute('linkedid', $data['meetme_id']); |
1049 | 1049 | $res = $row->save(); |
1050 | - if ( ! $res) { |
|
1050 | + if (!$res) { |
|
1051 | 1051 | Util::sysLogMsg('Action_hangup_chan_meetme', implode(' ', $row->getMessages())); |
1052 | 1052 | } |
1053 | 1053 | } |
@@ -1064,11 +1064,11 @@ discard block |
||
1064 | 1064 | $row->writeAttribute('transfer', 0); |
1065 | 1065 | $row->writeAttribute('linkedid', $data['meetme_id']); |
1066 | 1066 | |
1067 | - if ( ! empty($recordingfile)) { |
|
1067 | + if (!empty($recordingfile)) { |
|
1068 | 1068 | $row->writeAttribute('recordingfile', $recordingfile); |
1069 | 1069 | } |
1070 | 1070 | $res = $row->save(); |
1071 | - if ( ! $res) { |
|
1071 | + if (!$res) { |
|
1072 | 1072 | Util::sysLogMsg('Action_hangup_chan_meetme', implode(' ', $row->getMessages())); |
1073 | 1073 | } |
1074 | 1074 | } |
@@ -1107,9 +1107,9 @@ discard block |
||
1107 | 1107 | */ |
1108 | 1108 | public function callEventsWorker($tube): void |
1109 | 1109 | { |
1110 | - $data = json_decode($tube->getBody(), true); |
|
1111 | - $funcName = "Action_".$data['action']??''; |
|
1112 | - if ( method_exists($this, $funcName) ) { |
|
1110 | + $data = json_decode($tube->getBody(), true); |
|
1111 | + $funcName = "Action_".$data['action'] ?? ''; |
|
1112 | + if (method_exists($this, $funcName)) { |
|
1113 | 1113 | $this->$funcName($data); |
1114 | 1114 | } |
1115 | 1115 | $tube->reply(json_encode(true)); |
@@ -1139,14 +1139,14 @@ discard block |
||
1139 | 1139 | public function updateDataInDbM($data): bool |
1140 | 1140 | { |
1141 | 1141 | if (empty($data['UNIQUEID'])) { |
1142 | - Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data)); |
|
1142 | + Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty '.json_encode($data)); |
|
1143 | 1143 | |
1144 | 1144 | return false; |
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | $filter = [ |
1148 | 1148 | "UNIQUEID=:id:", |
1149 | - 'bind' => ['id' => $data['UNIQUEID'],], |
|
1149 | + 'bind' => ['id' => $data['UNIQUEID'], ], |
|
1150 | 1150 | ]; |
1151 | 1151 | /** @var CallDetailRecordsTmp $m_data */ |
1152 | 1152 | $m_data = CallDetailRecordsTmp::findFirst($filter); |
@@ -1155,7 +1155,7 @@ discard block |
||
1155 | 1155 | } |
1156 | 1156 | $f_list = $m_data->toArray(); |
1157 | 1157 | foreach ($data as $attribute => $value) { |
1158 | - if ( ! array_key_exists($attribute, $f_list)) { |
|
1158 | + if (!array_key_exists($attribute, $f_list)) { |
|
1159 | 1159 | continue; |
1160 | 1160 | } |
1161 | 1161 | if ('UNIQUEID' === $attribute) { |
@@ -1164,7 +1164,7 @@ discard block |
||
1164 | 1164 | $m_data->writeAttribute($attribute, $value); |
1165 | 1165 | } |
1166 | 1166 | $res = $m_data->save(); |
1167 | - if ( ! $res) { |
|
1167 | + if (!$res) { |
|
1168 | 1168 | Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages())); |
1169 | 1169 | } |
1170 | 1170 | |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | public static function insertDataToDbM($data): bool |
1204 | 1204 | { |
1205 | 1205 | if (empty($data['UNIQUEID'])) { |
1206 | - Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data)); |
|
1206 | + Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty '.json_encode($data)); |
|
1207 | 1207 | |
1208 | 1208 | return false; |
1209 | 1209 | } |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | } elseif (isset($data['IS_ORGNT']) && $data['IS_ORGNT'] !== false && $data['action'] === 'dial') { |
1226 | 1226 | if (empty($m_data->endtime)) { |
1227 | 1227 | // Если это оригинация dial может прийти дважды. |
1228 | - if(!empty($m_data->src_num) && $m_data->src_num === $data['dst_num']){ |
|
1228 | + if (!empty($m_data->src_num) && $m_data->src_num === $data['dst_num']) { |
|
1229 | 1229 | $m_data->dst_num = $data['src_num']; |
1230 | 1230 | $m_data->save(); |
1231 | 1231 | } |
@@ -1250,7 +1250,7 @@ discard block |
||
1250 | 1250 | $new_m_data->transfer = $data['transfer']; |
1251 | 1251 | |
1252 | 1252 | $res = $new_m_data->save(); |
1253 | - if ( ! $res) { |
|
1253 | + if (!$res) { |
|
1254 | 1254 | Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages())); |
1255 | 1255 | } |
1256 | 1256 | |
@@ -1259,7 +1259,7 @@ discard block |
||
1259 | 1259 | |
1260 | 1260 | $f_list = $m_data->toArray(); |
1261 | 1261 | foreach ($data as $attribute => $value) { |
1262 | - if ( ! array_key_exists($attribute, $f_list)) { |
|
1262 | + if (!array_key_exists($attribute, $f_list)) { |
|
1263 | 1263 | continue; |
1264 | 1264 | } |
1265 | 1265 | if ($is_new === false && 'UNIQUEID' === $attribute) { |
@@ -1268,7 +1268,7 @@ discard block |
||
1268 | 1268 | $m_data->writeAttribute($attribute, $value); |
1269 | 1269 | } |
1270 | 1270 | $res = $m_data->save(); |
1271 | - if ( ! $res) { |
|
1271 | + if (!$res) { |
|
1272 | 1272 | Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages())); |
1273 | 1273 | } |
1274 | 1274 | |
@@ -1283,12 +1283,12 @@ discard block |
||
1283 | 1283 | $q = $tube->getBody(); |
1284 | 1284 | $filter = json_decode($q, true); |
1285 | 1285 | |
1286 | - if($this->filterNotValid($filter)){ |
|
1286 | + if ($this->filterNotValid($filter)) { |
|
1287 | 1287 | $tube->reply('[]'); |
1288 | 1288 | return; |
1289 | 1289 | } |
1290 | 1290 | |
1291 | - $res = null; |
|
1291 | + $res = null; |
|
1292 | 1292 | try { |
1293 | 1293 | if (isset($filter['miko_tmp_db'])) { |
1294 | 1294 | $res = CallDetailRecordsTmp::find($filter); |
@@ -1307,7 +1307,7 @@ discard block |
||
1307 | 1307 | } |
1308 | 1308 | $filter['add_pack_query']['bind'][$filter['columns']] = $arr; |
1309 | 1309 | |
1310 | - if($this->filterNotValid($filter['add_pack_query'])){ |
|
1310 | + if ($this->filterNotValid($filter['add_pack_query'])) { |
|
1311 | 1311 | $tube->reply('[]'); |
1312 | 1312 | return; |
1313 | 1313 | } |
@@ -1323,7 +1323,7 @@ discard block |
||
1323 | 1323 | if (isset($filter['miko_result_in_file'])) { |
1324 | 1324 | $di = Di::getDefault(); |
1325 | 1325 | $dirsConfig = $di->getShared('config'); |
1326 | - $filename = $dirsConfig->path('core.tempDir') . '/' . md5(microtime(true)); |
|
1326 | + $filename = $dirsConfig->path('core.tempDir').'/'.md5(microtime(true)); |
|
1327 | 1327 | file_put_contents($filename, $res_data); |
1328 | 1328 | Util::addRegularWWWRights($filename); |
1329 | 1329 | $res_data = json_encode($filename); |
@@ -1339,16 +1339,16 @@ discard block |
||
1339 | 1339 | * |
1340 | 1340 | * @return bool |
1341 | 1341 | */ |
1342 | - private function filterNotValid($filter){ |
|
1342 | + private function filterNotValid($filter) { |
|
1343 | 1343 | $haveErrors = false; |
1344 | - if(isset($filter['bind'])){ |
|
1345 | - if(is_array($filter)){ |
|
1344 | + if (isset($filter['bind'])) { |
|
1345 | + if (is_array($filter)) { |
|
1346 | 1346 | foreach ($filter['bind'] as $bindValue) { |
1347 | - if(empty($bindValue)){ |
|
1347 | + if (empty($bindValue)) { |
|
1348 | 1348 | $haveErrors = true; |
1349 | 1349 | } |
1350 | 1350 | } |
1351 | - }else{ |
|
1351 | + } else { |
|
1352 | 1352 | $haveErrors = true; |
1353 | 1353 | } |
1354 | 1354 | } |
@@ -1357,7 +1357,7 @@ discard block |
||
1357 | 1357 | |
1358 | 1358 | public function errorHandler($m): void |
1359 | 1359 | { |
1360 | - Util::sysLogMsg(self::class . '_ERROR', $m); |
|
1360 | + Util::sysLogMsg(self::class.'_ERROR', $m); |
|
1361 | 1361 | } |
1362 | 1362 | } |
1363 | 1363 |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $date = CallEventsLogs::maximum( |
50 | 50 | ['linkedid = "'.$row_cdr->linkedid.'"', 'column' => 'eventtime'] |
51 | 51 | ); |
52 | - if ( ! $row_cdr->endtime) { |
|
52 | + if (!$row_cdr->endtime) { |
|
53 | 53 | if ($date) { |
54 | 54 | $row_cdr->endtime = $date; |
55 | 55 | } elseif ($row_cdr->answer) { |
@@ -189,7 +189,7 @@ discard block |
||
189 | 189 | foreach ($additionalModules as $appClass) { |
190 | 190 | // Проверим, зависит ли объект от измененных данных. |
191 | 191 | $dependences = $appClass->dependenceModels(); |
192 | - if (in_array($called_class, $dependences, true)){ |
|
192 | + if (in_array($called_class, $dependences, true)) { |
|
193 | 193 | // Получаем новые настройки. |
194 | 194 | $appClass->getSettings(); |
195 | 195 | } |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | break; |
236 | 236 | case Codecs::class: |
237 | 237 | $this->modified_tables[self::R_IAX] = true; |
238 | - $this->modified_tables[self::R_SIP] = true; |
|
238 | + $this->modified_tables[self::R_SIP] = true; |
|
239 | 239 | break; |
240 | 240 | case SoundFiles::class: |
241 | 241 | $this->modified_tables[self::R_MOH] = true; |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | break; |
254 | 254 | case PbxSettings::class: |
255 | 255 | $pbxSettings = PbxSettings::findFirstByKey($data['recordId']); |
256 | - if ($pbxSettings===null){ |
|
256 | + if ($pbxSettings === null) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 | if ($pbxSettings->itHasFeaturesSettingsChanges()) { |
@@ -295,17 +295,17 @@ discard block |
||
295 | 295 | $this->modified_tables[self::R_NATS] = true; |
296 | 296 | } |
297 | 297 | if ($pbxSettings->itHasTimeZoneSettings()) { |
298 | - $this->modified_tables[self::R_TIMEZONE] = true; |
|
299 | - $this->modified_tables[self::R_NGINX] = true; |
|
300 | - $this->modified_tables[self::R_PHP_FPM] = true; |
|
298 | + $this->modified_tables[self::R_TIMEZONE] = true; |
|
299 | + $this->modified_tables[self::R_NGINX] = true; |
|
300 | + $this->modified_tables[self::R_PHP_FPM] = true; |
|
301 | 301 | $this->modified_tables[self::R_REST_API_WORKER] = true; |
302 | 302 | } |
303 | 303 | if ($pbxSettings->itHasNTPSettings()) { |
304 | - $this->modified_tables[self::R_NTP] = true; |
|
304 | + $this->modified_tables[self::R_NTP] = true; |
|
305 | 305 | } |
306 | 306 | if ($pbxSettings->itHasCallRecordSettings()) { |
307 | - $this->modified_tables[self::R_CALL_EVENTS_WORKER] = true; |
|
308 | - $this->modified_tables[self::R_DIALPLAN] = true; |
|
307 | + $this->modified_tables[self::R_CALL_EVENTS_WORKER] = true; |
|
308 | + $this->modified_tables[self::R_DIALPLAN] = true; |
|
309 | 309 | } |
310 | 310 | break; |
311 | 311 | case PbxExtensionModules::class: |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | */ |
467 | 467 | public function reloadNginx(): void |
468 | 468 | { |
469 | - $nginxConf = new NginxConf(); |
|
469 | + $nginxConf = new NginxConf(); |
|
470 | 470 | $nginxConf->generateConf(); |
471 | 471 | $nginxConf->reStart(); |
472 | 472 | } |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | $data = $this->request->getPost(); |
102 | 102 | $this->sendRequestToBackendWorker('system', $actionName, $data); |
103 | 103 | // Clear WWW models cache after successfully install or remove module |
104 | - if ($this->response->getStatusCode()===200){ |
|
104 | + if ($this->response->getStatusCode() === 200) { |
|
105 | 105 | PbxExtensionModules::clearCache(Extensions::class); |
106 | 106 | PbxExtensionModules::clearCache(PbxExtensionModules::class); |
107 | 107 | PbxExtensionModules::clearCache(PbxSettings::class); |
@@ -126,10 +126,10 @@ discard block |
||
126 | 126 | $mohDir = $di->getShared('config')->path('asterisk.mohdir'); |
127 | 127 | switch ($category) { |
128 | 128 | case SoundFiles::CATEGORY_MOH: |
129 | - $data['filename'] = "{$mohDir}/" . basename($data['temp_filename']); |
|
129 | + $data['filename'] = "{$mohDir}/".basename($data['temp_filename']); |
|
130 | 130 | break; |
131 | 131 | case SoundFiles::CATEGORY_CUSTOM: |
132 | - $data['filename'] = "{$mediaDir}/" . basename($data['temp_filename']); |
|
132 | + $data['filename'] = "{$mediaDir}/".basename($data['temp_filename']); |
|
133 | 133 | break; |
134 | 134 | default: |
135 | 135 | $this->sendError(400, 'Category not set'); |
@@ -28,7 +28,7 @@ |
||
28 | 28 | { |
29 | 29 | $managedCache = $this->di->get('managedCache'); |
30 | 30 | $lastTubesCheck = $managedCache->get('lastTubesCheck'); |
31 | - if ($lastTubesCheck === null){ |
|
31 | + if ($lastTubesCheck === null) { |
|
32 | 32 | $client = new BeanstalkClient(); |
33 | 33 | $client->cleanTubes(); |
34 | 34 | $managedCache->set('lastTubesCheck', time(), 300); |
@@ -80,14 +80,14 @@ discard block |
||
80 | 80 | $extensionTable[$extension->userid]['email'] = $extension->email; |
81 | 81 | $extensionTable[$extension->userid]['secret'] = $extension->secret; |
82 | 82 | |
83 | - if ( ! array_key_exists('mobile', $extensionTable[$extension->userid])) { |
|
83 | + if (!array_key_exists('mobile', $extensionTable[$extension->userid])) { |
|
84 | 84 | $extensionTable[$extension->userid]['mobile'] = ''; |
85 | 85 | } |
86 | 86 | if ($extension->avatar) { |
87 | 87 | $filename = md5($extension->avatar); |
88 | 88 | $imgCacheDir = appPath('sites/admin-cabinet/assets/img/cache'); |
89 | 89 | $imgFile = "{$imgCacheDir}/$filename.jpg"; |
90 | - if ( ! file_exists($imgFile)) { |
|
90 | + if (!file_exists($imgFile)) { |
|
91 | 91 | $this->base64ToJpeg($extension->avatar, $imgFile); |
92 | 92 | } |
93 | 93 | |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $extension->Sip = new Sip(); |
153 | 153 | $extension->Sip->disabled = 0; |
154 | 154 | $extension->Sip->type = 'peer'; |
155 | - $extension->Sip->uniqid = Extensions::TYPE_SIP.strtoupper('-PHONE-' . md5(time())); |
|
155 | + $extension->Sip->uniqid = Extensions::TYPE_SIP.strtoupper('-PHONE-'.md5(time())); |
|
156 | 156 | $extension->Sip->busylevel = 1; |
157 | 157 | $extension->Sip->qualify = '1'; |
158 | 158 | $extension->Sip->qualifyfreq = 60; |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $arrNetworkFilters[$filter->id] = $filter->getRepresent(); |
175 | 175 | } |
176 | 176 | |
177 | - $parameters = [ |
|
177 | + $parameters = [ |
|
178 | 178 | 'conditions' => 'type = "'.Extensions::TYPE_EXTERNAL.'" AND is_general_user_number = "1" AND userid=:userid:', |
179 | 179 | 'bind' => [ |
180 | 180 | 'userid' => $extension->userid, |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | $externalExtension->type = Extensions::TYPE_EXTERNAL; |
188 | 188 | $externalExtension->is_general_user_number = '1'; |
189 | 189 | $externalExtension->ExternalPhones = new ExternalPhones(); |
190 | - $externalExtension->ExternalPhones->uniqid = Extensions::TYPE_EXTERNAL.strtoupper('-' . md5(time())); |
|
190 | + $externalExtension->ExternalPhones->uniqid = Extensions::TYPE_EXTERNAL.strtoupper('-'.md5(time())); |
|
191 | 191 | $externalExtension->ExternalPhones->disabled = '0'; |
192 | 192 | } |
193 | 193 | |
194 | - $forwardingExtensions = []; |
|
194 | + $forwardingExtensions = []; |
|
195 | 195 | $forwardingExtensions[''] = $this->translation->_('ex_SelectNumber'); |
196 | 196 | |
197 | 197 | $parameters = [ |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | 'conditions' => 'type = "'.Extensions::TYPE_SIP.'"', |
236 | 236 | 'column' => 'number', |
237 | 237 | ]; |
238 | - $query = Extensions::maximum($parameters); |
|
238 | + $query = Extensions::maximum($parameters); |
|
239 | 239 | if ($query === null) { |
240 | 240 | $query = 200; |
241 | 241 | } |
242 | - $result = (int)$query + 1; |
|
242 | + $result = (int) $query + 1; |
|
243 | 243 | $extensionsLength = PbxSettings::getValueByKey('PBXInternalExtensionLength'); |
244 | 244 | $maxExtension = (10 ** $extensionsLength) - 1; |
245 | 245 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function saveAction(): void |
255 | 255 | { |
256 | - if ( ! $this->request->isPost()) { |
|
256 | + if (!$this->request->isPost()) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 | |
@@ -275,21 +275,21 @@ discard block |
||
275 | 275 | $fwdEntity->ringlength = 45; |
276 | 276 | } else { |
277 | 277 | $extension = $sipEntity->Extensions; |
278 | - if ( ! $extension) { |
|
278 | + if (!$extension) { |
|
279 | 279 | $extension = new Extensions(); |
280 | 280 | } |
281 | 281 | $userEntity = $extension->Users; |
282 | - if ( ! $userEntity) { |
|
282 | + if (!$userEntity) { |
|
283 | 283 | $userEntity = new Users(); |
284 | 284 | } |
285 | 285 | $fwdEntity = $extension->ExtensionForwardingRights; |
286 | - if ( ! $fwdEntity) { |
|
286 | + if (!$fwdEntity) { |
|
287 | 287 | $fwdEntity = new ExtensionForwardingRights(); |
288 | 288 | } |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Заполним параметры пользователя |
292 | - if ( ! $this->saveUser($userEntity, $data)) { |
|
292 | + if (!$this->saveUser($userEntity, $data)) { |
|
293 | 293 | $this->view->success = false; |
294 | 294 | $this->db->rollback(); |
295 | 295 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | } |
298 | 298 | |
299 | 299 | // Заполним параметры внутреннего номера |
300 | - if ( ! $this->saveExtension($extension, $userEntity, $data, false)) { |
|
300 | + if (!$this->saveExtension($extension, $userEntity, $data, false)) { |
|
301 | 301 | $this->view->success = false; |
302 | 302 | $this->db->rollback(); |
303 | 303 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | } |
306 | 306 | |
307 | 307 | // Заполним параметры SIP учетки |
308 | - if ( ! $this->saveSip($sipEntity, $data)) { |
|
308 | + if (!$this->saveSip($sipEntity, $data)) { |
|
309 | 309 | $this->view->success = false; |
310 | 310 | $this->db->rollback(); |
311 | 311 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | |
315 | 315 | |
316 | 316 | // Заполним параметры маршрутизации |
317 | - if ( ! $this->saveForwardingRights($fwdEntity, $data)) { |
|
317 | + if (!$this->saveForwardingRights($fwdEntity, $data)) { |
|
318 | 318 | $this->view->success = false; |
319 | 319 | $this->db->rollback(); |
320 | 320 | |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | } |
323 | 323 | |
324 | 324 | // Если мобильный не указан, то не будем его добавлять в базу |
325 | - if ( ! empty($data['mobile_number'])) { |
|
325 | + if (!empty($data['mobile_number'])) { |
|
326 | 326 | $externalPhone = ExternalPhones::findFirstByUniqid($data['mobile_uniqid']); |
327 | 327 | if ($externalPhone === null) { |
328 | 328 | $externalPhone = new ExternalPhones(); |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | } |
333 | 333 | |
334 | 334 | // Заполним параметры Extension для мобильного |
335 | - if ( ! $this->saveExtension($mobileExtension, $userEntity, $data, true)) { |
|
335 | + if (!$this->saveExtension($mobileExtension, $userEntity, $data, true)) { |
|
336 | 336 | $this->view->success = false; |
337 | 337 | $this->db->rollback(); |
338 | 338 | |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | } |
341 | 341 | |
342 | 342 | // Заполним параметры ExternalPhones для мобильного |
343 | - if ( ! $this->saveExternalPhones($externalPhone, $data)) { |
|
343 | + if (!$this->saveExternalPhones($externalPhone, $data)) { |
|
344 | 344 | $this->view->success = false; |
345 | 345 | $this->db->rollback(); |
346 | 346 | |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | } |
349 | 349 | } else { |
350 | 350 | // Удалить номер мобильного если он был привязан к пользователю |
351 | - $parameters = [ |
|
351 | + $parameters = [ |
|
352 | 352 | 'conditions' => 'type="'.Extensions::TYPE_EXTERNAL.'" AND is_general_user_number = "1" AND userid=:userid:', |
353 | 353 | 'bind' => [ |
354 | 354 | 'userid' => $userEntity->id, |
@@ -390,16 +390,16 @@ discard block |
||
390 | 390 | foreach ($userEntity as $name => $value) { |
391 | 391 | switch ($name) { |
392 | 392 | case 'role': |
393 | - if (array_key_exists('user_' . $name, $data)) { |
|
394 | - $userEntity->$name = ($userEntity->$name === 'user') ? 'user' : $data['user_' . $name]; // не повышаем роль |
|
393 | + if (array_key_exists('user_'.$name, $data)) { |
|
394 | + $userEntity->$name = ($userEntity->$name === 'user') ? 'user' : $data['user_'.$name]; // не повышаем роль |
|
395 | 395 | } |
396 | 396 | break; |
397 | 397 | case 'language': |
398 | 398 | $userEntity->$name = PbxSettings::getValueByKey('PBXLanguage'); |
399 | 399 | break; |
400 | 400 | default: |
401 | - if (array_key_exists('user_' . $name, $data)) { |
|
402 | - $userEntity->$name = $data['user_' . $name]; |
|
401 | + if (array_key_exists('user_'.$name, $data)) { |
|
402 | + $userEntity->$name = $data['user_'.$name]; |
|
403 | 403 | } |
404 | 404 | } |
405 | 405 | } |
@@ -491,20 +491,20 @@ discard block |
||
491 | 491 | break; |
492 | 492 | case 'disabled': |
493 | 493 | case 'disablefromuser': |
494 | - if (array_key_exists('sip_' . $name, $data)) { |
|
495 | - $sipEntity->$name = ($data['sip_' . $name] === 'on') ? '1' : '0'; |
|
494 | + if (array_key_exists('sip_'.$name, $data)) { |
|
495 | + $sipEntity->$name = ($data['sip_'.$name] === 'on') ? '1' : '0'; |
|
496 | 496 | } else { |
497 | 497 | $sipEntity->$name = "0"; |
498 | 498 | } |
499 | 499 | break; |
500 | 500 | case 'networkfilterid': |
501 | - if ( ! array_key_exists('sip_' . $name, $data)) { |
|
501 | + if (!array_key_exists('sip_'.$name, $data)) { |
|
502 | 502 | continue 2; |
503 | 503 | } |
504 | - if ($data['sip_' . $name] === 'none') { |
|
504 | + if ($data['sip_'.$name] === 'none') { |
|
505 | 505 | $sipEntity->$name = null; |
506 | 506 | } else { |
507 | - $sipEntity->$name = $data['sip_' . $name]; |
|
507 | + $sipEntity->$name = $data['sip_'.$name]; |
|
508 | 508 | } |
509 | 509 | break; |
510 | 510 | case 'extension': |
@@ -517,8 +517,8 @@ discard block |
||
517 | 517 | $sipEntity->setManualAttributes($data['sip_manualattributes']); |
518 | 518 | break; |
519 | 519 | default: |
520 | - if (array_key_exists('sip_' . $name, $data)) { |
|
521 | - $sipEntity->$name = $data['sip_' . $name]; |
|
520 | + if (array_key_exists('sip_'.$name, $data)) { |
|
521 | + $sipEntity->$name = $data['sip_'.$name]; |
|
522 | 522 | } |
523 | 523 | } |
524 | 524 | } |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | $forwardingRight->$name = $data['number']; |
549 | 549 | break; |
550 | 550 | default: |
551 | - if (array_key_exists('fwd_' . $name, $data)) { |
|
552 | - $forwardingRight->$name = ($data['fwd_' . $name] === -1) ? '' : $data['fwd_' . $name]; |
|
551 | + if (array_key_exists('fwd_'.$name, $data)) { |
|
552 | + $forwardingRight->$name = ($data['fwd_'.$name] === -1) ? '' : $data['fwd_'.$name]; |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | } |
@@ -586,15 +586,15 @@ discard block |
||
586 | 586 | $externalPhone->$name = $data['user_username']; |
587 | 587 | break; |
588 | 588 | case 'disabled': |
589 | - if (array_key_exists('mobile_' . $name, $data)) { |
|
590 | - $externalPhone->$name = ($data['mobile_' . $name] === 'on') ? '1' : '0'; |
|
589 | + if (array_key_exists('mobile_'.$name, $data)) { |
|
590 | + $externalPhone->$name = ($data['mobile_'.$name] === 'on') ? '1' : '0'; |
|
591 | 591 | } else { |
592 | 592 | $externalPhone->$name = '0'; |
593 | 593 | } |
594 | 594 | break; |
595 | 595 | default: |
596 | - if (array_key_exists('mobile_' . $name, $data)) { |
|
597 | - $externalPhone->$name = $data['mobile_' . $name]; |
|
596 | + if (array_key_exists('mobile_'.$name, $data)) { |
|
597 | + $externalPhone->$name = $data['mobile_'.$name]; |
|
598 | 598 | } |
599 | 599 | } |
600 | 600 | } |
@@ -623,13 +623,13 @@ discard block |
||
623 | 623 | |
624 | 624 | $errors = null; |
625 | 625 | if ($extension !== null && $extension->ExtensionForwardingRights |
626 | - && ! $extension->ExtensionForwardingRights->delete()) { |
|
626 | + && !$extension->ExtensionForwardingRights->delete()) { |
|
627 | 627 | $errors = $extension->ExtensionForwardingRights->getMessages(); |
628 | 628 | } |
629 | 629 | |
630 | - if ( ! $errors && $extension) { |
|
630 | + if (!$errors && $extension) { |
|
631 | 631 | $user = $extension->Users; |
632 | - if ( ! $user->delete()) { |
|
632 | + if (!$user->delete()) { |
|
633 | 633 | $errors = $user->getMessages(); |
634 | 634 | } |
635 | 635 | } |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | */ |
750 | 750 | public function GetPhonesRepresentAction(): void |
751 | 751 | { |
752 | - if ( ! $this->request->isPost()) { |
|
752 | + if (!$this->request->isPost()) { |
|
753 | 753 | return; |
754 | 754 | } |
755 | 755 | $numbers = $this->request->getPost('numbers'); |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | { |
39 | 39 | $di->setShared( |
40 | 40 | self::SERVICE_NAME, |
41 | - function () { |
|
41 | + function() { |
|
42 | 42 | $eventsManager = new EventsManager(); |
43 | 43 | |
44 | 44 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | /** |
62 | 62 | * Handle exceptions and not-found exceptions using NotFoundPlugin |
63 | 63 | */ |
64 | - if (! class_exists(PrettyPageHandler::class)) { |
|
64 | + if (!class_exists(PrettyPageHandler::class)) { |
|
65 | 65 | $eventsManager->attach( |
66 | 66 | 'dispatch:beforeException', |
67 | 67 | new NotFoundPlugin() |
@@ -38,7 +38,8 @@ |
||
38 | 38 | { |
39 | 39 | $di->setShared( |
40 | 40 | self::SERVICE_NAME, |
41 | - function () { |
|
41 | + function () |
|
42 | + { |
|
42 | 43 | $eventsManager = new EventsManager(); |
43 | 44 | |
44 | 45 |