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; } //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 .= "Please provide: domain_uuid
\n"; } if (strlen($destination_data) == 0) { $msg .= "Please provide: Destination
\n"; } if (strlen($destination_type) == 0) { $msg .= "Please provide: Type
\n"; } //if (strlen($destination_timeout) == 0) { $msg .= "Please provide: Timeout
\n"; } //if (strlen($destination_order) == 0) { $msg .= "Please provide: Order
\n"; } //if (strlen($destination_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } //if (strlen($destination_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; } //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 "Add Complete\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 "Update Complete\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"; //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 "
Destination AddDestination Edit
\n"; echo " Destination:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "extension: 1001
\n"; echo "voicemail: 1001
\n"; echo "sip uri (voicemail): sofia/internal/*98@\${domain}
\n"; echo "sip uri (external number): sofia/gateway/gatewayname/12081231234
\n"; echo "sip uri (auto attendant): sofia/internal/5002@\${domain}
\n"; echo "sip uri (user): /user/1001@\${domain}\n"; echo "
\n"; echo " Type:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " Timeout:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Select the destination timeout in seconds. \n"; echo "
\n"; echo " Order:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Processing of each destination is determined by this order. \n"; echo "
\n"; echo " Enabled:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "\n"; echo "
\n"; echo " Description:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "You may enter a description here for your reference (not parsed).\n"; echo "
\n"; echo " \n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
"; echo ""; echo "
"; echo "
"; //show the footer require_once "includes/footer.php"; ?>