Update domain_edit.php
This commit is contained in:
parent
f0e02654b2
commit
784aabca7e
|
|
@ -66,50 +66,82 @@
|
||||||
$domain_description = $_POST["domain_description"];
|
$domain_description = $_POST["domain_description"];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
//process the data
|
||||||
|
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||||
|
|
||||||
$msg = '';
|
//get the domain_uuid
|
||||||
if ($action == "update") {
|
if ($action == "update" && $_POST["domain_uuid"]) {
|
||||||
$domain_uuid = $_POST["domain_uuid"];
|
$domain_uuid = $_POST["domain_uuid"];
|
||||||
}
|
}
|
||||||
|
|
||||||
//validate the token
|
//validate the token
|
||||||
$token = new token;
|
$token = new token;
|
||||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||||
message::add($text['message-invalid_token'],'negative');
|
message::add($text['message-invalid_token'],'negative');
|
||||||
header('Location: domains.php');
|
header('Location: domains.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//check for all required data
|
//check for all required data
|
||||||
if (strlen($domain_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
|
$msg = '';
|
||||||
//if (strlen($domain_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
|
if (strlen($domain_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
|
||||||
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
//if (strlen($domain_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
|
||||||
require_once "resources/header.php";
|
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||||
require_once "resources/persist_form_var.php";
|
require_once "resources/header.php";
|
||||||
echo "<div align='center'>\n";
|
require_once "resources/persist_form_var.php";
|
||||||
echo "<table><tr><td>\n";
|
echo "<div align='center'>\n";
|
||||||
echo $msg."<br />";
|
echo "<table><tr><td>\n";
|
||||||
echo "</td></tr></table>\n";
|
echo $msg."<br />";
|
||||||
persistformvar($_POST);
|
echo "</td></tr></table>\n";
|
||||||
echo "</div>\n";
|
persistformvar($_POST);
|
||||||
require_once "resources/footer.php";
|
echo "</div>\n";
|
||||||
return;
|
require_once "resources/footer.php";
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//add or update the database
|
//add or update the database
|
||||||
if ($_POST["persistformvar"] != "true") {
|
if ($_POST["persistformvar"] != "true") {
|
||||||
if ($action == "add" && permission_exists('domain_add')) {
|
if ($action == "add" && permission_exists('domain_add')) {
|
||||||
$sql = "select count(*) from v_domains ";
|
$sql = "select count(*) from v_domains ";
|
||||||
$sql .= "where domain_name = :domain_name ";
|
$sql .= "where domain_name = :domain_name ";
|
||||||
$parameters['domain_name'] = $domain_name;
|
$parameters['domain_name'] = $domain_name;
|
||||||
$database = new database;
|
$database = new database;
|
||||||
$num_rows = $database->select($sql, $parameters, 'column');
|
$num_rows = $database->select($sql, $parameters, 'column');
|
||||||
unset($sql, $parameters);
|
unset($sql, $parameters);
|
||||||
|
|
||||||
if ($num_rows == 0) {
|
if ($num_rows == 0) {
|
||||||
$domain_enabled = 'true';
|
//add the domain name
|
||||||
$array['domains'][0]['domain_uuid'] = uuid();
|
$domain_enabled = 'true';
|
||||||
|
$domain_uuid = uuid();
|
||||||
|
$array['domains'][0]['domain_uuid'] = $domain_uuid;
|
||||||
|
$array['domains'][0]['domain_name'] = $domain_name;
|
||||||
|
$array['domains'][0]['domain_enabled'] = $domain_enabled;
|
||||||
|
$array['domains'][0]['domain_description'] = $domain_description;
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = 'domains';
|
||||||
|
$database->app_uuid = '8b91605b-f6d2-42e6-a56d-5d1ded01bb44';
|
||||||
|
$database->save($array);
|
||||||
|
|
||||||
|
//add dialplans to the domain
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/dialplans/app_config.php")) {
|
||||||
|
$dialplan = new dialplan;
|
||||||
|
$dialplan->import($array['domains']);
|
||||||
|
unset($array);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($action == "update" && permission_exists('domain_edit')) {
|
||||||
|
// get original domain name
|
||||||
|
$sql = "select domain_name from v_domains ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$original_domain_name = $database->select($sql, $parameters, 'column');
|
||||||
|
unset($sql, $parameters);
|
||||||
|
|
||||||
|
// update domain name, description
|
||||||
|
$array['domains'][0]['domain_uuid'] = $domain_uuid;
|
||||||
$array['domains'][0]['domain_name'] = $domain_name;
|
$array['domains'][0]['domain_name'] = $domain_name;
|
||||||
$array['domains'][0]['domain_enabled'] = $domain_enabled;
|
$array['domains'][0]['domain_enabled'] = $domain_enabled;
|
||||||
$array['domains'][0]['domain_description'] = $domain_description;
|
$array['domains'][0]['domain_description'] = $domain_description;
|
||||||
|
|
@ -117,364 +149,342 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||||
$database->app_name = 'domains';
|
$database->app_name = 'domains';
|
||||||
$database->app_uuid = '8b91605b-f6d2-42e6-a56d-5d1ded01bb44';
|
$database->app_uuid = '8b91605b-f6d2-42e6-a56d-5d1ded01bb44';
|
||||||
$database->save($array);
|
$database->save($array);
|
||||||
unset($array);
|
|
||||||
|
// add dialplans to the domain
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/dialplans/app_config.php")) {
|
||||||
|
$dialplan = new dialplan;
|
||||||
|
$dialplan->import($array);
|
||||||
|
unset($array);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($original_domain_name != $domain_name) {
|
||||||
|
|
||||||
|
// update dialplans
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/dialplans/app_config.php")) {
|
||||||
|
$sql = "update v_dialplans set ";
|
||||||
|
$sql .= "dialplan_context = replace(dialplan_context, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "dialplan_xml = replace(dialplan_xml, :domain_name_old, :domain_name_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
|
||||||
|
$sql = "update v_dialplan_details set ";
|
||||||
|
$sql .= "dialplan_detail_data = replace(dialplan_detail_data, :domain_name_old, :domain_name_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update destinations
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/destinations/app_config.php")) {
|
||||||
|
$sql = "update v_destinations set ";
|
||||||
|
$sql .= "destination_data = replace(destination_data, :destination_data_old, :destination_data_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['destination_data_old'] = $original_domain_name;
|
||||||
|
$parameters['destination_data_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update extensions (accountcode, user_context, dial_domain)
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/extensions/app_config.php")) {
|
||||||
|
$sql = "update v_extensions set ";
|
||||||
|
$sql .= "user_context = replace(user_context, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "accountcode = replace(accountcode, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "dial_domain = replace(dial_domain, :domain_name_old, :domain_name_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update ivr_menus (ivr_menu_context, ivr_menu_greet_long, ivr_menu_greet_short) and ivr_menu_options (ivr_menu_option_param)
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/ivr_menus/app_config.php")) {
|
||||||
|
$sql = "update v_ivr_menus set ";
|
||||||
|
$sql .= "ivr_menu_context = replace(ivr_menu_context, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "ivr_menu_greet_long = replace(ivr_menu_greet_long, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "ivr_menu_greet_short = replace(ivr_menu_greet_short, :domain_name_old, :domain_name_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
|
||||||
|
$sql = "update v_ivr_menu_options set ";
|
||||||
|
$sql .= "ivr_menu_option_param = replace(ivr_menu_option_param, :domain_name_old, :domain_name_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update ring_groups (ring_group_context, ring_group_forward_destination, ring_group_timeout_data)
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/ring_groups/app_config.php")) {
|
||||||
|
$sql = "update v_ring_groups set ";
|
||||||
|
$sql .= "ring_group_context = replace(ring_group_context, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "ring_group_forward_destination = replace(ring_group_forward_destination, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "ring_group_timeout_data = replace(ring_group_timeout_data, :domain_name_old, :domain_name_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update cdr records (domain_name, context)
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/xml_cdr/app_config.php")){
|
||||||
|
$sql = "update v_xml_cdr set ";
|
||||||
|
$sql .= "domain_name = :domain_name_new ";
|
||||||
|
$sql .= "where domain_name = :domain_name_old ";
|
||||||
|
$sql .= "and domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
|
||||||
|
$sql = "update v_xml_cdr set ";
|
||||||
|
$sql .= "context = replace(user_context, :context_old, :context_new), ";
|
||||||
|
$sql .= "where context = :context_old ";
|
||||||
|
$sql .= "and domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['context_old'] = $original_domain_name;
|
||||||
|
$parameters['context_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update billing, if installed
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/billing/app_config.php")){
|
||||||
|
$sql = "update v_billings set ";
|
||||||
|
$sql .= "type_value = :type_value_new ";
|
||||||
|
$sql .= "where type_value = :type_value_old ";
|
||||||
|
$sql .= "and domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['type_value_old'] = $original_domain_name;
|
||||||
|
$parameters['type_value_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update conference session recording paths
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/conference_centers/app_config.php")) {
|
||||||
|
$sql = "update v_conference_sessions set ";
|
||||||
|
$sql .= "recording = replace(recording, :domain_name_old, :domain_name_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update conference center greetings
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/conference_centers/app_config.php")) {
|
||||||
|
$sql = "update v_conference_centers set ";
|
||||||
|
$sql .= "conference_center_greeting = replace(conference_center_greeting, :domain_name_old, :domain_name_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update call center queue record templates
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/call_center/app_config.php")) {
|
||||||
|
$sql = "update v_call_center_queues set ";
|
||||||
|
$sql .= "queue_record_template = replace(queue_record_template, :domain_name_old, :domain_name_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update call center agent contacts
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/call_center/app_config.php")) {
|
||||||
|
$sql = "update v_call_center_agents set ";
|
||||||
|
$sql .= "agent_contact = replace(agent_contact, :domain_name_old, :domain_name_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update call flows data, alternate-data and contexts
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/call_flows/app_config.php")) {
|
||||||
|
$sql = "update v_call_flows set ";
|
||||||
|
$sql .= "call_flow_data = replace(call_flow_data, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "call_flow_alternate_data = replace(call_flow_alternate_data, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "call_flow_context = replace(call_flow_context, :domain_name_old, :domain_name_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// update device lines server_address, server_address_primary, server_address_secondary, outbound_proxy_primary, outbound_proxy_secondary
|
||||||
|
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/devices/app_config.php")) {
|
||||||
|
$sql = "update v_device_lines set ";
|
||||||
|
$sql .= "server_address = replace(server_address, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "server_address_primary = replace(server_address_primary, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "server_address_secondary = replace(server_address_secondary, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "outbound_proxy_primary = replace(outbound_proxy_primary, :domain_name_old, :domain_name_new), ";
|
||||||
|
$sql .= "outbound_proxy_secondary = replace(outbound_proxy_secondary, :domain_name_old, :domain_name_new) ";
|
||||||
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
|
$parameters['domain_name_old'] = $original_domain_name;
|
||||||
|
$parameters['domain_name_new'] = $domain_name;
|
||||||
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
|
$database = new database;
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
// rename switch/storage/voicemail/default/[domain] (folder)
|
||||||
|
if (isset($_SESSION['switch']['voicemail']['dir']) && file_exists($_SESSION['switch']['voicemail']['dir']."/default/".$original_domain_name)) {
|
||||||
|
@rename($_SESSION['switch']['voicemail']['dir']."/default/".$original_domain_name, $_SESSION['switch']['voicemail']['dir']."/default/".$domain_name); // folder
|
||||||
|
}
|
||||||
|
|
||||||
|
// rename switch/storage/fax/[domain] (folder)
|
||||||
|
if (isset($_SESSION['switch']['storage']['dir']) && file_exists($_SESSION['switch']['storage']['dir']."/fax/".$original_domain_name)) {
|
||||||
|
@rename($_SESSION['switch']['storage']['dir']."/fax/".$original_domain_name, $_SESSION['switch']['storage']['dir']."/fax/".$domain_name); // folder
|
||||||
|
}
|
||||||
|
|
||||||
|
// rename switch/conf/dialplan/[domain] (folder/file)
|
||||||
|
if (isset($_SESSION['switch']['dialplan']['dir'])) {
|
||||||
|
if (file_exists($_SESSION['switch']['dialplan']['dir']."/".$original_domain_name)) {
|
||||||
|
@rename($_SESSION['switch']['dialplan']['dir']."/".$original_domain_name, $_SESSION['switch']['dialplan']['dir']."/".$domain_name); // folder
|
||||||
|
}
|
||||||
|
if (file_exists($_SESSION['switch']['dialplan']['dir']."/".$original_domain_name.".xml")) {
|
||||||
|
@rename($_SESSION['switch']['dialplan']['dir']."/".$original_domain_name.".xml", $_SESSION['switch']['dialplan']['dir']."/".$domain_name.".xml"); // file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// rename switch/conf/dialplan/public/[domain] (folder/file)
|
||||||
|
if (isset($_SESSION['switch']['dialplan']['dir'])) {
|
||||||
|
if (file_exists($_SESSION['switch']['dialplan']['dir']."/public/".$original_domain_name)) {
|
||||||
|
@rename($_SESSION['switch']['dialplan']['dir']."/public/".$original_domain_name, $_SESSION['switch']['dialplan']['dir']."/public/".$domain_name); // folder
|
||||||
|
}
|
||||||
|
if (file_exists($_SESSION['switch']['dialplan']['dir']."/public/".$original_domain_name.".xml")) {
|
||||||
|
@rename($_SESSION['switch']['dialplan']['dir']."/public/".$original_domain_name.".xml", $_SESSION['switch']['dialplan']['dir']."/public/".$domain_name.".xml"); // file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// rename switch/conf/directory/[domain] (folder/file)
|
||||||
|
if (isset($_SESSION['switch']['extensions']['dir'])) {
|
||||||
|
if (file_exists($_SESSION['switch']['extensions']['dir']."/".$original_domain_name)) {
|
||||||
|
@rename($_SESSION['switch']['extensions']['dir']."/".$original_domain_name, $_SESSION['switch']['extensions']['dir']."/".$domain_name); // folder
|
||||||
|
}
|
||||||
|
if (file_exists($_SESSION['switch']['extensions']['dir']."/".$original_domain_name.".xml")) {
|
||||||
|
@rename($_SESSION['switch']['extensions']['dir']."/".$original_domain_name.".xml", $_SESSION['switch']['extensions']['dir']."/".$domain_name.".xml"); // file
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// rename switch/recordings/[domain] (folder)
|
||||||
|
if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'])) {
|
||||||
|
$switch_recordings_dir = str_replace("/".$_SESSION["domain_name"], "", $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']);
|
||||||
|
if (file_exists($switch_recordings_dir."/".$original_domain_name)) {
|
||||||
|
@rename($switch_recordings_dir."/".$original_domain_name, $switch_recordings_dir."/".$domain_name); // folder
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update dialplan, dialplan/public xml files
|
||||||
|
$dialplan_xml = file_get_contents($_SESSION['switch']['dialplan']['dir']."/".$domain_name.".xml");
|
||||||
|
$dialplan_xml = str_replace($original_domain_name, $domain_name, $dialplan_xml);
|
||||||
|
file_put_contents($_SESSION['switch']['dialplan']['dir']."/".$domain_name.".xml", $dialplan_xml);
|
||||||
|
unset($dialplan_xml);
|
||||||
|
|
||||||
|
$dialplan_public_xml = file_get_contents($_SESSION['switch']['dialplan']['dir']."/public/".$domain_name.".xml");
|
||||||
|
$dialplan_public_xml = str_replace($original_domain_name, $domain_name, $dialplan_public_xml);
|
||||||
|
file_put_contents($_SESSION['switch']['dialplan']['dir']."/public/".$domain_name.".xml", $dialplan_public_xml);
|
||||||
|
unset($dialplan_public_xml);
|
||||||
|
|
||||||
|
// update session domain name
|
||||||
|
$_SESSION['domains'][$domain_uuid]['domain_name'] = $domain_name;
|
||||||
|
|
||||||
|
// recreate dialplan and extension xml files
|
||||||
|
if (is_readable($_SESSION['switch']['dialplan']['dir'])) {
|
||||||
|
save_dialplan_xml();
|
||||||
|
}
|
||||||
|
if (is_readable($_SESSION['switch']['extensions']['dir'])) {
|
||||||
|
require_once $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/resources/classes/extension.php";
|
||||||
|
$extension = new extension;
|
||||||
|
$extension->xml();
|
||||||
|
}
|
||||||
|
|
||||||
|
// if single-tenant and variables exist, update variables > domain value to match new domain
|
||||||
|
if (count($_SESSION['domains']) == 1 && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/vars/")) {
|
||||||
|
$sql = "update v_vars set ";
|
||||||
|
$sql .= "var_value = :var_value ";
|
||||||
|
$sql .= "where var_name = 'domain' ";
|
||||||
|
$parameters['var_value'] = $domain_name;
|
||||||
|
$database = new database;
|
||||||
|
$database->app_name = 'domains';
|
||||||
|
$database->app_uuid = '8b91605b-f6d2-42e6-a56d-5d1ded01bb44';
|
||||||
|
$database->execute($sql, $parameters);
|
||||||
|
unset($sql, $parameters);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
//clear the domains session array to update it
|
||||||
|
unset($_SESSION["domains"]);
|
||||||
|
unset($_SESSION["domain_uuid"]);
|
||||||
|
unset($_SESSION["domain_name"]);
|
||||||
|
unset($_SESSION['domain']);
|
||||||
|
unset($_SESSION['switch']);
|
||||||
|
|
||||||
if ($action == "update" && permission_exists('domain_edit')) {
|
//redirect the browser
|
||||||
// get original domain name
|
if ($action == "update") {
|
||||||
$sql = "select domain_name from v_domains ";
|
message::add($text['message-update']);
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
if (!permission_exists('domain_add')) { //admin, updating own domain
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
header("Location: domain_edit.php");
|
||||||
$database = new database;
|
}
|
||||||
$original_domain_name = $database->select($sql, $parameters, 'column');
|
else {
|
||||||
unset($sql, $parameters);
|
header("Location: domains.php"); //superadmin
|
||||||
|
}
|
||||||
// update domain name, description
|
|
||||||
$array['domains'][0]['domain_uuid'] = $domain_uuid;
|
|
||||||
$array['domains'][0]['domain_name'] = $domain_name;
|
|
||||||
$array['domains'][0]['domain_enabled'] = $domain_enabled;
|
|
||||||
$array['domains'][0]['domain_description'] = $domain_description;
|
|
||||||
$database = new database;
|
|
||||||
$database->app_name = 'domains';
|
|
||||||
$database->app_uuid = '8b91605b-f6d2-42e6-a56d-5d1ded01bb44';
|
|
||||||
$database->save($array);
|
|
||||||
unset($array);
|
|
||||||
|
|
||||||
if ($original_domain_name != $domain_name) {
|
|
||||||
|
|
||||||
// update dialplans
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/dialplans/app_config.php")) {
|
|
||||||
$sql = "update v_dialplans set ";
|
|
||||||
$sql .= "dialplan_context = replace(dialplan_context, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "dialplan_xml = replace(dialplan_xml, :domain_name_old, :domain_name_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
|
|
||||||
$sql = "update v_dialplan_details set ";
|
|
||||||
$sql .= "dialplan_detail_data = replace(dialplan_detail_data, :domain_name_old, :domain_name_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update destinations
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/destinations/app_config.php")) {
|
|
||||||
$sql = "update v_destinations set ";
|
|
||||||
$sql .= "destination_data = replace(destination_data, :destination_data_old, :destination_data_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['destination_data_old'] = $original_domain_name;
|
|
||||||
$parameters['destination_data_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update extensions (accountcode, user_context, dial_domain)
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/extensions/app_config.php")) {
|
|
||||||
$sql = "update v_extensions set ";
|
|
||||||
$sql .= "user_context = replace(user_context, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "accountcode = replace(accountcode, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "dial_domain = replace(dial_domain, :domain_name_old, :domain_name_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update ivr_menus (ivr_menu_context, ivr_menu_greet_long, ivr_menu_greet_short) and ivr_menu_options (ivr_menu_option_param)
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/ivr_menus/app_config.php")) {
|
|
||||||
$sql = "update v_ivr_menus set ";
|
|
||||||
$sql .= "ivr_menu_context = replace(ivr_menu_context, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "ivr_menu_greet_long = replace(ivr_menu_greet_long, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "ivr_menu_greet_short = replace(ivr_menu_greet_short, :domain_name_old, :domain_name_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
|
|
||||||
$sql = "update v_ivr_menu_options set ";
|
|
||||||
$sql .= "ivr_menu_option_param = replace(ivr_menu_option_param, :domain_name_old, :domain_name_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update ring_groups (ring_group_context, ring_group_forward_destination, ring_group_timeout_data)
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/ring_groups/app_config.php")) {
|
|
||||||
$sql = "update v_ring_groups set ";
|
|
||||||
$sql .= "ring_group_context = replace(ring_group_context, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "ring_group_forward_destination = replace(ring_group_forward_destination, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "ring_group_timeout_data = replace(ring_group_timeout_data, :domain_name_old, :domain_name_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update cdr records (domain_name, context)
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/xml_cdr/app_config.php")){
|
|
||||||
$sql = "update v_xml_cdr set ";
|
|
||||||
$sql .= "domain_name = :domain_name_new ";
|
|
||||||
$sql .= "where domain_name = :domain_name_old ";
|
|
||||||
$sql .= "and domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
|
|
||||||
$sql = "update v_xml_cdr set ";
|
|
||||||
$sql .= "context = replace(user_context, :context_old, :context_new), ";
|
|
||||||
$sql .= "where context = :context_old ";
|
|
||||||
$sql .= "and domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['context_old'] = $original_domain_name;
|
|
||||||
$parameters['context_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update billing, if installed
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/billing/app_config.php")){
|
|
||||||
$sql = "update v_billings set ";
|
|
||||||
$sql .= "type_value = :type_value_new ";
|
|
||||||
$sql .= "where type_value = :type_value_old ";
|
|
||||||
$sql .= "and domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['type_value_old'] = $original_domain_name;
|
|
||||||
$parameters['type_value_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update conference session recording paths
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/conference_centers/app_config.php")) {
|
|
||||||
$sql = "update v_conference_sessions set ";
|
|
||||||
$sql .= "recording = replace(recording, :domain_name_old, :domain_name_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update conference center greetings
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/conference_centers/app_config.php")) {
|
|
||||||
$sql = "update v_conference_centers set ";
|
|
||||||
$sql .= "conference_center_greeting = replace(conference_center_greeting, :domain_name_old, :domain_name_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update call center queue record templates
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/call_center/app_config.php")) {
|
|
||||||
$sql = "update v_call_center_queues set ";
|
|
||||||
$sql .= "queue_record_template = replace(queue_record_template, :domain_name_old, :domain_name_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update call center agent contacts
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/call_center/app_config.php")) {
|
|
||||||
$sql = "update v_call_center_agents set ";
|
|
||||||
$sql .= "agent_contact = replace(agent_contact, :domain_name_old, :domain_name_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update call flows data, alternate-data and contexts
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/call_flows/app_config.php")) {
|
|
||||||
$sql = "update v_call_flows set ";
|
|
||||||
$sql .= "call_flow_data = replace(call_flow_data, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "call_flow_alternate_data = replace(call_flow_alternate_data, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "call_flow_context = replace(call_flow_context, :domain_name_old, :domain_name_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// update device lines server_address, server_address_primary, server_address_secondary, outbound_proxy_primary, outbound_proxy_secondary
|
|
||||||
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/devices/app_config.php")) {
|
|
||||||
$sql = "update v_device_lines set ";
|
|
||||||
$sql .= "server_address = replace(server_address, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "server_address_primary = replace(server_address_primary, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "server_address_secondary = replace(server_address_secondary, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "outbound_proxy_primary = replace(outbound_proxy_primary, :domain_name_old, :domain_name_new), ";
|
|
||||||
$sql .= "outbound_proxy_secondary = replace(outbound_proxy_secondary, :domain_name_old, :domain_name_new) ";
|
|
||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
|
||||||
$parameters['domain_name_old'] = $original_domain_name;
|
|
||||||
$parameters['domain_name_new'] = $domain_name;
|
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
// rename switch/storage/voicemail/default/[domain] (folder)
|
|
||||||
if (isset($_SESSION['switch']['voicemail']['dir']) && file_exists($_SESSION['switch']['voicemail']['dir']."/default/".$original_domain_name)) {
|
|
||||||
@rename($_SESSION['switch']['voicemail']['dir']."/default/".$original_domain_name, $_SESSION['switch']['voicemail']['dir']."/default/".$domain_name); // folder
|
|
||||||
}
|
|
||||||
|
|
||||||
// rename switch/storage/fax/[domain] (folder)
|
|
||||||
if (isset($_SESSION['switch']['storage']['dir']) && file_exists($_SESSION['switch']['storage']['dir']."/fax/".$original_domain_name)) {
|
|
||||||
@rename($_SESSION['switch']['storage']['dir']."/fax/".$original_domain_name, $_SESSION['switch']['storage']['dir']."/fax/".$domain_name); // folder
|
|
||||||
}
|
|
||||||
|
|
||||||
// rename switch/conf/dialplan/[domain] (folder/file)
|
|
||||||
if (isset($_SESSION['switch']['dialplan']['dir'])) {
|
|
||||||
if (file_exists($_SESSION['switch']['dialplan']['dir']."/".$original_domain_name)) {
|
|
||||||
@rename($_SESSION['switch']['dialplan']['dir']."/".$original_domain_name, $_SESSION['switch']['dialplan']['dir']."/".$domain_name); // folder
|
|
||||||
}
|
|
||||||
if (file_exists($_SESSION['switch']['dialplan']['dir']."/".$original_domain_name.".xml")) {
|
|
||||||
@rename($_SESSION['switch']['dialplan']['dir']."/".$original_domain_name.".xml", $_SESSION['switch']['dialplan']['dir']."/".$domain_name.".xml"); // file
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rename switch/conf/dialplan/public/[domain] (folder/file)
|
|
||||||
if (isset($_SESSION['switch']['dialplan']['dir'])) {
|
|
||||||
if (file_exists($_SESSION['switch']['dialplan']['dir']."/public/".$original_domain_name)) {
|
|
||||||
@rename($_SESSION['switch']['dialplan']['dir']."/public/".$original_domain_name, $_SESSION['switch']['dialplan']['dir']."/public/".$domain_name); // folder
|
|
||||||
}
|
|
||||||
if (file_exists($_SESSION['switch']['dialplan']['dir']."/public/".$original_domain_name.".xml")) {
|
|
||||||
@rename($_SESSION['switch']['dialplan']['dir']."/public/".$original_domain_name.".xml", $_SESSION['switch']['dialplan']['dir']."/public/".$domain_name.".xml"); // file
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rename switch/conf/directory/[domain] (folder/file)
|
|
||||||
if (isset($_SESSION['switch']['extensions']['dir'])) {
|
|
||||||
if (file_exists($_SESSION['switch']['extensions']['dir']."/".$original_domain_name)) {
|
|
||||||
@rename($_SESSION['switch']['extensions']['dir']."/".$original_domain_name, $_SESSION['switch']['extensions']['dir']."/".$domain_name); // folder
|
|
||||||
}
|
|
||||||
if (file_exists($_SESSION['switch']['extensions']['dir']."/".$original_domain_name.".xml")) {
|
|
||||||
@rename($_SESSION['switch']['extensions']['dir']."/".$original_domain_name.".xml", $_SESSION['switch']['extensions']['dir']."/".$domain_name.".xml"); // file
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rename switch/recordings/[domain] (folder)
|
|
||||||
if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name'])) {
|
|
||||||
$switch_recordings_dir = str_replace("/".$_SESSION["domain_name"], "", $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']);
|
|
||||||
if (file_exists($switch_recordings_dir."/".$original_domain_name)) {
|
|
||||||
@rename($switch_recordings_dir."/".$original_domain_name, $switch_recordings_dir."/".$domain_name); // folder
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// update dialplan, dialplan/public xml files
|
|
||||||
$dialplan_xml = file_get_contents($_SESSION['switch']['dialplan']['dir']."/".$domain_name.".xml");
|
|
||||||
$dialplan_xml = str_replace($original_domain_name, $domain_name, $dialplan_xml);
|
|
||||||
file_put_contents($_SESSION['switch']['dialplan']['dir']."/".$domain_name.".xml", $dialplan_xml);
|
|
||||||
unset($dialplan_xml);
|
|
||||||
|
|
||||||
$dialplan_public_xml = file_get_contents($_SESSION['switch']['dialplan']['dir']."/public/".$domain_name.".xml");
|
|
||||||
$dialplan_public_xml = str_replace($original_domain_name, $domain_name, $dialplan_public_xml);
|
|
||||||
file_put_contents($_SESSION['switch']['dialplan']['dir']."/public/".$domain_name.".xml", $dialplan_public_xml);
|
|
||||||
unset($dialplan_public_xml);
|
|
||||||
|
|
||||||
// update session domain name
|
|
||||||
$_SESSION['domains'][$domain_uuid]['domain_name'] = $domain_name;
|
|
||||||
|
|
||||||
// recreate dialplan and extension xml files
|
|
||||||
if (is_readable($_SESSION['switch']['dialplan']['dir'])) {
|
|
||||||
save_dialplan_xml();
|
|
||||||
}
|
|
||||||
if (is_readable($_SESSION['switch']['extensions']['dir'])) {
|
|
||||||
require_once $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/extensions/resources/classes/extension.php";
|
|
||||||
$extension = new extension;
|
|
||||||
$extension->xml();
|
|
||||||
}
|
|
||||||
|
|
||||||
// if single-tenant and variables exist, update variables > domain value to match new domain
|
|
||||||
if (count($_SESSION['domains']) == 1 && file_exists($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/app/vars/")) {
|
|
||||||
$sql = "update v_vars set ";
|
|
||||||
$sql .= "var_value = :var_value ";
|
|
||||||
$sql .= "where var_name = 'domain' ";
|
|
||||||
$parameters['var_value'] = $domain_name;
|
|
||||||
$database = new database;
|
|
||||||
$database->app_name = 'domains';
|
|
||||||
$database->app_uuid = '8b91605b-f6d2-42e6-a56d-5d1ded01bb44';
|
|
||||||
$database->execute($sql, $parameters);
|
|
||||||
unset($sql, $parameters);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
if ($action == "add") {
|
||||||
|
message::add($text['message-add']);
|
||||||
//upgrade the domains
|
header("Location: domains.php");
|
||||||
if (permission_exists('upgrade_apps') || if_group("superadmin")) {
|
|
||||||
require_once "core/upgrade/upgrade_domains.php";
|
|
||||||
}
|
|
||||||
|
|
||||||
//clear the domains session array to update it
|
|
||||||
unset($_SESSION["domains"]);
|
|
||||||
unset($_SESSION["domain_uuid"]);
|
|
||||||
unset($_SESSION["domain_name"]);
|
|
||||||
unset($_SESSION['domain']);
|
|
||||||
unset($_SESSION['switch']);
|
|
||||||
|
|
||||||
//redirect the browser
|
|
||||||
if ($action == "update") {
|
|
||||||
message::add($text['message-update']);
|
|
||||||
if (!permission_exists('domain_add')) { //admin, updating own domain
|
|
||||||
header("Location: domain_edit.php");
|
|
||||||
}
|
}
|
||||||
else {
|
return;
|
||||||
header("Location: domains.php"); //superadmin
|
} //if ($_POST["persistformvar"] != "true")
|
||||||
}
|
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
|
||||||
}
|
|
||||||
if ($action == "add") {
|
|
||||||
message::add($text['message-add']);
|
|
||||||
header("Location: domains.php");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} //if ($_POST["persistformvar"] != "true")
|
|
||||||
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
|
|
||||||
|
|
||||||
//pre-populate the form (admin won't have domain_add permissions, but domain_uuid will already be set above)
|
//pre-populate the form (admin won't have domain_add permissions, but domain_uuid will already be set above)
|
||||||
if ((count($_GET) > 0 || (!permission_exists('domain_add') && $domain_uuid != '')) && $_POST["persistformvar"] != "true") {
|
if ((count($_GET) > 0 || (!permission_exists('domain_add') && $domain_uuid != '')) && $_POST["persistformvar"] != "true") {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue