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

Revision 3832, 2.5 kB (checked in by p_lindheimer, 5 years ago)

Merged revisions 3831 via svnmerge from
https://amportal.svn.sourceforge.net/svnroot/amportal/modules/branches/2.2

........

r3831 | p_lindheimer | 2007-02-26 13:42:57 -0800 (Mon, 26 Feb 2007) | 1 line


destination changed from Dial(Local/nnn@from-internal) to Goto(from-internal,nnn,1), no reason a new channel should be created

........

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
Line 
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 ?>
Note: See TracBrowser for help on using the browser.