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

Revision 3878, 4.6 kB (checked in by p_lindheimer, 6 years ago)

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

........

r3877 | p_lindheimer | 2007-03-26 21:56:35 -0700 (Mon, 26 Mar 2007) | 1 line


added cid masquerade ability for internal calls
(bogus ci message: actually, skip answer(), wait(1) if channel already

answered)
........

Line 
1 <?php
2
3 function announcement_destinations() {
4     // return an associative array with destination and description
5     foreach (announcement_list() as $row) {
6         $extens[] = array('destination' => 'app-announcement-'.$row[0].',s,1', 'description' => $row[1]);
7     }
8     return $extens;
9 }
10
11 function announcement_get_config($engine) {
12     global $ext;
13     switch ($engine) {
14         case 'asterisk':
15             foreach (announcement_list() as $row) {
16                 if (! $row[6]) {
17                     $ext->add('app-announcement-'.$row[0], 's', '', new ext_gotoif('$["${CDR(disposition)}" = "ANSWERED"]','begin'));
18                     $ext->add('app-announcement-'.$row[0], 's', '', new ext_answer(''));
19                     $ext->add('app-announcement-'.$row[0], 's', '', new ext_wait('1'));
20                 }
21                 $ext->add('app-announcement-'.$row[0], 's', 'begin', new ext_noop('Playing announcement '.$row[1]));
22                 if ($row[3] || $row[7]) {
23                     // allow skip
24                     if ($row[7]) {
25                         $ext->add('app-announcement-'.$row[0], 's', '', new ext_responsetimeout(3));
26                     }
27                     $ext->add('app-announcement-'.$row[0], 's', 'play', new ext_background($row[2].'|nm'));
28                     
29                     if ($row[3]) {
30                         $ext->add('app-announcement-'.$row[0], '_X', '', new ext_noop('User skipped announcement'));
31                         if ($row[5]) {
32                             $ext->add('app-announcement-'.$row[0], '_X', '', new ext_gotoif('$["x${IVR_CONTEXT}" = "x"]', $row[4].':${IVR_CONTEXT},return,1'));
33                         } else {
34                             $ext->add('app-announcement-'.$row[0], '_X', '', new ext_goto($row[4]));
35                         }
36                     }
37                     if ($row[7]) {
38                         $ext->add('app-announcement-'.$row[0], $row[7], '', new ext_goto('s,play'));
39                     }
40                 } else {
41                     $ext->add('app-announcement-'.$row[0], 's', '', new ext_playback($row[2].'|noanswer'));
42                 }
43
44                 // if repeat_msg enabled then set exten to t to allow for the key to be pressed, otherwise play message and go
45                 $exten = $row[7] ? 't':'s';
46                 if ($row[5]) {
47                     $ext->add('app-announcement-'.$row[0], $exten, '', new ext_gotoif('$["x${IVR_CONTEXT}" = "x"]', $row[4].':${IVR_CONTEXT},return,1'));
48                     if ($row[3] || $row[7])
49                         $ext->add('app-announcement-'.$row[0], 'i', '', new ext_gotoif('$["x${IVR_CONTEXT}" = "x"]', $row[4].':${IVR_CONTEXT},return,1'));
50                 } else {
51                     $ext->add('app-announcement-'.$row[0], $exten, '', new ext_goto($row[4]));
52                     if ($row[3] || $row[7])
53                         $ext->add('app-announcement-'.$row[0], 'i', '', new ext_goto($row[4]));
54                 }
55                 
56             }
57         break;
58     }
59 }
60
61 function announcement_list() {
62     global $db;
63     $sql = "SELECT announcement_id, description, recording, allow_skip, post_dest, return_ivr, noanswer, repeat_msg FROM announcement ORDER BY description ";
64     $results = $db->getAll($sql);
65     if(DB::IsError($results)) {
66         die($results->getMessage()."<br><br>Error selecting from announcement");   
67     }
68     return $results;
69 }
70
71 function announcement_get($announcement_id) {
72     global $db;
73     $sql = "SELECT announcement_id, description, recording, allow_skip, post_dest, return_ivr, noanswer, repeat_msg FROM announcement WHERE announcement_id = ".addslashes($announcement_id);
74     $row = $db->getRow($sql);
75     if(DB::IsError($row)) {
76         die($row->getMessage()."<br><br>Errpr selecting row from announcement");   
77     }
78     return $row;
79 }
80
81 function announcement_add($description, $recording, $allow_skip, $post_dest, $return_ivr, $noanswer, $repeat_msg) {
82     global $db;
83     $sql = "INSERT INTO announcement (description, recording, allow_skip, post_dest, return_ivr, noanswer, repeat_msg) VALUES (".
84         "'".addslashes($description)."', ".
85         "'".addslashes($recording)."', ".
86         "'".($allow_skip ? 1 : 0)."', ".
87         "'".addslashes($post_dest)."', ".
88         "'".($return_ivr ? 1 : 0)."', ".
89         "'".($noanswer ? 1 : 0)."', ".
90         "'".addslashes($repeat_msg)."')";
91     $result = $db->query($sql);
92     if(DB::IsError($result)) {
93         die($result->getMessage().$sql);
94     }
95 }
96
97 function announcement_delete($announcement_id) {
98     global $db;
99     $sql = "DELETE FROM announcement WHERE announcement_id = ".addslashes($announcement_id);
100     $result = $db->query($sql);
101     if(DB::IsError($result)) {
102         die($result->getMessage().$sql);
103     }
104     
105 }
106
107 function announcement_edit($announcement_id, $description, $recording, $allow_skip, $post_dest, $return_ivr, $noanswer, $repeat_msg) {
108     global $db;
109     $sql = "UPDATE announcement SET ".
110         "description = '".addslashes($description)."', ".
111         "recording = '".addslashes($recording)."', ".
112         "allow_skip = '".($allow_skip ? 1 : 0)."', ".
113         "post_dest = '".addslashes($post_dest)."', ".
114         "return_ivr = '".($return_ivr ? 1 : 0)."', ".
115         "noanswer = '".($noanswer ? 1 : 0)."', ".
116         "repeat_msg = '".addslashes($repeat_msg)."' ".
117         "WHERE announcement_id = ".addslashes($announcement_id);
118     $result = $db->query($sql);
119     if(DB::IsError($result)) {
120         die($result->getMessage().$sql);
121     }
122 }
123
124 ?>
125
Note: See TracBrowser for help on using the browser.