| 1 |
<?php /* $Id: $ */ |
|---|
| 2 |
|
|---|
| 3 |
// returns a associative arrays with keys 'destination' and 'description' |
|---|
| 4 |
function miscdests_destinations() { |
|---|
| 5 |
$results = miscdests_list(); |
|---|
| 6 |
|
|---|
| 7 |
// return an associative array with destination and description |
|---|
| 8 |
if (isset($results)) { |
|---|
| 9 |
foreach($results as $result){ |
|---|
| 10 |
$extens[] = array('destination' => 'ext-miscdests,'.$result['0'].',1', 'description' => $result['1']); |
|---|
| 11 |
} |
|---|
| 12 |
return $extens; |
|---|
| 13 |
} else { |
|---|
| 14 |
return null; |
|---|
| 15 |
} |
|---|
| 16 |
} |
|---|
| 17 |
|
|---|
| 18 |
/* Generates dialplan for conferences |
|---|
| 19 |
We call this with retrieve_conf |
|---|
| 20 |
*/ |
|---|
| 21 |
function miscdests_get_config($engine) { |
|---|
| 22 |
global $ext; // is this the best way to pass this? |
|---|
| 23 |
|
|---|
| 24 |
switch($engine) { |
|---|
| 25 |
case "asterisk": |
|---|
| 26 |
$contextname = 'ext-miscdests'; |
|---|
| 27 |
$fctemplate = '/\{(.+)\:(.+)\}/'; |
|---|
| 28 |
|
|---|
| 29 |
if(is_array($destlist = miscdests_list())) { |
|---|
| 30 |
|
|---|
| 31 |
foreach($destlist as $item) { |
|---|
| 32 |
$miscdest = miscdests_get($item['0']); |
|---|
| 33 |
|
|---|
| 34 |
$miscid = $miscdest['id']; |
|---|
| 35 |
$miscdescription = $miscdest['description']; |
|---|
| 36 |
$miscdialdest = $miscdest['destdial']; |
|---|
| 37 |
|
|---|
| 38 |
// exchange {mod:fc} for the relevent feature codes in $miscdialdest |
|---|
| 39 |
$miscdialdest = preg_replace_callback($fctemplate, "miscdests_lookupfc", $miscdialdest); |
|---|
| 40 |
|
|---|
| 41 |
// write out the dialplan details |
|---|
| 42 |
$ext->add($contextname, $miscid, '', new ext_noop('MiscDest: '.$miscdescription)); |
|---|
| 43 |
$ext->add($contextname, $miscid, '', new ext_goto('from-internal,'.$miscdialdest.',1', '')); |
|---|
| 44 |
|
|---|
| 45 |
} |
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
break; |
|---|
| 49 |
} |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
function miscdests_list() { |
|---|
| 53 |
$results = sql("SELECT id, description FROM miscdests ORDER BY description","getAll",DB_FETCHMODE_ASSOC); |
|---|
| 54 |
foreach($results as $result){ |
|---|
| 55 |
$extens[] = array($result['id'],$result['description']); |
|---|
| 56 |
} |
|---|
| 57 |
|
|---|
| 58 |
if (isset($extens)) { |
|---|
| 59 |
return $extens; |
|---|
| 60 |
} else { |
|---|
| 61 |
return null; |
|---|
| 62 |
} |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
function miscdests_get($id){ |
|---|
| 66 |
$results = sql("SELECT id, description, destdial FROM miscdests WHERE id = $id","getRow",DB_FETCHMODE_ASSOC); |
|---|
| 67 |
return $results; |
|---|
| 68 |
} |
|---|
| 69 |
|
|---|
| 70 |
function miscdests_del($id){ |
|---|
| 71 |
$results = sql("DELETE FROM miscdests WHERE id = $id","query"); |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
function miscdests_add($description, $destdial){ |
|---|
| 75 |
$results = sql("INSERT INTO miscdests (description, destdial) VALUES (".sql_formattext($description).",".sql_formattext($destdial).")"); |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
function miscdests_update($id, $description, $destdial){ |
|---|
| 79 |
$results = sql("UPDATE miscdests SET description = ".sql_formattext($description).", destdial = ".sql_formattext($destdial)." WHERE id = ".$id); |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
function miscdests_lookupfc($matches) { |
|---|
| 83 |
$modulename = $matches[1]; |
|---|
| 84 |
$featurename = $matches[2]; |
|---|
| 85 |
|
|---|
| 86 |
$fcc = new featurecode($modulename, $featurename); |
|---|
| 87 |
$fc = $fcc->getCodeActive(); |
|---|
| 88 |
return $fc; |
|---|
| 89 |
} |
|---|
| 90 |
?> |
|---|