Portions created by the Initial Developer are Copyright (C) 2013 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('ring_group_add') || permission_exists('ring_group_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support require_once "app_languages.php"; foreach($text as $key => $value) { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $ring_group_destination_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //set the parent uuid if (strlen($_GET["ring_group_uuid"]) > 0) { $ring_group_uuid = check_str($_GET["ring_group_uuid"]); } //get http post variables and set them to php variables if (count($_POST)>0) { $ring_group_uuid = check_str($_POST["ring_group_uuid"]); $destination_number = check_str($_POST["destination_number"]); $destination_delay = check_str($_POST["destination_delay"]); $destination_timeout = check_str($_POST["destination_timeout"]); $destination_prompt = check_str($_POST["destination_prompt"]); } //define the destination_select function function destination_select($select_name, $select_value, $select_default) { if (strlen($select_value) == 0) { $select_value = $select_default; } echo " \n"; } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; if ($action == "update") { $ring_group_destination_uuid = check_str($_POST["ring_group_destination_uuid"]); } //check for all required data //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } //if (strlen($ring_group_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-ring_group_uuid']."
\n"; } //if (strlen($destination_number) == 0) { $msg .= $text['message-required']." ".$text['label-destination_number']."
\n"; } //if (strlen($destination_delay) == 0) { $msg .= $text['message-required']." ".$text['label-destination_delay']."
\n"; } //if (strlen($destination_timeout) == 0) { $msg .= $text['message-required']." ".$text['label-destination_timeout']."
\n"; } //if (strlen($destination_prompt) == 0) { $msg .= $text['message-required']." ".$text['label-destination_prompt']."
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persistformvar.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //add or update the database if ($_POST["persistformvar"] != "true") { if ($action == "add" && permission_exists('ring_group_add')) { $sql = "insert into v_ring_group_destinations "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "ring_group_destination_uuid, "; $sql .= "ring_group_uuid, "; $sql .= "destination_number, "; $sql .= "destination_delay, "; $sql .= "destination_timeout, "; $sql .= "destination_prompt "; $sql .= ") "; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'".uuid()."', "; $sql .= "'$ring_group_uuid', "; $sql .= "'$destination_number', "; $sql .= "'$destination_delay', "; $sql .= "'$destination_timeout', "; $sql .= "'$destination_prompt' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); $_SESSION["message"] = $text['message-add']; header("Location: ring_group_edit.php?id=".$ring_group_uuid); return; } //if ($action == "add") if ($action == "update" && permission_exists('ring_group_edit')) { $sql = "update v_ring_group_destinations set "; $sql .= "destination_number = '$destination_number', "; $sql .= "destination_delay = '$destination_delay', "; $sql .= "destination_timeout = '$destination_timeout', "; if (strlen($destination_prompt) == 0) { $sql .= "destination_prompt = null "; } else { $sql .= "destination_prompt = '$destination_prompt' "; } $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and ring_group_destination_uuid = '$ring_group_destination_uuid' "; $db->exec(check_sql($sql)); unset($sql); $_SESSION["message"] = $text['message-update']; header("Location: ring_group_edit.php?id=".$ring_group_uuid); return; } //if ($action == "update") } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (count($_GET)>0 && $_POST["persistformvar"] != "true") { $ring_group_destination_uuid = check_str($_GET["id"]); $sql = "select * from v_ring_group_destinations "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and ring_group_destination_uuid = '$ring_group_destination_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $ring_group_uuid = $row["ring_group_uuid"]; $destination_number = $row["destination_number"]; $destination_delay = $row["destination_delay"]; $destination_timeout = $row["destination_timeout"]; $destination_prompt = $row["destination_prompt"]; } unset ($prep_statement); } //show the header require_once "resources/header.php"; //show the content 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"; if (permission_exists('ring_group_prompt')) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; } echo " \n"; echo " \n"; echo " "; echo "
".$text['title-ring_group_destination']."
\n"; echo " ".$text['label-destination_number'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-destination_number']."\n"; echo "
\n"; echo " ".$text['label-destination_delay'].":\n"; echo "\n"; destination_select('destination_delay', $destination_delay, '0'); //echo " \n"; echo "
\n"; echo $text['description-destination_delay']."\n"; echo "
\n"; echo " ".$text['label-destination_timeout'].":\n"; echo "\n"; destination_select('destination_timeout', $destination_timeout, '30'); //echo " \n"; echo "
\n"; echo $text['description-destination_timeout']."\n"; echo "
\n"; echo " ".$text['label-destination_prompt'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-destination_prompt']."\n"; echo "
\n"; echo " \n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
"; echo ""; echo "
"; echo "
"; //include the footer require_once "resources/footer.php"; ?>