From 5bd3d3310d848da6f7cd1ac0f4f4ef0756e87f5c Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Mon, 3 Oct 2016 20:15:28 -0600 Subject: [PATCH] Update conference_center_edit.php --- .../conference_center_edit.php | 322 +++++++----------- 1 file changed, 125 insertions(+), 197 deletions(-) diff --git a/app/conference_centers/conference_center_edit.php b/app/conference_centers/conference_center_edit.php index ce66e44c2e..51de1f940c 100644 --- a/app/conference_centers/conference_center_edit.php +++ b/app/conference_centers/conference_center_edit.php @@ -27,9 +27,9 @@ //includes require_once "root.php"; require_once "resources/require.php"; - require_once "resources/check_auth.php"; //check permissions + require_once "resources/check_auth.php"; if (permission_exists('conference_center_add') || permission_exists('conference_center_edit')) { //access granted } @@ -52,30 +52,27 @@ } //get http post variables and set them to php variables - if (count($_POST) > 0) { + if (is_array($_POST)) { + $conference_center_uuid = check_str($_POST["conference_center_uuid"]); $dialplan_uuid = check_str($_POST["dialplan_uuid"]); $conference_center_name = check_str($_POST["conference_center_name"]); $conference_center_extension = check_str($_POST["conference_center_extension"]); $conference_center_greeting = check_str($_POST["conference_center_greeting"]); $conference_center_pin_length = check_str($_POST["conference_center_pin_length"]); - $conference_center_description = check_str($_POST["conference_center_description"]); $conference_center_enabled = check_str($_POST["conference_center_enabled"]); - - //sanitize the conference name - $conference_center_name = preg_replace("/[^A-Za-z0-9\- ]/", "", $conference_center_name); - $conference_center_name = str_replace(" ", "-", $conference_center_name); + $conference_center_description = check_str($_POST["conference_center_description"]); } -//process user data - if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { +//process the user data and save it to the database + if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { - //get the id + //get the uuid from the POST if ($action == "update") { $conference_center_uuid = check_str($_POST["conference_center_uuid"]); } //check for all required data - $msg = ''; + $msg = ''; //if (strlen($dialplan_uuid) == 0) { $msg .= "Please provide: Dialplan UUID
\n"; } if (strlen($conference_center_name) == 0) { $msg .= "Please provide: Name
\n"; } if (strlen($conference_center_extension) == 0) { $msg .= "Please provide: Extension
\n"; } @@ -96,163 +93,103 @@ return; } - //add or update the database - if ($_POST["persistformvar"] != "true") { + //set the domain_uuid + $_POST["domain_uuid"] = $_SESSION["domain_uuid"]; + + //add the conference_center_uuid + if (!isset($_POST["conference_center_uuid"])) { + $conference_center_uuid = uuid(); + $_POST["conference_center_uuid"] = $conference_center_uuid; + } + + //add the dialplan_uuid + if (!isset($_POST["dialplan_uuid"])) { + $dialplan_uuid = uuid(); + $_POST["dialplan_uuid"] = $dialplan_uuid; + } + + //build the xml dialplan + $dialplan_xml = "\n"; + $dialplan_xml .= " \n"; + $dialplan_xml .= " \n"; + $dialplan_xml .= " \n"; + $dialplan_xml .= "\n"; + + //build the dialplan array + $dialplan["domain_uuid"] = $_SESSION['domain_uuid']; + $dialplan["dialplan_uuid"] = $dialplan_uuid; + $dialplan["dialplan_name"] = $conference_center_name; + $dialplan["dialplan_number"] = $conference_center_extension; + $dialplan["dialplan_context"] = $_SESSION['context']; + $dialplan["dialplan_continue"] = "false"; + $dialplan["dialplan_xml"] = $dialplan_xml; + $dialplan["dialplan_order"] = "333"; + $dialplan["dialplan_enabled"] = $conference_center_enabled; + $dialplan["dialplan_description"] = $conference_center_description; + $dialplan["app_uuid"] = "b81412e8-7253-91f4-e48e-42fc2c9a38d9"; + + //prepare the array + $array['conference_centers'][] = $_POST; + $array['dialplans'][] = $dialplan; + + //save to the data + $orm = new orm; + //$orm->name('conference_centers'); + $orm->app_name = "conference_centers"; + $orm->app_uuid = "b81412e8-7253-91f4-e48e-42fc2c9a38d9"; + if (strlen($conference_center_uuid) > 0) { + $orm->uuid($conference_center_uuid); + } + $orm->save($array); + $message = $orm->message; + + //debug information + //echo "
\n";
+			//print_r($message);
+			//echo "
\n"; + //exit; + + //syncrhonize configuration + save_dialplan_xml(); + + //apply settings reminder + $_SESSION["reload_xml"] = true; + + //clear the cache + $cache = new cache; + $cache->delete("dialplan:".$_SESSION["context"]); + + //redirect the user + if (isset($action)) { if ($action == "add") { - //prepare the uuids - $conference_center_uuid = uuid(); - $dialplan_uuid = uuid(); - //add the conference - $sql = "insert into v_conference_centers "; - $sql .= "("; - $sql .= "domain_uuid, "; - $sql .= "conference_center_uuid, "; - $sql .= "dialplan_uuid, "; - $sql .= "conference_center_name, "; - $sql .= "conference_center_extension, "; - $sql .= "conference_center_pin_length, "; - $sql .= "conference_center_greeting, "; - $sql .= "conference_center_description, "; - $sql .= "conference_center_enabled "; - $sql .= ")"; - $sql .= "values "; - $sql .= "("; - $sql .= "'$domain_uuid', "; - $sql .= "'$conference_center_uuid', "; - $sql .= "'$dialplan_uuid', "; - $sql .= "'$conference_center_name', "; - $sql .= "'$conference_center_extension', "; - $sql .= "'$conference_center_pin_length', "; - $sql .= "'$conference_center_greeting', "; - $sql .= "'$conference_center_description', "; - $sql .= "'$conference_center_enabled' "; - $sql .= ")"; - $db->exec(check_sql($sql)); - unset($sql); - - //create the dialplan entry - $dialplan_name = $conference_center_name; - $dialplan_order ='333'; - $dialplan_context = $_SESSION['context']; - $dialplan_enabled = 'true'; - $dialplan_description = $conference_center_description; - $app_uuid = 'b81412e8-7253-91f4-e48e-42fc2c9a38d9'; - dialplan_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_name, $dialplan_order, $dialplan_context, $dialplan_enabled, $dialplan_description, $app_uuid); - - // - $dialplan_detail_tag = 'condition'; //condition, action, antiaction - $dialplan_detail_type = 'destination_number'; - $dialplan_detail_data = '^'.$conference_center_extension.'$'; - $dialplan_detail_order = '010'; - $dialplan_detail_group = '2'; - dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); - - // - $dialplan_detail_tag = 'action'; //condition, action, antiaction - $dialplan_detail_type = 'lua'; - $dialplan_detail_data = 'app.lua conference_center'; - $dialplan_detail_order = '020'; - $dialplan_detail_group = '2'; - dialplan_detail_add($_SESSION['domain_uuid'], $dialplan_uuid, $dialplan_detail_tag, $dialplan_detail_order, $dialplan_detail_group, $dialplan_detail_type, $dialplan_detail_data); - - //save the xml - save_dialplan_xml(); - $_SESSION["message"] = $text['message-add']; - header("Location: conference_centers.php"); - return; - } //if ($action == "add") - + } if ($action == "update") { - //update the conference center extension - $sql = "update v_conference_centers set "; - $sql .= "conference_center_name = '$conference_center_name', "; - $sql .= "conference_center_extension = '$conference_center_extension', "; - $sql .= "conference_center_pin_length = '$conference_center_pin_length', "; - $sql .= "conference_center_greeting = '$conference_center_greeting', "; - $sql .= "conference_center_description = '$conference_center_description', "; - $sql .= "conference_center_enabled = '$conference_center_enabled' "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and conference_center_uuid = '$conference_center_uuid'"; - $db->exec(check_sql($sql)); - unset($sql); - - //udpate the conference center dialplan - $sql = "update v_dialplans set "; - $sql .= "dialplan_name = '$conference_center_name', "; - if (strlen($dialplan_order) > 0) { - $sql .= "dialplan_order = '333', "; - } - $sql .= "dialplan_context = '".$_SESSION['context']."', "; - $sql .= "dialplan_enabled = 'true', "; - $sql .= "dialplan_description = '$conference_center_description' "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and dialplan_uuid = '$dialplan_uuid' "; - $db->query($sql); - unset($sql); - - //update dialplan detail condition - $sql = "update v_dialplan_details set "; - $sql .= "dialplan_detail_data = '^".$conference_center_extension."$' "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and dialplan_detail_tag = 'condition' "; - $sql .= "and dialplan_detail_type = 'destination_number' "; - $sql .= "and dialplan_uuid = '$dialplan_uuid' "; - $db->query($sql); - unset($sql); - - //update dialplan detail action - $dialplan_detail_type = 'lua'; - $dialplan_detail_data = 'app.lua conference_center'; - $sql = "update v_dialplan_details set "; - $sql .= "dialplan_detail_type = '".$dialplan_detail_type."', "; - $sql .= "dialplan_detail_data = '".$dialplan_detail_data."' "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and dialplan_detail_tag = 'action' "; - $sql .= "and dialplan_detail_type = 'lua' "; - $sql .= "and dialplan_uuid = '$dialplan_uuid' "; - $db->query($sql); - - //syncrhonize configuration - save_dialplan_xml(); - - //apply settings reminder - $_SESSION["reload_xml"] = true; - - //clear the cache - $cache = new cache; - $cache->delete("dialplan:".$_SESSION["context"]); - - //redirect the browser - $_SESSION["message"] = $text['message-update']; - header("Location: conference_centers.php"); - return; - } //if ($action == "update") - } //if ($_POST["persistformvar"] != "true") - } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) - -//function to show the list of sound files - // moved to functions.php + $_SESSION["message"] = $text['message-update']; + } + header("Location: conference_centers.php"); + return; + } + } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) //pre-populate the form - if (count($_GET)>0 && $_POST["persistformvar"] != "true") { - $conference_center_uuid = $_GET["id"]; + if (is_array($_GET) && $_POST["persistformvar"] != "true") { + $conference_center_uuid = check_str($_GET["id"]); $sql = "select * from v_conference_centers "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and conference_center_uuid = '$conference_center_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); - $result = $prep_statement->fetchAll(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { + $conference_center_uuid = $row["conference_center_uuid"]; $dialplan_uuid = $row["dialplan_uuid"]; $conference_center_name = $row["conference_center_name"]; - $conference_center_greeting = $row["conference_center_greeting"]; $conference_center_extension = $row["conference_center_extension"]; + $conference_center_greeting = $row["conference_center_greeting"]; $conference_center_pin_length = $row["conference_center_pin_length"]; - $conference_center_order = $row["conference_center_order"]; - $conference_center_description = $row["conference_center_description"]; $conference_center_enabled = $row["conference_center_enabled"]; - $conference_center_name = str_replace("-", " ", $conference_center_name); + $conference_center_description = $row["conference_center_description"]; } unset ($prep_statement); } @@ -271,7 +208,7 @@ //get the phrases $sql = "select * from v_phrases "; - $sql .= "where (domain_uuid = '".$domain_uuid."' or domain_uuid is null) "; + $sql .= "where (domain_uuid = '".$_SESSION["domain_uuid"]."' or domain_uuid is null) "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $phrases = $prep_statement->fetchAll(PDO::FETCH_NAMED); @@ -280,51 +217,44 @@ require_once "resources/header.php"; //show the content - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
".$text['title-conference_center']."\n"; - echo " \n"; - if (permission_exists('conference_active_advanced_view')) { - echo " \n"; - } - echo " \n"; - echo "
\n"; - echo "
"; - echo $text['description-conference_center']."\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 "
".$text['title-conference_center']."

