@@ -84,8 +84,7 @@ discard block |
||
| 84 | 84 | $job_data, |
| 85 | 85 | int $timeout = 10, |
| 86 | 86 | int $priority = PheanstalkInterface::DEFAULT_PRIORITY |
| 87 | - ) |
|
| 88 | - { |
|
| 87 | + ) { |
|
| 89 | 88 | $this->message = false; |
| 90 | 89 | $inbox_tube = uniqid('INBOX_', true); |
| 91 | 90 | $this->queue->watch($inbox_tube); |
@@ -186,7 +185,7 @@ discard block |
||
| 186 | 185 | // Processing job over callable function attached in $this->subscribe |
| 187 | 186 | if(json_decode($job->getData(), true) !==null){ |
| 188 | 187 | $mData = $job->getData(); |
| 189 | - }else{ |
|
| 188 | + } else{ |
|
| 190 | 189 | $mData = unserialize($job->getData(), [false]); |
| 191 | 190 | } |
| 192 | 191 | $this->message = $mData; |
@@ -266,7 +265,8 @@ discard block |
||
| 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 |
||
| 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 | |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | $internetInterface = LanInterfaces::findFirstByInternet('1'); |
| 38 | 38 | if ($internetInterface === null) { |
| 39 | 39 | $internetInterface = new LanInterfaces(); |
| 40 | - $internetInterface->id = 1; |
|
| 40 | + $internetInterface->id = 1; |
|
| 41 | 41 | } |
| 42 | 42 | |
| 43 | 43 | // We will find additional interfaces which we can delete |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function saveAction(): void |
| 62 | 62 | { |
| 63 | - if ( ! $this->request->isPost()) { |
|
| 63 | + if (!$this->request->isPost()) { |
|
| 64 | 64 | return; |
| 65 | 65 | } |
| 66 | 66 | |
@@ -125,9 +125,9 @@ discard block |
||
| 125 | 125 | case 'extipaddr': |
| 126 | 126 | if ($itIsInternetInterfce) { |
| 127 | 127 | if (array_key_exists($name, $data)) { |
| 128 | - $eth->$name = ($data['usenat'] === 'on') ? $data[$name] : $data['ipaddr_' . $eth->id]; |
|
| 128 | + $eth->$name = ($data['usenat'] === 'on') ? $data[$name] : $data['ipaddr_'.$eth->id]; |
|
| 129 | 129 | } else { |
| 130 | - $eth->$name = $data['ipaddr_' . $eth->id]; |
|
| 130 | + $eth->$name = $data['ipaddr_'.$eth->id]; |
|
| 131 | 131 | } |
| 132 | 132 | } else { |
| 133 | 133 | $eth->$name = ''; |
@@ -146,8 +146,8 @@ discard block |
||
| 146 | 146 | } |
| 147 | 147 | break; |
| 148 | 148 | case 'dhcp': |
| 149 | - if (array_key_exists($name . '_' . $eth->id, $data)) { |
|
| 150 | - $eth->$name = ($data['dhcp_' . $eth->id]) === 'on' ? '1' : '0'; |
|
| 149 | + if (array_key_exists($name.'_'.$eth->id, $data)) { |
|
| 150 | + $eth->$name = ($data['dhcp_'.$eth->id]) === 'on' ? '1' : '0'; |
|
| 151 | 151 | } |
| 152 | 152 | break; |
| 153 | 153 | case 'internet': |
@@ -156,13 +156,13 @@ discard block |
||
| 156 | 156 | case 'ipaddr': |
| 157 | 157 | case 'subnet': |
| 158 | 158 | $eth->$name = ''; |
| 159 | - if (array_key_exists($name . '_' . $eth->id, $data)) { |
|
| 160 | - $eth->$name = ($data['dhcp_' . $eth->id]) === 'on' ? '' : $data[$name . '_' . $eth->id]; |
|
| 159 | + if (array_key_exists($name.'_'.$eth->id, $data)) { |
|
| 160 | + $eth->$name = ($data['dhcp_'.$eth->id]) === 'on' ? '' : $data[$name.'_'.$eth->id]; |
|
| 161 | 161 | } |
| 162 | 162 | break; |
| 163 | 163 | case 'interface': |
| 164 | 164 | if ($eth->id === 0) { |
| 165 | - $eth->$name = LanInterfaces::findFirstById($data[$name . '_' . $eth->id])->interface; |
|
| 165 | + $eth->$name = LanInterfaces::findFirstById($data[$name.'_'.$eth->id])->interface; |
|
| 166 | 166 | } |
| 167 | 167 | break; |
| 168 | 168 | case 'domain': |
@@ -177,8 +177,8 @@ discard block |
||
| 177 | 177 | } |
| 178 | 178 | break; |
| 179 | 179 | default: |
| 180 | - if (array_key_exists($name . '_' . $eth->id, $data)) { |
|
| 181 | - $eth->$name = $data[$name . '_' . $eth->id]; |
|
| 180 | + if (array_key_exists($name.'_'.$eth->id, $data)) { |
|
| 181 | + $eth->$name = $data[$name.'_'.$eth->id]; |
|
| 182 | 182 | } |
| 183 | 183 | } |
| 184 | 184 | } |
@@ -25,11 +25,11 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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['PickupExten']; |
|
| 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['PickupExten']; |
|
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |