Portions created by the Initial Developer are Copyright (C) 2008-2018 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes require_once "root.php"; require_once "resources/require.php"; //check permissions require_once "resources/check_auth.php"; if (permission_exists('conference_center_add') || permission_exists('conference_center_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $conference_center_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get http post variables and set them to php variables 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_enabled = check_str($_POST["conference_center_enabled"]); $conference_center_description = check_str($_POST["conference_center_description"]); } //process the user data and save it to the database if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { //get the uuid from the POST if ($action == "update") { $conference_center_uuid = check_str($_POST["conference_center_uuid"]); } //check for all required data $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"; } if (strlen($conference_center_pin_length) == 0) { $msg .= "Please provide: PIN Length
\n"; } //if (strlen($conference_center_order) == 0) { $msg .= "Please provide: Order
\n"; } //if (strlen($conference_center_description) == 0) { $msg .= "Please provide: Description
\n"; } if (strlen($conference_center_enabled) == 0) { $msg .= "Please provide: Enabled
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //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"; if ($conference_center_pin_length > 1 && $conference_center_pin_length < 4) { $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; $dialplan_xml .= " \n"; $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; //add the dialplan permission $p = new permissions; $p->add("dialplan_add", "temp"); $p->add("dialplan_edit", "temp"); //save to the data $database = new database; $database->app_name = "conference_centers"; $database->app_uuid = "b81412e8-7253-91f4-e48e-42fc2c9a38d9"; if (strlen($conference_center_uuid) > 0) { $database->uuid($conference_center_uuid); } $database->save($array); $message = $database->message; //remove the temporary permission $p->delete("dialplan_add", "temp"); $p->delete("dialplan_edit", "temp"); //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") { message::add($text['message-add']); } if ($action == "update") { message::add($text['message-update']); } header("Location: conference_centers.php"); return; } } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) //pre-populate the form 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(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_extension = $row["conference_center_extension"]; $conference_center_greeting = $row["conference_center_greeting"]; $conference_center_pin_length = $row["conference_center_pin_length"]; $conference_center_enabled = $row["conference_center_enabled"]; $conference_center_description = $row["conference_center_description"]; } unset ($prep_statement); } //set defaults if (strlen($conference_center_enabled) == 0) { $conference_center_enabled = "true"; } if (strlen($conference_center_pin_length) == 0) { $conference_center_pin_length = 9; } //get the recordings $sql = "select recording_name, recording_filename from v_recordings "; $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; $sql .= "order by recording_name asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $recordings = $prep_statement->fetchAll(PDO::FETCH_ASSOC); //get the phrases $sql = "select * from v_phrases "; $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); //get the streams $sql = "select * from v_streams "; $sql .= "where (domain_uuid = '".$_SESSION["domain_uuid"]."' or domain_uuid is null) "; $sql .= "and stream_enabled = 'true' "; $sql .= "order by stream_name asc "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $streams = $prep_statement->fetchAll(PDO::FETCH_NAMED); //show the header require_once "resources/header.php"; //show the content 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-conference_center_name']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-conference_center_name']."\n"; echo "
\n"; echo " ".$text['label-conference_center_extension']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-conference_center_extension']."\n"; echo "
\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-conference_center_greeting']."\n"; echo "
\n"; echo " ".$text['label-conference_center_pin_length']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-conference_center_pin_length']."\n"; echo "
\n"; echo " ".$text['label-conference_center_enabled']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-conference_center_enabled']."\n"; echo "
\n"; echo " ".$text['label-conference_center_description']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-conference_center_description']."\n"; echo "
\n"; if ($action == "update") { echo " \n"; echo " \n"; } echo " \n"; echo "
"; echo "
"; echo "

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