| 189 | | $ext->add($context, $exten, '', new ext_set('TO', '"'.$row['faxemail'].'"')); |
|---|
| 190 | | if ($fax['module'] == 'spandsp') { |
|---|
| 191 | | $ext->add($context, $exten, 'receivefax', new ext_rxfax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on |
|---|
| 192 | | } else { |
|---|
| 193 | | $ext->add($context, $exten, 'receivefax', new ext_receivefax('${ASTSPOOLDIR}/fax/${UNIQUEID}.tif')); //recive fax, then email it on |
|---|
| 194 | | } |
|---|
| | 189 | $ext->add($context, $exten, '', new ext_set('FAX_RX_EMAIL', '"'.$row['faxemail'].'"')); |
|---|
| | 190 | $ext->add($context, $exten, '', new ext_goto('receivefax','s')); |
|---|
| 196 | | $ext->add($context, 'h', '', new ext_execif('$["${TO}" != ""]','system','\'${ASTVARLIBDIR}/bin/fax-process.pl --to ${TO} --from "'.$sender_address['0'].'" --dest "${FROM_DID}" --subject "New fax from ${URIENCODE(${CALLERID(all)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif\'')); |
|---|
| 197 | | } |
|---|
| 198 | | $ext->add('ext-did-0001', 'fax', '', new ext_goto('${FAX_DEST}')); |
|---|
| 199 | | $ext->add('ext-did-0002', 'fax', '', new ext_goto('${FAX_DEST}')); |
|---|
| 200 | | |
|---|
| 201 | | // Add fax extension to ivr and announcement as inbound controle may be passed quickly to them and still detection is desired |
|---|
| 202 | | if (function_exists('ivr_list')) { |
|---|
| 203 | | $ivrlist = ivr_list(); |
|---|
| 204 | | if(is_array($ivrlist)) foreach($ivrlist as $item) { |
|---|
| 205 | | $ext->add("ivr-".$item['ivr_id'], 'fax', '', new ext_goto('${FAX_DEST}')); |
|---|
| 206 | | } |
|---|
| 207 | | } |
|---|
| 208 | | if (function_exists('announcement_list')) foreach (announcement_list() as $row) { |
|---|
| 209 | | $ext->add('app-announcement-'.$row['announcement_id'], 'fax', '', new ext_goto('${FAX_DEST}')); |
|---|
| 210 | | } |
|---|
| 211 | | |
|---|
| 212 | | //write out res_fax.conf and res_fax_digium.conf |
|---|
| 213 | | fax_write_conf(); |
|---|
| 214 | | // generate ext-fax-legacy used for both legacy mode and app-fax feature code |
|---|
| 215 | | // |
|---|
| 216 | | $context='ext-fax-legacy'; |
|---|
| | 192 | } |
|---|
| | 193 | /* |
|---|
| | 194 | FAX Failures are not handled well as of this coding in by ReceiveFAX. If there is a license available then it provides |
|---|
| | 195 | information. If not, nothing is provided. FAXSTATUS is supported in 1.4 to handle legacy with RxFax(). In order to create |
|---|
| | 196 | dialplan to try and handle all cases, we use FAXSTATUS and set it ourselves as needed. It appears that if a fax fails with |
|---|
| | 197 | ReceiveFAX we can always continue execution and if it succeeds, then execution goes to hangup. So using that information |
|---|
| | 198 | we try to trap and report on all cases. |
|---|
| | 199 | */ |
|---|
| 224 | | } |
|---|
| 225 | | $ext->add($context, 'h', '', new ext_execif('$["${FAX_RX_EMAIL}" != ""]','system','\'${ASTVARLIBDIR}/bin/fax-process.pl --to ${FAX_RX_EMAIL} --from "'.$sender_address['0'].'" --dest "${FROM_DID}" --subject "New fax from ${URIENCODE(${CALLERID(all)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif\'')); |
|---|
| | 207 | $ext->add($context, $exten, '', new ext_set('FAXSTATUS','${IF($["${FAXOPT(error)}" = ""]?"FAILED LICENSE EXCEEDED":"FAILED FAXOPT: error: ${FAXOPT(error)} status: ${FAXOPT(status)} statusstr: ${FAXOPT(statusstr)}")}')); |
|---|
| | 208 | } |
|---|
| | 209 | $exten = 'h'; |
|---|
| | 210 | $ext->add($context, $exten, '', new ext_gotoif('$["${FAXSTATUS:0:6}" = "FAILED"]', 'failed')); |
|---|
| | 211 | $ext->add($context, $exten, 'process', new ext_execif('$["${FAX_RX_EMAIL}" != ""]','system','\'${ASTVARLIBDIR}/bin/fax-process.pl --to ${FAX_RX_EMAIL} --from "'.$sender_address['0'].'" --dest "${FROM_DID}" --subject "New fax from ${URIENCODE(${CALLERID(all)})}" --attachment fax_${URIENCODE(${CALLERID(number)})}.pdf --type application/pdf --file ${ASTSPOOLDIR}/fax/${UNIQUEID}.tif\'')); |
|---|
| | 212 | $ext->add($context, $exten, 'end', new ext_macro('hangupcall')); |
|---|
| | 213 | $ext->add($context, $exten, 'failed', new ext_noop('FAX ${FAXSTATUS} for: ${FAX_RX_EMAIL} , From: ${CALLERID(all)}'),'process',101); |
|---|
| | 214 | $ext->add($context, $exten, '', new ext_macro('hangupcall')); |
|---|
| | 215 | |
|---|
| | 216 | $ext->add('ext-did-0001', 'fax', '', new ext_goto('${FAX_DEST}')); |
|---|
| | 217 | $ext->add('ext-did-0002', 'fax', '', new ext_goto('${FAX_DEST}')); |
|---|
| | 218 | |
|---|
| | 219 | // Add fax extension to ivr and announcement as inbound controle may be passed quickly to them and still detection is desired |
|---|
| | 220 | if (function_exists('ivr_list')) { |
|---|
| | 221 | $ivrlist = ivr_list(); |
|---|
| | 222 | if(is_array($ivrlist)) foreach($ivrlist as $item) { |
|---|
| | 223 | $ext->add("ivr-".$item['ivr_id'], 'fax', '', new ext_goto('${FAX_DEST}')); |
|---|
| | 224 | } |
|---|
| | 225 | } |
|---|
| | 226 | if (function_exists('announcement_list')) foreach (announcement_list() as $row) { |
|---|
| | 227 | $ext->add('app-announcement-'.$row['announcement_id'], 'fax', '', new ext_goto('${FAX_DEST}')); |
|---|
| | 228 | } |
|---|
| | 229 | |
|---|
| | 230 | //write out res_fax.conf and res_fax_digium.conf |
|---|
| | 231 | fax_write_conf(); |
|---|