| 1 |
<?php /* $Id: functions.inc.php 175 2006-10-03 19:12:39Z plindheimer $ */ |
|---|
| 2 |
|
|---|
| 3 |
/* Generates dialplan for findmefollow |
|---|
| 4 |
We call this with retrieve_conf |
|---|
| 5 |
*/ |
|---|
| 6 |
function findmefollow_get_config($engine) { |
|---|
| 7 |
global $ext; // is this the best way to pass this? |
|---|
| 8 |
global $amp_conf; |
|---|
| 9 |
switch($engine) { |
|---|
| 10 |
case "asterisk": |
|---|
| 11 |
|
|---|
| 12 |
$fcc = new featurecode('findmefollow', 'fmf_toggle'); |
|---|
| 13 |
$fmf_code = $fcc->getCodeActive(); |
|---|
| 14 |
unset($fcc); |
|---|
| 15 |
|
|---|
| 16 |
if ($fmf_code != '') { |
|---|
| 17 |
findmefollow_fmf_toggle($fmf_code); |
|---|
| 18 |
} |
|---|
| 19 |
|
|---|
| 20 |
$ext->addInclude('from-internal-additional','ext-findmefollow'); |
|---|
| 21 |
$ext->addInclude('from-internal-additional','fmgrps'); |
|---|
| 22 |
$contextname = 'ext-findmefollow'; |
|---|
| 23 |
$ringlist = findmefollow_full_list(); |
|---|
| 24 |
if (is_array($ringlist)) { |
|---|
| 25 |
foreach($ringlist as $item) { |
|---|
| 26 |
$grpnum = ltrim($item['0']); |
|---|
| 27 |
$grp = findmefollow_get($grpnum); |
|---|
| 28 |
|
|---|
| 29 |
$strategy = $grp['strategy']; |
|---|
| 30 |
$grptime = $grp['grptime']; |
|---|
| 31 |
$grplist = $grp['grplist']; |
|---|
| 32 |
$postdest = $grp['postdest']; |
|---|
| 33 |
$grppre = (isset($grp['grppre'])?$grp['grppre']:''); |
|---|
| 34 |
$annmsg = $grp['annmsg']; |
|---|
| 35 |
$dring = $grp['dring']; |
|---|
| 36 |
|
|---|
| 37 |
$needsconf = $grp['needsconf']; |
|---|
| 38 |
$remotealert = $grp['remotealert']; |
|---|
| 39 |
$toolate = $grp['toolate']; |
|---|
| 40 |
$ringing = $grp['ringing']; |
|---|
| 41 |
$pre_ring = $grp['pre_ring']; |
|---|
| 42 |
|
|---|
| 43 |
if($ringing == 'Ring' || empty($ringing) ) { |
|---|
| 44 |
$dialopts = '${DIAL_OPTIONS}'; |
|---|
| 45 |
} else { |
|---|
| 46 |
// We need the DIAL_OPTIONS variable |
|---|
| 47 |
$sops = sql("SELECT value from globals where variable='DIAL_OPTIONS'", "getRow"); |
|---|
| 48 |
$dialopts = "m(${ringing})".str_replace('r', '', $sops[0]); |
|---|
| 49 |
} |
|---|
| 50 |
|
|---|
| 51 |
if ($fmf_code != '') { |
|---|
| 52 |
$ext->add($contextname, $fmf_code.$grpnum, '', new ext_goto("1",$fmf_code,"app-fmf-toggle")); |
|---|
| 53 |
if ($amp_conf['USEDEVSTATE']) { |
|---|
| 54 |
$ext->addHint($contextname, $fmf_code.$grpnum, "Custom:FOLLOWME".$grpnum); |
|---|
| 55 |
} |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
// Direct target to Follow-Me come here bypassing the followme/ddial conditional check |
|---|
| 59 |
// |
|---|
| 60 |
$ext->add($contextname, 'FM'.$grpnum, '', new ext_goto("FM$grpnum","$grpnum")); |
|---|
| 61 |
|
|---|
| 62 |
// |
|---|
| 63 |
// If the followme is configured for extension dialing to go to the the extension and not followme then |
|---|
| 64 |
// go there. This is often used in VmX Locater functionality when the user does not want the followme |
|---|
| 65 |
// to automatically be called but only if chosen by the caller as an alternative to going to voicemail |
|---|
| 66 |
// |
|---|
| 67 |
$ext->add($contextname, $grpnum, '', new ext_gotoif('$[ "${DB(AMPUSER/'.$grpnum.'/followme/ddial)}" = "EXTENSION" ]', 'ext-local,'.$grpnum.',1')); |
|---|
| 68 |
$ext->add($contextname, $grpnum, 'FM'.$grpnum, new ext_macro('user-callerid')); |
|---|
| 69 |
|
|---|
| 70 |
// block voicemail until phone is answered at which point a macro should be called on the answering |
|---|
| 71 |
// line to clear this flag so that subsequent transfers can occur, if already set by a the caller |
|---|
| 72 |
// then don't change. |
|---|
| 73 |
// |
|---|
| 74 |
$ext->add($contextname, $grpnum, '', new ext_gotoif('$["foo${BLKVM_OVERRIDE}" = "foo"]', 'skipdb')); |
|---|
| 75 |
$ext->add($contextname, $grpnum, '', new ext_gotoif('$["${DB(${BLKVM_OVERRIDE})}" = "TRUE"]', 'skipov')); |
|---|
| 76 |
|
|---|
| 77 |
$ext->add($contextname, $grpnum, 'skipdb', new ext_setvar('__NODEST', '')); |
|---|
| 78 |
$ext->add($contextname, $grpnum, '', new ext_setvar('__BLKVM_OVERRIDE', 'BLKVM/${EXTEN}/${CHANNEL}')); |
|---|
| 79 |
$ext->add($contextname, $grpnum, '', new ext_setvar('__BLKVM_BASE', '${EXTEN}')); |
|---|
| 80 |
$ext->add($contextname, $grpnum, '', new ext_setvar('DB(${BLKVM_OVERRIDE})', 'TRUE')); |
|---|
| 81 |
|
|---|
| 82 |
// Remember if NODEST was set later, but clear it in case the call is answered so that subsequent |
|---|
| 83 |
// transfers work. |
|---|
| 84 |
// |
|---|
| 85 |
$ext->add($contextname, $grpnum, 'skipov', new ext_setvar('RRNODEST', '${NODEST}')); |
|---|
| 86 |
$ext->add($contextname, $grpnum, 'skipvmblk', new ext_setvar('__NODEST', '${EXTEN}')); |
|---|
| 87 |
|
|---|
| 88 |
// deal with group CID prefix |
|---|
| 89 |
// but strip only if you plan on setting a new one |
|---|
| 90 |
if ($grppre != '') { |
|---|
| 91 |
$ext->add($contextname, $grpnum, '', new ext_gotoif('$["foo${RGPREFIX}" = "foo"]', 'REPCID')); |
|---|
| 92 |
$ext->add($contextname, $grpnum, '', new ext_gotoif('$["${RGPREFIX}" != "${CALLERID(name):0:${LEN(${RGPREFIX})}}"]', 'REPCID')); |
|---|
| 93 |
$ext->add($contextname, $grpnum, '', new ext_noop('Current RGPREFIX is ${RGPREFIX}....stripping from Caller ID')); |
|---|
| 94 |
$ext->add($contextname, $grpnum, '', new ext_setvar('CALLERID(name)', '${CALLERID(name):${LEN(${RGPREFIX})}}')); |
|---|
| 95 |
$ext->add($contextname, $grpnum, '', new ext_setvar('_RGPREFIX', '')); |
|---|
| 96 |
$ext->add($contextname, $grpnum, 'REPCID', new ext_noop('CALLERID(name) is ${CALLERID(name)}')); |
|---|
| 97 |
$ext->add($contextname, $grpnum, '', new ext_setvar('_RGPREFIX', $grppre)); |
|---|
| 98 |
$ext->add($contextname, $grpnum, '', new ext_setvar('CALLERID(name)','${RGPREFIX}${CALLERID(name)}')); |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
// MODIFIED (PL) |
|---|
| 102 |
// Add Alert Info if set but don't override and already set value (could be from ringgroup, directdid, etc.) |
|---|
| 103 |
// |
|---|
| 104 |
if ((isset($dring) ? $dring : '') != '') { |
|---|
| 105 |
// If ALERTINFO is set, then skip to the next set command. This was modified to two lines because the previous |
|---|
| 106 |
// IF() couldn't handle ':' as part of the string. The jump to PRIORITY+2 allows for now destination label |
|---|
| 107 |
// which is needed in the 2.3 version. |
|---|
| 108 |
$ext->add($contextname, $grpnum, '', new ext_gotoif('$["x${ALERT_INFO}"!="x"]','$[${PRIORITY}+2])}')); |
|---|
| 109 |
$ext->add($contextname, $grpnum, '', new ext_setvar("__ALERT_INFO", str_replace(';', '\;', $dring) )); |
|---|
| 110 |
} |
|---|
| 111 |
// If pre_ring is set, then ring this number of seconds prior to moving on |
|---|
| 112 |
if ((isset($strategy) ? substr($strategy,0,strlen('ringallv2')) : '') != 'ringallv2') { |
|---|
| 113 |
$ext->add($contextname, $grpnum, '', new ext_gotoif('$[$[ "${DB(AMPUSER/'.$grpnum.'/followme/prering)}" = "0" ] | $[ "${DB(AMPUSER/'.$grpnum.'/followme/prering)}" = "" ]] ', 'skipsimple')); |
|---|
| 114 |
$ext->add($contextname, $grpnum, '', new ext_macro('simple-dial',$grpnum.',${DB(AMPUSER/'."$grpnum/followme/prering)}")); |
|---|
| 115 |
} |
|---|
| 116 |
|
|---|
| 117 |
// recording stuff |
|---|
| 118 |
$ext->add($contextname, $grpnum, 'skipsimple', new ext_setvar('RecordMethod','Group')); |
|---|
| 119 |
$ext->add($contextname, $grpnum, '', new ext_macro('record-enable','${DB(AMPUSER/'."$grpnum/followme/grplist)}".',${RecordMethod}')); |
|---|
| 120 |
|
|---|
| 121 |
// group dial |
|---|
| 122 |
$ext->add($contextname, $grpnum, '', new ext_setvar('RingGroupMethod',$strategy)); |
|---|
| 123 |
$ext->add($contextname, $grpnum, '', new ext_setvar('_FMGRP',$grpnum)); |
|---|
| 124 |
if ((isset($annmsg) ? $annmsg : '') != '') { |
|---|
| 125 |
// should always answer before playing anything, shouldn't we ? |
|---|
| 126 |
$ext->add($contextname, $grpnum, '', new ext_gotoif('$[$["${DIALSTATUS}" = "ANSWER"] | $["foo${RRNODEST}" != "foo"]]','DIALGRP')); |
|---|
| 127 |
$ext->add($contextname, $grpnum, '', new ext_answer('')); |
|---|
| 128 |
$ext->add($contextname, $grpnum, '', new ext_wait(1)); |
|---|
| 129 |
$ext->add($contextname, $grpnum, '', new ext_playback($annmsg)); |
|---|
| 130 |
} |
|---|
| 131 |
|
|---|
| 132 |
// Create the confirm target |
|---|
| 133 |
$len=strlen($grpnum)+4; |
|---|
| 134 |
$ext->add("fmgrps", "_RG-${grpnum}-.", '', new ext_macro('dial','${DB(AMPUSER/'."$grpnum/followme/grptime)},". |
|---|
| 135 |
"M(confirm^${remotealert}^${toolate}^${grpnum})$dialopts".',${EXTEN:'.$len.'}')); |
|---|
| 136 |
|
|---|
| 137 |
// If grpconf == ENABLED call with confirmation ELSE call normal |
|---|
| 138 |
$ext->add($contextname, $grpnum, 'DIALGRP', new |
|---|
| 139 |
ext_gotoif('$[ "${DB(AMPUSER/'.$grpnum.'/followme/grpconf)}" = "ENABLED" ]', 'doconfirm')); |
|---|
| 140 |
|
|---|
| 141 |
// Normal call |
|---|
| 142 |
if ((isset($strategy) ? substr($strategy,0,strlen('ringallv2')) : '') != 'ringallv2') { |
|---|
| 143 |
$ext->add($contextname, $grpnum, '', new ext_macro('dial','${DB(AMPUSER/'."$grpnum/followme/grptime)},$dialopts,".'${DB(AMPUSER/'."$grpnum/followme/grplist)}")); |
|---|
| 144 |
} else { |
|---|
| 145 |
$ext->add($contextname, $grpnum, '', new ext_macro('dial','$[ ${DB(AMPUSER/'.$grpnum.'/followme/grptime)} + ${DB(AMPUSER/'.$grpnum.'/followme/prering)} ],'.$dialopts.',${DB(AMPUSER/'.$grpnum.'/followme/grplist)}')); |
|---|
| 146 |
} |
|---|
| 147 |
$ext->add($contextname, $grpnum, '', new ext_goto('nextstep')); |
|---|
| 148 |
|
|---|
| 149 |
// Call Confirm call |
|---|
| 150 |
if ((isset($strategy) ? substr($strategy,0,strlen('ringallv2')) : '') != 'ringallv2') { |
|---|
| 151 |
$ext->add($contextname, $grpnum, 'doconfirm', new ext_macro('dial-confirm','${DB(AMPUSER/'."$grpnum/followme/grptime)},$dialopts,".'${DB(AMPUSER/'."$grpnum/followme/grplist)},".$grpnum)); |
|---|
| 152 |
} else { |
|---|
| 153 |
$ext->add($contextname, $grpnum, 'doconfirm', new ext_macro('dial-confirm','$[ ${DB(AMPUSER/'.$grpnum.'/followme/grptime)} + ${DB(AMPUSER/'.$grpnum.'/followme/prering)} ],'.$dialopts.',${DB(AMPUSER/'.$grpnum.'/followme/grplist)},'.$grpnum)); |
|---|
| 154 |
} |
|---|
| 155 |
|
|---|
| 156 |
$ext->add($contextname, $grpnum, 'nextstep', new ext_setvar('RingGroupMethod','')); |
|---|
| 157 |
|
|---|
| 158 |
// Did the call come from a queue or ringgroup, if so, don't go to the destination, just end and let |
|---|
| 159 |
// the queue or ringgroup decide what to do next |
|---|
| 160 |
// |
|---|
| 161 |
$ext->add($contextname, $grpnum, '', new ext_gotoif('$["foo${RRNODEST}" != "foo"]', 'nodest')); |
|---|
| 162 |
$ext->add($contextname, $grpnum, '', new ext_setvar('__NODEST', '')); |
|---|
| 163 |
|
|---|
| 164 |
$ext->add($contextname, $grpnum, '', new ext_dbdel('${BLKVM_OVERRIDE}')); |
|---|
| 165 |
|
|---|
| 166 |
// where next? |
|---|
| 167 |
if ((isset($postdest) ? $postdest : '') != '') { |
|---|
| 168 |
$ext->add($contextname, $grpnum, '', new ext_goto($postdest)); |
|---|
| 169 |
} else { |
|---|
| 170 |
$ext->add($contextname, $grpnum, '', new ext_hangup('')); |
|---|
| 171 |
} |
|---|
| 172 |
$ext->add($contextname, $grpnum, 'nodest', new ext_noop('SKIPPING DEST, CALL CAME FROM Q/RG: ${RRNODEST}')); |
|---|
| 173 |
} |
|---|
| 174 |
} |
|---|
| 175 |
break; |
|---|
| 176 |
} |
|---|
| 177 |
} |
|---|
| 178 |
|
|---|
| 179 |
function findmefollow_add($grpnum,$strategy,$grptime,$grplist,$postdest,$grppre='',$annmsg='',$dring,$needsconf,$remotealert,$toolate,$ringing,$pre_ring,$ddial) { |
|---|
| 180 |
global $amp_conf; |
|---|
| 181 |
global $astman; |
|---|
| 182 |
|
|---|
| 183 |
$sql = "INSERT INTO findmefollow (grpnum, strategy, grptime, grppre, grplist, annmsg, postdest, dring, needsconf, remotealert, toolate, ringing, pre_ring) VALUES ('".str_replace("'", "''",$grpnum)."', '".str_replace("'", "''", $strategy)."', ".str_replace("'", "''", $grptime).", '".str_replace("'", "''", $grppre)."', '".str_replace("'", "''", $grplist)."', '".str_replace("'", "''", $annmsg)."', '".str_replace("'", "''", $postdest)."', '".str_replace("'", "''", $dring)."', '$needsconf', '$remotealert', '$toolate', '$ringing', '$pre_ring')"; |
|---|
| 184 |
$results = sql($sql); |
|---|
| 185 |
|
|---|
| 186 |
if ($astman) { |
|---|
| 187 |
$astman->database_put("AMPUSER",$grpnum."/followme/prering",isset($pre_ring)?$pre_ring:''); |
|---|
| 188 |
$astman->database_put("AMPUSER",$grpnum."/followme/grptime",isset($grptime)?$grptime:''); |
|---|
| 189 |
$astman->database_put("AMPUSER",$grpnum."/followme/grplist",isset($grplist)?$grplist:''); |
|---|
| 190 |
|
|---|
| 191 |
$needsconf = isset($needsconf)?$needsconf:''; |
|---|
| 192 |
$confvalue = ($needsconf == 'CHECKED')?'ENABLED':'DISABLED'; |
|---|
| 193 |
$astman->database_put("AMPUSER",$grpnum."/followme/grpconf",$confvalue); |
|---|
| 194 |
|
|---|
| 195 |
$ddial = isset($ddial)?$ddial:''; |
|---|
| 196 |
$ddialvalue = ($ddial == 'CHECKED')?'EXTENSION':'DIRECT'; |
|---|
| 197 |
$astman->database_put("AMPUSER",$grpnum."/followme/ddial",$ddialvalue); |
|---|
| 198 |
} else { |
|---|
| 199 |
fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); |
|---|
| 200 |
} |
|---|
| 201 |
} |
|---|
| 202 |
|
|---|
| 203 |
function findmefollow_del($grpnum) { |
|---|
| 204 |
global $amp_conf; |
|---|
| 205 |
global $astman; |
|---|
| 206 |
|
|---|
| 207 |
$results = sql("DELETE FROM findmefollow WHERE grpnum = '".str_replace("'", "''", $grpnum)."'","query"); |
|---|
| 208 |
|
|---|
| 209 |
if ($astman) { |
|---|
| 210 |
$astman->database_deltree("AMPUSER/".$grpnum."/followme"); |
|---|
| 211 |
} else { |
|---|
| 212 |
fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); |
|---|
| 213 |
} |
|---|
| 214 |
} |
|---|
| 215 |
|
|---|
| 216 |
function findmefollow_full_list() { |
|---|
| 217 |
$results = sql("SELECT grpnum FROM findmefollow ORDER BY CAST(grpnum as UNSIGNED)","getAll",DB_FETCHMODE_ASSOC); |
|---|
| 218 |
foreach ($results as $result) { |
|---|
| 219 |
if (isset($result['grpnum']) && checkRange($result['grpnum'])) { |
|---|
| 220 |
$grps[] = array($result['grpnum']); |
|---|
| 221 |
} |
|---|
| 222 |
} |
|---|
| 223 |
if (isset($grps)) |
|---|
| 224 |
return $grps; |
|---|
| 225 |
else |
|---|
| 226 |
return null; |
|---|
| 227 |
} |
|---|
| 228 |
|
|---|
| 229 |
function findmefollow_list() { |
|---|
| 230 |
|
|---|
| 231 |
global $db; |
|---|
| 232 |
$sql = "SELECT grpnum FROM findmefollow ORDER BY CAST(grpnum as UNSIGNED)"; |
|---|
| 233 |
$results = $db->getCol($sql); |
|---|
| 234 |
if(DB::IsError($results)) { |
|---|
| 235 |
$results = null; |
|---|
| 236 |
} |
|---|
| 237 |
if (isset($results)) { |
|---|
| 238 |
foreach($results as $result) { |
|---|
| 239 |
if (checkRange($result)){ |
|---|
| 240 |
$grps[] = $result; |
|---|
| 241 |
} |
|---|
| 242 |
} |
|---|
| 243 |
} |
|---|
| 244 |
if (isset($grps)) { |
|---|
| 245 |
sort($grps); // hmm, should be sorted already |
|---|
| 246 |
return $grps; |
|---|
| 247 |
} |
|---|
| 248 |
else { |
|---|
| 249 |
return null; |
|---|
| 250 |
} |
|---|
| 251 |
} |
|---|
| 252 |
|
|---|
| 253 |
// This gets the list of all active users so that the Find Me Follow display can limit the options to only created users. |
|---|
| 254 |
// the returned arrays contain [0]:extension [1]:name |
|---|
| 255 |
// |
|---|
| 256 |
// This was pulled straight out of previous 1.x version, might need cleanup laster |
|---|
| 257 |
// |
|---|
| 258 |
function findmefollow_allusers() { |
|---|
| 259 |
global $db; |
|---|
| 260 |
$sql = "SELECT extension,name FROM users ORDER BY extension"; |
|---|
| 261 |
$results = $db->getAll($sql); |
|---|
| 262 |
if(DB::IsError($results)) { |
|---|
| 263 |
$results = null; |
|---|
| 264 |
} |
|---|
| 265 |
foreach($results as $result){ |
|---|
| 266 |
if (checkRange($result[0])){ |
|---|
| 267 |
$users[] = array($result[0],$result[1]); |
|---|
| 268 |
} |
|---|
| 269 |
} |
|---|
| 270 |
if (isset($users)) sort($users); |
|---|
| 271 |
return $users; |
|---|
| 272 |
} |
|---|
| 273 |
|
|---|
| 274 |
// Only check astdb if check_astdb is not 0. For some reason, this fails if the asterisk manager code |
|---|
| 275 |
// is included (executed) by all calls to this function. This results in silently not generating the |
|---|
| 276 |
// extensions_additional.conf file. page.findmefollow.php does set it to 1 which means that when running |
|---|
| 277 |
// the GUI, any changes not reflected in SQL will be detected and written back to SQL so that they are |
|---|
| 278 |
// in sync. Ideally, anything that changes the astdb should change SQL. (in some ways, these should both |
|---|
| 279 |
// not be here but ... |
|---|
| 280 |
// |
|---|
| 281 |
// Need to go back and confirm at some point that the $check_astdb error is still there and deal with it. |
|---|
| 282 |
// as variables like $ddial get introduced to only be in astdb, the result array will not include them |
|---|
| 283 |
// if not able to get to astdb. (I suspect in 2.2 and beyond this may all be fixed). |
|---|
| 284 |
// |
|---|
| 285 |
function findmefollow_get($grpnum, $check_astdb=0) { |
|---|
| 286 |
global $amp_conf; |
|---|
| 287 |
global $astman; |
|---|
| 288 |
|
|---|
| 289 |
$results = sql("SELECT grpnum, strategy, grptime, grppre, grplist, annmsg, postdest, dring, needsconf, remotealert, toolate, ringing, pre_ring FROM findmefollow WHERE grpnum = '".str_replace("'", "''", $grpnum)."'","getRow",DB_FETCHMODE_ASSOC); |
|---|
| 290 |
|
|---|
| 291 |
if ($check_astdb) { |
|---|
| 292 |
if ($astman) { |
|---|
| 293 |
$astdb_prering = $astman->database_get("AMPUSER",$grpnum."/followme/prering"); |
|---|
| 294 |
$astdb_grptime = $astman->database_get("AMPUSER",$grpnum."/followme/grptime"); |
|---|
| 295 |
$astdb_grplist = $astman->database_get("AMPUSER",$grpnum."/followme/grplist"); |
|---|
| 296 |
$astdb_grpconf = $astman->database_get("AMPUSER",$grpnum."/followme/grpconf"); |
|---|
| 297 |
} else { |
|---|
| 298 |
fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); |
|---|
| 299 |
} |
|---|
| 300 |
$astdb_ddial = $astman->database_get("AMPUSER",$grpnum."/followme/ddial"); |
|---|
| 301 |
// If the values are different then use what is in astdb as it may have been changed. |
|---|
| 302 |
// |
|---|
| 303 |
$changed=0; |
|---|
| 304 |
if (($astdb_prering != $results['pre_ring']) && ($astdb_prering >= 0)) { |
|---|
| 305 |
$results['pre_ring'] = $astdb_prering; |
|---|
| 306 |
$changed=1; |
|---|
| 307 |
} |
|---|
| 308 |
if (($astdb_grptime != $results['grptime']) && ($astdb_grptime > 0)) { |
|---|
| 309 |
$results['grptime'] = $astdb_grptime; |
|---|
| 310 |
$changed=1; |
|---|
| 311 |
} |
|---|
| 312 |
if ((trim($astdb_grplist) != trim($results['grplist'])) && (trim($astdb_grplist) != '')) { |
|---|
| 313 |
$results['grplist'] = $astdb_grplist; |
|---|
| 314 |
$changed=1; |
|---|
| 315 |
} |
|---|
| 316 |
|
|---|
| 317 |
if (trim($astdb_grpconf) == 'ENABLED') { |
|---|
| 318 |
$confvalue = 'CHECKED'; |
|---|
| 319 |
} elseif (trim($astdb_grpconf) == 'DISABLED') { |
|---|
| 320 |
$confvalue = ''; |
|---|
| 321 |
} else { |
|---|
| 322 |
//Bogus value, should not get here but treat as disabled |
|---|
| 323 |
$confvalue = ''; |
|---|
| 324 |
} |
|---|
| 325 |
if ($confvalue != trim($results['needsconf'])) { |
|---|
| 326 |
$results['needsconf'] = $confvalue; |
|---|
| 327 |
$changed=1; |
|---|
| 328 |
} |
|---|
| 329 |
|
|---|
| 330 |
// Not in sql so no sanity check needed |
|---|
| 331 |
// |
|---|
| 332 |
if (trim($astdb_ddial) == 'EXTENSION') { |
|---|
| 333 |
$ddial = 'CHECKED'; |
|---|
| 334 |
} elseif (trim($astdb_ddial) == 'DIRECT') { |
|---|
| 335 |
$ddial = ''; |
|---|
| 336 |
} else { |
|---|
| 337 |
//Bogus value, should not get here but treat as disabled |
|---|
| 338 |
$ddial = ''; |
|---|
| 339 |
} |
|---|
| 340 |
$results['ddial'] = $ddial; |
|---|
| 341 |
|
|---|
| 342 |
if ($changed) { |
|---|
| 343 |
$sql = "UPDATE findmefollow SET grptime = '".$results['grptime']."', grplist = '". |
|---|
| 344 |
str_replace("'", "''", trim($results['grplist']))."', pre_ring = '".$results['pre_ring']. |
|---|
| 345 |
"', needsconf = '".$results['needsconf']."' WHERE grpnum = '".str_replace("'", "''", $grpnum)."' LIMIT 1"; |
|---|
| 346 |
$sql_results = sql($sql); |
|---|
| 347 |
} |
|---|
| 348 |
} // if check_astdb |
|---|
| 349 |
|
|---|
| 350 |
return $results; |
|---|
| 351 |
} |
|---|
| 352 |
|
|---|
| 353 |
function findmefollow_configpageinit($dispnum) { |
|---|
| 354 |
global $currentcomponent; |
|---|
| 355 |
|
|---|
| 356 |
if ( ($dispnum == 'users' || $dispnum == 'extensions') ) { |
|---|
| 357 |
$currentcomponent->addguifunc('findmefollow_configpageload'); |
|---|
| 358 |
} |
|---|
| 359 |
} |
|---|
| 360 |
|
|---|
| 361 |
function findmefollow_configpageload() { |
|---|
| 362 |
global $currentcomponent; |
|---|
| 363 |
|
|---|
| 364 |
$viewing_itemid = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; |
|---|
| 365 |
$action = isset($_REQUEST['action'])?$_REQUEST['action']:null; |
|---|
| 366 |
if ( $viewing_itemid != '' && $action != 'del') { |
|---|
| 367 |
$set_findmefollow = findmefollow_list(); |
|---|
| 368 |
$grpURL = $_SERVER['PHP_SELF'].'?'.'display=findmefollow&extdisplay=GRP-'.$viewing_itemid; |
|---|
| 369 |
if (is_array($set_findmefollow)) { |
|---|
| 370 |
if (in_array($viewing_itemid,$set_findmefollow)) { |
|---|
| 371 |
$grpTEXT = _("Edit Follow Me Settings"); |
|---|
| 372 |
$icon = "images/user_go.png"; |
|---|
| 373 |
} else { |
|---|
| 374 |
$grpTEXT = _("Add Follow Me Settings"); |
|---|
| 375 |
$icon = "images/user_add.png"; |
|---|
| 376 |
} |
|---|
| 377 |
} else { |
|---|
| 378 |
$grpTEXT = _("Add Follow Me Settings"); |
|---|
| 379 |
$icon = "images/user_add.png"; |
|---|
| 380 |
} |
|---|
| 381 |
$label = '<span><img width="16" height="16" border="0" title="Delete Extension" alt="" src="'.$icon.'"/> '.$grpTEXT.'</span>'; |
|---|
| 382 |
$currentcomponent->addguielem('_top', new gui_link('findmefollowlink', $label, $grpURL)); |
|---|
| 383 |
} |
|---|
| 384 |
} |
|---|
| 385 |
|
|---|
| 386 |
function findmefollow_check_destinations($dest=true) { |
|---|
| 387 |
global $active_modules; |
|---|
| 388 |
|
|---|
| 389 |
$destlist = array(); |
|---|
| 390 |
if (is_array($dest) && empty($dest)) { |
|---|
| 391 |
return $destlist; |
|---|
| 392 |
} |
|---|
| 393 |
$sql = "SELECT grpnum, postdest, name FROM findmefollow INNER JOIN users ON grpnum = extension "; |
|---|
| 394 |
if ($dest !== true) { |
|---|
| 395 |
$sql .= "WHERE postdest in ('".implode("','",$dest)."')"; |
|---|
| 396 |
} |
|---|
| 397 |
$results = sql($sql,"getAll",DB_FETCHMODE_ASSOC); |
|---|
| 398 |
|
|---|
| 399 |
//$type = isset($active_modules['announcement']['type'])?$active_modules['announcement']['type']:'setup'; |
|---|
| 400 |
|
|---|
| 401 |
foreach ($results as $result) { |
|---|
| 402 |
$thisdest = $result['postdest']; |
|---|
| 403 |
$thisid = $result['grpnum']; |
|---|
| 404 |
$destlist[] = array( |
|---|
| 405 |
'dest' => $thisdest, |
|---|
| 406 |
'description' => 'Follow-Me: '.$thisid.' ('.$result['name'].')', |
|---|
| 407 |
'edit_url' => 'config.php?display=findmefollow&extdisplay=GRP-'.urlencode($thisid), |
|---|
| 408 |
); |
|---|
| 409 |
} |
|---|
| 410 |
return $destlist; |
|---|
| 411 |
} |
|---|
| 412 |
|
|---|
| 413 |
function findmefollow_fmf_toggle($c) { |
|---|
| 414 |
global $ext; |
|---|
| 415 |
global $amp_conf; |
|---|
| 416 |
|
|---|
| 417 |
$id = "app-fmf-toggle"; // The context to be included |
|---|
| 418 |
$ext->addInclude('from-internal-additional', $id); // Add the include from from-internal |
|---|
| 419 |
|
|---|
| 420 |
$ext->add($id, $c, '', new ext_goto('start','s',$id)); |
|---|
| 421 |
$c = 's'; |
|---|
| 422 |
|
|---|
| 423 |
$ext->add($id, $c, 'start', new ext_answer('')); |
|---|
| 424 |
$ext->add($id, $c, '', new ext_wait('1')); |
|---|
| 425 |
$ext->add($id, $c, '', new ext_macro('user-callerid')); |
|---|
| 426 |
|
|---|
| 427 |
$ext->add($id, $c, '', new ext_gotoif('$["${DB(AMPUSER/${AMPUSER}/followme/ddial)}" = "EXTENSION"]', 'activate')); |
|---|
| 428 |
$ext->add($id, $c, '', new ext_gotoif('$["${DB(AMPUSER/${AMPUSER}/followme/ddial)}" = "DIRECT"]', 'deactivate','end')); |
|---|
| 429 |
|
|---|
| 430 |
$ext->add($id, $c, 'deactivate', new ext_setvar('DB(AMPUSER/${AMPUSER}/followme/ddial)', 'EXTENSION')); |
|---|
| 431 |
if ($amp_conf['USEDEVSTATE']) { |
|---|
| 432 |
$ext->add($id, $c, '', new ext_setvar('DEVSTATE(Custom:FOLLOWME${AMPUSER})', 'NOT_INUSE')); |
|---|
| 433 |
} |
|---|
| 434 |
$ext->add($id, $c, 'end', new ext_playback('followme&de-activated')); |
|---|
| 435 |
$ext->add($id, $c, '', new ext_macro('hangupcall')); |
|---|
| 436 |
|
|---|
| 437 |
$ext->add($id, $c, 'activate', new ext_setvar('DB(AMPUSER/${AMPUSER}/followme/ddial)', 'DIRECT')); |
|---|
| 438 |
if ($amp_conf['USEDEVSTATE']) { |
|---|
| 439 |
$ext->add($id, $c, '', new ext_setvar('DEVSTATE(Custom:FOLLOWME${AMPUSER})', 'INUSE')); |
|---|
| 440 |
} |
|---|
| 441 |
$ext->add($id, $c, '', new ext_playback('followme&activated')); |
|---|
| 442 |
$ext->add($id, $c, '', new ext_macro('hangupcall')); |
|---|
| 443 |
|
|---|
| 444 |
} |
|---|
| 445 |
|
|---|
| 446 |
?> |
|---|