Portions created by the Initial Developer are Copyright (C) 2008-2025 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ //includes files require_once dirname(__DIR__, 2) . "/resources/require.php"; require_once "resources/check_auth.php"; //check permissions if (!(permission_exists('conference_center_add') || permission_exists('conference_center_edit'))) { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //action add or update if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) { $action = "update"; $conference_center_uuid = $_REQUEST["id"]; } else { $action = "add"; } //set the defaults $conference_center_name = ''; $conference_center_extension = ''; $conference_center_description = ''; $conference_center_greeting = ''; //process the user data and save it to the database if (!empty($_POST) && empty($_POST["persistformvar"])) { //delete the conference center if (!empty($_POST['action']) && $_POST['action'] == 'delete' && permission_exists('conference_center_delete') && is_uuid($conference_center_uuid)) { //prepare $array[0]['checked'] = 'true'; $array[0]['uuid'] = $conference_center_uuid; //delete $obj = new conference_centers; $obj->delete_conference_centers($array); //redirect header('Location: conference_centers.php'); exit; } //get http post variables and set them to php variables $conference_center_uuid = $_POST["conference_center_uuid"] ?? null; $dialplan_uuid = $_POST["dialplan_uuid"] ?? null; $conference_center_name = $_POST["conference_center_name"]; $conference_center_extension = $_POST["conference_center_extension"]; $conference_center_greeting = $_POST["conference_center_greeting"]; $conference_center_pin_length = $_POST["conference_center_pin_length"]; $conference_center_enabled = $_POST["conference_center_enabled"]; $conference_center_description = $_POST["conference_center_description"]; //validate the token $token = new token; if (!$token->validate($_SERVER['PHP_SELF'])) { message::add($text['message-invalid_token'],'negative'); header('Location: conference_centers.php'); exit; } //check for all required data $msg = ''; //if (empty($dialplan_uuid)) { $msg .= "Please provide: Dialplan UUID
\n"; } if (empty($conference_center_name)) { $msg .= "Please provide: Name
\n"; } if (empty($conference_center_extension)) { $msg .= "Please provide: Extension
\n"; } if (empty($conference_center_pin_length)) { $msg .= "Please provide: PIN Length
\n"; } //if (empty($conference_center_order)) { $msg .= "Please provide: Order
\n"; } //if (empty($conference_center_description)) { $msg .= "Please provide: Description
\n"; } if (empty($conference_center_enabled)) { $msg .= "Please provide: Enabled
\n"; } if (!empty($msg) && empty($_POST["persistformvar"])) { 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; } //add the conference_center_uuid if (empty($_POST["conference_center_uuid"]) || !is_uuid($_POST["conference_center_uuid"])) { $conference_center_uuid = uuid(); } //add the dialplan_uuid if (empty($_POST["dialplan_uuid"]) || !is_uuid($_POST["dialplan_uuid"])) { $dialplan_uuid = uuid(); } //prepare the array $array['conference_centers'][0]['domain_uuid'] = $_SESSION['domain_uuid'];; $array['conference_centers'][0]['conference_center_uuid'] = $conference_center_uuid; $array['conference_centers'][0]['dialplan_uuid'] = $dialplan_uuid; $array['conference_centers'][0]['conference_center_name'] = $conference_center_name; $array['conference_centers'][0]['conference_center_extension'] = $conference_center_extension; $array['conference_centers'][0]['conference_center_greeting'] = $conference_center_greeting; $array['conference_centers'][0]['conference_center_pin_length'] = $conference_center_pin_length; $array['conference_centers'][0]['conference_center_enabled'] = $conference_center_enabled; $array['conference_centers'][0]['conference_center_description'] = $conference_center_description; //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 $array['dialplans'][0]["domain_uuid"] = $_SESSION['domain_uuid']; $array['dialplans'][0]["dialplan_uuid"] = $dialplan_uuid; $array['dialplans'][0]["dialplan_name"] = $conference_center_name; $array['dialplans'][0]["dialplan_number"] = $conference_center_extension; $array['dialplans'][0]["dialplan_context"] = $_SESSION['domain_name']; $array['dialplans'][0]["dialplan_continue"] = "false"; $array['dialplans'][0]["dialplan_xml"] = $dialplan_xml; $array['dialplans'][0]["dialplan_order"] = "333"; $array['dialplans'][0]["dialplan_enabled"] = $conference_center_enabled; $array['dialplans'][0]["dialplan_description"] = $conference_center_description; $array['dialplans'][0]["app_uuid"] = "b81412e8-7253-91f4-e48e-42fc2c9a38d9"; //add the dialplan permission $p = permissions::new(); $p->add("dialplan_add", "temp"); $p->add("dialplan_edit", "temp"); //save to the data $database->save($array); //$message = $database->message; unset($array); //remove the temporary permission $p->delete("dialplan_add", "temp"); $p->delete("dialplan_edit", "temp"); //debug information //echo "
\n";
			//print_r($message);
			//echo "
