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 (if_group("admin") || if_group("superadmin")) { //access granted } else { echo "access denied"; exit; } //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $destination_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get http post variables and set them to php variables if (count($_POST)>0) { $dialplan_uuid = check_str($_POST["dialplan_uuid"]); $destination_type = check_str($_POST["destination_type"]); $destination_number = check_str($_POST["destination_number"]); $destination_caller_id_name = check_str($_POST["destination_caller_id_name"]); $destination_caller_id_number = check_str($_POST["destination_caller_id_number"]); $destination_context = check_str($_POST["destination_context"]); $fax_uuid = check_str($_POST["fax_uuid"]); $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") { $destination_uuid = check_str($_POST["destination_uuid"]); } //check for all required data //if (strlen($dialplan_uuid) == 0) { $msg .= "Please provide: Dialplan UUID
\n"; } //if (strlen($destination_type) == 0) { $msg .= "Please provide: Name
\n"; } //if (strlen($destination_number) == 0) { $msg .= "Please provide: Extension
\n"; } //if (strlen($destination_caller_id_name) == 0) { $msg .= "Please provide: Caller ID Name
\n"; } //if (strlen($destination_caller_id_number) == 0) { $msg .= "Please provide: Caller ID Number
\n"; } //if (strlen($destination_context) == 0) { $msg .= "Please provide: Context
\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") { $sql = "insert into v_destinations "; $sql .= "("; $sql .= "domain_uuid, "; if (strlen($dialplan_uuid) > 0) { $sql .= "dialplan_uuid, "; } $sql .= "destination_uuid, "; $sql .= "destination_type, "; $sql .= "destination_number, "; $sql .= "destination_caller_id_name, "; $sql .= "destination_caller_id_number, "; $sql .= "destination_context, "; if (strlen($fax_uuid) > 0) { $sql .= "fax_uuid, "; } $sql .= "destination_enabled, "; $sql .= "destination_description "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; if (strlen($dialplan_uuid) > 0) { $sql .= "'$dialplan_uuid', "; } $sql .= "'".uuid()."', "; $sql .= "'$destination_type', "; $sql .= "'$destination_number', "; $sql .= "'$destination_caller_id_name', "; $sql .= "'$destination_caller_id_number', "; $sql .= "'$destination_context', "; if (strlen($fax_uuid) > 0) { $sql .= "'$fax_uuid', "; } $sql .= "'$destination_enabled', "; $sql .= "'$destination_description' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); 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") { $sql = "update v_destinations set "; if (strlen($dialplan_uuid) > 0) { $sql .= "dialplan_uuid = '$dialplan_uuid', "; } $sql .= "destination_type = '$destination_type', "; $sql .= "destination_number = '$destination_number', "; $sql .= "destination_caller_id_name = '$destination_caller_id_name', "; $sql .= "destination_caller_id_number = '$destination_caller_id_number', "; $sql .= "destination_context = '$destination_context', "; $sql .= "fax_uuid = '$fax_uuid', "; $sql .= "destination_enabled = '$destination_enabled', "; $sql .= "destination_description = '$destination_description' "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and destination_uuid = '$destination_uuid'"; $db->exec(check_sql($sql)); unset($sql); 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") { $destination_uuid = $_GET["id"]; $sql = "select * from v_destinations "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and destination_uuid = '$destination_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(); foreach ($result as &$row) { $dialplan_uuid = $row["dialplan_uuid"]; $destination_type = $row["destination_type"]; $destination_number = $row["destination_number"]; $destination_caller_id_name = $row["destination_caller_id_name"]; $destination_caller_id_number = $row["destination_caller_id_number"]; $destination_context = $row["destination_context"]; $fax_uuid = $row["fax_uuid"]; $destination_enabled = $row["destination_enabled"]; $destination_description = $row["destination_description"]; break; //limit to 1 row } unset ($prep_statement); } //set the defaults if (strlen($destination_type) == 0) { $destination_type = 'inbound'; } if (strlen($destination_context) == 0) { $destination_context = 'public'; } //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"; 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 " "; echo "
Destination
\n"; echo "An alias for a call destination. The destination will use the dialplan to find it its target.

\n"; echo "
\n"; echo " Type:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Select the type.\n"; echo "
\n"; echo " Destination:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Enter the destination.\n"; echo "
\n"; echo " Caller ID Name:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Enter the caller id name.\n"; echo "
\n"; echo " Caller ID Number:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Enter the caller id number.\n"; echo "
\n"; echo " Context:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Enter the context.\n"; echo "
\n"; echo " Fax Destination:\n"; echo "\n"; $sql = "select * from v_fax "; $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; $sql .= "order by fax_name asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC); echo " \n"; unset ($prep_statement, $extension); echo "
\n"; echo " Select the fax destination to enable fax detection.\n"; echo "
\n"; echo " Enabled:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "
\n"; echo " Description:\n"; echo "\n"; echo " \n"; echo "
\n"; echo "Enter the description.\n"; echo "
\n"; if ($action == "update") { echo " \n"; echo " \n"; } echo " \n"; echo "
"; echo ""; echo "
"; echo "
"; //include the footer require_once "includes/footer.php"; ?>