| 1 |
<?php |
|---|
| 2 |
/** Announcments module for FreePBX 2.2+ |
|---|
| 3 |
* Copyright 2006 Greg MacLellan |
|---|
| 4 |
* This program is free software; you can redistribute it and/or |
|---|
| 5 |
* modify it under the terms of the GNU General Public License |
|---|
| 6 |
* as published by the Free Software Foundation; either version 2 |
|---|
| 7 |
* of the License, or (at your option) any later version. |
|---|
| 8 |
* |
|---|
| 9 |
* This program is distributed in the hope that it will be useful, |
|---|
| 10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 |
* GNU General Public License for more details. |
|---|
| 13 |
*/ |
|---|
| 14 |
|
|---|
| 15 |
$action = isset($_POST['action']) ? $_POST['action'] : ''; |
|---|
| 16 |
if (isset($_POST['delete'])) $action = 'delete'; |
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
$announcement_id = isset($_POST['announcement_id']) ? $_POST['announcement_id'] : false; |
|---|
| 20 |
$description = isset($_POST['description']) ? $_POST['description'] : ''; |
|---|
| 21 |
$recording = isset($_POST['recording']) ? $_POST['recording'] : ''; |
|---|
| 22 |
$allow_skip = isset($_POST['allow_skip']) ? $_POST['allow_skip'] : 0; |
|---|
| 23 |
$return_ivr = isset($_POST['return_ivr']) ? $_POST['return_ivr'] : 0; |
|---|
| 24 |
$noanswer = isset($_POST['noanswer']) ? $_POST['noanswer'] : 0; |
|---|
| 25 |
$post_dest = isset($_POST['post_dest']) ? $_POST['post_dest'] : ''; |
|---|
| 26 |
$repeat_msg = isset($_POST['repeat_msg']) ? $_POST['repeat_msg'] : ''; |
|---|
| 27 |
|
|---|
| 28 |
if (isset($_POST['goto0']) && $_POST['goto0']) { |
|---|
| 29 |
// 'ringgroup_post_dest' 'ivr_post_dest' or whatever |
|---|
| 30 |
$post_dest = $_POST[ $_POST['goto0'].'0' ]; |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
switch ($action) { |
|---|
| 35 |
case 'add': |
|---|
| 36 |
announcement_add($description, $recording, $allow_skip, $post_dest, $return_ivr, $noanswer, $repeat_msg); |
|---|
| 37 |
needreload(); |
|---|
| 38 |
redirect_standard(); |
|---|
| 39 |
break; |
|---|
| 40 |
case 'edit': |
|---|
| 41 |
announcement_edit($announcement_id, $description, $recording, $allow_skip, $post_dest, $return_ivr, $noanswer, $repeat_msg); |
|---|
| 42 |
needreload(); |
|---|
| 43 |
redirect_standard('extdisplay'); |
|---|
| 44 |
break; |
|---|
| 45 |
case 'delete': |
|---|
| 46 |
announcement_delete($announcement_id); |
|---|
| 47 |
needreload(); |
|---|
| 48 |
redirect_standard(); |
|---|
| 49 |
break; |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
?> |
|---|
| 54 |
</div> |
|---|
| 55 |
|
|---|
| 56 |
<div class="rnav"><ul> |
|---|
| 57 |
<?php |
|---|
| 58 |
// Eventually I recon the drawListMenu could be built into the new component class thus making |
|---|
| 59 |
// the relevent page.php file unnessassary |
|---|
| 60 |
|
|---|
| 61 |
echo '<li><a href="config.php?display=announcement&type=setup">'._('Add Announcement').'</a></li>'; |
|---|
| 62 |
|
|---|
| 63 |
foreach (announcement_list() as $row) { |
|---|
| 64 |
echo '<li><a href="config.php?display=announcement&type=setup&extdisplay='.$row[0].'" class="">'.$row[1].'</a></li>'; |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
?> |
|---|
| 68 |
</ul></div> |
|---|
| 69 |
|
|---|
| 70 |
<div class="content"> |
|---|
| 71 |
|
|---|
| 72 |
<?php |
|---|
| 73 |
if ($extdisplay) { |
|---|
| 74 |
// load |
|---|
| 75 |
$row = announcement_get($extdisplay); |
|---|
| 76 |
|
|---|
| 77 |
$description = $row[1]; |
|---|
| 78 |
$recording = $row[2]; |
|---|
| 79 |
$allow_skip = $row[3]; |
|---|
| 80 |
$post_dest = $row[4]; |
|---|
| 81 |
$return_ivr = $row[5]; |
|---|
| 82 |
$noanswer = $row[6]; |
|---|
| 83 |
$repeat_msg = $row[7]; |
|---|
| 84 |
|
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
?> |
|---|
| 88 |
<form name="editAnnouncement" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkAnnouncement(editAnnouncement);"> |
|---|
| 89 |
<input type="hidden" name="extdisplay" value="<?php echo $extdisplay; ?>"> |
|---|
| 90 |
<input type="hidden" name="announcement_id" value="<?php echo $extdisplay; ?>"> |
|---|
| 91 |
<input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add'); ?>"> |
|---|
| 92 |
<table> |
|---|
| 93 |
<tr><td colspan="2"><h5><?php echo ($extdisplay ? _("Edit Announcement") : _("Add Announcement")) ?><hr></h5></td></tr> |
|---|
| 94 |
<tr> |
|---|
| 95 |
<td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("The name of this announcement")?></span></a></td> |
|---|
| 96 |
<td><input size="15" type="text" name="description" value="<?php echo $description; ?>"></td> |
|---|
| 97 |
</tr> |
|---|
| 98 |
|
|---|
| 99 |
<?php if(function_exists('recordings_list')) { //only include if recordings is enabled?> |
|---|
| 100 |
<tr> |
|---|
| 101 |
<td><a href="#" class="info"><?php echo _("Recording")?><span><?php echo _("Message to be played.<br>To add additional recordings use the \"System Recordings\" MENU to the left")?></span></a></td> |
|---|
| 102 |
<td> |
|---|
| 103 |
<select name="recording"/> |
|---|
| 104 |
<?php |
|---|
| 105 |
$tresults = recordings_list(); |
|---|
| 106 |
$default = (isset($recording) ? $recording : ''); |
|---|
| 107 |
if (isset($tresults[0])) { |
|---|
| 108 |
foreach ($tresults as $tresult) { |
|---|
| 109 |
echo '<option value="'.$tresult[2].'"'.($tresult[2] == $default ? ' SELECTED' : '').'>'.$tresult[1]."</option>\n"; |
|---|
| 110 |
} |
|---|
| 111 |
} |
|---|
| 112 |
?> |
|---|
| 113 |
</select> |
|---|
| 114 |
</td> |
|---|
| 115 |
</tr> |
|---|
| 116 |
<?php } ?> |
|---|
| 117 |
<tr> |
|---|
| 118 |
<td><a href="#" class="info"><?php echo _("Repeat")?><span><?php echo _("Key to press that will allow for the message to be replayed. If you choose this option there will be a short delay inserted after the message. If a longer delay is needed it should be incoporated into the recording.")?></span></a></td> |
|---|
| 119 |
<td> |
|---|
| 120 |
<select name="repeat_msg"/> |
|---|
| 121 |
<?php |
|---|
| 122 |
$default = isset($repeat_msg) ? $repeat_msg : ''; |
|---|
| 123 |
for ($i=0; $i<=9; $i++ ) { |
|---|
| 124 |
$digits[]="$i"; |
|---|
| 125 |
} |
|---|
| 126 |
$digits[] = '*'; |
|---|
| 127 |
$digits[] = '#'; |
|---|
| 128 |
echo '<option value=""'.($default == '' ? ' SELECTED' : '').'>'._("Disable")."</option>"; |
|---|
| 129 |
foreach ($digits as $digit) { |
|---|
| 130 |
echo '<option value="'.$digit.'"'.($digit == $default ? ' SELECTED' : '').'>'.$digit."</option>\n"; |
|---|
| 131 |
} |
|---|
| 132 |
?> |
|---|
| 133 |
</select> |
|---|
| 134 |
</td> |
|---|
| 135 |
</tr> |
|---|
| 136 |
<tr> |
|---|
| 137 |
<td><a href="#" class="info"><?php echo _("Allow Skip")?><span><?php echo _("If the caller is allowed to press a key to skip the message.")?></span></a></td> |
|---|
| 138 |
<td><input type="checkbox" name="allow_skip" value="1" <?php echo ($allow_skip ? 'CHECKED' : ''); ?> /></td> |
|---|
| 139 |
</tr> |
|---|
| 140 |
<tr> |
|---|
| 141 |
<td><a href="#" class="info"><?php echo _("Return to IVR")?><span><?php echo _("If this announcement came from an IVR and this box is checked, the destination below will be ignored and instead it will return to the calling IVR. Otherwise, the destinatino below will be taken. Don't check if not using in this mode. <br>The IVR return location will be to the last IVR in the call chain that was called so be careful to only check when needed. For example, if an IVR directs a call to another destination which eventually calls this annoucement and this box is checked, it will return to that IVR which may not be the expected behavior.")?></span></a></td> |
|---|
| 142 |
<td><input type="checkbox" name="return_ivr" value="1" <?php echo ($return_ivr ? 'CHECKED' : ''); ?> /></td> |
|---|
| 143 |
</tr> |
|---|
| 144 |
<tr> |
|---|
| 145 |
<td><a href="#" class="info"><?php echo _("Don't Answer Channel")?><span><?php echo _("Check this to keep the channel from explicitly being answered. When checked, the message will be played and if the channel is not already answered it will be delivered as early media if the channel supports that. When not checked, the channel is answered followed by a 1 second delay. When using an annoucement from an IVR or other sources that have already answered the channel, that 1 second delay may not be desired.")?></span></a></td> |
|---|
| 146 |
<td><input type="checkbox" name="noanswer" value="1" <?php echo ($noanswer ? 'CHECKED' : ''); ?> /></td> |
|---|
| 147 |
</tr> |
|---|
| 148 |
|
|---|
| 149 |
<tr><td colspan="2"><br><h5><?php echo _("Destination after playback")?>:<hr></h5></td></tr> |
|---|
| 150 |
|
|---|
| 151 |
<?php |
|---|
| 152 |
//draw goto selects |
|---|
| 153 |
echo drawselects($post_dest,0); |
|---|
| 154 |
?> |
|---|
| 155 |
|
|---|
| 156 |
<tr> |
|---|
| 157 |
<td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"> |
|---|
| 158 |
<?php if ($extdisplay) { echo ' <input name="delete" type="submit" value="'._("Delete").'">'; } ?> |
|---|
| 159 |
</td> |
|---|
| 160 |
|
|---|
| 161 |
</tr> |
|---|
| 162 |
</table> |
|---|
| 163 |
</form> |
|---|
| 164 |
|
|---|
| 165 |
|
|---|
| 166 |
<script language="javascript"> |
|---|
| 167 |
<!-- |
|---|
| 168 |
|
|---|
| 169 |
function checkAnnouncement(theForm) { |
|---|
| 170 |
var msgInvalidDescription = "<?php echo _('Invalid description specified'); ?>"; |
|---|
| 171 |
|
|---|
| 172 |
// set up the Destination stuff |
|---|
| 173 |
setDestinations(theForm, '_post_dest'); |
|---|
| 174 |
|
|---|
| 175 |
// form validation |
|---|
| 176 |
defaultEmptyOK = false; |
|---|
| 177 |
if (isEmpty(theForm.description.value)) |
|---|
| 178 |
return warnInvalid(theForm.description, msgInvalidDescription); |
|---|
| 179 |
|
|---|
| 180 |
if (!validateDestinations(theForm, 1, true)) |
|---|
| 181 |
return false; |
|---|
| 182 |
|
|---|
| 183 |
return true; |
|---|
| 184 |
} |
|---|
| 185 |
//--> |
|---|
| 186 |
</script> |
|---|