| 326 | | |
|---|
| 327 | | |
|---|
| 328 | | // Create the paging context that is used in the paging application for each phone to auto-answer |
|---|
| 329 | | // |
|---|
| 330 | | $ext->addInclude('from-internal-noxfer-additional',$extpaging); |
|---|
| 331 | | |
|---|
| | 326 | |
|---|
| | 327 | //auto answer stuff |
|---|
| | 328 | //set autoanswer variables |
|---|
| | 329 | $ext->add($apppaging, '_AUTOASWER.', '', new ext_setvar('_SIPURI', '')); |
|---|
| | 330 | if (isset($alertinfo) && trim($alertinfo) != "") { |
|---|
| | 331 | $ext->add($apppaging, '_AUTOASWER.', '', new ext_setvar('_ALERTINFO', $alertinfo)); |
|---|
| | 332 | } |
|---|
| | 333 | |
|---|
| | 334 | if (isset($callinfo) && trim($callinfo) != "") { |
|---|
| | 335 | $ext->add($apppaging, '_AUTOASWER.', '', new ext_setvar('_CALLINFO', $callinfo)); |
|---|
| | 336 | } |
|---|
| | 337 | if (isset($sipuri) && trim($sipuri) != "") { |
|---|
| | 338 | $ext->add($apppaging, '_AUTOASWER.', '', new ext_setvar('_SIPURI', $sipuri)); |
|---|
| | 339 | } |
|---|
| | 340 | if (isset($vxml_url) && trim($vxml_url) != "") { |
|---|
| | 341 | $ext->add($apppaging, '_AUTOASWER.', '', new ext_setvar('_VXML_URL', $vxml_url)); |
|---|
| | 342 | } |
|---|
| | 343 | if (isset($doptions) && trim($doptions) != "") { |
|---|
| | 344 | $ext->add($apppaging, '_AUTOASWER.', '', new ext_setvar('_DOPTIONS', $doptions)); |
|---|
| | 345 | } |
|---|
| | 346 | $ext->add($apppaging, '_AUTOASWER.', '', new ext_setvar('_DTIME', $dtime)); |
|---|
| | 347 | $ext->add($apppaging, '_AUTOASWER.', '', new ext_setvar('_ANSWERMACRO', '')); |
|---|
| | 348 | foreach ($custom_vars as $key => $value) { |
|---|
| | 349 | $ext->add($apppaging, '_AUTOASWER.', '', new ext_setvar('_'.ltrim($key,'_'), $value)); |
|---|
| | 350 | } |
|---|
| | 351 | $ext->add($apppaging, '_AUTOASWER.', '', new ext_setvar('__FORWARD_CONTEXT', 'block-cf')); |
|---|
| | 352 | $ext->add($apppaging, '_AUTOASWER.', '', new ext_macro('autoanswer','${EXTEN:9}')); |
|---|
| | 353 | $ext->add($apppaging, '_AUTOASWER.', '', new ext_return()); |
|---|
| | 354 | |
|---|
| 333 | | $ext->add($extpaging, "_PAGE.", '', new ext_gotoif('$[ ${AMPUSER} = ${EXTEN:4} ]','skipself')); |
|---|
| 334 | | if ($ast_ge_14) { |
|---|
| 335 | | $ext->add($extpaging, "_PAGE.", 'AVAIL', new ext_chanisavail('${DB(DEVICE/${EXTEN:4}/dial)}', 's')); |
|---|
| 336 | | $ext->add($extpaging, "_PAGE.", '', new ext_noop_trace('AVAILCHAN: ${AVAILCHAN}, AVAILORIGCHAN: ${AVAILORIGCHAN}, AVAILSTATUS: ${AVAILSTATUS}',5)); |
|---|
| 337 | | $ext->add($extpaging, "_PAGE.", '', new ext_gotoif('$["${AVAILORIGCHAN}" = ""]', 'skipself')); |
|---|
| 338 | | } else { |
|---|
| 339 | | $ext->add($extpaging, "_PAGE.", 'AVAIL', new ext_chanisavail('${DB(DEVICE/${EXTEN:4}/dial)}', 'js')); |
|---|
| 340 | | } |
|---|
| 341 | | $ext->add($extpaging, "_PAGE.", '', new ext_gotoif('$["${DB(DND/${DB(DEVICE/${EXTEN:4}/user)})}" = "YES"]', 'skipself')); |
|---|
| 342 | | $ext->add($extpaging, "_PAGE.", 'SKIPCHECK', new ext_macro('autoanswer','${EXTEN:4}')); |
|---|
| 343 | | $ext->add($extpaging, "_PAGE.", '', new ext_dial('${DIAL}','${DTIME},${DOPTIONS}')); |
|---|
| 344 | | $ext->add($extpaging, "_PAGE.", 'skipself', new ext_hangup()); |
|---|
| 345 | | if (!$ast_ge_14) { |
|---|
| 346 | | $ext->add($extpaging, "_PAGE.", '', new ext_hangup(''), 'AVAIL',101); |
|---|
| 347 | | } |
|---|
| | 356 | $ext->add($apppaging, "_PAGE.", '', new ext_gotoif('$[ "${AMPUSER}" = "${EXTEN:4}" ]','skipself')); |
|---|
| | 357 | $ext->add($apppaging, "_PAGE.", 'AVAIL', new ext_chanisavail('${DB(DEVICE/${EXTEN:4}/dial)}', 'js')); |
|---|
| | 358 | $ext->add($apppaging, "_PAGE.", '', new ext_gotoif('$["${DB(DND/${DB(DEVICE/${EXTEN:4}/user)})}" = "YES"]', 'skipself')); |
|---|
| | 359 | $ext->add($apppaging, "_PAGE.", 'SKIPCHECK', new ext_gosub('AUTOASWER${EXTEN:4},1')); |
|---|
| | 360 | $ext->add($apppaging, "_PAGE.", '', new ext_dial('${DIAL}','${DTIME},${DOPTIONS}')); |
|---|
| | 361 | $ext->add($apppaging, "_PAGE.", 'skipself', new ext_hangup()); |
|---|
| | 362 | $ext->add($apppaging, "_PAGE.", '', new ext_hangup(''), 'AVAIL',101); |
|---|
| 350 | | $ext->add($extpaging, "_SPAGE.", '', new ext_gotoif('$[ ${AMPUSER} = ${EXTEN:5} ]','skipself')); |
|---|
| 351 | | if ($ast_ge_14) { |
|---|
| 352 | | $ext->add($extpaging, "_SPAGE.", 'AVAIL', new ext_chanisavail('${DB(DEVICE/${EXTEN:5}/dial)}', 's')); |
|---|
| 353 | | $ext->add($extpaging, "_SPAGE.", '', new ext_noop_trace('AVAILCHAN: ${AVAILCHAN}, AVAILORIGCHAN: ${AVAILORIGCHAN}, AVAILSTATUS: ${AVAILSTATUS}',5)); |
|---|
| 354 | | $ext->add($extpaging, "_SPAGE.", '', new ext_gotoif('$["${AVAILORIGCHAN}" = ""]', 'chanspy')); |
|---|
| 355 | | } else { |
|---|
| 356 | | $ext->add($extpaging, "_SPAGE.", 'AVAIL', new ext_chanisavail('${DB(DEVICE/${EXTEN:5}/dial)}', 'js')); |
|---|
| 357 | | } |
|---|
| 358 | | $ext->add($extpaging, "_SPAGE.", '', new ext_gotoif('$["${DB(DND/${DB(DEVICE/${EXTEN:5}/user)})}" = "YES"]', 'chanspy')); |
|---|
| 359 | | $ext->add($extpaging, "_SPAGE.", 'SKIPCHECK', new ext_macro('autoanswer','${EXTEN:5}')); |
|---|
| 360 | | $ext->add($extpaging, "_SPAGE.", '', new ext_dial('${DIAL}','${DTIME},${DOPTIONS}')); |
|---|
| 361 | | $ext->add($extpaging, "_SPAGE.", 'skipself', new ext_hangup()); |
|---|
| 362 | | $ext->add($extpaging, "_SPAGE.", 'chanspy', new ext_execif('$["${CUT(DB(DEVICE/${EXTEN:5}/dial),/,1)}" = "SIP"]', 'ChanSpy','${DB(DEVICE/${EXTEN:5}/dial)}-,qW')); |
|---|
| 363 | | $ext->add($extpaging, "_SPAGE.", '', new ext_noop_trace('Comparison: ${EXTEN:5}, "${CUT(DB(DEVICE/${EXTEN:5}/dial),/,1)}" = "SIP"',9)); |
|---|
| 364 | | $ext->add($extpaging, "_SPAGE.", '', new ext_hangup()); |
|---|
| 365 | | if (!$ast_ge_14) { |
|---|
| 366 | | $ext->add($extpaging, "_SPAGE.", '', new ext_hangup(''), 'AVAIL',101); |
|---|
| 367 | | } |
|---|
| | 365 | $ext->add($apppaging, "_SPAGE.", '', new ext_gotoif('$[ "${AMPUSER}" = "${EXTEN:5}" ]','skipself')); |
|---|
| | 366 | $ext->add($apppaging, "_SPAGE.", 'AVAIL', new ext_chanisavail('${DB(DEVICE/${EXTEN:5}/dial)}', 'js')); |
|---|
| | 367 | $ext->add($apppaging, "_SPAGE.", '', new ext_gotoif('$["${DB(DND/${DB(DEVICE/${EXTEN:5}/user)})}" = "YES"]', 'chanspy')); |
|---|
| | 368 | $ext->add($apppaging, "_SPAGE.", 'SKIPCHECK', new ext_gosub('AUTOASWER${EXTEN:5},1')); |
|---|
| | 369 | $ext->add($apppaging, "_SPAGE.", '', new ext_dial('${DIAL}','${DTIME},${DOPTIONS}')); |
|---|
| | 370 | $ext->add($apppaging, "_SPAGE.", 'skipself', new ext_hangup()); |
|---|
| | 371 | $ext->add($apppaging, "_SPAGE.", 'chanspy', new ext_execif('$["${CUT(DB(DEVICE/${EXTEN:5}/dial),/,1)}" = "SIP"]', 'ChanSpy','${DB(DEVICE/${EXTEN:5}/dial)}-,qW')); |
|---|
| | 372 | $ext->add($apppaging, "_SPAGE.", '', new ext_noop_trace('Comparison: ${EXTEN:5}, "${CUT(DB(DEVICE/${EXTEN:5}/dial),/,1)}" = "SIP"',9)); |
|---|
| | 373 | $ext->add($apppaging, "_SPAGE.", '', new ext_hangup()); |
|---|
| | 374 | $ext->add($apppaging, "_SPAGE.", '', new ext_hangup(''), 'AVAIL',101); |
|---|
| | 375 | |
|---|
| 370 | | $ext->add($extpaging, "_FPAGE.", '', new ext_gotoif('$[ ${AMPUSER} = ${EXTEN:5} ]','skipself')); |
|---|
| 371 | | $ext->add($extpaging, "_FPAGE.", 'SKIPCHECK', new ext_macro('autoanswer','${EXTEN:5}')); |
|---|
| 372 | | $ext->add($extpaging, "_FPAGE.", '', new ext_dial('${DIAL}','${DTIME},${DOPTIONS}')); |
|---|
| 373 | | $ext->add($extpaging, "_FPAGE.", 'skipself', new ext_hangup()); |
|---|
| 374 | | |
|---|
| 375 | | // |
|---|
| | 378 | $ext->add($apppaging, "_FPAGE.", '', new ext_gotoif('$[ "${AMPUSER}" = "${EXTEN:5}" ]','skipself')); |
|---|
| | 379 | $ext->add($apppaging, "_FPAGE.", 'SKIPCHECK', new ext_gosub('AUTOASWER${EXTEN:5},1')); |
|---|
| | 380 | $ext->add($apppaging, "_FPAGE.", '', new ext_dial('${DIAL}','${DTIME},${DOPTIONS}')); |
|---|
| | 381 | $ext->add($apppaging, "_FPAGE.", 'skipself', new ext_hangup()); |
|---|
| | 382 | |
|---|
| 400 | | |
|---|
| 401 | | $dialstr .= "LOCAL/$pagemode".trim($local_dial[0])."@".$extpaging."&"; |
|---|
| 402 | | } |
|---|
| 403 | | // It will always end with an &, so lets take that off. |
|---|
| 404 | | $dialstr = rtrim($dialstr, "&"); |
|---|
| 405 | | |
|---|
| 406 | | if ($thisgroup['duplex']) { |
|---|
| 407 | | $dialstr .= ",d"; |
|---|
| 408 | | } |
|---|
| 409 | | $ext->add($extpaging, $grp, '', new ext_answer('')); |
|---|
| 410 | | $ext->add($extpaging, $grp, '', new ext_macro('user-callerid')); |
|---|
| 411 | | // make AMPUSER inherited here, so we can skip the proper 'self' if using cidnum masquerading |
|---|
| 412 | | $ext->add($extpaging, $grp, '', new ext_setvar('_AMPUSER', '${AMPUSER}')); |
|---|
| 413 | | |
|---|
| 414 | | $ext->add($extpaging, $grp, '', new ext_setvar('_SIPURI', '')); |
|---|
| 415 | | if (isset($alertinfo) && trim($alertinfo) != "") { |
|---|
| 416 | | $ext->add($extpaging, $grp, '', new ext_setvar('_ALERTINFO', $alertinfo)); |
|---|
| 417 | | } |
|---|
| 418 | | if (isset($callinfo) && trim($callinfo) != "") { |
|---|
| 419 | | $ext->add($extpaging, $grp, '', new ext_setvar('_CALLINFO', $callinfo)); |
|---|
| 420 | | } |
|---|
| 421 | | if (isset($sipuri) && trim($sipuri) != "") { |
|---|
| 422 | | $ext->add($extpaging, $grp, '', new ext_setvar('_SIPURI', $sipuri)); |
|---|
| 423 | | } |
|---|
| 424 | | if (isset($vxml_url) && trim($vxml_url) != "") { |
|---|
| 425 | | $ext->add($extpaging, $grp, '', new ext_setvar('_VXML_URL', $vxml_url)); |
|---|
| 426 | | } |
|---|
| 427 | | if (isset($doptions) && trim($doptions) != "") { |
|---|
| 428 | | $ext->add($extpaging, $grp, '', new ext_setvar('_DOPTIONS', $doptions)); |
|---|
| 429 | | } |
|---|
| 430 | | $ext->add($extpaging, $grp, '', new ext_setvar('_DTIME', $dtime)); |
|---|
| 431 | | $ext->add($extpaging, $grp, '', new ext_setvar('_ANSWERMACRO', '')); |
|---|
| 432 | | foreach ($custom_vars as $key => $value) { |
|---|
| 433 | | $ext->add($extpaging, $grp, '', new ext_setvar('_'.ltrim($key,'_'), $value)); |
|---|
| 434 | | } |
|---|
| 435 | | $ext->add($extpaging, $grp, '', new ext_setvar('__FORWARD_CONTEXT', 'block-cf')); |
|---|
| 436 | | |
|---|
| 437 | | $ext->add($extpaging, $grp, '', new ext_page($dialstr)); |
|---|
| 438 | | } |
|---|
| | 416 | $page_memebers[] = "LOCAL/$pagemode".trim($local_dial[0])."@".$apppaging; |
|---|
| | 417 | |
|---|
| | 418 | } |
|---|
| | 419 | |
|---|
| | 420 | $ext->add($apppaging, $grp, '', new ext_macro('user-callerid')); |
|---|
| | 421 | $ext->add($apppaging, $grp, '', new ext_setvar('_PAGEGROUP', $grp)); |
|---|
| | 422 | $ext->add($apppaging, $grp, '', new ext_setvar('PAGE${PAGEGROUP}ADMIN', 'TRUE')); |
|---|
| | 423 | |
|---|
| | 424 | //if page group it in use, got to busy |
|---|
| | 425 | $ext->add($apppaging, $grp, '', |
|---|
| | 426 | new ext_gotoif('$[${TRYLOCK(apppaging'. $grp .')}]', '', 'busy')); |
|---|
| | 427 | |
|---|
| | 428 | //set blf to in use |
|---|
| | 429 | $ext->add($apppaging, $grp, 'devstate', |
|---|
| | 430 | new ext_setvar('DEVICE_STATE(Custom:PAGE' . $grp .')', 'INUSE')); |
|---|
| | 431 | |
|---|
| | 432 | $ext->add($apppaging, $grp, '', new ext_answer('')); |
|---|
| | 433 | $ext->add($apppaging, $grp, '', new ext_set('PAGE_CONF', '${EPOCH}${RAND(100,999)}')); |
|---|
| | 434 | $ext->add($apppaging, $grp, '', |
|---|
| | 435 | new ext_set('PAGE_CONF_OPTS', '1doqsx' . (!$thisgroup['duplex'] ? 'm' : ''))); |
|---|
| | 436 | $ext->add($apppaging, $grp, 'agi', new ext_agi('page.agi,' |
|---|
| | 437 | . 'extensions=' . implode(':',$page_memebers) . ',' |
|---|
| | 438 | . 'meetmeopts=${PAGE_CONF}\,${PAGE_CONF_OPTS}\,\,,' |
|---|
| | 439 | . 'AMPUSER=${AMPUSER}' |
|---|
| | 440 | )); |
|---|
| | 441 | //we cant use originate from the dialplan as the dialplan command is not asynchronous |
|---|
| | 442 | //we would like to though... |
|---|
| | 443 | //this code here as a sign of hope -MB |
|---|
| | 444 | /*foreach ($page_memebers as $member) { |
|---|
| | 445 | $ext->add($apppaging, $grp, 'page', new ext_originate($member,'app','meetme', '${PAGE_CONF}\,${PAGE_CONF_OPTS}')); |
|---|
| | 446 | }*/ |
|---|
| | 447 | unset($page_memebers); |
|---|
| | 448 | $ext->add($apppaging, $grp, 'page', new ext_meetme('${PAGE_CONF},doqwxCAG(beep)')); |
|---|
| | 449 | $ext->add($apppaging, $grp, '', new ext_hangup()); |
|---|
| | 450 | $ext->add($apppaging, $grp, 'busy', new ext_set('PAGE${PAGEGROUP}BUSY', 'TRUE')); |
|---|
| | 451 | $ext->add($apppaging, $grp, 'play-busy', new ext_busy(3)); |
|---|
| | 452 | $ext->add($apppaging, $grp, 'busy-hang', new ext_goto('ext-paging,h,1')); |
|---|
| | 453 | |
|---|
| | 454 | } |
|---|
| | 455 | //h |
|---|
| | 456 | $ext->add($apppaging, 'h', '', |
|---|
| | 457 | new ext_execif('$[' |
|---|
| | 458 | . '$["${PAGE${PAGEGROUP}ADMIN}" = "TRUE"]' |
|---|
| | 459 | . ' & $[${ISNULL(${PAGE${PAGEGROUP}BUSY})}]' |
|---|
| | 460 | . ']', |
|---|
| | 461 | 'Set', 'DEVICE_STATE(Custom:PAGE${PAGEGROUP})=NOT_INUSE')); |
|---|