| 1 |
<?php |
|---|
| 2 |
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } |
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
$dispnum = 'vmblast'; |
|---|
| 14 |
|
|---|
| 15 |
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
$account = isset($_REQUEST['account']) ? $_REQUEST['account'] : ''; |
|---|
| 19 |
$extdisplay = isset($_REQUEST['extdisplay']) ? ltrim($_REQUEST['extdisplay'],'GRP-') : (($account != '')?$account:''); |
|---|
| 20 |
$description = isset($_REQUEST['description']) ? $_REQUEST['description'] : ''; |
|---|
| 21 |
$audio_label = isset($_REQUEST['audio_label']) ? $_REQUEST['audio_label'] : -1; |
|---|
| 22 |
$password = isset($_REQUEST['password']) ? $_REQUEST['password'] : ''; |
|---|
| 23 |
$default_group = isset($_REQUEST['default_group']) ? $_REQUEST['default_group'] : '0'; |
|---|
| 24 |
$vmblast_list = isset($_REQUEST['vmblast_list']) ? $_REQUEST['vmblast_list'] : ''; |
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
if(isset($_REQUEST['action'])){ |
|---|
| 28 |
|
|---|
| 29 |
if (isset($account) && !checkRange($account)){ |
|---|
| 30 |
echo "<script>javascript:alert('". _("Warning! Extension")." ".$account." "._("is not allowed for your account").".');</script>"; |
|---|
| 31 |
} else { |
|---|
| 32 |
|
|---|
| 33 |
if ($action == 'addGRP') { |
|---|
| 34 |
|
|---|
| 35 |
$conflict_url = array(); |
|---|
| 36 |
$usage_arr = framework_check_extension_usage($account); |
|---|
| 37 |
if (!empty($usage_arr)) { |
|---|
| 38 |
$conflict_url = framework_display_extension_usage_alert($usage_arr); |
|---|
| 39 |
} else if (vmblast_add($account,$vmblast_list,$description,$audio_label,$password,$default_group)) { |
|---|
| 40 |
$_REQUEST['action'] = 'delGRP'; |
|---|
| 41 |
needreload(); |
|---|
| 42 |
redirect_standard('extdisplay'); |
|---|
| 43 |
} |
|---|
| 44 |
} |
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 |
if ($action == 'delGRP') { |
|---|
| 48 |
vmblast_del($account); |
|---|
| 49 |
needreload(); |
|---|
| 50 |
redirect_standard(); |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 |
if ($action == 'editGRP') { |
|---|
| 55 |
vmblast_del($account); |
|---|
| 56 |
vmblast_add($account,$vmblast_list,$description,$audio_label,$password,$default_group); |
|---|
| 57 |
needreload(); |
|---|
| 58 |
redirect_standard('extdisplay'); |
|---|
| 59 |
} |
|---|
| 60 |
} |
|---|
| 61 |
} |
|---|
| 62 |
?> |
|---|
| 63 |
|
|---|
| 64 |
<div class="rnav"><ul> |
|---|
| 65 |
<li><a id="<?php echo ($extdisplay=='' ? 'current':'') ?>" href="config.php?display=<?php echo urlencode($dispnum)?>"><?php echo _("Add VMBlast Group")?></a></li> <?php |
|---|
| 66 |
|
|---|
| 67 |
$gresults = vmblast_list(); |
|---|
| 68 |
$default_grp = vmblast_get_default_grp(); |
|---|
| 69 |
|
|---|
| 70 |
if (isset($gresults)) { |
|---|
| 71 |
foreach ($gresults as $gresult) { |
|---|
| 72 |
$hl = $gresult[0] == $default_grp ? _(' [DEFAULT]') : ''; |
|---|
| 73 |
echo "<li><a class=\"".($extdisplay==$gresult[0] ? 'current':'')."\" href=\"config.php?display=".urlencode($dispnum)."&extdisplay=".urlencode("GRP-".$gresult[0])."\">".$gresult[1]." ({$gresult[0]})$hl</a></li>"; |
|---|
| 74 |
} |
|---|
| 75 |
} |
|---|
| 76 |
?> |
|---|
| 77 |
</ul></div> |
|---|
| 78 |
<?php |
|---|
| 79 |
if ($action == 'delGRP') { |
|---|
| 80 |
echo '<br><h3>'._("VMBlast Group").' '.$account.' '._("deleted").'!</h3><br><br><br><br><br><br><br><br>'; |
|---|
| 81 |
} else { |
|---|
| 82 |
if ($extdisplay != '') { |
|---|
| 83 |
|
|---|
| 84 |
$thisgrp = vmblast_get($extdisplay); |
|---|
| 85 |
$grplist = $thisgrp['grplist']; |
|---|
| 86 |
$description = $thisgrp['description']; |
|---|
| 87 |
$audio_label = $thisgrp['audio_label']; |
|---|
| 88 |
$password = $thisgrp['password']; |
|---|
| 89 |
$default_group = $thisgrp['default_group']; |
|---|
| 90 |
unset($thisgrp); |
|---|
| 91 |
|
|---|
| 92 |
$delButton = " |
|---|
| 93 |
<form name=delete action=\"{$_SERVER['PHP_SELF']}\" method=POST> |
|---|
| 94 |
<input type=\"hidden\" name=\"display\" value=\"{$dispnum}\"> |
|---|
| 95 |
<input type=\"hidden\" name=\"account\" value=\"".$extdisplay."\"> |
|---|
| 96 |
<input type=\"hidden\" name=\"action\" value=\"delGRP\"> |
|---|
| 97 |
<input type=submit value=\""._("Delete Group")."\"> |
|---|
| 98 |
</form>"; |
|---|
| 99 |
|
|---|
| 100 |
echo "<h2>"._("VMBlast Group").": ".$extdisplay."</h2>"; |
|---|
| 101 |
echo "<p>".$delButton."</p>"; |
|---|
| 102 |
|
|---|
| 103 |
$usage_list = framework_display_destination_usage(vmblast_getdest($extdisplay)); |
|---|
| 104 |
if (!empty($usage_list)) { |
|---|
| 105 |
?> |
|---|
| 106 |
<a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a> |
|---|
| 107 |
<?php |
|---|
| 108 |
} |
|---|
| 109 |
|
|---|
| 110 |
} else { |
|---|
| 111 |
$grplist = array(); |
|---|
| 112 |
$strategy = ''; |
|---|
| 113 |
$ringing = ''; |
|---|
| 114 |
|
|---|
| 115 |
if (!empty($conflict_url)) { |
|---|
| 116 |
echo "<h5>"._("Conflicting Extensions")."</h5>"; |
|---|
| 117 |
echo implode('<br .>',$conflict_url); |
|---|
| 118 |
} |
|---|
| 119 |
echo "<h2>"._("Add VMBlast Group")."</h2>"; |
|---|
| 120 |
} |
|---|
| 121 |
?> |
|---|
| 122 |
<form name="editGRP" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkGRP(editGRP);"> |
|---|
| 123 |
<input type="hidden" name="display" value="<?php echo $dispnum?>"> |
|---|
| 124 |
<input type="hidden" name="action" value="<?php echo ($extdisplay != '' ? 'editGRP' : 'addGRP'); ?>"> |
|---|
| 125 |
<table> |
|---|
| 126 |
<tr> |
|---|
| 127 |
<td colspan="2"><h5><?php echo ($extdisplay != '' ? _("Edit VMBlast Group") : _("Add VMBlast Group")) ?><hr></h5> |
|---|
| 128 |
</td> |
|---|
| 129 |
</tr> |
|---|
| 130 |
<tr> |
|---|
| 131 |
<?php |
|---|
| 132 |
if ($extdisplay != '') { |
|---|
| 133 |
|
|---|
| 134 |
?> |
|---|
| 135 |
<input size="5" type="hidden" name="account" value="<?php echo $extdisplay; ?>" tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 136 |
<?php } else { ?> |
|---|
| 137 |
<td><a href="#" class="info"><?php echo _("VMBlast Number")?>:<span><?php echo _("The number users will dial to voicemail boxes in this VMBlast group")?></span></a></td> |
|---|
| 138 |
<td><input size="5" type="text" name="account" value="<?php if ($gresult[0]==0) { echo "500"; } else { echo $gresult[0] + 1; } ?>" tabindex="<?php echo ++$tabindex;?>"></td> |
|---|
| 139 |
<?php } ?> |
|---|
| 140 |
</tr> |
|---|
| 141 |
|
|---|
| 142 |
<tr> |
|---|
| 143 |
<td> <a href="#" class="info"><?php echo _("Group Description:")?>:<span><?php echo _("Provide a descriptive title for this VMBlast Group.")?></span></a></td> |
|---|
| 144 |
<td><input size="20" maxlength="35" type="text" name="description" value="<?php echo htmlspecialchars($description); ?>" tabindex="<?php echo ++$tabindex;?>"></td> |
|---|
| 145 |
</tr> |
|---|
| 146 |
|
|---|
| 147 |
<?php if(function_exists('recordings_list')) { ?> |
|---|
| 148 |
<tr> |
|---|
| 149 |
<td><a href="#" class="info"><?php echo _("Audio Label:")?><span><?php echo _("Play this message to the caller so they can confirm they have dialed the proper voice mail group number, or have the system simply read the group number.")?></span></a></td> |
|---|
| 150 |
<td> |
|---|
| 151 |
<select name="audio_label" tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 152 |
<?php |
|---|
| 153 |
$tresults = recordings_list(); |
|---|
| 154 |
$default = (isset($audio_label) ? $audio_label : -1); |
|---|
| 155 |
echo '<option value="-1">'._("Read Group Number")."</option>"; |
|---|
| 156 |
echo '<option value="-2"'.(($default == -2) ? ' SELECTED':'').'>'._("Beep Only - No Confirmation")."</option>"; |
|---|
| 157 |
if (isset($tresults[0])) { |
|---|
| 158 |
foreach ($tresults as $tresult) { |
|---|
| 159 |
echo '<option value="'.$tresult[0].'"'.($tresult[0] == $default ? ' SELECTED' : '').'>'.$tresult[1]."</option>\n"; |
|---|
| 160 |
} |
|---|
| 161 |
} |
|---|
| 162 |
?> |
|---|
| 163 |
</select> |
|---|
| 164 |
</td> |
|---|
| 165 |
</tr> |
|---|
| 166 |
<?php } else { ?> |
|---|
| 167 |
<tr> |
|---|
| 168 |
<td><a href="#" class="info"><?php echo _("Audio Label:")?><span><?php echo _("The group number will be played to the caller so they can confirm they have dialed the proper voice mail group number.<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option and choose from recordings.")?></span></a></td> |
|---|
| 169 |
<td> |
|---|
| 170 |
<?php |
|---|
| 171 |
$default = (isset($audio_label) ? $audio_label : -1); |
|---|
| 172 |
?> |
|---|
| 173 |
<input type="hidden" name="audio_label" value="<?php echo $default; ?>"><?php echo ($default != -1 ? $default : _('Read Group Number')); ?> |
|---|
| 174 |
</td> |
|---|
| 175 |
</tr> |
|---|
| 176 |
<?php } |
|---|
| 177 |
?> |
|---|
| 178 |
<tr> |
|---|
| 179 |
<td><a href="#" class="info"><?php echo _("Optional Password")?>:<span><?php echo _('You can optionally include a password to authenticate before providing access to this group voicemail list.')?></span></a></td> |
|---|
| 180 |
<td><input size="12" type="text" name="password" value="<?php echo $password ?>" tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 181 |
</td> |
|---|
| 182 |
</tr> |
|---|
| 183 |
|
|---|
| 184 |
<tr> |
|---|
| 185 |
<td valign='top'><a href='#' class='info'><?php echo _("Voicemail Box List:")."<span><br>"._("Select voice mail boxes to add to this group. Use Ctrl key to select multiple..") ?> |
|---|
| 186 |
<br><br></span></a> |
|---|
| 187 |
</td> |
|---|
| 188 |
<td valign="top"> |
|---|
| 189 |
<select multiple="multiple" name="vmblast_list[]" id="xtnlist" tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 190 |
<?php |
|---|
| 191 |
$results = core_users_list(); |
|---|
| 192 |
if (!is_array($results)) $results = array(); |
|---|
| 193 |
foreach ($results as $result) { |
|---|
| 194 |
if ($result[2] != 'novm') { |
|---|
| 195 |
echo '<option value="'.$result[0].'" '; |
|---|
| 196 |
if (array_search($result[0], $grplist) !== false) echo ' selected="selected" '; |
|---|
| 197 |
echo '>'.$result[0].' ('.$result[1].')</option>'; |
|---|
| 198 |
} |
|---|
| 199 |
} |
|---|
| 200 |
?> |
|---|
| 201 |
</select> |
|---|
| 202 |
<br> |
|---|
| 203 |
</td> |
|---|
| 204 |
</tr> |
|---|
| 205 |
|
|---|
| 206 |
<tr> |
|---|
| 207 |
<td> |
|---|
| 208 |
<a href='#' class='info'><?php echo _("Default VMBlast Group") ?> |
|---|
| 209 |
<span> <?php echo _("Each PBX system can have a single Default Voicemail Blast Group. If specified, extensions can be automatically added (or removed) from this default group in the Extensions (or Users) tab.<br />Making this group the default will uncheck the option from the current default group if specified.") ?> </span> |
|---|
| 210 |
</a> |
|---|
| 211 |
</td> |
|---|
| 212 |
<td> |
|---|
| 213 |
<input type='checkbox' name='default_group' id="default_group" value='1' <?php if ($default_group) { echo 'CHECKED'; } ?> tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 214 |
</td> |
|---|
| 215 |
</tr> |
|---|
| 216 |
|
|---|
| 217 |
<?php |
|---|
| 218 |
|
|---|
| 219 |
// object was initialized in config.php |
|---|
| 220 |
echo $module_hook->hookHtml; |
|---|
| 221 |
?> |
|---|
| 222 |
<tr> |
|---|
| 223 |
<td colspan="2"><br><h6><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" tabindex="<?php echo ++$tabindex;?>"></h6></td> |
|---|
| 224 |
|
|---|
| 225 |
</tr> |
|---|
| 226 |
</table> |
|---|
| 227 |
</form> |
|---|
| 228 |
<?php |
|---|
| 229 |
} |
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 |
?> |
|---|
| 233 |
<script language="javascript"> |
|---|
| 234 |
<!-- |
|---|
| 235 |
|
|---|
| 236 |
function checkGRP(theForm) { |
|---|
| 237 |
var msgInvalidGrpNum = "<?php echo _('Invalid Group Number specified'); ?>"; |
|---|
| 238 |
var msgInvalidGrpNumStartWithZero = "<?php echo _('Group numbers with more than one digit cannot begin with 0'); ?>"; |
|---|
| 239 |
var msgInvalidExtList = "<?php echo _('Please enter an extension list.'); ?>"; |
|---|
| 240 |
var msgInvalidDescription = "<?php echo _('Please enter a valid Group Description'); ?>"; |
|---|
| 241 |
var msgInvalidPassword = "<?php echo _('Please enter a valid numeric password, only numbers are allowed'); ?>"; |
|---|
| 242 |
var msgInvalidExtList = "<?php echo _('Please select at least one extension'); ?>"; |
|---|
| 243 |
|
|---|
| 244 |
// form validation |
|---|
| 245 |
defaultEmptyOK = false; |
|---|
| 246 |
if (!isInteger(theForm.account.value)) { |
|---|
| 247 |
return warnInvalid(theForm.account, msgInvalidGrpNum); |
|---|
| 248 |
} else if (theForm.account.value.indexOf('0') == 0 && theForm.account.value.length > 1) { |
|---|
| 249 |
return warnInvalid(theForm.account, msgInvalidGrpNumStartWithZero); |
|---|
| 250 |
} |
|---|
| 251 |
|
|---|
| 252 |
defaultEmptyOK = true; |
|---|
| 253 |
if (!isInteger(theForm.password.value)) |
|---|
| 254 |
return warnInvalid(theForm.password, msgInvalidPassword); |
|---|
| 255 |
|
|---|
| 256 |
defaultEmptyOK = false; |
|---|
| 257 |
if (!isAlphanumeric(theForm.description.value)) |
|---|
| 258 |
return warnInvalid(theForm.description, msgInvalidDescription); |
|---|
| 259 |
|
|---|
| 260 |
var selected = 0; |
|---|
| 261 |
for (var i=0; i < theForm.xtnlist.options.length; i++) { |
|---|
| 262 |
if (theForm.xtnlist.options[i].selected) selected += 1; |
|---|
| 263 |
} |
|---|
| 264 |
if (selected < 1) { |
|---|
| 265 |
theForm.xtnlist.focus(); |
|---|
| 266 |
alert(msgInvalidExtList); |
|---|
| 267 |
return false; |
|---|
| 268 |
} |
|---|
| 269 |
|
|---|
| 270 |
return true; |
|---|
| 271 |
} |
|---|
| 272 |
|
|---|
| 273 |
//--> |
|---|
| 274 |
</script> |
|---|
| 275 |
|
|---|
| 276 |
|
|---|