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 "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('voicemail_add') || permission_exists('voicemail_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $voicemail_option_uuid = check_str($_REQUEST["id"]); } //get the menu id if (strlen($_GET["voicemail_uuid"]) > 0) { $voicemail_uuid = check_str($_GET["voicemail_uuid"]); } //get the http post variables and set them to php variables if (count($_POST)>0) { $voicemail_uuid = check_str($_POST["voicemail_uuid"]); $voicemail_option_digits = check_str($_POST["voicemail_option_digits"]); $voicemail_option_action = check_str($_POST["voicemail_option_action"]); $voicemail_option_param = check_str($_POST["voicemail_option_param"]); $voicemail_option_order = check_str($_POST["voicemail_option_order"]); $voicemail_option_description = check_str($_POST["voicemail_option_description"]); //set the default voicemail_option_action if (strlen($voicemail_option_action) == 0) { $voicemail_option_action = "menu-exec-app"; } //seperate the action and the param $options_array = explode(":", $voicemail_option_param); $voicemail_option_action = array_shift($options_array); $voicemail_option_param = join(':', $options_array); } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; $voicemail_option_uuid = check_str($_POST["voicemail_option_uuid"]); //check for all required data if (strlen($voicemail_option_digits) == 0) { $msg .= $text['message-required'].$text['label-option']."
\n"; } if (strlen($voicemail_option_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //update the database if ($_POST["persistformvar"] != "true") { if (permission_exists('voicemail_edit')) { $sql = "update v_voicemail_options set "; $sql .= "voicemail_option_digits = '".$voicemail_option_digits."', "; $sql .= "voicemail_option_action = '".$voicemail_option_action."', "; $sql .= "voicemail_option_param = '".$voicemail_option_param."', "; $sql .= "voicemail_option_order = ".$voicemail_option_order.", "; $sql .= "voicemail_option_description = '".$voicemail_option_description."' "; $sql .= "where domain_uuid = '".$domain_uuid."' "; $sql .= "and voicemail_option_uuid = '".$voicemail_option_uuid."' "; $db->exec(check_sql($sql)); unset($sql); //redirect the user messages::add($text['message-update']); header('Location: voicemail_edit.php?id='.$voicemail_uuid); return; } } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //initialize the destinations object $destination = new destinations; //pre-populate the form if (count($_GET)>0 && $_POST["persistformvar"] != "true") { $voicemail_option_uuid = $_GET["id"]; $sql = "select * from v_voicemail_options "; $sql .= "where voicemail_option_uuid = '".$voicemail_option_uuid."' "; $sql .= "and domain_uuid = '".$domain_uuid."' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $domain_uuid = $row["domain_uuid"]; $voicemail_uuid = $row["voicemail_uuid"]; $voicemail_option_digits = trim($row["voicemail_option_digits"]); $voicemail_option_action = $row["voicemail_option_action"]; $voicemail_option_param = $row["voicemail_option_param"]; //if admin show only the param if (if_group("admin")) { $voicemail_options_label = $voicemail_option_param; } //if superadmin show both the action and param if (if_group("superadmin")) { $voicemail_options_label = $voicemail_option_action.':'.$voicemail_option_param; } $voicemail_option_order = $row["voicemail_option_order"]; $voicemail_option_description = $row["voicemail_option_description"]; break; //limit to 1 row } unset ($prep_statement); } //send the content to the browser require_once "resources/header.php"; $document['title'] = $text['title-voicemail_option']; 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 " "; echo "
"; echo " ".$text['header-voicemail_option'].""; echo "

"; echo "
"; echo " "; echo " \n"; echo "
\n"; echo " ".$text['label-option']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-option']."\n"; echo "
\n"; echo " ".$text['label-destination']."\n"; echo "\n"; $tmp_select_value = ''; if (strlen($voicemail_option_action.$voicemail_option_param) > 0) { $tmp_select_value = $voicemail_option_action.':'.$voicemail_option_param; } echo $destination->select('ivr', 'voicemail_option_param', $tmp_select_value); unset($tmp_select_value); echo "
\n"; echo $text['description-destination']."\n"; echo "
\n"; echo " ".$text['label-order']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-order']."\n"; echo "
\n"; echo " ".$text['label-description']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-description']."\n"; echo "
\n"; echo " \n"; echo " \n"; echo "
"; echo " \n"; echo "
\n"; echo "
\n"; require_once "resources/footer.php"; ?>