| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
/** |
|---|
| 4 |
* @file |
|---|
| 5 |
* Functions for the interface to the call monitor recordings |
|---|
| 6 |
*/ |
|---|
| 7 |
|
|---|
| 8 |
/** |
|---|
| 9 |
* Class for settings |
|---|
| 10 |
*/ |
|---|
| 11 |
class Settings { |
|---|
| 12 |
|
|---|
| 13 |
var $protocol_table; |
|---|
| 14 |
var $protocol_config_files; |
|---|
| 15 |
|
|---|
| 16 |
/* |
|---|
| 17 |
* rank (for prioritizing modules) |
|---|
| 18 |
*/ |
|---|
| 19 |
function rank() { |
|---|
| 20 |
|
|---|
| 21 |
$rank = 9; |
|---|
| 22 |
return $rank; |
|---|
| 23 |
} |
|---|
| 24 |
|
|---|
| 25 |
/* |
|---|
| 26 |
* init |
|---|
| 27 |
*/ |
|---|
| 28 |
function init() { |
|---|
| 29 |
|
|---|
| 30 |
// determine what protocol user is using |
|---|
| 31 |
global $ASTERISK_PROTOCOLS; |
|---|
| 32 |
|
|---|
| 33 |
foreach ($ASTERISK_PROTOCOLS as $protocol => $value) { |
|---|
| 34 |
$data = $this->getProtocolRecordSettings($value['table'],$_SESSION['ari_user']['extension']); |
|---|
| 35 |
if (count($data)) { |
|---|
| 36 |
$this->protocol_table = $value['table']; |
|---|
| 37 |
$this->protocol_config_files = $value['config_files']; |
|---|
| 38 |
break; |
|---|
| 39 |
} |
|---|
| 40 |
} |
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
/* |
|---|
| 44 |
* Adds menu item to nav menu |
|---|
| 45 |
* |
|---|
| 46 |
* @param $args |
|---|
| 47 |
* Common arguments |
|---|
| 48 |
*/ |
|---|
| 49 |
function navMenu($args) { |
|---|
| 50 |
|
|---|
| 51 |
$ret = ""; |
|---|
| 52 |
$exten = $_SESSION['ari_user']['extension']; |
|---|
| 53 |
|
|---|
| 54 |
// and we are not logged in as admin |
|---|
| 55 |
if ($exten!=$ARI_ADMIN_USERNAME) { |
|---|
| 56 |
$ret .= "<p><small><small><a href='" . $_SESSION['ARI_ROOT'] . "?m=Settings&f=display'>" . _("Settings") . "</a></small></small></p><br>"; |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
return $ret; |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
/* |
|---|
| 63 |
* Acts on the user settings |
|---|
| 64 |
* |
|---|
| 65 |
* @param $args |
|---|
| 66 |
* Common arguments |
|---|
| 67 |
* @param $a |
|---|
| 68 |
* action |
|---|
| 69 |
*/ |
|---|
| 70 |
function action($args) { |
|---|
| 71 |
|
|---|
| 72 |
global $ARI_ADMIN_USERNAME; |
|---|
| 73 |
global $ASTERISK_VOICEMAIL_CONF; |
|---|
| 74 |
global $SETTINGS_ALLOW_VOICEMAIL_SETTINGS; |
|---|
| 75 |
global $SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET; |
|---|
| 76 |
global $SETTINGS_VOICEMAIL_PASSWORD_LENGTH; |
|---|
| 77 |
global $SETTINGS_VOICEMAIL_PASSWORD_EXACT; |
|---|
| 78 |
global $SETTINGS_ALLOW_CALL_RECORDING_SET; |
|---|
| 79 |
|
|---|
| 80 |
// args |
|---|
| 81 |
$m = getArgument($args,'m'); |
|---|
| 82 |
$a = getArgument($args,'a'); |
|---|
| 83 |
|
|---|
| 84 |
$voicemail_password = getArgument($args,'voicemail_password'); |
|---|
| 85 |
$voicemail_password_confirm = getArgument($args,'voicemail_password_confirm'); |
|---|
| 86 |
$voicemail_email_address = getArgument($args,'voicemail_email_address'); |
|---|
| 87 |
$voicemail_pager_address = getArgument($args,'voicemail_pager_address'); |
|---|
| 88 |
$voicemail_email_enable = getArgument($args,'voicemail_email_enable'); |
|---|
| 89 |
$voicemail_audio_format = getArgument($args,'voicemail_audio_format'); |
|---|
| 90 |
$record_in = getArgument($args,'record_in'); |
|---|
| 91 |
$record_out = getArgument($args,'record_out'); |
|---|
| 92 |
|
|---|
| 93 |
if (isset($_SESSION['ari_user']['voicemail_email'])) { |
|---|
| 94 |
foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { |
|---|
| 95 |
$var = "voicemail_email_$key"; |
|---|
| 96 |
$$var = getArgument($args,$var); |
|---|
| 97 |
} |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
if ($a=='update') { |
|---|
| 101 |
|
|---|
| 102 |
$exten = $_SESSION['ari_user']['extension']; |
|---|
| 103 |
if ($exten!=$ARI_ADMIN_USERNAME) { |
|---|
| 104 |
|
|---|
| 105 |
// Make sure Follow-Me setup has not been deleted for this user since the last refresh |
|---|
| 106 |
$follow_me_disabled_delayed = $_COOKIE['ari_follow_me_disabled']; |
|---|
| 107 |
|
|---|
| 108 |
// voicemail settings |
|---|
| 109 |
if ($SETTINGS_ALLOW_VOICEMAIL_SETTINGS && $_SESSION['ari_user']['voicemail_enabled']==1) { |
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 |
// update voicemail password |
|---|
| 113 |
if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) { |
|---|
| 114 |
|
|---|
| 115 |
// update voicemail password |
|---|
| 116 |
if ($voicemail_password=='' || $voicemail_password_confirm=='') { |
|---|
| 117 |
$_SESSION['ari_error'] = |
|---|
| 118 |
_("Voicemail password not changed") . "<br>" . |
|---|
| 119 |
_("Password and password confirm must not be blank"); |
|---|
| 120 |
} |
|---|
| 121 |
else if ((strlen($voicemail_password)<$SETTINGS_VOICEMAIL_PASSWORD_LENGTH) || !is_numeric($voicemail_password)) { |
|---|
| 122 |
$_SESSION['ari_error'] = |
|---|
| 123 |
_("Voicemail password not changed") . "<br>" . |
|---|
| 124 |
sprintf(_("Passwords must be all numbers and greater than %d digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); |
|---|
| 125 |
} |
|---|
| 126 |
else if (strlen($voicemail_password)!=$SETTINGS_VOICEMAIL_PASSWORD_LENGTH && $SETTINGS_VOICEMAIL_PASSWORD_EXACT || !is_numeric($voicemail_password)) { |
|---|
| 127 |
$_SESSION['ari_error'] = |
|---|
| 128 |
_("Voicemail password not changed") . "<br>" . |
|---|
| 129 |
sprintf(_("Passwords must be all numbers and only %d digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); |
|---|
| 130 |
} |
|---|
| 131 |
else if ($voicemail_password!=$voicemail_password_confirm) { |
|---|
| 132 |
$_SESSION['ari_error'] = |
|---|
| 133 |
_("Voicemail password not changed") . "<br>" . |
|---|
| 134 |
_("Password and password confirm do not match"); |
|---|
| 135 |
} |
|---|
| 136 |
else { |
|---|
| 137 |
|
|---|
| 138 |
// check for writable the files |
|---|
| 139 |
$temp_file = $ASTERISK_VOICEMAIL_CONF . ".tmp"; |
|---|
| 140 |
$fp = fopen($temp_file, "w"); |
|---|
| 141 |
if (!$fp) { |
|---|
| 142 |
$_SESSION['ari_error'] = |
|---|
| 143 |
_("Voicemail password not changed") . "<br>" . |
|---|
| 144 |
sprintf(_("%s does not exist or is not writable"),$temp_file); |
|---|
| 145 |
} |
|---|
| 146 |
else if (!is_writable($ASTERISK_VOICEMAIL_CONF)) { |
|---|
| 147 |
$_SESSION['ari_error'] = |
|---|
| 148 |
_("Voicemail password not changed") . "<br>" . |
|---|
| 149 |
sprintf(_("%s does not exist or is not writable"),$ASTERISK_VOICEMAIL_CONF); |
|---|
| 150 |
} |
|---|
| 151 |
else { |
|---|
| 152 |
|
|---|
| 153 |
// update session |
|---|
| 154 |
$_SESSION['ari_user']['voicemail_password'] = $voicemail_password; |
|---|
| 155 |
|
|---|
| 156 |
// save password |
|---|
| 157 |
$lines = file($ASTERISK_VOICEMAIL_CONF); |
|---|
| 158 |
foreach ($lines as $key => $line) { |
|---|
| 159 |
unset($value); |
|---|
| 160 |
list($var,$value) = split('=>',$line); |
|---|
| 161 |
$var = trim($var); |
|---|
| 162 |
if ($var==$exten && $value) { |
|---|
| 163 |
|
|---|
| 164 |
// write out line with password change |
|---|
| 165 |
$buf = split(',',$value); |
|---|
| 166 |
$buf[0] = $voicemail_password; |
|---|
| 167 |
$line = $var . " => " . join(',', $buf); |
|---|
| 168 |
|
|---|
| 169 |
fwrite($fp, $line); |
|---|
| 170 |
} |
|---|
| 171 |
else { |
|---|
| 172 |
// write out original line with no changes |
|---|
| 173 |
fwrite($fp, $line); |
|---|
| 174 |
} |
|---|
| 175 |
} |
|---|
| 176 |
fclose($fp); |
|---|
| 177 |
unlink($ASTERISK_VOICEMAIL_CONF); |
|---|
| 178 |
rename($temp_file,$ASTERISK_VOICEMAIL_CONF); |
|---|
| 179 |
|
|---|
| 180 |
$voicemail_reload = 1; |
|---|
| 181 |
} |
|---|
| 182 |
} |
|---|
| 183 |
|
|---|
| 184 |
// voicemail email address |
|---|
| 185 |
if ($voicemail_email_enable && |
|---|
| 186 |
($voicemail_email_address && !preg_match('/@/',$voicemail_email_address) || |
|---|
| 187 |
($voicemail_pager_address && !preg_match('/@/',$voicemail_pager_address)))) { |
|---|
| 188 |
$_SESSION['ari_error'] = |
|---|
| 189 |
_("Voicemail email and pager address not changed") . "<br>" . |
|---|
| 190 |
("'$voicemail_email_address' and '$voicemail_pager_address' must be a valid email addresses"); |
|---|
| 191 |
} |
|---|
| 192 |
else { |
|---|
| 193 |
|
|---|
| 194 |
// check for writable the files |
|---|
| 195 |
$temp_file = $ASTERISK_VOICEMAIL_CONF . ".tmp"; |
|---|
| 196 |
$fp = fopen($temp_file, "w"); |
|---|
| 197 |
if (!$fp) { |
|---|
| 198 |
$_SESSION['ari_error'] = |
|---|
| 199 |
_("Voicemail email settings not changed") . "<br>" . |
|---|
| 200 |
sprintf(_("%s does not exist or is not writable"),$temp_file); |
|---|
| 201 |
} |
|---|
| 202 |
else if (!is_writable($ASTERISK_VOICEMAIL_CONF)) { |
|---|
| 203 |
$_SESSION['ari_error'] = |
|---|
| 204 |
_("Voicemail email settings not changed") . "<br>" . |
|---|
| 205 |
sprintf(_("%s does not exist or is not writable"),$ASTERISK_VOICEMAIL_CONF); |
|---|
| 206 |
} |
|---|
| 207 |
else { |
|---|
| 208 |
|
|---|
| 209 |
// store cookie |
|---|
| 210 |
if ($voicemail_email_enable) { |
|---|
| 211 |
setcookie("ari_voicemail_email_address", $voicemail_email_address, time()+365*24*60*60); |
|---|
| 212 |
setcookie("ari_voicemail_pager_address", $voicemail_pager_address, time()+365*24*60*60); |
|---|
| 213 |
foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { |
|---|
| 214 |
$var = "voicemail_email_$key"; |
|---|
| 215 |
$var_cookie = "ari_" . $var; |
|---|
| 216 |
setcookie("$var_cookie", $$var, time()+365*24*60*60); |
|---|
| 217 |
} |
|---|
| 218 |
} |
|---|
| 219 |
|
|---|
| 220 |
// update session |
|---|
| 221 |
$_SESSION['ari_user']['voicemail_email_enable'] = $voicemail_email_enable; |
|---|
| 222 |
if ($voicemail_email_enable) { |
|---|
| 223 |
$_SESSION['ari_user']['voicemail_email_address'] = $voicemail_email_address; |
|---|
| 224 |
$_SESSION['ari_user']['voicemail_pager_address'] = $voicemail_pager_address; |
|---|
| 225 |
foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { |
|---|
| 226 |
$option = "voicemail_email_$key"; |
|---|
| 227 |
$_SESSION['ari_user']['voicemail_email'][$key] = $$option; |
|---|
| 228 |
} |
|---|
| 229 |
} |
|---|
| 230 |
|
|---|
| 231 |
// save settings |
|---|
| 232 |
if (!$voicemail_email_enable) { |
|---|
| 233 |
$voicemail_email_address = ''; |
|---|
| 234 |
$voicemail_pager_address = ''; |
|---|
| 235 |
} |
|---|
| 236 |
|
|---|
| 237 |
$lines = file($ASTERISK_VOICEMAIL_CONF); |
|---|
| 238 |
foreach ($lines as $key => $line) { |
|---|
| 239 |
unset($value); |
|---|
| 240 |
list($var,$value) = split('=>',$line); |
|---|
| 241 |
$var = trim($var); |
|---|
| 242 |
if ($var==$exten && $value) { |
|---|
| 243 |
|
|---|
| 244 |
// write out line with voicemail email change |
|---|
| 245 |
$buf = split(',',$value); |
|---|
| 246 |
$buf[2] = $voicemail_email_address; |
|---|
| 247 |
$buf[3] = $voicemail_pager_address; |
|---|
| 248 |
|
|---|
| 249 |
foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { |
|---|
| 250 |
$option = "voicemail_email_$key"; |
|---|
| 251 |
if ($$option && $key) { |
|---|
| 252 |
$options .= $key . "=" . $value; |
|---|
| 253 |
} |
|---|
| 254 |
else { |
|---|
| 255 |
$options .= $key . "=no"; |
|---|
| 256 |
} |
|---|
| 257 |
$options .= "|"; |
|---|
| 258 |
} |
|---|
| 259 |
$buf[4] = substr($options, 0, -1); |
|---|
| 260 |
|
|---|
| 261 |
$line = $var . " =>" . join(',', $buf); |
|---|
| 262 |
if (substr($line, 0, -1)!="\n") { |
|---|
| 263 |
$line .= "\n"; |
|---|
| 264 |
} |
|---|
| 265 |
|
|---|
| 266 |
fwrite($fp, $line); |
|---|
| 267 |
} |
|---|
| 268 |
else { |
|---|
| 269 |
|
|---|
| 270 |
// write out original line with no changes |
|---|
| 271 |
fwrite($fp, $line); |
|---|
| 272 |
} |
|---|
| 273 |
} |
|---|
| 274 |
fclose($fp); |
|---|
| 275 |
unlink($ASTERISK_VOICEMAIL_CONF); |
|---|
| 276 |
rename($temp_file,$ASTERISK_VOICEMAIL_CONF); |
|---|
| 277 |
|
|---|
| 278 |
$voicemail_reload = 1; |
|---|
| 279 |
} |
|---|
| 280 |
} |
|---|
| 281 |
|
|---|
| 282 |
// reload asterisk voicemail |
|---|
| 283 |
if ($voicemail_reload) { |
|---|
| 284 |
$this->reloadAsteriskVoicemail(); |
|---|
| 285 |
} |
|---|
| 286 |
} |
|---|
| 287 |
|
|---|
| 288 |
// update voicemail audio format setting |
|---|
| 289 |
setcookie("ari_voicemail_audio_format", $voicemail_audio_format, time()+365*24*60*60); |
|---|
| 290 |
} |
|---|
| 291 |
|
|---|
| 292 |
// update call monitor record setting |
|---|
| 293 |
if ($SETTINGS_ALLOW_CALL_RECORDING_SET) { |
|---|
| 294 |
if ($record_in && $record_out) { |
|---|
| 295 |
$this->setRecordSettings($exten,$record_in,$record_out); |
|---|
| 296 |
} |
|---|
| 297 |
} |
|---|
| 298 |
} |
|---|
| 299 |
} |
|---|
| 300 |
|
|---|
| 301 |
// redirect to see updated page |
|---|
| 302 |
$ret .= " |
|---|
| 303 |
<head> |
|---|
| 304 |
<script> |
|---|
| 305 |
<!-- |
|---|
| 306 |
window.location = \"" . $_SESSION['ARI_ROOT'] . "?m=" . $m . "\" |
|---|
| 307 |
// --> |
|---|
| 308 |
</script> |
|---|
| 309 |
</head>"; |
|---|
| 310 |
|
|---|
| 311 |
return $ret; |
|---|
| 312 |
} |
|---|
| 313 |
|
|---|
| 314 |
/* |
|---|
| 315 |
* Displays stats page |
|---|
| 316 |
* |
|---|
| 317 |
* @param $args |
|---|
| 318 |
* Common arguments |
|---|
| 319 |
*/ |
|---|
| 320 |
function display($args) { |
|---|
| 321 |
global $SETTINGS_ALLOW_VOICEMAIL_SETTINGS; |
|---|
| 322 |
global $SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET; |
|---|
| 323 |
global $SETTINGS_VOICEMAIL_PASSWORD_LENGTH; |
|---|
| 324 |
global $SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS; |
|---|
| 325 |
global $ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT; |
|---|
| 326 |
global $SETTINGS_ALLOW_CALL_RECORDING_SET; |
|---|
| 327 |
|
|---|
| 328 |
global $loaded_modules; |
|---|
| 329 |
|
|---|
| 330 |
// args |
|---|
| 331 |
$m = getArgument($args,'m'); |
|---|
| 332 |
$q = getArgument($args,'q'); |
|---|
| 333 |
$start = getArgument($args,'start'); |
|---|
| 334 |
$span = getArgument($args,'span'); |
|---|
| 335 |
|
|---|
| 336 |
$displayname = $_SESSION['ari_user']['displayname']; |
|---|
| 337 |
$exten = $_SESSION['ari_user']['extension']; |
|---|
| 338 |
|
|---|
| 339 |
$language = new Language(); |
|---|
| 340 |
$display = new DisplaySearch(); |
|---|
| 341 |
|
|---|
| 342 |
// get data |
|---|
| 343 |
$data = $this->getRecordSettings($_SESSION['ari_user']['extension']); |
|---|
| 344 |
|
|---|
| 345 |
// lang setting options |
|---|
| 346 |
if (extension_loaded('gettext')) { |
|---|
| 347 |
$setLangText = "<p class='lang'>" . _("Language:") . " " . $language->GetForm() . "</p>"; |
|---|
| 348 |
} |
|---|
| 349 |
|
|---|
| 350 |
|
|---|
| 351 |
// voicemail settings |
|---|
| 352 |
if ($SETTINGS_ALLOW_VOICEMAIL_SETTINGS && $_SESSION['ari_user']['voicemail_enabled']==1 && |
|---|
| 353 |
in_array('voicemail',array_keys($loaded_modules))) { |
|---|
| 354 |
if ($SETTINGS_ALLOW_VOICEMAIL_PASSWORD_SET) { |
|---|
| 355 |
|
|---|
| 356 |
if ($SETTINGS_VOICEMAIL_PASSWORD_EXACT) { |
|---|
| 357 |
$voicemail_password_length_message = sprintf(_("Passwords must be all numbers and only %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); |
|---|
| 358 |
} |
|---|
| 359 |
else { |
|---|
| 360 |
$voicemail_password_length_message = sprintf(_("Passwords must be all numbers and at least %s digits"),$SETTINGS_VOICEMAIL_PASSWORD_LENGTH); |
|---|
| 361 |
} |
|---|
| 362 |
|
|---|
| 363 |
$set_voicemail_password_text = " |
|---|
| 364 |
<tr> |
|---|
| 365 |
<td>" . _("Voicemail Password:") . "</td> |
|---|
| 366 |
<td> |
|---|
| 367 |
<input name='voicemail_password' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . "> |
|---|
| 368 |
</td> |
|---|
| 369 |
</tr> |
|---|
| 370 |
<tr> |
|---|
| 371 |
<td>" . _("Enter again to confirm:") . "</td> |
|---|
| 372 |
<td> |
|---|
| 373 |
<input name='voicemail_password_confirm' type='password' size=16 value=" . $_SESSION['ari_user']['voicemail_password'] . "> |
|---|
| 374 |
</td> |
|---|
| 375 |
</tr> |
|---|
| 376 |
<tr> |
|---|
| 377 |
<td class='note' colspan=2><small>" . $voicemail_password_length_message . "</small></td> |
|---|
| 378 |
</tr>"; |
|---|
| 379 |
} |
|---|
| 380 |
|
|---|
| 381 |
if (isset($_SESSION['ari_user']['voicemail_email'])) { |
|---|
| 382 |
|
|---|
| 383 |
if ($_SESSION['ari_user']['voicemail_email_enable']) { |
|---|
| 384 |
$voicemail_email_address = $_SESSION['ari_user']['voicemail_email_address']; |
|---|
| 385 |
$voicemail_pager_address = $_SESSION['ari_user']['voicemail_pager_address']; |
|---|
| 386 |
$voicemail_email_enable = 'checked'; |
|---|
| 387 |
|
|---|
| 388 |
foreach (array_keys($_SESSION['ari_user']['voicemail_email']) as $key) { |
|---|
| 389 |
$var = "voicemail_email_$key"; |
|---|
| 390 |
$var_enable = $var . "enable"; |
|---|
| 391 |
if ($_SESSION['ari_user']['voicemail_email'][$key]=='yes') { |
|---|
| 392 |
$$var_enable = 'checked'; |
|---|
| 393 |
} |
|---|
| 394 |
} |
|---|
| 395 |
} |
|---|
| 396 |
else { |
|---|
| 397 |
|
|---|
| 398 |
$voicemail_email_address = $_COOKIE['ari_voicemail_email_address']; |
|---|
| 399 |
$voicemail_email_text_box_options = "disabled style='background: #DDD;'"; |
|---|
| 400 |
$voicemail_pager_address = $_COOKIE['ari_voicemail_pager_address']; |
|---|
| 401 |
$voicemail_pager_text_box_options = "disabled style='background: #DDD;'"; |
|---|
| 402 |
|
|---|
| 403 |
foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { |
|---|
| 404 |
$var = "voicemail_email_$key"; |
|---|
| 405 |
$var_cookie = "ari_" . $var; |
|---|
| 406 |
$var_enable = $var . "enable"; |
|---|
| 407 |
$var_text_box_options = $var . "text_box_options"; |
|---|
| 408 |
|
|---|
| 409 |
$$var_text_box_options = "disabled"; |
|---|
| 410 |
if ($_COOKIE[$var_cookie]=='yes') { |
|---|
| 411 |
$$var_enable = 'checked'; |
|---|
| 412 |
} |
|---|
| 413 |
} |
|---|
| 414 |
} |
|---|
| 415 |
|
|---|
| 416 |
$set_voicemail_email_text = " |
|---|
| 417 |
|
|---|
| 418 |
<tr> |
|---|
| 419 |
<td> " . _("Email Notification") . " <input " . $voicemail_email_enable . " type=checkbox name='voicemail_email_enable' value='1' OnClick=\"disable_fields(); return true;\"> |
|---|
| 420 |
<small> " ._("Enable") . " </small> |
|---|
| 421 |
</td> |
|---|
| 422 |
</tr><tr> |
|---|
| 423 |
<td><a href='#' class='info'>" . _("Email Voicemail To:") . "<span>" . ("Email a notification, including audio file if indicated below.") . " </span></a></td> |
|---|
| 424 |
<td> |
|---|
| 425 |
<input " . $voicemail_email_text_box_options . " name='voicemail_email_address' type='text' size=48 value='" . $voicemail_email_address . "'> |
|---|
| 426 |
</td> |
|---|
| 427 |
</tr> |
|---|
| 428 |
<tr> |
|---|
| 429 |
<td><a href='#' class='info'>" . _("Pager Email Notification To:") . "<span>" . ("Email a short notification") . " </span></a></td> |
|---|
| 430 |
<td> |
|---|
| 431 |
<input " . $voicemail_pager_text_box_options . " name='voicemail_pager_address' type='text' size=48 value='" . $voicemail_pager_address . "'> |
|---|
| 432 |
</td> |
|---|
| 433 |
</tr> |
|---|
| 434 |
<tr> |
|---|
| 435 |
<td></td> |
|---|
| 436 |
</tr>"; |
|---|
| 437 |
|
|---|
| 438 |
foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { |
|---|
| 439 |
|
|---|
| 440 |
$var = "voicemail_email_$key"; |
|---|
| 441 |
$var_enable = $var . "enable"; |
|---|
| 442 |
$var_text_box_options = $var . "text_box_options"; |
|---|
| 443 |
if ($SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]) { |
|---|
| 444 |
$var_text = $SETTINGS_VOICEMAIL_EMAIL_OPTION_DESCRIPTIONS[$key]; |
|---|
| 445 |
} |
|---|
| 446 |
else { |
|---|
| 447 |
$var_text = $key; |
|---|
| 448 |
} |
|---|
| 449 |
|
|---|
| 450 |
if ($value != 'yes' && $value != 'no' && $value !='') { |
|---|
| 451 |
|
|---|
| 452 |
$size = strlen($value) - 1; |
|---|
| 453 |
$set_voicemail_email_text .= " |
|---|
| 454 |
<tr> |
|---|
| 455 |
<td></td> |
|---|
| 456 |
<td> |
|---|
| 457 |
<input type=text size='" . $size . "' name='" . $var . "' value='" . $value . "'> |
|---|
| 458 |
<small>" . $var_text . "</small> |
|---|
| 459 |
</td> |
|---|
| 460 |
</tr>"; |
|---|
| 461 |
} |
|---|
| 462 |
else { |
|---|
| 463 |
|
|---|
| 464 |
$set_voicemail_email_text .= " |
|---|
| 465 |
<tr> |
|---|
| 466 |
<td></td> |
|---|
| 467 |
<td> |
|---|
| 468 |
<input " . $$var_enable . " " . $$var_text_box_options . " type=checkbox name='" . $var . "'> |
|---|
| 469 |
<small>" . $var_text . "</small> |
|---|
| 470 |
</td> |
|---|
| 471 |
</tr>"; |
|---|
| 472 |
} |
|---|
| 473 |
} |
|---|
| 474 |
} |
|---|
| 475 |
|
|---|
| 476 |
$wav_enable = 'selected'; |
|---|
| 477 |
if ($_COOKIE['ari_voicemail_audio_format']=='.gsm'|| |
|---|
| 478 |
($_COOKIE['ari_voicemail_audio_format']=='' && $ARI_VOICEMAIL_AUDIO_FORMAT_DEFAULT='.gsm')) { |
|---|
| 479 |
$wav_enable = ''; |
|---|
| 480 |
$gsm_enable = 'selected'; |
|---|
| 481 |
} |
|---|
| 482 |
|
|---|
| 483 |
$set_voicemail_audio_format_text = " |
|---|
| 484 |
<tr> |
|---|
| 485 |
<td>" . _("Audio Format:") . "</td> |
|---|
| 486 |
<td> |
|---|
| 487 |
<select name='voicemail_audio_format'> |
|---|
| 488 |
<option value='.wav' " . $wav_enable . ">" . _("Best Quality") . " (.wav)</option> |
|---|
| 489 |
<option value='.gsm' " . $gsm_enable . ">" . _("Smallest Download") . " (.gsm)</option> |
|---|
| 490 |
</select> |
|---|
| 491 |
</td> |
|---|
| 492 |
</tr>"; |
|---|
| 493 |
|
|---|
| 494 |
$set_voicemail_text = " |
|---|
| 495 |
<table class='settings'> |
|---|
| 496 |
<tr> |
|---|
| 497 |
<td><h3>" . _("Voicemail Settings") . "</h3></td> |
|---|
| 498 |
</tr> |
|---|
| 499 |
" . $set_voicemail_password_text . " |
|---|
| 500 |
" . $set_voicemail_email_text . " |
|---|
| 501 |
" . $set_voicemail_audio_format_text . " |
|---|
| 502 |
</table>"; |
|---|
| 503 |
} |
|---|
| 504 |
|
|---|
| 505 |
// call monitor settings |
|---|
| 506 |
if ($this->getFreePBXVersion() && |
|---|
| 507 |
$SETTINGS_ALLOW_CALL_RECORDING_SET && |
|---|
| 508 |
in_array('callmonitor',array_keys($loaded_modules))) { |
|---|
| 509 |
|
|---|
| 510 |
foreach($data as $key=>$value) { |
|---|
| 511 |
if ($key=='record_in') { |
|---|
| 512 |
if ($value=='Always') { |
|---|
| 513 |
$ri_always = 'checked=checked'; |
|---|
| 514 |
} |
|---|
| 515 |
elseif ($value=='Never') { |
|---|
| 516 |
$ri_never = 'checked=checked'; |
|---|
| 517 |
} |
|---|
| 518 |
elseif ($value=='Adhoc') { |
|---|
| 519 |
$ri_on_demand = 'checked=checked'; |
|---|
| 520 |
} |
|---|
| 521 |
} |
|---|
| 522 |
if ($key=='record_out') { |
|---|
| 523 |
if ($value=='Always') { |
|---|
| 524 |
$ro_always = 'checked=checked'; |
|---|
| 525 |
} |
|---|
| 526 |
elseif ($value=='Never') { |
|---|
| 527 |
$ro_never = 'checked=checked'; |
|---|
| 528 |
} |
|---|
| 529 |
elseif ($value=='Adhoc') { |
|---|
| 530 |
$ro_on_demand = 'checked=checked'; |
|---|
| 531 |
} |
|---|
| 532 |
} |
|---|
| 533 |
} |
|---|
| 534 |
|
|---|
| 535 |
$set_callmonitor_text = " |
|---|
| 536 |
<table class='settings'> |
|---|
| 537 |
<tr> |
|---|
| 538 |
<td><h3>" . _("Call Monitor Settings") . "</h3></td> |
|---|
| 539 |
</tr> |
|---|
| 540 |
<tr> |
|---|
| 541 |
<td>" . _("Record INCOMING:") . " </td> |
|---|
| 542 |
<td> |
|---|
| 543 |
<input type='radio' name='record_in' value='Always' " . $ri_always . "/> " . _("Always") . " |
|---|
| 544 |
<input type='radio' name='record_in' value='Never' " . $ri_never . "/> " . _("Never") . " |
|---|
| 545 |
<input type='radio' name='record_in' value='Adhoc' " . $ri_on_demand . "/> " . _("On-Demand") . " |
|---|
| 546 |
</td> |
|---|
| 547 |
</tr> |
|---|
| 548 |
<tr> |
|---|
| 549 |
<td>" . _("Record OUTGOING:") . " </td> |
|---|
| 550 |
<td> |
|---|
| 551 |
<input type='radio' name='record_out' value='Always' " . $ro_always . "/> " . _("Always") . " |
|---|
| 552 |
<input type='radio' name='record_out' value='Never' " . $ro_never . "/> " . _("Never") . " |
|---|
| 553 |
<input type='radio' name='record_out' value='Adhoc' " . $ro_on_demand . "/> " . _("On-Demand") . " |
|---|
| 554 |
</td> |
|---|
| 555 |
</tr> |
|---|
| 556 |
</table>"; |
|---|
| 557 |
} |
|---|
| 558 |
|
|---|
| 559 |
// javascript enable options |
|---|
| 560 |
if (isset($_SESSION['ari_user']['voicemail_email']) && |
|---|
| 561 |
in_array('voicemail',array_keys($loaded_modules))) { |
|---|
| 562 |
foreach ($_SESSION['ari_user']['voicemail_email'] as $key => $value) { |
|---|
| 563 |
$var = "voicemail_email_$key"; |
|---|
| 564 |
$js_voicemail_email_disable .= " |
|---|
| 565 |
document.ari_settings.$var.disabled = false;"; |
|---|
| 566 |
$js_voicemail_email_enable .= " |
|---|
| 567 |
document.ari_settings.$var.disabled = true;"; |
|---|
| 568 |
} |
|---|
| 569 |
|
|---|
| 570 |
$js_voicemail_script = " |
|---|
| 571 |
if (document.ari_settings.voicemail_email_enable.checked) { |
|---|
| 572 |
document.ari_settings.voicemail_email_address.style.backgroundColor = '#FFF'; |
|---|
| 573 |
document.ari_settings.voicemail_email_address.disabled = false; |
|---|
| 574 |
document.ari_settings.voicemail_email_address.value='" . $voicemail_email_address . "'; |
|---|
| 575 |
document.ari_settings.voicemail_pager_address.style.backgroundColor = '#FFF'; |
|---|
| 576 |
document.ari_settings.voicemail_pager_address.disabled = false; |
|---|
| 577 |
document.ari_settings.voicemail_pager_address.value='" . $voicemail_pager_address . "'; |
|---|
| 578 |
" . $js_voicemail_email_disable . " |
|---|
| 579 |
} |
|---|
| 580 |
else { |
|---|
| 581 |
document.ari_settings.voicemail_email_address.style.backgroundColor = '#DDD'; |
|---|
| 582 |
document.ari_settings.voicemail_email_address.disabled = true; |
|---|
| 583 |
document.ari_settings.voicemail_pager_address.style.backgroundColor = '#DDD'; |
|---|
| 584 |
document.ari_settings.voicemail_pager_address.disabled = true; |
|---|
| 585 |
" . $js_voicemail_email_enable . " |
|---|
| 586 |
}"; |
|---|
| 587 |
} |
|---|
| 588 |
|
|---|
| 589 |
// build page content |
|---|
| 590 |
$ret .= checkErrorMessage(); |
|---|
| 591 |
|
|---|
| 592 |
$headerText = sprintf(_("Settings for %s (%s)"),$displayname,$exten); |
|---|
| 593 |
|
|---|
| 594 |
$ret .= $display->displayHeaderText($headerText); |
|---|
| 595 |
$ret .= $display->displayLine(); |
|---|
| 596 |
|
|---|
| 597 |
$ret .= " |
|---|
| 598 |
<SCRIPT LANGUAGE='JavaScript'> |
|---|
| 599 |
<!-- Begin |
|---|
| 600 |
function rowCounter(field, maxlimit) { |
|---|
| 601 |
temp = field.value.split('\u000A',maxlimit+1) |
|---|
| 602 |
field.value = temp.join('\u000A') |
|---|
| 603 |
if (temp.length == maxlimit+1) { |
|---|
| 604 |
field.value = field.value.substring(0, field.value.length-1) |
|---|
| 605 |
} |
|---|
| 606 |
} |
|---|
| 607 |
|
|---|
| 608 |
function disable_fields() {"; |
|---|
| 609 |
$ret .= $js_voicemail_script . " |
|---|
| 610 |
} |
|---|
| 611 |
// End --> |
|---|
| 612 |
</script>"; |
|---|
| 613 |
|
|---|
| 614 |
$ret .= " |
|---|
| 615 |
" . $setLangText . " |
|---|
| 616 |
<form class='settings' name='ari_settings' action='' method='GET'> |
|---|
| 617 |
<input type=hidden name=m value=" . $m . "> |
|---|
| 618 |
<input type=hidden name=f value='action'> |
|---|
| 619 |
<input type=hidden name=a value='update'> |
|---|
| 620 |
<br> |
|---|
| 621 |
" . $set_voicemail_text . " |
|---|
| 622 |
<br> |
|---|
| 623 |
" . $set_callmonitor_text . " |
|---|
| 624 |
<br> |
|---|
| 625 |
<input name='submit' type='submit' value='" . _("Update") . "'> |
|---|
| 626 |
</form>"; |
|---|
| 627 |
|
|---|
| 628 |
return $ret; |
|---|
| 629 |
} |
|---|
| 630 |
|
|---|
| 631 |
|
|---|
| 632 |
|
|---|
| 633 |
|
|---|
| 634 |
|
|---|
| 635 |
|
|---|
| 636 |
/* |
|---|
| 637 |
* Sets Asterisk call recording setting |
|---|
| 638 |
* |
|---|
| 639 |
* @param $exten |
|---|
| 640 |
* Extension to modify |
|---|
| 641 |
* @param $direction |
|---|
| 642 |
* Call direction |
|---|
| 643 |
* @param $state |
|---|
| 644 |
* State to set to |
|---|
| 645 |
*/ |
|---|
| 646 |
function setRecordSettings($exten,$state_in,$state_out) { |
|---|
| 647 |
|
|---|
| 648 |
global $asterisk_manager_interface; |
|---|
| 649 |
|
|---|
| 650 |
if (version_compare($this->getFreePBXVersion(), '1.10', '<')) { |
|---|
| 651 |
|
|---|
| 652 |
if ($state_in=="Always") { |
|---|
| 653 |
$type_opt = "put"; |
|---|
| 654 |
$value_opt = " " . "ENABLED"; |
|---|
| 655 |
} |
|---|
| 656 |
elseif ($state_in=="Never") { |
|---|
| 657 |
$type_opt = "put"; |
|---|
| 658 |
$value_opt = " " . "DISABLED"; |
|---|
| 659 |
} |
|---|
| 660 |
else { |
|---|
| 661 |
$type_opt = "del"; |
|---|
| 662 |
$value_opt = ""; |
|---|
| 663 |
} |
|---|
| 664 |
$response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt RECORD-IN $exten $value_opt\r\n\r\n"); |
|---|
| 665 |
|
|---|
| 666 |
if ($state_out=="Always") { |
|---|
| 667 |
$type_opt = "put"; |
|---|
| 668 |
$value_opt = " " . "ENABLED"; |
|---|
| 669 |
} |
|---|
| 670 |
elseif ($state_out=="Never") { |
|---|
| 671 |
$type_opt = "put"; |
|---|
| 672 |
$value_opt = " " . "DISABLED"; |
|---|
| 673 |
} |
|---|
| 674 |
else { |
|---|
| 675 |
$type_opt = "del"; |
|---|
| 676 |
$value_opt = ""; |
|---|
| 677 |
} |
|---|
| 678 |
$response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database $type_opt RECORD-OUT $exten $value_opt\r\n\r\n"); |
|---|
| 679 |
} |
|---|
| 680 |
else { |
|---|
| 681 |
|
|---|
| 682 |
$value_opt= "out=".$state_out."|in=".$state_in; |
|---|
| 683 |
$response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database put AMPUSER $exten/recording $value_opt\r\n\r\n"); |
|---|
| 684 |
} |
|---|
| 685 |
} |
|---|
| 686 |
|
|---|
| 687 |
/* |
|---|
| 688 |
* Gets record settings for a protocol |
|---|
| 689 |
* |
|---|
| 690 |
* @param $table |
|---|
| 691 |
* Table to pull information from |
|---|
| 692 |
* @param $exten |
|---|
| 693 |
* Extension to get information about |
|---|
| 694 |
* @return $data |
|---|
| 695 |
* call monitor record settings |
|---|
| 696 |
*/ |
|---|
| 697 |
function getProtocolRecordSettings($table,$exten) { |
|---|
| 698 |
|
|---|
| 699 |
global $asterisk_manager_interface; |
|---|
| 700 |
|
|---|
| 701 |
$data = array(); |
|---|
| 702 |
|
|---|
| 703 |
if (version_compare($this->getFreePBXVersion(), '1.10', '<')) { |
|---|
| 704 |
|
|---|
| 705 |
$response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get RECORD-IN $exten\r\n\r\n"); |
|---|
| 706 |
if (preg_match("/ENABLED/",$response)) { |
|---|
| 707 |
$data['record_in'] = 'Always'; |
|---|
| 708 |
} |
|---|
| 709 |
elseif (preg_match("/DISABLED/",$response)) { |
|---|
| 710 |
$data['record_in'] = 'Never'; |
|---|
| 711 |
} |
|---|
| 712 |
else { |
|---|
| 713 |
$data['record_in'] = 'Adhoc'; |
|---|
| 714 |
} |
|---|
| 715 |
|
|---|
| 716 |
$response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get RECORD-OUT $exten\r\n\r\n"); |
|---|
| 717 |
if (preg_match("/ENABLED/",$response)) { |
|---|
| 718 |
$data['record_out'] = 'Always'; |
|---|
| 719 |
} |
|---|
| 720 |
elseif (preg_match("/DISABLED/",$response)) { |
|---|
| 721 |
$data['record_out'] = 'Never'; |
|---|
| 722 |
} |
|---|
| 723 |
else { |
|---|
| 724 |
$data['record_out'] = 'Adhoc'; |
|---|
| 725 |
} |
|---|
| 726 |
} |
|---|
| 727 |
else { |
|---|
| 728 |
|
|---|
| 729 |
$response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: database get AMPUSER $exten/recording\r\n\r\n"); |
|---|
| 730 |
if (strstr($response,"in=Always")) { |
|---|
| 731 |
$data['record_in'] = 'Always'; |
|---|
| 732 |
} |
|---|
| 733 |
elseif (strstr($response,"in=Never")) { |
|---|
| 734 |
$data['record_in'] = 'Never'; |
|---|
| 735 |
} |
|---|
| 736 |
else { |
|---|
| 737 |
$data['record_in'] = 'Adhoc'; |
|---|
| 738 |
} |
|---|
| 739 |
if (strstr($response,"out=Always")) { |
|---|
| 740 |
$data['record_out'] = 'Always'; |
|---|
| 741 |
} |
|---|
| 742 |
elseif (strstr($response,"out=Never")) { |
|---|
| 743 |
$data['record_out'] = 'Never'; |
|---|
| 744 |
} |
|---|
| 745 |
else { |
|---|
| 746 |
$data['record_out'] = 'Adhoc'; |
|---|
| 747 |
} |
|---|
| 748 |
} |
|---|
| 749 |
|
|---|
| 750 |
return $data; |
|---|
| 751 |
} |
|---|
| 752 |
|
|---|
| 753 |
/* |
|---|
| 754 |
* Gets record settings |
|---|
| 755 |
* |
|---|
| 756 |
* @param $exten |
|---|
| 757 |
* Extension to get information about |
|---|
| 758 |
* @param $data |
|---|
| 759 |
* Reference to the variable to store the data in |
|---|
| 760 |
*/ |
|---|
| 761 |
function getRecordSettings($exten) { |
|---|
| 762 |
|
|---|
| 763 |
// check protocol tables first |
|---|
| 764 |
$data = $this->getProtocolRecordSettings($this->protocol_table,$exten); |
|---|
| 765 |
|
|---|
| 766 |
return $data; |
|---|
| 767 |
} |
|---|
| 768 |
|
|---|
| 769 |
/* |
|---|
| 770 |
* Reloads Asterisk Configuration |
|---|
| 771 |
*/ |
|---|
| 772 |
function reloadAsteriskVoicemail() { |
|---|
| 773 |
|
|---|
| 774 |
global $asterisk_manager_interface; |
|---|
| 775 |
|
|---|
| 776 |
$response = $asterisk_manager_interface->Command("Action: Command\r\nCommand: Reload app_voicemail.so\r\n\r\n"); |
|---|
| 777 |
} |
|---|
| 778 |
|
|---|
| 779 |
/* |
|---|
| 780 |
* Gets FreePBX Version |
|---|
| 781 |
*/ |
|---|
| 782 |
function getFreePBXVersion() { |
|---|
| 783 |
|
|---|
| 784 |
if (isset($_SESSION['dbh_asterisk'])) { |
|---|
| 785 |
$sql = "SELECT * FROM admin WHERE variable = 'version'"; |
|---|
| 786 |
$results = $_SESSION['dbh_asterisk']->getAll($sql); |
|---|
| 787 |
if(DB::IsError($results)) { |
|---|
| 788 |
$_SESSION['ari_error'] = $results->getMessage(); |
|---|
| 789 |
} |
|---|
| 790 |
|
|---|
| 791 |
return $results[0][1]; |
|---|
| 792 |
} |
|---|
| 793 |
} |
|---|
| 794 |
|
|---|
| 795 |
function lookupSetExtensionFormat($exten) { |
|---|
| 796 |
|
|---|
| 797 |
if (trim($exten) == "") return $exten; |
|---|
| 798 |
|
|---|
| 799 |
$exten = preg_replace("/[^0-9*]/", "", $exten); |
|---|
| 800 |
|
|---|
| 801 |
$sql = "SELECT extension FROM users WHERE extension = '".$exten."'"; |
|---|
| 802 |
$asa = $_SESSION['dbh_asterisk']->getrow($sql, DB_FETCHMODE_ASSOC); |
|---|
| 803 |
if (!is_array($asa)) { |
|---|
| 804 |
return $exten.'#'; |
|---|
| 805 |
} else { |
|---|
| 806 |
return $exten; |
|---|
| 807 |
} |
|---|
| 808 |
} |
|---|
| 809 |
|
|---|
| 810 |
|
|---|
| 811 |
} // class |
|---|
| 812 |
|
|---|
| 813 |
?> |
|---|