Change. Does not use default dialplan/directory.

I think it more consistent that it allows edit domain in single place.
Also on my Windows machine while installing all users/context creates not in `default` directory.
And I have problem because remove users did not work, `default.xml` file contain `$${v_domain}` variables.
This commit is contained in:
Alexey Melnichuk
2015-07-02 13:14:35 +04:00
parent 999ae13d78
commit 9097861e30
6 changed files with 11 additions and 51 deletions

View File

@@ -46,7 +46,7 @@ function cmd_async($cmd) {
//windows
if (stristr(PHP_OS, 'WIN')) {
$descriptorspec = array(
0 => array("pipe", "r"), // stdin
0 => array("pipe", "r"), // stdin
1 => array("pipe", "w"), // stdout
2 => array("pipe", "w") // stderr
);
@@ -176,12 +176,7 @@ function cmd_async($cmd) {
$origination_url = "{".$channel_variables."}".$bridge_array[0];
//get the context
if (count($_SESSION["domains"]) > 1) {
$context = $_SESSION['domain_name'];
}
else {
$context = "default";
}
$context = $_SESSION['domain_name'];
//set the command
$cmd = "bgapi sched_api +".$sched_seconds." ".$call_broadcast_uuid." bgapi originate ".$origination_url." ".$broadcast_destination_data." XML $context";

View File

@@ -73,12 +73,7 @@ if (is_array($_REQUEST) && !empty($_REQUEST['src']) && !empty($_REQUEST['dest'])
$sip_auto_answer = '';
}
if (strlen($cid_number) == 0) { $cid_number = $src;}
if (strlen($_SESSION['context']) > 0) {
$context = $_SESSION['context'];
}
else {
$context = 'default';
}
$context = $_SESSION['context'];
//workaround for TBDialout on Thunderbird
//seems it can only handle the first %NUM%

View File

@@ -192,18 +192,10 @@ include "root.php";
$file_default_path = $src_dir.'/dialplan/default.xml';
$file_default_contents = file_get_contents($file_default_path);
//prepare the file contents and the path
if (count($_SESSION['domains']) < 2) {
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
$file_default_contents = str_replace("{v_domain}", 'default', $file_default_contents);
//set the file path
$file_path = $switch_dialplan_dir.'/default.xml';
}
else {
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
$file_default_contents = str_replace("{v_domain}", $_SESSION['domain_name'], $file_default_contents);
//set the file path
$file_path = $switch_dialplan_dir.'/'.$_SESSION['domain_name'].'.xml';
}
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
$file_default_contents = str_replace("{v_domain}", $_SESSION['domain_name'], $file_default_contents);
//set the file path
$file_path = $switch_dialplan_dir.'/'.$_SESSION['domain_name'].'.xml';
//write the default dialplan
$fh = fopen($file_path,'w') or die('Unable to write to '.$file_path.'. Make sure the path exists and permissons are set correctly.');
fwrite($fh, $file_default_contents);

View File

@@ -159,16 +159,9 @@
//declare global variables
global $config, $db, $domain_uuid;
//get the context based from the domain_uuid
if (count($_SESSION['domains']) == 1) {
$user_context = "default";
}
else {
$user_context = $_SESSION['domains'][$domain_uuid]['domain_name'];
}
//get the domain_name
$domain_name = $_SESSION['domains'][$domain_uuid]['domain_name'];
$user_context = $domain_name;
//delete all old extensions to prepare for new ones
$dialplan_list = glob($_SESSION['switch']['extensions']['dir']."/".$user_context."/v_*.xml");

View File

@@ -94,12 +94,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
else {
//if the user_context was not set then set the default value
if (strlen($user_context) == 0) {
if (count($_SESSION["domains"]) > 1) {
$user_context = $_SESSION['domain_name'];
}
else {
$user_context = "default";
}
$user_context = $_SESSION['domain_name'];
}
}

View File

@@ -211,12 +211,7 @@ function load_extensions() {
}
//if no extension has been assigned then setting the user_context will still need to be set
if (strlen($_SESSION['user_context']) == 0) {
if (count($_SESSION['domains']) == 1) {
$_SESSION['user_context'] = "default";
}
else {
$_SESSION['user_context'] = $_SESSION['domain_name'];
}
$_SESSION['user_context'] = $_SESSION['domain_name'];
}
}
}
@@ -1906,12 +1901,7 @@ function save_dialplan_xml() {
global $db, $domain_uuid;
//get the context based from the domain_uuid
if (count($_SESSION['domains']) == 1) {
$user_context = "default";
}
else {
$user_context = $_SESSION['domains'][$domain_uuid]['domain_name'];
}
$user_context = $_SESSION['domains'][$domain_uuid]['domain_name'];
//prepare for dialplan .xml files to be written. delete all dialplan files that are prefixed with dialplan_ and have a file extension of .xml
$dialplan_list = glob($_SESSION['switch']['dialplan']['dir'] . "/*/*v_dialplan*.xml");