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

Revision 5167, 5.5 kB (checked in by p_lindheimer, 6 years ago)

Merged revisions 5165 via svnmerge from
http://svn.freepbx.org/modules/branches/2.3

........

r5165 | p_lindheimer | 2007-10-26 19:01:53 -0700 (Fri, 26 Oct 2007) | 1 line


add call to Macro(user-callerid) to get proper CID in Meetme Conference

........

  • 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     switch($engine) {
49         case "asterisk":
50             $ext->addInclude('from-internal-additional','ext-meetme');
51             $contextname = 'ext-meetme';
52             if(is_array($conflist = conferences_list())) {
53                 
54                 // Start the conference
55                 $ext->add($contextname, 'STARTMEETME', '', new ext_macro('user-callerid'));
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                     $roomuserpin = $room['userpin'];
68                     $roomadminpin = $room['adminpin'];
69                     $roomjoinmsg = (isset($room['joinmsg'])?$room['joinmsg']:'');
70                     
71                     // entry point
72                     $ext->add($contextname, $roomnum, '', new ext_setvar('MEETME_ROOMNUM',$roomnum));
73                     $ext->add($contextname, $roomnum, '', new ext_gotoif('$["${DIALSTATUS}" = "ANSWER"]',($roomuserpin == '' && $roomadminpin == '' ? 'USER' : 'READPIN')));           
74                     $ext->add($contextname, $roomnum, '', new ext_answer(''));
75                     $ext->add($contextname, $roomnum, '', new ext_wait(1));
76                     
77                     // Deal with PINs -- if exist
78                     if ($roomuserpin != '' || $roomadminpin != '') {
79                         $ext->add($contextname, $roomnum, '', new ext_setvar('PINCOUNT','0'));
80                         $ext->add($contextname, $roomnum, 'READPIN', new ext_read('PIN','enter-conf-pin-number'));
81                         
82                         // userpin -- must do always, otherwise if there is just an adminpin
83                         // there would be no way to get to the conference !
84                         $ext->add($contextname, $roomnum, '', new ext_gotoif('$[x${PIN} = x'.$roomuserpin.']','USER'));
85
86                         // admin pin -- exists
87                         if ($roomadminpin != '') {
88                             $ext->add($contextname, $roomnum, '', new ext_gotoif('$[x${PIN} = x'.$roomadminpin.']','ADMIN'));
89                         }
90
91                         // pin invalid
92                         $ext->add($contextname, $roomnum, '', new ext_setvar('PINCOUNT','$[${PINCOUNT}+1]'));
93                         $ext->add($contextname, $roomnum, '', new ext_gotoif('$[${PINCOUNT}>3]', "h"));
94                         $ext->add($contextname, $roomnum, '', new ext_playback('conf-invalidpin'));
95                         $ext->add($contextname, $roomnum, '', new ext_goto('READPIN'));
96                         
97                         // admin mode -- only valid if there is an admin pin
98                         if ($roomadminpin != '') {
99                             $ext->add($contextname, $roomnum, 'ADMIN', new ext_setvar('MEETME_OPTS','aA'.$roomoptions));
100                             if ($roomjoinmsg != '') {  // play joining message if one defined
101                                 $ext->add($contextname, $roomnum, '', new ext_playback($roomjoinmsg));
102                             }
103                             $ext->add($contextname, $roomnum, '', new ext_goto('STARTMEETME,1'));                           
104                         }
105                     }
106                     
107                     // user mode
108                     $ext->add($contextname, $roomnum, 'USER', new ext_setvar('MEETME_OPTS',$roomoptions));
109                     if ($roomjoinmsg != '') {  // play joining message if one defined
110                         $ext->add($contextname, $roomnum, '', new ext_playback($roomjoinmsg));
111                     }
112                     $ext->add($contextname, $roomnum, '', new ext_goto('STARTMEETME,1'));
113                     
114                     // add meetme config
115                     $conferences_conf->addMeetme($room['exten'],$room['userpin']);
116                 }
117             }
118
119         break;
120     }
121 }
122
123 //get the existing meetme extensions
124 function conferences_list() {
125     $results = sql("SELECT exten,description FROM meetme ORDER BY exten","getAll",DB_FETCHMODE_ASSOC);
126     foreach($results as $result){
127         // check to see if we are in-range for the current AMP User.
128         if (isset($result['exten']) && checkRange($result['exten'])){
129             // return this item's dialplan destination, and the description
130             $extens[] = array($result['exten'],$result['description']);
131         }
132     }
133     if (isset($extens)) {
134         return $extens;
135     } else {
136         return null;
137     }
138 }
139
140 function conferences_get($account){
141     //get all the variables for the meetme
142     $results = sql("SELECT exten,options,userpin,adminpin,description,joinmsg FROM meetme WHERE exten = '$account'","getRow",DB_FETCHMODE_ASSOC);
143     return $results;
144 }
145
146 function conferences_del($account){
147     $results = sql("DELETE FROM meetme WHERE exten = \"$account\"","query");
148 }
149
150 function conferences_add($account,$name,$userpin,$adminpin,$options,$joinmsg=null){
151     $results = sql("INSERT INTO meetme (exten,description,userpin,adminpin,options,joinmsg) values (\"$account\",\"$name\",\"$userpin\",\"$adminpin\",\"$options\",\"$joinmsg\")");
152 }
153 ?>
154
Note: See TracBrowser for help on using the browser.