root/modules/branches/2.4/infoservices/functions.inc.php

Revision 5727, 6.4 kB (checked in by p_lindheimer, 4 years ago)

#2731 fix press 0 for operator in directory

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
Line 
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   $oxtn = $db->getOne("SELECT value from globals where variable='OPERATOR_XTN'"); //this needs to be here!
36
37   $id = "app-directory"; // The context to be included. This must be unique.
38
39   // Start creating the dialplan
40   $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal
41   // Build the context
42   $ext->add($id, $c, '', new ext_answer(''));
43   $ext->add($id, $c, '', new ext_wait('1')); // $cmd,1,Wait(1)
44   $ext->add($id, $c, '', new ext_agi('directory,${DIR-CONTEXT},from-did-direct,${DIRECTORY:0:1}${DIRECTORY_OPTS}'.($oxtn != '' ? 'o' : '') ));
45   $ext->add($id, $c, '', new ext_playback('vm-goodbye')); // $cmd,n,Playback(vm-goodbye)
46   $ext->add($id, $c, '', new ext_hangup('')); // hangup
47   if ($oxtn != '') {
48     $ext->add($id, 'o', '', new ext_goto('from-internal,${OPERATOR_XTN},1'));
49   } else {
50     $ext->add($id, 'i', '', new ext_playback('privacy-incorrect'));
51   }
52 }
53
54 function infoservices_calltrace($c) {
55   global $ext;
56
57   $id = "app-calltrace"; // The context to be included
58
59   $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal
60
61   $ext->add($id, $c, '', new ext_goto('1', 's', 'app-calltrace-perform'));
62
63   // Create the calltrace application, which we are doing a 'Goto' to above.
64   // I just reset these for ease of copying and pasting.
65   $id = 'app-calltrace-perform';
66   $c = 's';
67   $ext->add($id, $c, '', new ext_answer(''));
68   $ext->add($id, $c, '', new ext_wait('1'));
69   $ext->add($id, $c, '', new ext_macro('user-callerid'));
70   $ext->add($id, $c, '', new ext_playback('info-about-last-call&telephone-number'));
71   $ext->add($id, $c, '', new ext_setvar('lastcaller', '${DB(CALLTRACE/${AMPUSER})}'));
72   $ext->add($id, $c, '', new ext_gotoif('$[ $[ "${lastcaller}" = "" ] | $[ "${lastcaller}" = "unknown" ] ]', 'noinfo'));
73   $ext->add($id, $c, '', new ext_saydigits('${lastcaller}'));
74   $ext->add($id, $c, '', new ext_setvar('TIMEOUT(digit)', '3'));
75   $ext->add($id, $c, '', new ext_setvar('TIMEOUT(response)', '7'));
76   $ext->add($id, $c, '', new ext_background('to-call-this-number&press-1'));
77   $ext->add($id, $c, '', new ext_goto('fin'));
78   $ext->add($id, $c, 'noinfo', new ext_playback('from-unknown-caller'));
79   $ext->add($id, $c, '', new ext_macro('hangupcall'));
80   $ext->add($id, $c, 'fin', new ext_noop('Waiting for input'));
81   $ext->add($id, $c, '', new ext_waitexten(60));
82   $ext->add($id, $c, '', new ext_Playback('sorry-youre-having-problems&goodbye'));
83   $ext->add($id, '1', '', new ext_goto('1', '${lastcaller}', 'from-internal'));
84   $ext->add($id, 'i', '', new ext_playback('vm-goodbye'));
85   $ext->add($id, 'i', '', new ext_macro('hangupcall'));
86   $ext->add($id, 't', '', new ext_playback('vm-goodbye'));
87   $ext->add($id, 't', '', new ext_macro('hangupcall'));
88
89 }
90
91 function infoservices_echotest($c) {
92   global $ext;
93
94   $id = "app-echo-test"; // The context to be included
95
96   $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal
97
98   $ext->add($id, $c, '', new ext_answer('')); // $cmd,1,Answer
99   $ext->add($id, $c, '', new ext_wait('1')); // $cmd,n,Wait(1)
100   $ext->add($id, $c, '', new ext_playback('demo-echotest')); // $cmd,n,Macro(user-callerid)
101   $ext->add($id, $c, '', new ext_echo(''));
102   $ext->add($id, $c, '', new ext_playback('demo-echodone')); // $cmd,n,Playback(...)
103   $ext->add($id, $c, '', new ext_hangup('')); // $cmd,n,Macro(user-callerid)
104 }
105
106 function infoservices_speakingclock($c) {
107   global $ext;
108
109   $id = "app-speakingclock"; // The context to be included
110
111   $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal
112
113   $ext->add($id, $c, '', new ext_answer('')); // $cmd,1,Answer
114   $ext->add($id, $c, '', new ext_wait('1')); // $cmd,n,Wait(1)
115   $ext->add($id, $c, '', new ext_setvar('NumLoops','0'));
116  
117   $ext->add($id, $c, 'start', new ext_setvar('FutureTime','$[${EPOCH} + 11]'));  // 10 seconds to try this out
118   $ext->add($id, $c, '', new ext_playback('at-tone-time-exactly'));
119   $ext->add($id, $c, '', new ext_gotoif('$["${TIMEFORMAT}" = "kM"]','hr24format'));
120   $ext->add($id, $c, '', new ext_sayunixtime('${FutureTime},,IM \\\'and\\\' S \\\'seconds\\\' p'));
121   $ext->add($id, $c, '', new ext_goto('waitloop'));
122   $ext->add($id, $c, 'hr24format', new ext_sayunixtime('${FutureTime},,kM \\\'and\\\' S \\\'seconds\\\''));
123   $ext->add($id, $c, 'waitloop', new ext_set('TimeLeft', '$[${FutureTime} - ${EPOCH}]'));
124   $ext->add($id, $c, '', new ext_gotoif('$[${TimeLeft} < 1]','playbeep'));
125   //$ext->add($id, $c, '', new ext_saynumber('${TimeLeft}'));
126   $ext->add($id, $c, '', new ext_wait(1));
127   $ext->add($id, $c, '', new ext_goto('waitloop'));
128   $ext->add($id, $c, 'playbeep', new ext_playback('beep'));
129   $ext->add($id, $c, '', new ext_wait(5));
130  
131   $ext->add($id, $c, '', new ext_setvar('NumLoops','$[${NumLoops} + 1]'));
132   $ext->add($id, $c, '', new ext_gotoif('$[${NumLoops} < 5]','start')); // 5 is maximum number of times to repeat
133   $ext->add($id, $c, '', new ext_playback('goodbye'));
134   $ext->add($id, $c, '', new ext_hangup(''));
135 }
136
137 function infoservices_speakextennum($c) {
138   global $ext;
139  
140   $id = "app-speakextennum";
141  
142   $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal
143
144   $ext->add($id, $c, '', new ext_answer('')); // $cmd,1,Answer
145   $ext->add($id, $c, '', new ext_wait('1')); // $cmd,n,Wait(1)
146   $ext->add($id, $c, '', new ext_macro('user-callerid')); // $cmd,n,Macro(user-callerid)
147   $ext->add($id, $c, '', new ext_playback('your'));
148   $ext->add($id, $c, '', new ext_playback('extension'));
149   $ext->add($id, $c, '', new ext_playback('number'));
150   $ext->add($id, $c, '', new ext_playback('is'));
151   $ext->add($id, $c, '', new ext_saydigits('${AMPUSER}'));
152   $ext->add($id, $c, '', new ext_wait('2')); // $cmd,n,Wait(1)
153   $ext->add($id, $c, '', new ext_hangup(''));
154 }
155 ?>
Note: See TracBrowser for help on using the browser.