\n"; + echo " "; + echo " "; + echo "
\n"; - echo " ".$text['label-name']."\n"; + echo " ".$text['label-conference_center_name']."\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo " ".$text['description-name']."\n"; + echo "
\n"; + echo $text['description-conference_center_name']."\n"; echo "
\n"; - echo " ".$text['label-extension']."\n"; + echo " ".$text['label-conference_center_extension']."\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo " ".$text['description-extension']."\n"; + echo "
\n"; + echo $text['description-conference_center_extension']."\n"; echo "
\n"; - echo " ".$text['label-greeting']."\n"; + echo " ".$text['label-conference_center_greeting']."\n"; echo "\n"; + //echo " \n"; if (permission_exists('conference_center_add') || permission_exists('conference_center_edit')) { echo "\n"; echo "\n"; } - echo " \n"; - echo "
\n"; - echo $text['description-greeting']."\n"; + echo "
\n"; + echo " ".$text['description-conference_center_greeting']."\n"; echo "
\n"; - echo " ".$text['label-pin-length']."\n"; + echo " ".$text['label-conference_center_pin_length']."\n"; echo "\n"; - echo " \n"; - echo "
\n"; - echo " ".$text['description-pin-length']."\n"; + echo " \n"; + echo "
\n"; + echo $text['description-conference_center_pin_length']."\n"; echo "
\n"; - echo " ".$text['label-enabled']."\n"; + echo " ".$text['label-conference_center_enabled']."\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo " ".$text['description-enabled']."\n"; + echo "
\n"; + echo $text['description-conference_center_enabled']."\n"; echo "
\n"; - echo " ".$text['label-description']."\n"; + echo " ".$text['label-conference_center_description']."\n"; echo "\n"; echo " \n"; - echo "
\n"; - echo " ".$text['description-description']."\n"; + echo "
\n"; + echo $text['description-conference_center_description']."\n"; echo "
\n"; if ($action == "update") { - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; } - echo "
"; - echo " \n"; + echo " \n"; echo "
"; - echo "

"; echo "
"; + echo "

"; //include the footer require_once "resources/footer.php"; + ?>