Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ require_once "root.php"; require_once "includes/require.php"; require_once "includes/checkauth.php"; if (permission_exists('ivr_menu_add') || permission_exists('ivr_menu_edit')) { //access granted } else { echo "access denied"; exit; } function recur_sounds_dir($dir) { global $dir_array; global $dir_path; $dir_list = opendir($dir); while ($file = readdir ($dir_list)) { if ($file != '.' && $file != '..') { $newpath = $dir.'/'.$file; $level = explode('/',$newpath); if (substr($newpath, -4) == ".svn") { //ignore .svn dir and subdir } else { if (is_dir($newpath)) { //directories recur_sounds_dir($newpath); } else { //files if (strlen($newpath) > 0) { //make the path relative $relative_path = substr($newpath, strlen($dir_path), strlen($newpath)); //remove the 8000-48000 khz from the path $relative_path = str_replace("/8000/", "/", $relative_path); $relative_path = str_replace("/16000/", "/", $relative_path); $relative_path = str_replace("/32000/", "/", $relative_path); $relative_path = str_replace("/48000/", "/", $relative_path); //remove the default_language, default_dialect, and default_voice (en/us/callie) from the path $file_array = explode( "/", $relative_path ); $x = 1; $relative_path = ''; foreach( $file_array as $tmp) { if ($x == 5) { $relative_path .= $tmp; } if ($x > 5) { $relative_path .= '/'.$tmp; } $x++; } //add the file if it does not exist in the array if (isset($dir_array[$relative_path])) { //already exists } else { //add the new path if (strlen($relative_path) > 0) { $dir_array[$relative_path] = '0'; } } } } } } } closedir($dir_list); } //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $ivr_menu_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get http post values and set them to php variables if (count($_POST)>0) { $ivr_menu_name = check_str($_POST["ivr_menu_name"]); $ivr_menu_extension = check_str($_POST["ivr_menu_extension"]); $ivr_menu_greet_long = check_str($_POST["ivr_menu_greet_long"]); $ivr_menu_greet_short = check_str($_POST["ivr_menu_greet_short"]); $ivr_menu_invalid_sound = check_str($_POST["ivr_menu_invalid_sound"]); $ivr_menu_exit_sound = check_str($_POST["ivr_menu_exit_sound"]); $ivr_menu_confirm_macro = check_str($_POST["ivr_menu_confirm_macro"]); $ivr_menu_confirm_key = check_str($_POST["ivr_menu_confirm_key"]); $ivr_menu_tts_engine = check_str($_POST["ivr_menu_tts_engine"]); $ivr_menu_tts_voice = check_str($_POST["ivr_menu_tts_voice"]); $ivr_menu_confirm_attempts = check_str($_POST["ivr_menu_confirm_attempts"]); $ivr_menu_timeout = check_str($_POST["ivr_menu_timeout"]); $ivr_menu_inter_digit_timeout = check_str($_POST["ivr_menu_inter_digit_timeout"]); $ivr_menu_max_failures = check_str($_POST["ivr_menu_max_failures"]); $ivr_menu_max_timeouts = check_str($_POST["ivr_menu_max_timeouts"]); $ivr_menu_digit_len = check_str($_POST["ivr_menu_digit_len"]); $ivr_menu_direct_dial = check_str($_POST["ivr_menu_direct_dial"]); $ivr_menu_ringback = check_str($_POST["ivr_menu_ringback"]); $ivr_menu_enabled = check_str($_POST["ivr_menu_enabled"]); $ivr_menu_description = check_str($_POST["ivr_menu_description"]); $ivr_menu_exit_action = check_str($_POST["ivr_menu_exit_action"]); //$ivr_menu_exit_action = "transfer:1001 XML default"; $timeout_action_array = explode(":", $ivr_menu_exit_action); $ivr_menu_exit_app = array_shift($timeout_action_array); $ivr_menu_exit_data = join(':', $timeout_action_array); } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; if ($action == "update") { $ivr_menu_uuid = check_str($_POST["ivr_menu_uuid"]); } //check for all required data //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } if (strlen($ivr_menu_name) == 0) { $msg .= "Please provide: Name
\n"; } if (strlen($ivr_menu_extension) == 0) { $msg .= "Please provide: Extension
\n"; } if (strlen($ivr_menu_greet_long) == 0) { $msg .= "Please provide: Greet Long
\n"; } //if (strlen($ivr_menu_greet_short) == 0) { $msg .= "Please provide: Greet Short
\n"; } if (strlen($ivr_menu_invalid_sound) == 0) { $msg .= "Please provide: Invalid Sound
\n"; } //if (strlen($ivr_menu_exit_sound) == 0) { $msg .= "Please provide: Exit Sound
\n"; } //if (strlen($ivr_menu_confirm_macro) == 0) { $msg .= "Please provide: Confirm Macro
\n"; } //if (strlen($ivr_menu_confirm_key) == 0) { $msg .= "Please provide: Confirm Key
\n"; } //if (strlen($ivr_menu_tts_engine) == 0) { $msg .= "Please provide: TTS Engine
\n"; } //if (strlen($ivr_menu_tts_voice) == 0) { $msg .= "Please provide: TTS Voice
\n"; } if (strlen($ivr_menu_confirm_attempts) == 0) { $msg .= "Please provide: Confirm Attempts
\n"; } if (strlen($ivr_menu_timeout) == 0) { $msg .= "Please provide: Timeout
\n"; } //if (strlen($ivr_menu_exit_app) == 0) { $msg .= "Please provide: Exit Action
\n"; } //if (strlen($ivr_menu_exit_data) == 0) { $msg .= "Please provide: Timeout Data
\n"; } if (strlen($ivr_menu_inter_digit_timeout) == 0) { $msg .= "Please provide: Inter Digit Timeout
\n"; } if (strlen($ivr_menu_max_failures) == 0) { $msg .= "Please provide: Max Failures
\n"; } if (strlen($ivr_menu_max_timeouts) == 0) { $msg .= "Please provide: Max Timeouts
\n"; } if (strlen($ivr_menu_digit_len) == 0) { $msg .= "Please provide: Digit Length
\n"; } if (strlen($ivr_menu_direct_dial) == 0) { $msg .= "Please provide: Direct Dial
\n"; } //if (strlen($ivr_menu_ringback) == 0) { $msg .= "Please provide: Ringback
\n"; } if (strlen($ivr_menu_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } //if (strlen($ivr_menu_description) == 0) { $msg .= "Please provide: Description
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "includes/header.php"; require_once "includes/persistformvar.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "includes/footer.php"; return; } //replace the space with a dash $ivr_menu_name = str_replace(" ", "-", $ivr_menu_name); //add or update the database if ($_POST["persistformvar"] != "true") { //prepare the object require_once "includes/classes/database.php"; require_once "resources/classes/switch_ivr_menu.php"; $ivr = new switch_ivr_menu; $ivr->domain_uuid = $_SESSION["domain_uuid"]; $ivr->ivr_menu_name = $ivr_menu_name; $ivr->ivr_menu_extension = $ivr_menu_extension; $ivr->ivr_menu_greet_long = $ivr_menu_greet_long; $ivr->ivr_menu_greet_short = $ivr_menu_greet_short; $ivr->ivr_menu_invalid_sound = $ivr_menu_invalid_sound; $ivr->ivr_menu_exit_sound = $ivr_menu_exit_sound; $ivr->ivr_menu_confirm_macro = $ivr_menu_confirm_macro; $ivr->ivr_menu_confirm_key = $ivr_menu_confirm_key; $ivr->ivr_menu_tts_engine = $ivr_menu_tts_engine; $ivr->ivr_menu_tts_voice = $ivr_menu_tts_voice; $ivr->ivr_menu_confirm_attempts = $ivr_menu_confirm_attempts; $ivr->ivr_menu_timeout = $ivr_menu_timeout; $ivr->ivr_menu_exit_app = $ivr_menu_exit_app; $ivr->ivr_menu_exit_data = $ivr_menu_exit_data; $ivr->ivr_menu_inter_digit_timeout = $ivr_menu_inter_digit_timeout; $ivr->ivr_menu_max_failures = $ivr_menu_max_failures; $ivr->ivr_menu_max_timeouts = $ivr_menu_max_timeouts; $ivr->ivr_menu_max_timeouts = $ivr_menu_max_timeouts; $ivr->ivr_menu_digit_len = $ivr_menu_digit_len; $ivr->ivr_menu_digit_len = $ivr_menu_digit_len; $ivr->ivr_menu_direct_dial = $ivr_menu_direct_dial; $ivr->ivr_menu_ringback = $ivr_menu_ringback; $ivr->ivr_menu_enabled = $ivr_menu_enabled; $ivr->ivr_menu_description = $ivr_menu_description; //add the data if ($action == "add" && permission_exists('ivr_menu_add')) { //run the add method in the ivr menu class $ivr->add(); //synchronize the xml config save_dialplan_xml(); //redirect the user require_once "includes/header.php"; echo "\n"; echo "
\n"; echo "Add Complete\n"; echo "
\n"; require_once "includes/footer.php"; return; } //update the data if ($action == "update" && permission_exists('ivr_menu_edit')) { //run the update method in the ivr menu class $ivr->ivr_menu_uuid = $ivr_menu_uuid; $ivr->update(); //redirect the user require_once "includes/header.php"; echo "\n"; echo "
\n"; echo "Update Complete\n"; echo "
\n"; require_once "includes/footer.php"; return; } } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (count($_GET)>0 && $_POST["persistformvar"] != "true") { $ivr_menu_uuid = $_GET["id"]; require_once "resources/classes/switch_ivr_menu.php"; $ivr = new switch_ivr_menu; $ivr->domain_uuid = $_SESSION["domain_uuid"]; $ivr->ivr_menu_uuid = $ivr_menu_uuid; $result = $ivr->find(); $result_count = count($result); foreach ($result as &$row) { $ivr_menu_name = $row["ivr_menu_name"]; $ivr_menu_extension = $row["ivr_menu_extension"]; $ivr_menu_greet_long = $row["ivr_menu_greet_long"]; $ivr_menu_greet_short = $row["ivr_menu_greet_short"]; $ivr_menu_invalid_sound = $row["ivr_menu_invalid_sound"]; $ivr_menu_exit_sound = $row["ivr_menu_exit_sound"]; $ivr_menu_confirm_macro = $row["ivr_menu_confirm_macro"]; $ivr_menu_confirm_key = $row["ivr_menu_confirm_key"]; $ivr_menu_tts_engine = $row["ivr_menu_tts_engine"]; $ivr_menu_tts_voice = $row["ivr_menu_tts_voice"]; $ivr_menu_confirm_attempts = $row["ivr_menu_confirm_attempts"]; $ivr_menu_timeout = $row["ivr_menu_timeout"]; $ivr_menu_exit_app = $row["ivr_menu_exit_app"]; $ivr_menu_exit_data = $row["ivr_menu_exit_data"]; $ivr_menu_inter_digit_timeout = $row["ivr_menu_inter_digit_timeout"]; $ivr_menu_max_failures = $row["ivr_menu_max_failures"]; $ivr_menu_max_timeouts = $row["ivr_menu_max_timeouts"]; $ivr_menu_digit_len = $row["ivr_menu_digit_len"]; $ivr_menu_direct_dial = $row["ivr_menu_direct_dial"]; $ivr_menu_ringback = $row["ivr_menu_ringback"]; $ivr_menu_enabled = $row["ivr_menu_enabled"]; $ivr_menu_description = $row["ivr_menu_description"]; //replace the dash with a space $ivr_menu_name = str_replace("-", " ", $ivr_menu_name); if (strlen($ivr_menu_exit_app) > 0) { $ivr_menu_exit_action = $ivr_menu_exit_app.":".$ivr_menu_exit_data; } } unset ($prep_statement); } //set defaults if (strlen($ivr_menu_timeout) == 0) { $ivr_menu_timeout = '3000'; } if (strlen($ivr_menu_invalid_sound) == 0) { $ivr_menu_invalid_sound = 'ivr/ivr-that_was_an_invalid_entry.wav'; } if (strlen($ivr_menu_tts_engine) == 0) { $ivr_menu_tts_engine = 'flite'; } if (strlen($ivr_menu_tts_voice) == 0) { $ivr_menu_tts_voice = 'rms'; } if (strlen($ivr_menu_confirm_attempts) == 0) { $ivr_menu_confirm_attempts = '3'; } if (strlen($ivr_menu_inter_digit_timeout) == 0) { $ivr_menu_inter_digit_timeout = '2000'; } if (strlen($ivr_menu_max_failures) == 0) { $ivr_menu_max_failures = '3'; } if (strlen($ivr_menu_max_timeouts) == 0) { $ivr_menu_max_timeouts = '3'; } if (strlen($ivr_menu_digit_len) == 0) { $ivr_menu_digit_len = '5'; } if (strlen($ivr_menu_direct_dial) == 0) { $ivr_menu_direct_dial = 'false'; } if (strlen($ivr_menu_enabled) == 0) { $ivr_menu_enabled = 'true'; } if (!isset($ivr_menu_exit_action)) { $ivr_menu_exit_action = ''; } //content require_once "includes/header.php"; echo ""; echo "
"; echo "\n"; echo "\n"; echo " "; echo " "; echo "
\n"; echo "
"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; //--- begin: show_advanced ----------------------- echo "\n"; echo "\n"; echo "\n"; //--- end: show_advanced ----------------------- echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
IVR Menu\n"; echo " \n"; echo " \n"; echo "
\n"; echo "The IVR Menu plays a recording or a pre-defined phrase that presents the caller with options to choose from. Each option has a corresponding destination. The destinations can be extensions, voicemail, IVR menus, hunt groups, FAX extensions, and more.

\n"; echo "
\n"; echo " Name:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Enter a name for the IVR menu.\n"; echo "
\n"; echo " Extension:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Enter the extension number. \n"; echo "
\n"; echo " Greet Long:\n"; echo "\n"; if (if_group("superadmin")) { echo "\n"; echo "\n"; } if (if_group("superadmin")) { echo " \n"; } echo " \n"; //misc optgroup if (if_group("superadmin")) { echo "\n"; echo " \n"; echo " \n"; echo " \n"; echo "\n"; } //recordings if($dh = opendir($_SESSION['switch']['recordings']['dir']."/")) { $tmp_selected = false; $files = Array(); echo "\n"; while($file = readdir($dh)) { if($file != "." && $file != ".." && $file[0] != '.') { if(is_dir($_SESSION['switch']['recordings']['dir'] . "/" . $file)) { //this is a directory } else { if ($ivr_menu_greet_long == $_SESSION['switch']['recordings']['dir']."/".$file && strlen($ivr_menu_greet_long) > 0) { $tmp_selected = true; echo " \n"; } else { echo " \n"; } } } } closedir($dh); echo "\n"; } //sounds $dir_path = $_SESSION['switch']['sounds']['dir']; recur_sounds_dir($_SESSION['switch']['sounds']['dir']); echo "\n"; foreach ($dir_array as $key => $value) { if (strlen($value) > 0) { if (substr($ivr_menu_greet_long, 0, 71) == "\$\${sounds_dir}/\${default_language}/\${default_dialect}/\${default_voice}/") { $ivr_menu_greet_long = substr($ivr_menu_greet_long, 71); } if ($ivr_menu_greet_long == $key) { $tmp_selected = true; echo " \n"; } else { echo " \n"; } } } echo "\n"; //select if (if_group("superadmin")) { if (!$tmp_selected) { echo "\n"; if (file_exists($_SESSION['switch']['recordings']['dir']."/".$ivr_menu_greet_long)) { echo " \n"; } elseif (substr($ivr_menu_greet_long, -3) == "wav" || substr($ivr_menu_greet_long, -3) == "mp3") { echo " \n"; } else { echo " \n"; } echo "\n"; } unset($tmp_selected); } echo " \n"; echo "
\n"; echo "The long greeting is played when entering the menu.\n"; echo "
\n"; echo " Greet Short:\n"; echo "\n"; echo "\n"; echo " \n"; echo "
\n"; echo "The short greeting is played when returning to the menu.\n"; echo "
\n"; echo " Timeout:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "The number of milliseconds to wait after playing the greeting or the confirm macro.\n"; echo "
\n"; echo " Exit Action:\n"; echo "\n"; //switch_select_destination(select_type, select_label, select_name, select_value, select_style, action); switch_select_destination("dialplan", "", "ivr_menu_exit_action", $ivr_menu_exit_action, "", ""); echo "
\n"; echo " Select the exit action to be performed if the IVR exits.\n"; echo "
\n"; echo " Direct Dial:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Define whether callers can dial directly to extensions and feature codes.\n"; echo "
\n"; echo " Ring Back:\n"; echo "\n"; $select_options = ""; if ($ivr_menu_ringback == "\${us-ring}" || $ivr_menu_ringback == "us-ring") { $select_options .= " \n"; } else { $select_options .= " \n"; } if ($ivr_menu_ringback == "\${fr-ring}" || $ivr_menu_ringback == "fr-ring") { $select_options .= " \n"; } else { $select_options .= " \n"; } if ($ivr_menu_ringback == "\${uk-ring}" || $ivr_menu_ringback == "uk-ring") { $select_options .= " \n"; } else { $select_options .= " \n"; } if ($ivr_menu_ringback == "\${rs-ring}" || $ivr_menu_ringback == "rs-ring") { $select_options .= " \n"; } else { $select_options .= " \n"; } require_once "app/music_on_hold/resources/classes/switch_music_on_hold.php"; $moh = new switch_music_on_hold; $moh->select_name = "ivr_menu_ringback"; $moh->select_value = $ivr_menu_ringback; $moh->select_options = $select_options; echo $moh->select(); echo "
\n"; echo "Defines what the caller will hear while the destination is being called.\n"; echo "
\n"; echo "
\n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo " \n"; echo "
Show Advanced\n"; echo " \n"; echo "
\n"; echo "
\n"; echo "
\n"; echo " \n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo " Invalid Sound:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Played when and invalid option is chosen.\n"; echo "
\n"; echo " Exit Sound:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Played when leaving the menu.\n"; echo "
\n"; echo " Confirm Macro:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Enter the confirm macro.\n"; echo "
\n"; echo " Confirm Key:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Enter the confirm key.\n"; echo "
\n"; echo " TTS Engine:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Text to speech engine.\n"; echo "
\n"; echo " TTS Voice:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Text to speech voice.\n"; echo "
\n"; echo " Confirm Attempts:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "The maximum number of confirm attempts allowed.\n"; echo "
\n"; echo " Inter Digit Timeout:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "The number of milliseconds to wait between digits.\n"; echo "
\n"; echo " Max Failures:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Maximum number of retries before exit.\n"; echo "
\n"; echo " Max Timeouts:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Maximum number of timeouts before exit.\n"; echo "
\n"; echo " Digit Length:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Maximum number of digits allowed.\n"; echo "
\n"; echo "
"; echo "
\n"; echo " Enabled:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Define whether the IVR Menu is enabled or disabled.\n"; echo "
\n"; echo " Description:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Enter a description.\n"; echo "
\n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
"; echo ""; if ($action == "update") { require "ivr_menu_options.php"; } echo "
"; echo "
"; require_once "includes/footer.php"; ?>