| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
function infoservices_get_config($engine) { |
|---|
| 4 |
$modulename = 'infoservices'; |
|---|
| 5 |
|
|---|
| 6 |
// This generates the dialplan |
|---|
| 7 |
global $ext; |
|---|
| 8 |
switch($engine) { |
|---|
| 9 |
case "asterisk": |
|---|
| 10 |
if (is_array($featurelist = featurecodes_getModuleFeatures($modulename))) { |
|---|
| 11 |
foreach($featurelist as $item) { |
|---|
| 12 |
$featurename = $item['featurename']; |
|---|
| 13 |
$fname = $modulename.'_'.$featurename; |
|---|
| 14 |
if (function_exists($fname)) { |
|---|
| 15 |
$fcc = new featurecode($modulename, $featurename); |
|---|
| 16 |
$fc = $fcc->getCodeActive(); |
|---|
| 17 |
unset($fcc); |
|---|
| 18 |
|
|---|
| 19 |
if ($fc != '') |
|---|
| 20 |
$fname($fc); |
|---|
| 21 |
} else { |
|---|
| 22 |
$ext->add('from-internal-additional', 'debug', '', new ext_noop($modulename.": No func $fname")); |
|---|
| 23 |
var_dump($item); |
|---|
| 24 |
} |
|---|
| 25 |
} |
|---|
| 26 |
} |
|---|
| 27 |
break; |
|---|
| 28 |
} |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
function infoservices_directory($c) { |
|---|
| 32 |
global $ext; |
|---|
| 33 |
global $db; |
|---|
| 34 |
|
|---|
| 35 |
$id = "app-directory"; // The context to be included. This must be unique. |
|---|
| 36 |
|
|---|
| 37 |
// Start creating the dialplan |
|---|
| 38 |
$ext->addInclude('from-internal-additional', $id); // Add the include from from-internal |
|---|
| 39 |
// Build the context |
|---|
| 40 |
$ext->add($id, $c, '', new ext_answer('')); |
|---|
| 41 |
$ext->add($id, $c, '', new ext_wait('1')); // $cmd,1,Wait(1) |
|---|
| 42 |
$ext->add($id, $c, '', new ext_agi('directory,${DIR-CONTEXT},from-did-direct,${DIRECTORY:0:1}${DIRECTORY_OPTS}'.(!empty($oxtn) ? 'o' : '') )); // AGI |
|---|
| 43 |
$ext->add($id, $c, '', new ext_playback('vm-goodbye')); // $cmd,n,Playback(vm-goodbye) |
|---|
| 44 |
$ext->add($id, $c, '', new ext_hangup('')); // hangup |
|---|
| 45 |
$oxtn = $db->getOne("SELECT value from globals where variable='OPERATOR_XTN'"); |
|---|
| 46 |
if ($oxtn != '') { |
|---|
| 47 |
$ext->add($id, 'o', '', new ext_goto('from-internal,${OPERATOR_XTN},1')); |
|---|
| 48 |
} else { |
|---|
| 49 |
$ext->add($id, 'i', '', new ext_playback('privacy-incorrect')); |
|---|
| 50 |
} |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
function infoservices_calltrace($c) { |
|---|
| 54 |
global $ext; |
|---|
| 55 |
|
|---|
| 56 |
$id = "app-calltrace"; // The context to be included |
|---|
| 57 |
|
|---|
| 58 |
$ext->addInclude('from-internal-additional', $id); // Add the include from from-internal |
|---|
| 59 |
|
|---|
| 60 |
$ext->add($id, $c, '', new ext_goto('1', 's', 'app-calltrace-perform')); |
|---|
| 61 |
|
|---|
| 62 |
// Create the calltrace application, which we are doing a 'Goto' to above. |
|---|
| 63 |
// I just reset these for ease of copying and pasting. |
|---|
| 64 |
$id = 'app-calltrace-perform'; |
|---|
| 65 |
$c = 's'; |
|---|
| 66 |
$ext->add($id, $c, '', new ext_macro('user-callerid')); |
|---|
| 67 |
$ext->add($id, $c, '', new ext_answer('')); |
|---|
| 68 |
$ext->add($id, $c, '', new ext_wait('1')); |
|---|
| 69 |
$ext->add($id, $c, '', new ext_playback('info-about-last-call&telephone-number')); |
|---|
| 70 |
$ext->add($id, $c, '', new ext_setvar('lastcaller', '${DB(CALLTRACE/${CALLERID(number)})}')); |
|---|
| 71 |
$ext->add($id, $c, '', new ext_gotoif('$[ $[ "${lastcaller}" = "" ] | $[ "${lastcaller}" = "unknown" ] ]', 'noinfo')); |
|---|
| 72 |
$ext->add($id, $c, '', new ext_saydigits('${lastcaller}')); |
|---|
| 73 |
$ext->add($id, $c, '', new ext_setvar('TIMEOUT(digit)', '3')); |
|---|
| 74 |
$ext->add($id, $c, '', new ext_setvar('TIMEOUT(response)', '7')); |
|---|
| 75 |
$ext->add($id, $c, '', new ext_background('to-call-this-number&press-1')); |
|---|
| 76 |
$ext->add($id, $c, '', new ext_goto('fin')); |
|---|
| 77 |
$ext->add($id, $c, 'noinfo', new ext_playback('from-unknown-caller')); |
|---|
| 78 |
$ext->add($id, $c, '', new ext_macro('hangupcall')); |
|---|
| 79 |
$ext->add($id, $c, 'fin', new ext_noop('Waiting for input')); |
|---|
| 80 |
$ext->add($id, '1', '', new ext_goto('1', '${lastcaller}', 'from-internal')); |
|---|
| 81 |
$ext->add($id, 'i', '', new ext_playback('vm-goodbye')); |
|---|
| 82 |
$ext->add($id, 'i', '', new ext_macro('hangupcall')); |
|---|
| 83 |
$ext->add($id, 't', '', new ext_playback('vm-goodbye')); |
|---|
| 84 |
$ext->add($id, 't', '', new ext_macro('hangupcall')); |
|---|
| 85 |
|
|---|
| 86 |
} |
|---|
| 87 |
|
|---|
| 88 |
function infoservices_echotest($c) { |
|---|
| 89 |
global $ext; |
|---|
| 90 |
|
|---|
| 91 |
$id = "app-echo-test"; // The context to be included |
|---|
| 92 |
|
|---|
| 93 |
$ext->addInclude('from-internal-additional', $id); // Add the include from from-internal |
|---|
| 94 |
|
|---|
| 95 |
$ext->add($id, $c, '', new ext_answer('')); // $cmd,1,Answer |
|---|
| 96 |
$ext->add($id, $c, '', new ext_wait('1')); // $cmd,n,Wait(1) |
|---|
| 97 |
$ext->add($id, $c, '', new ext_playback('demo-echotest')); // $cmd,n,Macro(user-callerid) |
|---|
| 98 |
$ext->add($id, $c, '', new ext_echo('')); |
|---|
| 99 |
$ext->add($id, $c, '', new ext_playback('demo-echodone')); // $cmd,n,Playback(...) |
|---|
| 100 |
$ext->add($id, $c, '', new ext_hangup('')); // $cmd,n,Macro(user-callerid) |
|---|
| 101 |
} |
|---|
| 102 |
|
|---|
| 103 |
function infoservices_speakingclock($c) { |
|---|
| 104 |
global $ext; |
|---|
| 105 |
|
|---|
| 106 |
$id = "app-speakingclock"; // The context to be included |
|---|
| 107 |
|
|---|
| 108 |
$ext->addInclude('from-internal-additional', $id); // Add the include from from-internal |
|---|
| 109 |
|
|---|
| 110 |
$ext->add($id, $c, '', new ext_answer('')); // $cmd,1,Answer |
|---|
| 111 |
$ext->add($id, $c, '', new ext_wait('1')); // $cmd,n,Wait(1) |
|---|
| 112 |
$ext->add($id, $c, '', new ext_setvar('NumLoops','0')); |
|---|
| 113 |
|
|---|
| 114 |
$ext->add($id, $c, 'start', new ext_setvar('FutureTime','$[${EPOCH} + 11]')); // 10 seconds to try this out |
|---|
| 115 |
$ext->add($id, $c, '', new ext_playback('at-tone-time-exactly')); |
|---|
| 116 |
$ext->add($id, $c, '', new ext_gotoif('$["${TIMEFORMAT}" = "kM"]','hr24format')); |
|---|
| 117 |
$ext->add($id, $c, '', new ext_sayunixtime('${FutureTime},,IM \\\'and\\\' S \\\'seconds\\\' p')); |
|---|
| 118 |
$ext->add($id, $c, '', new ext_goto('waitloop')); |
|---|
| 119 |
$ext->add($id, $c, 'hr24format', new ext_sayunixtime('${FutureTime},,kM \\\'and\\\' S \\\'seconds\\\'')); |
|---|
| 120 |
$ext->add($id, $c, 'waitloop', new ext_set('TimeLeft', '$[${FutureTime} - ${EPOCH}]')); |
|---|
| 121 |
$ext->add($id, $c, '', new ext_gotoif('$[${TimeLeft} < 1]','playbeep')); |
|---|
| 122 |
//$ext->add($id, $c, '', new ext_saynumber('${TimeLeft}')); |
|---|
| 123 |
$ext->add($id, $c, '', new ext_wait(1)); |
|---|
| 124 |
$ext->add($id, $c, '', new ext_goto('waitloop')); |
|---|
| 125 |
$ext->add($id, $c, 'playbeep', new ext_playback('beep')); |
|---|
| 126 |
$ext->add($id, $c, '', new ext_wait(5)); |
|---|
| 127 |
|
|---|
| 128 |
$ext->add($id, $c, '', new ext_setvar('NumLoops','$[${NumLoops} + 1]')); |
|---|
| 129 |
$ext->add($id, $c, '', new ext_gotoif('$[${NumLoops} < 5]','start')); // 5 is maximum number of times to repeat |
|---|
| 130 |
$ext->add($id, $c, '', new ext_playback('goodbye')); |
|---|
| 131 |
$ext->add($id, $c, '', new ext_hangup('')); |
|---|
| 132 |
} |
|---|
| 133 |
|
|---|
| 134 |
function infoservices_speakextennum($c) { |
|---|
| 135 |
global $ext; |
|---|
| 136 |
|
|---|
| 137 |
$id = "app-speakextennum"; |
|---|
| 138 |
|
|---|
| 139 |
$ext->addInclude('from-internal-additional', $id); // Add the include from from-internal |
|---|
| 140 |
|
|---|
| 141 |
$ext->add($id, $c, '', new ext_answer('')); // $cmd,1,Answer |
|---|
| 142 |
$ext->add($id, $c, '', new ext_wait('1')); // $cmd,n,Wait(1) |
|---|
| 143 |
$ext->add($id, $c, '', new ext_playback('your')); |
|---|
| 144 |
$ext->add($id, $c, '', new ext_playback('extension')); |
|---|
| 145 |
$ext->add($id, $c, '', new ext_playback('number')); |
|---|
| 146 |
$ext->add($id, $c, '', new ext_playback('is')); |
|---|
| 147 |
$ext->add($id, $c, '', new ext_saydigits('${CALLERIDNUM}')); |
|---|
| 148 |
$ext->add($id, $c, '', new ext_wait('2')); // $cmd,n,Wait(1) |
|---|
| 149 |
$ext->add($id, $c, '', new ext_hangup('')); |
|---|
| 150 |
} |
|---|
| 151 |
?> |
|---|