| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
// extend extensions class. |
|---|
| 4 |
// This example is about as simple as it gets |
|---|
| 5 |
class conferences_conf { |
|---|
| 6 |
|
|---|
| 7 |
function get_filename() { |
|---|
| 8 |
return "meetme_additional.conf"; |
|---|
| 9 |
} |
|---|
| 10 |
function addMeetme($room, $pin) { |
|---|
| 11 |
$this->_meetmes[$room] = $pin; |
|---|
| 12 |
} |
|---|
| 13 |
|
|---|
| 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 |
|
|---|
| 26 |
function conferences_destinations() { |
|---|
| 27 |
|
|---|
| 28 |
$results = conferences_list(); |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 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 |
|
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
function conferences_get_config($engine) { |
|---|
| 46 |
global $ext; |
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 87 |
if ($roomadminpin != '') { |
|---|
| 88 |
$ext->add($contextname, $roomnum, '', new ext_gotoif('$[x${PIN} = x'.$roomadminpin.']','ADMIN')); |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 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 |
|
|---|
| 98 |
if ($roomadminpin != '') { |
|---|
| 99 |
$ext->add($contextname, $roomnum, 'ADMIN', new ext_setvar('MEETME_OPTS','aA'.$roomoptions)); |
|---|
| 100 |
if ($roomjoinmsg != '') { |
|---|
| 101 |
$ext->add($contextname, $roomnum, '', new ext_playback($roomjoinmsg)); |
|---|
| 102 |
} |
|---|
| 103 |
$ext->add($contextname, $roomnum, '', new ext_goto('STARTMEETME,1')); |
|---|
| 104 |
} |
|---|
| 105 |
} |
|---|
| 106 |
|
|---|
| 107 |
|
|---|
| 108 |
$ext->add($contextname, $roomnum, 'USER', new ext_setvar('MEETME_OPTS',$roomoptions)); |
|---|
| 109 |
if ($roomjoinmsg != '') { |
|---|
| 110 |
$ext->add($contextname, $roomnum, '', new ext_playback($roomjoinmsg)); |
|---|
| 111 |
} |
|---|
| 112 |
$ext->add($contextname, $roomnum, '', new ext_goto('STARTMEETME,1')); |
|---|
| 113 |
|
|---|
| 114 |
|
|---|
| 115 |
$conferences_conf->addMeetme($room['exten'],$room['userpin']); |
|---|
| 116 |
} |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
break; |
|---|
| 120 |
} |
|---|
| 121 |
} |
|---|
| 122 |
|
|---|
| 123 |
|
|---|
| 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 |
|
|---|
| 128 |
if (isset($result['exten']) && checkRange($result['exten'])){ |
|---|
| 129 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|