\n"; //exit; //apply settings reminder $_SESSION["reload_xml"] = true; //clear the cache $cache = new cache; $cache->delete("dialplan:".$_SESSION["domain_name"]); //clear the destinations session array if (isset($_SESSION['destinations']['array'])) { unset($_SESSION['destinations']['array']); } //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) && empty($_POST["persistformvar"])) //pre-populate the form if (!empty($_GET) && empty($_POST["persistformvar"])) { $conference_center_uuid = $_GET["id"]; $sql = "select * from v_conference_centers "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and conference_center_uuid = :conference_center_uuid "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $parameters['conference_center_uuid'] = $conference_center_uuid; $row = $database->select($sql, $parameters ?? null, 'row'); if (!empty($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($sql, $parameters, $row); } //set the defaults $conference_center_pin_length = $conference_center_pin_length ?? 9; $conference_center_enabled = $conference_center_enabled ?? true; //get the sounds $sounds = new sounds; $sounds->sound_types = ['recordings','phrases','sounds']; $sounds->full_path = ['recordings']; $audio_files = $sounds->get(); //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); //show the header $document['title'] = $text['title-conference_center']; require_once "resources/header.php"; //show the content if (permission_exists('recording_play') || permission_exists('recording_download')) { echo "\n"; } if (if_group("superadmin")) { echo "\n"; } echo "
\n"; echo "
\n"; echo "
".$text['title-conference_center']."
\n"; echo "
\n"; echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','style'=>'margin-right: 15px;','link'=>'conference_centers.php']); if ($action == 'update' && permission_exists('conference_center_delete')) { echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'name'=>'btn_delete','style'=>'margin-right: 15px;','onclick'=>"modal_open('modal-delete','btn_delete');"]); } echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme', 'button_icon_save'),'id'=>'btn_save']); echo "
\n"; echo "
\n"; echo "
\n"; if ($action == 'update' && permission_exists('conference_center_delete')) { echo modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'submit','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','name'=>'action','value'=>'delete','onclick'=>"modal_close();"])]); } echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $instance_id = 'conference_center_greeting'; $instance_label = 'conference_center_greeting'; $instance_value = $conference_center_greeting; 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 " ".$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 " get('conference_center', 'extension_range') ?? '')."\">\n"; echo "
\n"; echo $text['description-conference_center_extension']."\n"; echo "
\n"; echo " ".$text['label-'.$instance_label]."\n"; echo "
\n"; echo "\n"; if (if_group("superadmin")) { echo ""; } if ((permission_exists('recording_play') || permission_exists('recording_download')) && (!empty($playable) || empty($instance_value))) { switch (pathinfo($playable, PATHINFO_EXTENSION)) { case 'wav' : $mime_type = 'audio/wav'; break; case 'mp3' : $mime_type = 'audio/mpeg'; break; case 'ogg' : $mime_type = 'audio/ogg'; break; } echo ""; echo button::create(['type'=>'button','title'=>$text['label-play'].' / '.$text['label-pause'],'icon'=>$settings->get('theme', 'button_icon_play'),'id'=>'recording_button_'.$instance_id,'style'=>'display: '.(!empty($mime_type) ? 'inline' : 'none'),'onclick'=>"recording_play('".$instance_id."', document.getElementById('".$instance_id."').value, document.getElementById('".$instance_id."').options[document.getElementById('".$instance_id."').selectedIndex].parentNode.getAttribute('data-type'))"]); unset($playable, $mime_type); } echo "
\n"; echo $text['description-'.$instance_label]."\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"; if ($input_toggle_style_switch) { echo " \n"; } echo " \n"; if ($input_toggle_style_switch) { 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 "
"; echo "
\n"; echo "

"; if ($action == "update") { echo "\n"; echo "\n"; } echo "\n"; echo "
"; //include the footer require_once "resources/footer.php"; ?>