| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
function announcement_destinations() { |
|---|
| 4 |
|
|---|
| 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 |
$ext->add('app-announcement-'.$row[0], 's', '', new ext_noop('Playing announcement '.$row[1])); |
|---|
| 17 |
if (! $row[6]) { |
|---|
| 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 |
if ($row[3]) { |
|---|
| 22 |
|
|---|
| 23 |
$ext->add('app-announcement-'.$row[0], 's', '', new ext_background($row[2].'|n')); |
|---|
| 24 |
|
|---|
| 25 |
$ext->add('app-announcement-'.$row[0], '_X', '', new ext_noop('User skipped announcement')); |
|---|
| 26 |
if ($row[5]) { |
|---|
| 27 |
$ext->add('app-announcement-'.$row[0], '_X', '', new ext_gotoif('$["x${IVR_CONTEXT}" = "x"]', $row[4].':${IVR_CONTEXT},return,1')); |
|---|
| 28 |
} else { |
|---|
| 29 |
$ext->add('app-announcement-'.$row[0], '_X', '', new ext_goto($row[4])); |
|---|
| 30 |
} |
|---|
| 31 |
} else { |
|---|
| 32 |
$ext->add('app-announcement-'.$row[0], 's', '', new ext_playback($row[2].'|noanswer')); |
|---|
| 33 |
} |
|---|
| 34 |
|
|---|
| 35 |
if ($row[5]) { |
|---|
| 36 |
$ext->add('app-announcement-'.$row[0], 's', '', new ext_gotoif('$["x${IVR_CONTEXT}" = "x"]', $row[4].':${IVR_CONTEXT},return,1')); |
|---|
| 37 |
} else { |
|---|
| 38 |
$ext->add('app-announcement-'.$row[0], 's', '', new ext_goto($row[4])); |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
} |
|---|
| 42 |
break; |
|---|
| 43 |
} |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
function announcement_list() { |
|---|
| 47 |
global $db; |
|---|
| 48 |
$sql = "SELECT announcement_id, description, recording, allow_skip, post_dest, return_ivr, noanswer FROM announcement ORDER BY description "; |
|---|
| 49 |
$results = $db->getAll($sql); |
|---|
| 50 |
if(DB::IsError($results)) { |
|---|
| 51 |
die($results->getMessage()."<br><br>Error selecting from announcement"); |
|---|
| 52 |
} |
|---|
| 53 |
return $results; |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
function announcement_get($announcement_id) { |
|---|
| 57 |
global $db; |
|---|
| 58 |
$sql = "SELECT announcement_id, description, recording, allow_skip, post_dest, return_ivr, noanswer FROM announcement WHERE announcement_id = ".addslashes($announcement_id); |
|---|
| 59 |
$row = $db->getRow($sql); |
|---|
| 60 |
if(DB::IsError($row)) { |
|---|
| 61 |
die($row->getMessage()."<br><br>Errpr selecting row from announcement"); |
|---|
| 62 |
} |
|---|
| 63 |
return $row; |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|
| 66 |
function announcement_add($description, $recording, $allow_skip, $post_dest, $return_ivr, $noanswer) { |
|---|
| 67 |
global $db; |
|---|
| 68 |
$sql = "INSERT INTO announcement (description, recording, allow_skip, post_dest, return_ivr, noanswer) VALUES (". |
|---|
| 69 |
"'".addslashes($description)."', ". |
|---|
| 70 |
"'".addslashes($recording)."', ". |
|---|
| 71 |
"'".($allow_skip ? 1 : 0)."', ". |
|---|
| 72 |
"'".addslashes($post_dest)."', ". |
|---|
| 73 |
"'".($return_ivr ? 1 : 0)."', ". |
|---|
| 74 |
"'".($noanswer ? 1 : 0)."')"; |
|---|
| 75 |
$result = $db->query($sql); |
|---|
| 76 |
if(DB::IsError($result)) { |
|---|
| 77 |
die($result->getMessage().$sql); |
|---|
| 78 |
} |
|---|
| 79 |
} |
|---|
| 80 |
|
|---|
| 81 |
function announcement_delete($announcement_id) { |
|---|
| 82 |
global $db; |
|---|
| 83 |
$sql = "DELETE FROM announcement WHERE announcement_id = ".addslashes($announcement_id); |
|---|
| 84 |
$result = $db->query($sql); |
|---|
| 85 |
if(DB::IsError($result)) { |
|---|
| 86 |
die($result->getMessage().$sql); |
|---|
| 87 |
} |
|---|
| 88 |
|
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
function announcement_edit($announcement_id, $description, $recording, $allow_skip, $post_dest, $return_ivr, $noanswer) { |
|---|
| 92 |
global $db; |
|---|
| 93 |
$sql = "UPDATE announcement SET ". |
|---|
| 94 |
"description = '".addslashes($description)."', ". |
|---|
| 95 |
"recording = '".addslashes($recording)."', ". |
|---|
| 96 |
"allow_skip = '".($allow_skip ? 1 : 0)."', ". |
|---|
| 97 |
"post_dest = '".addslashes($post_dest)."', ". |
|---|
| 98 |
"return_ivr = '".($return_ivr ? 1 : 0)."', ". |
|---|
| 99 |
"noanswer = '".($noanswer ? 1 : 0)."' ". |
|---|
| 100 |
"WHERE announcement_id = ".addslashes($announcement_id); |
|---|
| 101 |
$result = $db->query($sql); |
|---|
| 102 |
if(DB::IsError($result)) { |
|---|
| 103 |
die($result->getMessage().$sql); |
|---|
| 104 |
} |
|---|
| 105 |
} |
|---|
| 106 |
|
|---|
| 107 |
?> |
|---|
| 108 |
|
|---|