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

Revision 13487, 7.4 kB (checked in by p_lindheimer, 1 year ago)

clean up order re #5115

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
Line 
1 <?php
2 if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
3
4 function infoservices_get_config($engine) {
5   $modulename = 'infoservices';
6  
7   // This generates the dialplan
8   global $ext; 
9   switch($engine) {
10     case "asterisk":
11       if (is_array($featurelist = featurecodes_getModuleFeatures($modulename))) {
12         foreach($featurelist as $item) {
13           $featurename = $item['featurename'];
14           $fname = $modulename.'_'.$featurename;
15           if (function_exists($fname)) {
16             $fcc = new featurecode($modulename, $featurename);
17             $fc = $fcc->getCodeActive();
18             unset($fcc);
19             
20             if ($fc != '')
21               $fname($fc);
22           } else {
23             $ext->add('from-internal-additional', 'debug', '', new ext_noop($modulename.": No func $fname"));
24             var_dump($item);
25           }
26         }
27       }
28     break;
29   }
30 }
31
32 function infoservices_directory($c) {
33   global $ext;
34   global $db;
35
36   $oxtn = $db->getOne("SELECT value from globals where variable='OPERATOR_XTN'"); //this needs to be here!
37
38   $id = "app-directory"; // The context to be included. This must be unique.
39
40   // Start creating the dialplan
41   $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal
42   // Build the context
43   $ext->add($id, $c, '', new ext_answer(''));
44   $ext->add($id, $c, '', new ext_wait('1')); // $cmd,1,Wait(1)
45   $ext->add($id, $c, '', new ext_agi('directory,${DIR-CONTEXT},from-did-direct,${DIRECTORY:0:1}${DIRECTORY_OPTS}'.($oxtn != '' ? 'o' : '') ));
46   $ext->add($id, $c, '', new ext_playback('vm-goodbye')); // $cmd,n,Playback(vm-goodbye)
47   $ext->add($id, $c, '', new ext_hangup('')); // hangup
48   if ($oxtn != '') {
49     $ext->add($id, 'o', '', new ext_goto('from-internal,${OPERATOR_XTN},1'));
50   } else {
51     $ext->add($id, 'o', '', new ext_playback('privacy-incorrect'));
52   }
53 }
54
55 function infoservices_calltrace($c) {
56   global $ext;
57
58   $id = "app-calltrace"; // The context to be included
59
60   $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal
61
62   $ext->add($id, $c, '', new ext_goto('1', 's', 'app-calltrace-perform'));
63
64   // Create the calltrace application, which we are doing a 'Goto' to above.
65   // I just reset these for ease of copying and pasting.
66   $id = 'app-calltrace-perform';
67   $c = 's';
68   $ext->add($id, $c, '', new ext_answer(''));
69   $ext->add($id, $c, '', new ext_wait('1'));
70   $ext->add($id, $c, '', new ext_macro('user-callerid'));
71   $ext->add($id, $c, '', new ext_playback('info-about-last-call&telephone-number'));
72   $ext->add($id, $c, '', new ext_setvar('lastcaller', '${DB(CALLTRACE/${AMPUSER})}'));
73   $ext->add($id, $c, '', new ext_gotoif('$[ $[ "${lastcaller}" = "" ] | $[ "${lastcaller}" = "unknown" ] ]', 'noinfo'));
74   $ext->add($id, $c, '', new ext_saydigits('${lastcaller}'));
75   $ext->add($id, $c, '', new ext_setvar('TIMEOUT(digit)', '3'));
76   $ext->add($id, $c, '', new ext_setvar('TIMEOUT(response)', '7'));
77   $ext->add($id, $c, '', new ext_background('to-call-this-number&press-1'));
78   $ext->add($id, $c, '', new ext_goto('fin'));
79   $ext->add($id, $c, 'noinfo', new ext_playback('from-unknown-caller'));
80   $ext->add($id, $c, '', new ext_macro('hangupcall'));
81   $ext->add($id, $c, 'fin', new ext_noop('Waiting for input'));
82   $ext->add($id, $c, '', new ext_waitexten(60));
83   $ext->add($id, $c, '', new ext_Playback('sorry-youre-having-problems&goodbye'));
84   $ext->add($id, '1', '', new ext_goto('1', '${lastcaller}', 'from-internal'));
85   $ext->add($id, 'i', '', new ext_playback('vm-goodbye'));
86   $ext->add($id, 'i', '', new ext_macro('hangupcall'));
87   $ext->add($id, 't', '', new ext_playback('vm-goodbye'));
88   $ext->add($id, 't', '', new ext_macro('hangupcall'));
89
90 }
91
92 function infoservices_echotest($c) {
93   global $ext;
94
95   $id = "app-echo-test"; // The context to be included
96
97   $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal
98
99   $ext->add($id, $c, '', new ext_answer('')); // $cmd,1,Answer
100   $ext->add($id, $c, '', new ext_wait('1')); // $cmd,n,Wait(1)
101   $ext->add($id, $c, '', new ext_playback('demo-echotest')); // $cmd,n,Macro(user-callerid)
102   $ext->add($id, $c, '', new ext_echo(''));
103   $ext->add($id, $c, '', new ext_playback('demo-echodone')); // $cmd,n,Playback(...)
104   $ext->add($id, $c, '', new ext_hangup('')); // $cmd,n,Macro(user-callerid)
105 }
106
107 function infoservices_speakingclock($c) {
108   global $ext;
109
110   $id = "app-speakingclock"; // The context to be included
111
112   $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal
113
114   $ext->add($id, $c, '', new ext_answer('')); // $cmd,1,Answer
115   $ext->add($id, $c, '', new ext_wait('1')); // $cmd,n,Wait(1)
116   $ext->add($id, $c, '', new ext_setvar('NumLoops','0'));
117  
118   $ext->add($id, $c, 'start', new ext_setvar('FutureTime','$[${EPOCH} + 11]'));  // 10 seconds to try this out
119   $ext->add($id, $c, '', new ext_gosubif('$["${TIMEFORMAT}"="kM"]','sub-hr24format,s,1','sub-hr12format,s,1'));
120
121   $ext->add($id, $c, 'waitloop', new ext_set('TimeLeft', '$[${FutureTime} - ${EPOCH}]'));
122   $ext->add($id, $c, '', new ext_gotoif('$[${TimeLeft} < 1]','playbeep'));
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   $ext->add($id, $c, '', new ext_setvar('NumLoops','$[${NumLoops} + 1]'));
128   $ext->add($id, $c, '', new ext_gotoif('$[${NumLoops} < 5]','start')); // 5 is maximum number of times to repeat
129   $ext->add($id, $c, '', new ext_playback('goodbye'));
130   $ext->add($id, $c, '', new ext_hangup(''));
131
132
133   // 24 hr format default if no language provided
134   //
135   $id = "sub-hr24format";
136   $ex = 'i';
137   $ext->add($id, 's', '', new ext_goto('1', '${CHANNEL(language)}'));
138   $ext->add($id, $ex, '', new ext_playback('at-tone-time-exactly'));
139   $ext->add($id, $ex, '', new ext_sayunixtime('${FutureTime},,kM \\\'and\\\' S \\\'seconds\\\''));
140   $ext->add($id, $ex, '', new ext_return(''));
141
142   // German specific language format
143   $ex = 'de';
144   $ext->add($id, $ex, '', new ext_playback('at-tone-time-exactly'));
145   $ext->add($id, $ex, '', new ext_sayunixtime('${FutureTime},,kMS'));
146   $ext->add($id, $ex, '', new ext_return(''));
147
148
149   // 12 hr format default if no language provided
150   //
151   $id = "sub-hr12format";
152   $ex = 'i';
153   $ext->add($id, 's', '', new ext_goto('1', '${CHANNEL(language)}'));
154   $ext->add($id, $ex, '', new ext_playback('at-tone-time-exactly'));
155   $ext->add($id, $ex, '', new ext_sayunixtime('${FutureTime},,IM \\\'and\\\' S \\\'seconds\\\' p'));
156   $ext->add($id, $ex, '', new ext_return(''));
157
158   // German specific language format
159   $ex = 'de';
160   $ext->add($id, $ex, '', new ext_playback('at-tone-time-exactly'));
161   $ext->add($id, $ex, '', new ext_sayunixtime('${FutureTime},,IMSp'));
162   $ext->add($id, $ex, '', new ext_return(''));
163
164   // To add another language follow the pattern done for German. You should also be able to use
165   // extensions_custom.conf for this
166 }
167
168 function infoservices_speakextennum($c) {
169   global $ext;
170  
171   $id = "app-speakextennum";
172  
173   $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal
174
175   $ext->add($id, $c, '', new ext_answer('')); // $cmd,1,Answer
176   $ext->add($id, $c, '', new ext_wait('1')); // $cmd,n,Wait(1)
177   $ext->add($id, $c, '', new ext_macro('user-callerid')); // $cmd,n,Macro(user-callerid)
178   $ext->add($id, $c, '', new ext_playback('your'));
179   $ext->add($id, $c, '', new ext_playback('extension'));
180   $ext->add($id, $c, '', new ext_playback('number'));
181   $ext->add($id, $c, '', new ext_playback('is'));
182   $ext->add($id, $c, '', new ext_saydigits('${AMPUSER}'));
183   $ext->add($id, $c, '', new ext_wait('2')); // $cmd,n,Wait(1)
184   $ext->add($id, $c, '', new ext_hangup(''));
185 }
186 ?>
Note: See TracBrowser for help on using the browser.