root/modules/branches/2.3/conferences/functions.inc.php

Revision 5208, 5.7 kB (checked in by p_lindheimer, 5 years ago)

don't ask for name confirmation when recording names on Asterisk 1.3 (new option I replaces i)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php /* $Id$ */
2
3 // extend extensions class.
4 // This example is about as simple as it gets
5 class conferences_conf {
6   // return the filename to write
7   function get_filename() {
8     return "meetme_additional.conf";
9   }
10   function addMeetme($room, $pin) {
11     $this->_meetmes[$room] = $pin;
12   }
13   // return the output that goes in the file
14   function generateConf() {
15     $output = "";
16     if (isset($this->_meetmes) && is_array($this->_meetmes)) {
17       foreach (array_keys($this->_meetmes) as $meetme) {
18         $output .= 'conf => '.$meetme.",".$this->_meetmes[$meetme]."\n";
19       }
20     }
21     return $output;
22   }
23 }
24
25 // returns a associative arrays with keys 'destination' and 'description'
26 function conferences_destinations() {
27   //get the list of meetmes
28   $results = conferences_list();
29
30   // return an associative array with destination and description
31   if (isset($results)) {
32     foreach($results as $result){
33         $extens[] = array('destination' => 'ext-meetme,'.$result['0'].',1', 'description' => $result['1']." <".$result['0'].">");
34     }
35   return $extens;
36   } else {
37   return null;
38   }
39 }
40
41
42 /*  Generates dialplan for conferences
43   We call this with retrieve_conf
44 */
45 function conferences_get_config($engine) {
46   global $ext;  // is this the best way to pass this?
47   global $conferences_conf;
48   global $version;
49   switch($engine) {
50     case "asterisk":
51       $ext->addInclude('from-internal-additional','ext-meetme');
52       $contextname = 'ext-meetme';
53       if(is_array($conflist = conferences_list())) {
54        
55         // Start the conference
56         $ext->add($contextname, 'STARTMEETME', '', new ext_meetme('${MEETME_ROOMNUM}','${MEETME_OPTS}','${PIN}'));
57         $ext->add($contextname, 'STARTMEETME', '', new ext_hangup(''));
58        
59         // hangup for whole context
60         $ext->add($contextname, 'h', '', new ext_hangup(''));           
61        
62         foreach($conflist as $item) {
63           $room = conferences_get(ltrim($item['0']));
64          
65           $roomnum = ltrim($item['0']);
66           $roomoptions = $room['options'];
67           if (version_compare($version, "1.4",">=")) {
68             $roomoptions = str_replace('i','I',$roomoptions);
69           }
70           $roomuserpin = $room['userpin'];
71           $roomadminpin = $room['adminpin'];
72           $roomjoinmsg = (isset($room['joinmsg'])?$room['joinmsg']:'');
73          
74           // entry point
75           $ext->add($contextname, $roomnum, '', new ext_macro('user-callerid'));
76           $ext->add($contextname, $roomnum, '', new ext_setvar('MEETME_ROOMNUM',$roomnum));
77           $ext->add($contextname, $roomnum, '', new ext_gotoif('$["${DIALSTATUS}" = "ANSWER"]',($roomuserpin == '' && $roomadminpin == '' ? 'USER' : 'READPIN')));     
78           $ext->add($contextname, $roomnum, '', new ext_answer(''));
79           $ext->add($contextname, $roomnum, '', new ext_wait(1));
80          
81           // Deal with PINs -- if exist
82           if ($roomuserpin != '' || $roomadminpin != '') {
83             $ext->add($contextname, $roomnum, '', new ext_setvar('PINCOUNT','0'));
84             $ext->add($contextname, $roomnum, 'READPIN', new ext_read('PIN','enter-conf-pin-number'));
85            
86             // userpin -- must do always, otherwise if there is just an adminpin
87             // there would be no way to get to the conference !
88             $ext->add($contextname, $roomnum, '', new ext_gotoif('$[x${PIN} = x'.$roomuserpin.']','USER'));
89
90             // admin pin -- exists
91             if ($roomadminpin != '') {
92               $ext->add($contextname, $roomnum, '', new ext_gotoif('$[x${PIN} = x'.$roomadminpin.']','ADMIN'));
93             }
94
95             // pin invalid
96             $ext->add($contextname, $roomnum, '', new ext_setvar('PINCOUNT','$[${PINCOUNT}+1]'));
97             $ext->add($contextname, $roomnum, '', new ext_gotoif('$[${PINCOUNT}>3]', "h"));
98             $ext->add($contextname, $roomnum, '', new ext_playback('conf-invalidpin'));
99             $ext->add($contextname, $roomnum, '', new ext_goto('READPIN'));
100            
101             // admin mode -- only valid if there is an admin pin
102             if ($roomadminpin != '') {
103               $ext->add($contextname, $roomnum, 'ADMIN', new ext_setvar('MEETME_OPTS','aA'.$roomoptions));
104               if ($roomjoinmsg != '') {  // play joining message if one defined
105                 $ext->add($contextname, $roomnum, '', new ext_playback($roomjoinmsg));
106               }
107               $ext->add($contextname, $roomnum, '', new ext_goto('STARTMEETME,1'));             
108             }
109           }
110          
111           // user mode
112           $ext->add($contextname, $roomnum, 'USER', new ext_setvar('MEETME_OPTS',$roomoptions));
113           if ($roomjoinmsg != '') {  // play joining message if one defined
114             $ext->add($contextname, $roomnum, '', new ext_playback($roomjoinmsg));
115           }
116           $ext->add($contextname, $roomnum, '', new ext_goto('STARTMEETME,1'));
117          
118           // add meetme config
119           $conferences_conf->addMeetme($room['exten'],$room['userpin']);
120         }
121       }
122
123     break;
124   }
125 }
126
127 //get the existing meetme extensions
128 function conferences_list() {
129   $results = sql("SELECT exten,description FROM meetme ORDER BY exten","getAll",DB_FETCHMODE_ASSOC);
130   foreach($results as $result){
131     // check to see if we are in-range for the current AMP User.
132     if (isset($result['exten']) && checkRange($result['exten'])){
133       // return this item's dialplan destination, and the description
134       $extens[] = array($result['exten'],$result['description']);
135     }
136   }
137   if (isset($extens)) {
138     return $extens;
139   } else {
140     return null;
141   }
142 }
143
144 function conferences_get($account){
145   //get all the variables for the meetme
146   $results = sql("SELECT exten,options,userpin,adminpin,description,joinmsg FROM meetme WHERE exten = '$account'","getRow",DB_FETCHMODE_ASSOC);
147   return $results;
148 }
149
150 function conferences_del($account){
151   $results = sql("DELETE FROM meetme WHERE exten = \"$account\"","query");
152 }
153
154 function conferences_add($account,$name,$userpin,$adminpin,$options,$joinmsg=null){
155   $results = sql("INSERT INTO meetme (exten,description,userpin,adminpin,options,joinmsg) values (\"$account\",\"$name\",\"$userpin\",\"$adminpin\",\"$options\",\"$joinmsg\")");
156 }
157 ?>
Note: See TracBrowser for help on using the browser.