1<?php 2/* 3 FusionPBX 4 Version: MPL 1.1 5 6 The contents of this file are subject to the Mozilla Public License Version 7 1.1 (the "License"); you may not use this file except in compliance with 8 the License. You may obtain a copy of the License at 9 http://www.mozilla.org/MPL/ 10 11 Software distributed under the License is distributed on an "AS IS" basis, 12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 for the specific language governing rights and limitations under the 14 License. 15 16 The Original Code is FusionPBX 17 18 The Initial Developer of the Original Code is 19 Mark J Crane <markjcrane@fusionpbx.com> 20 Portions created by the Initial Developer are Copyright (C) 2008-2016 21 the Initial Developer. All Rights Reserved. 22 23 Contributor(s): 24 Mark J Crane <markjcrane@fusionpbx.com> 25*/ 26 27//includes 28 require_once "root.php"; 29 require_once "resources/require.php"; 30 require_once "resources/check_auth.php"; 31 32//check permissions 33 if (permission_exists('voicemail_add') || permission_exists('voicemail_edit')) { 34 //access granted 35 } 36 else { 37 echo "access denied"; 38 exit; 39 } 40 41//add multi-lingual support 42 $language = new text; 43 $text = $language->get(); 44 45//action add or update 46 if (isset($_REQUEST["id"])) { 47 $action = "update"; 48 $voicemail_uuid = check_str($_REQUEST["id"]); 49 } 50 else { 51 $action = "add"; 52 } 53 54//get http variables and set them to php variables 55 $referer_path = check_str($_REQUEST["referer_path"]); 56 $referer_query = check_str($_REQUEST["referer_query"]); 57 if (count($_POST)>0) { 58 //set the variables from the HTTP values 59 $voicemail_id = check_str($_POST["voicemail_id"]); 60 $voicemail_password = check_str($_POST["voicemail_password"]); 61 $greeting_id = check_str($_POST["greeting_id"]); 62 $voicemail_options = $_POST["voicemail_options"]; 63 $voicemail_alternate_greet_id = check_str($_POST["voicemail_alternate_greet_id"]); 64 $voicemail_mail_to = check_str($_POST["voicemail_mail_to"]); 65 $voicemail_sms_to = check_str($_POST["voicemail_sms_to"]); 66 $voicemail_transcription_enabled = check_str($_POST["voicemail_transcription_enabled"]); 67 $voicemail_file = check_str($_POST["voicemail_file"]); 68 $voicemail_local_after_email = check_str($_POST["voicemail_local_after_email"]); 69 $voicemail_enabled = check_str($_POST["voicemail_enabled"]); 70 $voicemail_description = check_str($_POST["voicemail_description"]); 71 $voicemail_tutorial = check_str($_POST["voicemail_tutorial"]); 72 //remove the space 73 $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to); 74 //debug info 75 //echo "<pre>"; print_r($voicemail_options); echo "</pre>"; 76 } 77 78//unassign the voicemail id copy from the voicemail id 79 if ($_GET["a"] == "delete" && strlen($voicemail_uuid) > 0 && strlen($_REQUEST["voicemail_destination_uuid"]) > 0) { 80 //set the variables 81 $voicemail_destination_uuid = check_str($_REQUEST["voicemail_destination_uuid"]); 82 //delete the voicemail from the destionations 83 $sqld = " 84 delete from 85 v_voicemail_destinations 86 where 87 voicemail_destination_uuid = '".$voicemail_destination_uuid."' and 88 voicemail_uuid = '".$voicemail_uuid."'"; 89 $db->exec(check_sql($sqld)); 90 //redirect the browser 91 messages::add($text['message-delete']); 92 header("Location: voicemail_edit.php?id=".$voicemail_uuid); 93 return; 94 } 95 96//assign the voicemail id copy to the voicemail id 97 if (strlen($voicemail_uuid) > 0 && strlen($_REQUEST["voicemail_uuid_copy"]) > 0) { 98 //set the variables 99 $voicemail_uuid_copy = check_str($_REQUEST["voicemail_uuid_copy"]); 100 //assign the user to the extension 101 $sqli = " 102 insert into 103 v_voicemail_destinations 104 ( 105 domain_uuid, 106 voicemail_destination_uuid, 107 voicemail_uuid, 108 voicemail_uuid_copy 109 ) 110 values 111 ( 112 '".$domain_uuid."', 113 '".uuid()."', 114 '".$voicemail_uuid."', 115 '".$voicemail_uuid_copy."' 116 )"; 117 $db->exec(check_sql($sqli)); 118 //redirect the browser 119 messages::add($text['message-add']); 120 } 121 122if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { 123 124 $msg = ''; 125 if ($action == "update") { 126 $voicemail_uuid = check_str($_POST["voicemail_uuid"]); 127 } 128 129 //check for all required data 130 if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { 131 require_once "resources/header.php"; 132 require_once "resources/persist_form_var.php"; 133 echo "<div align='center'>\n"; 134 echo "<table><tr><td>\n"; 135 echo $msg."<br />"; 136 echo "</td></tr></table>\n"; 137 persistformvar($_POST); 138 echo "</div>\n"; 139 require_once "resources/footer.php"; 140 return; 141 } 142 143 //add or update the database 144 if ($_POST["persistformvar"] != "true") { 145 if ($action == "add" && permission_exists('voicemail_add')) { 146 $sql = "insert into v_voicemails "; 147 $sql .= "("; 148 $sql .= "domain_uuid, "; 149 $sql .= "voicemail_uuid, "; 150 $sql .= "voicemail_id, "; 151 $sql .= "voicemail_password, "; 152 $sql .= "greeting_id, "; 153 $sql .= "voicemail_alternate_greet_id, "; 154 $sql .= "voicemail_mail_to, "; 155 $sql .= "voicemail_sms_to, "; 156 $sql .= "voicemail_transcription_enabled, "; 157 $sql .= "voicemail_tutorial, "; 158 $sql .= "voicemail_file, "; 159 if (permission_exists('voicemail_local_after_email')) { 160 $sql .= "voicemail_local_after_email, "; 161 } 162 $sql .= "voicemail_enabled, "; 163 $sql .= "voicemail_description "; 164 $sql .= ")"; 165 $sql .= "values "; 166 $sql .= "("; 167 $sql .= "'".$domain_uuid."', "; 168 $sql .= "'".uuid()."', "; 169 $sql .= "'".$voicemail_id."', "; 170 $sql .= "'".$voicemail_password."', "; 171 $sql .= (($greeting_id != '') ? "'".$greeting_id."'" : 'null').", "; 172 $sql .= (($voicemail_alternate_greet_id != '') ? "'".$voicemail_alternate_greet_id."'" : 'null').", "; 173 $sql .= "'".$voicemail_mail_to."', "; 174 $sql .= "'".$voicemail_sms_to."', "; 175 $sql .= "'".$voicemail_transcription_enabled."', "; 176 $sql .= "'".$voicemail_tutorial."', "; 177 $sql .= "'".$voicemail_file."', "; 178 if (permission_exists('voicemail_local_after_email')) { 179 $sql .= "'".$voicemail_local_after_email."', "; 180 } 181 $sql .= "'".$voicemail_enabled."', "; 182 $sql .= "'".$voicemail_description."' "; 183 $sql .= ")"; 184 $db->exec(check_sql($sql)); 185 unset($sql); 186 187 messages::add($text['message-add']); 188 } //if ($action == "add") 189 190 if ($action == "update" && permission_exists('voicemail_edit')) { 191 $sql = "update v_voicemails set "; 192 $sql .= "voicemail_id = '".$voicemail_id."', "; 193 $sql .= "voicemail_password = '".$voicemail_password."', "; 194 $sql .= "greeting_id = ".(($greeting_id != '') ? "'".$greeting_id."'" : 'null').", "; 195 $sql .= "voicemail_alternate_greet_id = ".(($voicemail_alternate_greet_id != '') ? "'".$voicemail_alternate_greet_id."'" : 'null').", "; 196 $sql .= "voicemail_mail_to = '".$voicemail_mail_to."', "; 197 $sql .= "voicemail_sms_to = '".$voicemail_sms_to."', "; 198 $sql .= "voicemail_transcription_enabled = '".$voicemail_transcription_enabled."', "; 199 $sql .= "voicemail_tutorial = '".$voicemail_tutorial."', "; 200 $sql .= "voicemail_file = '".$voicemail_file."', "; 201 if (permission_exists('voicemail_local_after_email')) { 202 $sql .= "voicemail_local_after_email = '".$voicemail_local_after_email."', "; 203 } 204 $sql .= "voicemail_enabled = '".$voicemail_enabled."', "; 205 $sql .= "voicemail_description = '".$voicemail_description."' "; 206 $sql .= "where domain_uuid = '".$domain_uuid."' "; 207 $sql .= "and voicemail_uuid = '".$voicemail_uuid."'"; 208 $db->exec(check_sql($sql)); 209 unset($sql); 210 211 messages::add($text['message-update']); 212 } //if ($action == "update") 213 214 215 // add voicemail options 216 if (sizeof($voicemail_options) > 0) { 217 foreach ($voicemail_options as $index => $voicemail_option) { 218 if ($voicemail_option['voicemail_option_digits'] == '' || $voicemail_option['voicemail_option_param'] == '') { unset($voicemail_options[$index]); } 219 } 220 } 221 if (sizeof($voicemail_options) > 0) { 222 $sql = "insert into v_voicemail_options "; 223 $sql .= "( "; 224 $sql .= "voicemail_option_uuid, "; 225 $sql .= "voicemail_uuid, "; 226 $sql .= "domain_uuid, "; 227 $sql .= "voicemail_option_digits, "; 228 $sql .= "voicemail_option_action, "; 229 $sql .= "voicemail_option_param, "; 230 $sql .= "voicemail_option_order, "; 231 $sql .= "voicemail_option_description "; 232 $sql .= ") "; 233 $sql .= "values "; 234 foreach ($voicemail_options as $index => $voicemail_option) { 235 236 //set the uuid 237 $voicemail_option_uuid = uuid(); 238 239 if (is_numeric($voicemail_option["voicemail_option_param"])) { 240 //if numeric then add tranfer $1 XML domain_name 241 $voicemail_option['voicemail_option_action'] = "menu-exec-app"; 242 $voicemail_option['voicemail_option_param'] = "transfer ".$voicemail_option["voicemail_option_param"]." XML ".$_SESSION['domain_name']; 243 } 244 else { 245 //seperate the action and the param 246 $option_array = explode(":", $voicemail_option["voicemail_option_param"]); 247 $voicemail_option['voicemail_option_action'] = array_shift($option_array); 248 $voicemail_option['voicemail_option_param'] = join(':', $option_array); 249 } 250 251 //continue building insert query 252 $sql_record[$index] = "( "; 253 $sql_record[$index] .= "'".$voicemail_option_uuid."', "; 254 $sql_record[$index] .= "'".$voicemail_uuid."', "; 255 $sql_record[$index] .= "'".$domain_uuid."', "; 256 $sql_record[$index] .= "'".trim($voicemail_option['voicemail_option_digits'])."', "; 257 $sql_record[$index] .= "'".trim($voicemail_option['voicemail_option_action'])."', "; 258 $sql_record[$index] .= "'".trim($voicemail_option['voicemail_option_param'])."', "; 259 $sql_record[$index] .= $voicemail_option['voicemail_option_order'].", "; 260 $sql_record[$index] .= "'".trim($voicemail_option['voicemail_option_description'])."' "; 261 $sql_record[$index] .= ") "; 262 } 263 $sql .= implode(",", $sql_record); 264 $db->exec(check_sql($sql)); 265 unset($sql); 266 } 267 268 //redirect user 269 if ($action == 'add') { 270 header("Location: voicemails.php"); 271 } 272 else if ($action == "update") { 273 header("Location: voicemail_edit.php?id=".$voicemail_uuid); 274 } 275 exit; 276 277 } //if ($_POST["persistformvar"] != "true") 278} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) 279 280//initialize the destinations object 281 $destination = new destinations; 282 283//pre-populate the form 284 if (count($_GET)>0 && $_POST["persistformvar"] != "true") { 285 $voicemail_uuid = check_str($_GET["id"]); 286 $sql = "select * from v_voicemails "; 287 $sql .= "where domain_uuid = '".$domain_uuid."' "; 288 $sql .= "and voicemail_uuid = '".$voicemail_uuid."' "; 289 $prep_statement = $db->prepare(check_sql($sql)); 290 $prep_statement->execute(); 291 $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); 292 foreach ($result as &$row) { 293 $voicemail_id = $row["voicemail_id"]; 294 $voicemail_password = $row["voicemail_password"]; 295 $greeting_id = $row["greeting_id"]; 296 $voicemail_alternate_greet_id = $row["voicemail_alternate_greet_id"]; 297 $voicemail_mail_to = $row["voicemail_mail_to"]; 298 $voicemail_sms_to = $row["voicemail_sms_to"]; 299 $voicemail_transcription_enabled = $row["voicemail_transcription_enabled"]; 300 $voicemail_tutorial = $row["voicemail_tutorial"]; 301 $voicemail_file = $row["voicemail_file"]; 302 $voicemail_local_after_email = $row["voicemail_local_after_email"]; 303 $voicemail_enabled = $row["voicemail_enabled"]; 304 $voicemail_description = $row["voicemail_description"]; 305 break; //limit to 1 row 306 } 307 unset ($prep_statement); 308 } 309 else { 310 $voicemail_file = $_SESSION['voicemail']['voicemail_file']['text']; 311 $voicemail_local_after_email = $_SESSION['voicemail']['keep_local']['boolean']; 312 } 313 314//remove the spaces 315 $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to); 316 317//set defaults 318 if (strlen($voicemail_local_after_email) == 0) { $voicemail_local_after_email = "true"; } 319 if (strlen($voicemail_enabled) == 0) { $voicemail_enabled = "true"; } 320 if (strlen($voicemail_transcription_enabled) == 0) { $voicemail_transcription_enabled = "false"; } 321 if (strlen($voicemail_tutorial) == 0) { $voicemail_tutorial = "false"; } 322 323//get the greetings list 324 $sql = "select * from v_voicemail_greetings "; 325 $sql .= "where domain_uuid = '".$domain_uuid."' "; 326 $sql .= "and voicemail_id = '".$voicemail_id."' "; 327 $sql .= "order by greeting_name asc "; 328 $prep_statement = $db->prepare(check_sql($sql)); 329 $prep_statement->execute(); 330 $greetings = $prep_statement->fetchAll(PDO::FETCH_NAMED); 331 $greeting_count = count($greetings); 332 unset ($prep_statement, $sql); 333 334//show the header 335 require_once "resources/header.php"; 336 $document['title'] = $text['title-voicemail']; 337 338//password complexity 339 $password_complexity = $_SESSION['voicemail']['password_complexity']['boolean']; 340 if ($password_complexity == "true") { 341 echo "<script>\n"; 342 $req['length'] = $_SESSION['voicemail']['password_min_length']['numeric']; 343 echo " function check_password_strength(pwd) {\n"; 344 echo " var msg_errors = [];\n"; 345 //length 346 if (is_numeric($req['length']) && $req['length'] != 0) { 347 echo " var re = /.{".$req['length'].",}/;\n"; 348 echo " if (!re.test(pwd)) { msg_errors.push('".$req['length']."+ ".$text['label-digits']."'); }\n"; 349 } 350 //numberic only 351 echo " var re = /(?=.*[a-zA-Z\W])/;\n"; 352 echo " if (re.test(pwd)) { msg_errors.push('".$text['label-numberic_only']."'); }\n"; 353 //repeating digits 354 echo " var re = /(\d)\\1{2}/;\n"; 355 echo " if (re.test(pwd)) { msg_errors.push('".$text['label-password_repeating']."'); }\n"; 356 //sequential digits 357 echo " var re = /(012|123|345|456|567|678|789|987|876|765|654|543|432|321|210)/;\n"; 358 echo " if (re.test(pwd)) { msg_errors.push('".$text['label-password_sequential']."'); }\n"; 359 360 echo " if (msg_errors.length > 0) {\n"; 361 echo " var msg = '".$text['message-password_requirements'].": ' + msg_errors.join(', ');\n"; 362 echo " display_message(msg, 'negative', '6000');\n"; 363 echo " return false;\n"; 364 echo " }\n"; 365 echo " else {\n"; 366 echo " return true;\n"; 367 echo " }\n"; 368 echo " }\n"; 369 echo "</script>\n"; 370 } 371//show the content 372 echo "<form method='post' name='frm' id='frm' action=''>\n"; 373 echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; 374 echo "<tr>\n"; 375 echo "<td align='left' width='30%' nowrap='nowrap' valign='top'>"; 376 echo " <b>".$text['title-voicemail']."</b>"; 377 echo " <br><br>"; 378 echo "</td>\n"; 379 echo "<td width='70%' align='right' valign='top'>\n"; 380 echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"javascript:history.back();\" value='".$text['button-back']."'>\n"; 381 if ($password_complexity == "true") { 382 echo " <input type='button' class='btn' value='".$text['button-save']."' onclick=\"if (check_password_strength(document.getElementById('password').value)) { submit_form(); }\">"; 383 } else { 384 echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'>\n"; 385 } 386 echo "</td>\n"; 387 echo "</tr>\n"; 388 389 echo "<tr>\n"; 390 echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; 391 echo " ".$text['label-voicemail_id']."\n"; 392 echo "</td>\n"; 393 echo "<td class='vtable' align='left'>\n"; 394 echo " <input class='formfld' type='text' name='voicemail_id' maxlength='255' value='$voicemail_id'>\n"; 395 echo "<br />\n"; 396 echo $text['description-voicemail_id']."\n"; 397 echo "</td>\n"; 398 echo "</tr>\n"; 399 400 echo "<tr>\n"; 401 echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; 402 echo " ".$text['label-voicemail_password']."\n"; 403 echo "</td>\n"; 404 echo "<td class='vtable' align='left'>\n"; 405 echo " <input class='formfld' type='text' name='voicemail_password' id='password' autocomplete='off' onmouseover=\"this.type='text';\" onfocus=\"this.type='text';\" onmouseout=\"if (!$(this).is(':focus')) { this.type='password'; }\" onblur=\"this.type='password';\" autocomplete='off' maxlength='50' value=\"$voicemail_password\">\n"; 406 echo "<br />\n"; 407 echo $text['description-voicemail_password']."\n"; 408 echo "</td>\n"; 409 echo "</tr>\n"; 410 411 echo "<tr>\n"; 412 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 413 echo " ".$text['label-voicemail_tutorial']."\n"; 414 echo "</td>\n"; 415 echo "<td class='vtable' align='left'>\n"; 416 echo " <select class='formfld' name='voicemail_tutorial' id='voicemail_tutorial'>\n"; 417 echo " <option value='true' ".(($voicemail_tutorial == "true") ? "selected='selected'" : null).">".$text['label-true']."</option>\n"; 418 echo " <option value='false' ".(($voicemail_tutorial == "false") ? "selected='selected'" : null).">".$text['label-false']."</option>\n"; 419 echo " </select>\n"; 420 echo "<br />\n"; 421 echo $text['description-voicemail_tutorial']."\n"; 422 echo "</td>\n"; 423 echo "</tr>\n"; 424 425 echo "<tr>\n"; 426 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 427 echo " ".$text['label-greeting']."\n"; 428 echo "</td>\n"; 429 echo "<td class='vtable' align='left'>\n"; 430 echo " <select class='formfld' name='greeting_id'>\n"; 431 echo " <option value=''></option>\n"; 432 if ($greeting_count > 0) { 433 foreach ($greetings as $greeting) { 434 $selected = ($greeting['greeting_id'] == $greeting_id) ? 'selected' : null; 435 echo "<option value='".$greeting['greeting_id']."' ".$selected.">".$greeting['greeting_name']."</option>\n"; 436 } 437 } 438 echo " </select>\n"; 439 echo "<br />\n"; 440 echo $text['description-greeting']."\n"; 441 echo "</td>\n"; 442 echo "</tr>\n"; 443 444 echo "<tr>\n"; 445 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 446 echo " ".$text['label-voicemail_alternate_greet_id']."\n"; 447 echo "</td>\n"; 448 echo "<td class='vtable' align='left'>\n"; 449 echo " <input class='formfld' type='text' name='voicemail_alternate_greet_id' maxlength='255' value='$voicemail_alternate_greet_id'>\n"; 450 echo " <br />\n"; 451 echo " ".$text['description-voicemail_alternate_greet_id']."\n"; 452 echo "</td>\n"; 453 echo "</tr>\n"; 454 455 echo " <tr>"; 456 echo " <td class='vncell' valign='top'>".$text['label-options']."</td>"; 457 echo " <td class='vtable' align='left'>"; 458 echo " <table width='59%' border='0' cellpadding='0' cellspacing='0'>\n"; 459 echo " <tr>\n"; 460 echo " <td class='vtable'>".$text['label-option']."</td>\n"; 461 echo " <td class='vtable'>".$text['label-destination']."</td>\n"; 462 echo " <td class='vtable'>".$text['label-order']."</td>\n"; 463 echo " <td class='vtable'>".$text['label-description']."</td>\n"; 464 echo " <td></td>\n"; 465 echo " </tr>\n"; 466 if (strlen($voicemail_uuid) > 0) { 467 $sql = "select * from v_voicemail_options "; 468 $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; 469 $sql .= "and voicemail_uuid = '".$voicemail_uuid."' "; 470 $sql .= "order by voicemail_option_digits, voicemail_option_order asc "; 471 $prep_statement = $db->prepare(check_sql($sql)); 472 $prep_statement->execute(); 473 $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); 474 $result_count = count($result); 475 foreach($result as $field) { 476 $voicemail_option_param = $field['voicemail_option_param']; 477 if (strlen(trim($voicemail_option_param)) == 0) { 478 $voicemail_option_param = $field['voicemail_option_action']; 479 } 480 $voicemail_option_param = str_replace("menu-", "", $voicemail_option_param); 481 $voicemail_option_param = str_replace("XML", "", $voicemail_option_param); 482 $voicemail_option_param = str_replace("transfer", "", $voicemail_option_param); 483 $voicemail_option_param = str_replace("bridge", "", $voicemail_option_param); 484 $voicemail_option_param = str_replace($_SESSION['domain_name'], "", $voicemail_option_param); 485 $voicemail_option_param = str_replace("\${domain_name}", "", $voicemail_option_param); 486 $voicemail_option_param = str_replace("\${domain}", "", $voicemail_option_param); 487 $voicemail_option_param = ucfirst(trim($voicemail_option_param)); 488 echo " <tr>\n"; 489 echo " <td class='vtable'>\n"; 490 echo " ".$field['voicemail_option_digits']; 491 echo " </td>\n"; 492 echo " <td class='vtable'>\n"; 493 echo " ".$voicemail_option_param." \n"; 494 echo " </td>\n"; 495 echo " <td class='vtable'>\n"; 496 echo " ".$field['voicemail_option_order']." \n"; 497 echo " </td>\n"; 498 echo " <td class='vtable'>\n"; 499 echo " ".$field['voicemail_option_description']." \n"; 500 echo " </td>\n"; 501 echo " <td class='list_control_icons'>"; 502 echo "<a href='voicemail_option_edit.php?id=".$field['voicemail_option_uuid']."&voicemail_uuid=".$field['voicemail_uuid']."' alt='".$text['button-edit']."'>".$v_link_label_edit."</a>"; 503 echo "<a href='voicemail_option_delete.php?id=".$field['voicemail_option_uuid']."&voicemail_uuid=".$field['voicemail_uuid']."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>"; 504 echo " </td>\n"; 505 echo " </tr>\n"; 506 } 507 } 508 unset($sql, $result); 509 510 for ($c = 0; $c < 1; $c++) { 511 echo " <tr>\n"; 512 echo "<td class='vtable' align='left'>\n"; 513 echo " <input class='formfld' style='width:70px' type='text' name='voicemail_options[".$c."][voicemail_option_digits]' maxlength='255' value='".$voicemail_option_digits."'>\n"; 514 echo "</td>\n"; 515 echo "<td class='vtable' align='left' nowrap='nowrap'>\n"; 516 echo $destination->select('ivr', 'voicemail_options['.$c.'][voicemail_option_param]', ''); 517 echo "</td>\n"; 518 echo "<td class='vtable' align='left'>\n"; 519 echo " <select name='voicemail_options[".$c."][voicemail_option_order]' class='formfld' style='width:55px'>\n"; 520 //echo " <option></option>\n"; 521 if (strlen(htmlspecialchars($voicemail_option_order))> 0) { 522 echo " <option selected='yes' value='".htmlspecialchars($voicemail_option_order)."'>".htmlspecialchars($voicemail_option_order)."</option>\n"; 523 } 524 $i=0; 525 while($i<=999) { 526 if (strlen($i) == 1) { 527 echo " <option value='00$i'>00$i</option>\n"; 528 } 529 if (strlen($i) == 2) { 530 echo " <option value='0$i'>0$i</option>\n"; 531 } 532 if (strlen($i) == 3) { 533 echo " <option value='$i'>$i</option>\n"; 534 } 535 $i++; 536 } 537 echo " </select>\n"; 538 echo "</td>\n"; 539 echo "<td class='vtable' align='left'>\n"; 540 echo " <input class='formfld' style='width:100px' type='text' name='voicemail_options[".$c."][voicemail_option_description]' maxlength='255' value=\"".$voicemail_option_description."\">\n"; 541 echo "</td>\n"; 542 543 echo " <td>\n"; 544 echo " <input type='button' class='btn' value=\"".$text['button-add']."\" onclick='submit_form();'>\n"; 545 echo " </td>\n"; 546 echo " </tr>\n"; 547 } 548 echo " </table>\n"; 549 550 echo " ".$text['description-options']."\n"; 551 echo " <br />\n"; 552 echo " </td>"; 553 echo " </tr>"; 554 555 echo "<tr>\n"; 556 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 557 echo " ".$text['label-voicemail_mail_to']."\n"; 558 echo "</td>\n"; 559 echo "<td class='vtable' align='left'>\n"; 560 echo " <input class='formfld' type='text' name='voicemail_mail_to' maxlength='255' value=\"$voicemail_mail_to\">\n"; 561 echo "<br />\n"; 562 echo $text['description-voicemail_mail_to']."\n"; 563 echo "</td>\n"; 564 echo "</tr>\n"; 565 if(permission_exists('voicemail_sms_edit')) { 566 echo "<tr>\n"; 567 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 568 echo " ".$text['label-voicemail_sms_to']."\n"; 569 echo "</td>\n"; 570 echo "<td class='vtable' align='left'>\n"; 571 echo " <input class='formfld' type='text' name='voicemail_sms_to' maxlength='255' value=\"$voicemail_sms_to\">\n"; 572 echo "<br />\n"; 573 echo $text['description-voicemail_sms_to']."\n"; 574 echo "</td>\n"; 575 echo "</tr>\n"; 576 } 577 if(permission_exists('voicemail_transcription_edit') && $_SESSION['voicemail']['transcribe_enabled']['boolean'] == "true") { 578 echo "<tr>\n"; 579 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 580 echo " ".$text['label-voicemail_transcription_enabled']."\n"; 581 echo "</td>\n"; 582 echo "<td class='vtable' align='left'>\n"; 583 echo " <select class='formfld' name='voicemail_transcription_enabled' id='voicemail_transcription_enabled'>\n"; 584 echo " <option value='true' ".(($voicemail_transcription_enabled == "true") ? "selected='selected'" : null).">".$text['label-true']."</option>\n"; 585 echo " <option value='false' ".(($voicemail_transcription_enabled == "false") ? "selected='selected'" : null).">".$text['label-false']."</option>\n"; 586 echo " </select>\n"; 587 echo "<br />\n"; 588 echo $text['description-voicemail_transcription_enabled']."\n"; 589 echo "</td>\n"; 590 echo "</tr>\n"; 591 } 592 593 echo "<tr>\n"; 594 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 595 echo " ".$text['label-voicemail_file']."\n"; 596 echo "</td>\n"; 597 echo "<td class='vtable' align='left'>\n"; 598 echo " <select class='formfld' name='voicemail_file' id='voicemail_file' onchange=\"if (this.selectedIndex != 2) { document.getElementById('voicemail_local_after_email').selectedIndex = 0; }\">\n"; 599 echo " <option value='' ".(($voicemail_file == "listen") ? "selected='selected'" : null).">".$text['option-voicemail_file_listen']."</option>\n"; 600 echo " <option value='link' ".(($voicemail_file == "link") ? "selected='selected'" : null).">".$text['option-voicemail_file_link']."</option>\n"; 601 echo " <option value='attach' ".(($voicemail_file == "attach") ? "selected='selected'" : null).">".$text['option-voicemail_file_attach']."</option>\n"; 602 echo " </select>\n"; 603 echo "<br />\n"; 604 echo $text['description-voicemail_file']."\n"; 605 echo "</td>\n"; 606 echo "</tr>\n"; 607 608 if (permission_exists('voicemail_local_after_email')) { 609 echo "<tr>\n"; 610 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 611 echo " ".$text['label-voicemail_local_after_email']."\n"; 612 echo "</td>\n"; 613 echo "<td class='vtable' align='left'>\n"; 614 echo " <select class='formfld' name='voicemail_local_after_email' id='voicemail_local_after_email' onchange=\"if (this.selectedIndex == 1) { document.getElementById('voicemail_file').selectedIndex = 2; }\">\n"; 615 echo " <option value='true' ".(($voicemail_local_after_email == "true") ? "selected='selected'" : null).">".$text['label-true']."</option>\n"; 616 echo " <option value='false' ".(($voicemail_local_after_email == "false") ? "selected='selected'" : null).">".$text['label-false']."</option>\n"; 617 echo " </select>\n"; 618 echo "<br />\n"; 619 echo $text['description-voicemail_local_after_email']."\n"; 620 echo "</td>\n"; 621 echo "</tr>\n"; 622 } 623 624 if ($action == "update") { 625 echo " <tr>"; 626 echo " <td class='vncell' valign='top'>".$text['label-forward_destinations']."</td>"; 627 echo " <td class='vtable'>"; 628 629 $sql = " 630 select 631 v.voicemail_id, 632 d.voicemail_destination_uuid, 633 d.voicemail_uuid_copy 634 from 635 v_voicemails as v, 636 v_voicemail_destinations as d 637 where 638 d.voicemail_uuid_copy = v.voicemail_uuid and 639 v.domain_uuid = '".$_SESSION['domain_uuid']."' and 640 v.voicemail_enabled = 'true' and 641 d.voicemail_uuid = '".$voicemail_uuid."' 642 order by 643 v.voicemail_id asc"; 644 $prep_statement = $db->prepare(check_sql($sql)); 645 $prep_statement->execute(); 646 $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); 647 $result_count = count($result); 648 if ($result_count > 0) { 649 echo " <table width='52%'>\n"; 650 foreach($result as $field) { 651 echo " <tr>\n"; 652 echo " <td class='vtable'>".$field['voicemail_id']."</td>\n"; 653 echo " <td>\n"; 654 echo " <a href='voicemail_edit.php?id=".$voicemail_uuid."&voicemail_destination_uuid=".$field['voicemail_destination_uuid']."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n"; 655 echo " </td>\n"; 656 echo " </tr>\n"; 657 $voicemail_uuid_copied[] = $field['voicemail_uuid_copy']; 658 } 659 echo " </table>\n"; 660 echo " <br />\n"; 661 } 662 663 if (sizeof($voicemail_uuid_copied) > 0) { 664 // modify sql to remove already copied voicemail uuids from the list 665 $sql_mod = " and v.voicemail_uuid not in ('".implode("','", $voicemail_uuid_copied)."') "; 666 } 667 668 $sql = " 669 select 670 v.voicemail_id, 671 v.voicemail_uuid 672 from 673 v_voicemails as v 674 where 675 v.domain_uuid = '".$_SESSION['domain_uuid']."' and 676 v.voicemail_enabled = 'true' and 677 v.voicemail_uuid <> '".$voicemail_uuid."' 678 ".$sql_mod." 679 order by 680 v.voicemail_id asc"; 681 $prep_statement = $db->prepare(check_sql($sql)); 682 $prep_statement->execute(); 683 echo " <select name=\"voicemail_uuid_copy\" class='formfld' style='width: auto;'>\n"; 684 echo " <option value=\"\"></option>\n"; 685 $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); 686 foreach($result as $field) { 687 echo " <option value='".$field['voicemail_uuid']."'>".$field['voicemail_id']."</option>\n"; 688 } 689 echo " </select>"; 690 echo " <input type='button' class='btn' value=\"".$text['button-add']."\" onclick='submit_form();'>\n"; 691 unset($sql, $result); 692 echo " <br>\n"; 693 echo " ".$text['description-forward_destinations']."\n"; 694 echo " <br />\n"; 695 echo " </td>"; 696 echo " </tr>"; 697 } 698 699 echo "<tr>\n"; 700 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 701 echo " ".$text['label-voicemail_enabled']."\n"; 702 echo "</td>\n"; 703 echo "<td class='vtable' align='left'>\n"; 704 echo " <select class='formfld' name='voicemail_enabled'>\n"; 705 if ($voicemail_enabled == "true") { 706 echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n"; 707 } 708 else { 709 echo " <option value='true'>".$text['label-true']."</option>\n"; 710 } 711 if ($voicemail_enabled == "false") { 712 echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n"; 713 } 714 else { 715 echo " <option value='false'>".$text['label-false']."</option>\n"; 716 } 717 echo " </select>\n"; 718 echo "<br />\n"; 719 echo $text['description-voicemail_enabled']."\n"; 720 echo "</td>\n"; 721 echo "</tr>\n"; 722 723 echo "<tr>\n"; 724 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 725 echo " ".$text['label-voicemail_description']."\n"; 726 echo "</td>\n"; 727 echo "<td class='vtable' align='left'>\n"; 728 echo " <input class='formfld' type='text' name='voicemail_description' maxlength='255' value=\"$voicemail_description\">\n"; 729 echo "<br />\n"; 730 echo $text['description-voicemail_description']."\n"; 731 echo "</td>\n"; 732 echo "</tr>\n"; 733 echo " <tr>\n"; 734 echo " <td colspan='2' align='right'>\n"; 735 if ($action == "update") { 736 echo " <input type='hidden' name='voicemail_uuid' value='$voicemail_uuid'>\n"; 737 } 738 $http_referer = parse_url($_SERVER["HTTP_REFERER"]); 739 echo " <input type='hidden' name='referer_path' value='".$http_referer['path']."'>\n"; 740 echo " <input type='hidden' name='referer_query' value='".$http_referer['query']."'>\n"; 741 echo " <br>"; 742 if ($password_complexity == "true") { 743 echo " <input type='button' class='btn' value='".$text['button-save']."' onclick=\"if (check_password_strength(document.getElementById('password').value)) { submit_form(); }\">"; 744 } else { 745 echo " <input type='button' class='btn' value='".$text['button-save']."' onclick='submit_form();'>\n"; 746 } 747 echo " </td>\n"; 748 echo " </tr>"; 749 echo "</table>"; 750 echo "<br><br>"; 751 echo "</form>"; 752 753 echo "<script>\n"; 754//capture enter key to submit form 755 echo " $(window).keypress(function(event){\n"; 756 echo " if (event.which == 13) { submit_form(); }\n"; 757 echo " });\n"; 758// convert password fields to 759 echo " function submit_form() {\n"; 760 echo " $('input:password').css('visibility','hidden');\n"; 761 echo " $('input:password').attr({type:'text'});\n"; 762 echo " $('form#frm').submit();\n"; 763 echo " }\n"; 764 echo "</script>\n"; 765 766//include the footer 767 require_once "resources/footer.php"; 768?> 769