Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "includes/require.php"; require_once "includes/checkauth.php"; //check permissions if (permission_exists('hunt_group_add') || permission_exists('hunt_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']]; } //set the action as an add or an update if (isset($_REQUEST["id"])) { $action = "update"; $hunt_group_destination_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } if (isset($_REQUEST["id2"])) { $hunt_group_uuid = check_str($_REQUEST["id2"]); } //get the http values and set them as variables if (count($_POST)>0) { if (isset($_POST["hunt_group_uuid"])) { $hunt_group_uuid = check_str($_POST["hunt_group_uuid"]); } $destination_data = check_str($_POST["destination_data"]); $destination_type = check_str($_POST["destination_type"]); $destination_timeout = check_str($_POST["destination_timeout"]); $destination_order = check_str($_POST["destination_order"]); $destination_enabled = check_str($_POST["destination_enabled"]); $destination_description = check_str($_POST["destination_description"]); } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; if ($action == "update") { $hunt_group_destination_uuid = check_str($_POST["hunt_group_destination_uuid"]); } //check for all required data if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid
\n"; } if (strlen($destination_data) == 0) { $msg .= $text['message-required'].$text['label-destination']."
\n"; } if (strlen($destination_type) == 0) { $msg .= $text['message-required'].$text['label-type']."
\n"; } //if (strlen($destination_timeout) == 0) { $msg .= $text['message-required'].$text['label-timeout']."
\n"; } //if (strlen($destination_order) == 0) { $msg .= $text['message-required'].$text['label-order']."
\n"; } //if (strlen($destination_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."
\n"; } //if (strlen($destination_description) == 0) { $msg .= $text['message-required'].$text['label-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; } //add or update the database if ($_POST["persistformvar"] != "true") { if ($action == "add" && permission_exists('hunt_group_add')) { $hunt_group_destination_uuid = uuid(); $sql = "insert into v_hunt_group_destinations "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "hunt_group_uuid, "; $sql .= "hunt_group_destination_uuid, "; $sql .= "destination_data, "; $sql .= "destination_type, "; $sql .= "destination_timeout, "; $sql .= "destination_order, "; $sql .= "destination_enabled, "; $sql .= "destination_description "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$hunt_group_uuid', "; $sql .= "'$hunt_group_destination_uuid', "; $sql .= "'$destination_data', "; $sql .= "'$destination_type', "; $sql .= "'$destination_timeout', "; $sql .= "'$destination_order', "; $sql .= "'$destination_enabled', "; $sql .= "'$destination_description' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); //synchronize the xml config save_hunt_group_xml(); require_once "includes/header.php"; echo "\n"; echo "
\n"; echo $text['message-add']."\n"; echo "
\n"; require_once "includes/footer.php"; return; } //if ($action == "add") if ($action == "update" && permission_exists('hunt_group_edit')) { $sql = "update v_hunt_group_destinations set "; $sql .= "domain_uuid = '$domain_uuid', "; $sql .= "hunt_group_uuid = '$hunt_group_uuid', "; $sql .= "destination_data = '$destination_data', "; $sql .= "destination_type = '$destination_type', "; $sql .= "destination_timeout = '$destination_timeout', "; $sql .= "destination_order = '$destination_order', "; $sql .= "destination_enabled = '$destination_enabled', "; $sql .= "destination_description = '$destination_description' "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and hunt_group_destination_uuid = '$hunt_group_destination_uuid'"; $db->exec(check_sql($sql)); //synchronize the xml config save_hunt_group_xml(); require_once "includes/header.php"; echo "\n"; echo "
\n"; echo $text['message-update']."\n"; echo "
\n"; require_once "includes/footer.php"; 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") { $hunt_group_destination_uuid = $_GET["id"]; $sql = "select * from v_hunt_group_destinations "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and hunt_group_destination_uuid = '$hunt_group_destination_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $hunt_group_uuid = $row["hunt_group_uuid"]; $destination_data = $row["destination_data"]; $destination_type = $row["destination_type"]; $destination_timeout = $row["destination_timeout"]; $destination_order = $row["destination_order"]; $destination_enabled = $row["destination_enabled"]; $destination_description = $row["destination_description"]; break; //limit to 1 row } unset ($prep_statement); } //show the header require_once "includes/header.php"; if ($action == "add") { $page["title"] = $text['title-hunt_group_destination_add']; } if ($action == "update") { $page["title"] = $text['title-hunt_group_destination_edit']; } //show the content echo "
"; echo "\n"; echo "\n"; echo " "; echo " "; echo "
\n"; echo "
"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; if ($action == "add") { echo "\n"; } if ($action == "update") { 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 " "; echo "
".$text['header-hunt_group_destination_add']."".$text['header-hunt_group_destination_edit']."
\n"; echo " ".$text['label-destination'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo "".$text['description-destination_examples']."...
\n"; echo $text['description-destination_example_extension'].": 1001
\n"; echo $text['description-destination_example_voicemail'].": 1001
\n"; echo $text['description-destination_example_sip_uri_voicemail'].": sofia/internal/*98@\${domain}
\n"; echo $text['description-destination_example_sip_uri_external_number'].": sofia/gateway/gatewayname/12081231234
\n"; echo $text['description-destination_example_sip_uri_auto_attendant'].": sofia/internal/5002@\${domain}
\n"; echo $text['description-destination_example_sip_uri_user'].": /user/1001@\${domain}\n"; echo "
\n"; echo " ".$text['label-type'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " ".$text['label-timeout'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-destination_timeout']."\n"; echo "
\n"; echo " ".$text['label-order'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-destination_order']."\n"; echo "
\n"; echo " ".$text['label-enabled'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " ".$text['label-description'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-description']."\n"; echo "
\n"; echo " \n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
"; echo ""; echo "
"; echo "
"; //show the footer require_once "includes/footer.php"; ?>