diff --git a/app/dialplan/resources/classes/dialplan.php b/app/dialplan/resources/classes/dialplan.php
index 92631e73d3..e2819db5fe 100644
--- a/app/dialplan/resources/classes/dialplan.php
+++ b/app/dialplan/resources/classes/dialplan.php
@@ -73,7 +73,12 @@ include "root.php";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
- $sql .= "'".check_str($this->domain_uuid)."', ";
+ if (strlen($this->domain_uuid) > 0) {
+ $sql .= "'".check_str($this->domain_uuid)."', ";
+ }
+ else {
+ $sql .= "null, ";
+ }
$sql .= "'".check_str($this->app_uuid)."', ";
$sql .= "'".check_str($this->dialplan_uuid)."', ";
$sql .= "'".check_str($this->dialplan_name)."', ";
@@ -99,7 +104,7 @@ include "root.php";
$sql .= "dialplan_context = '".check_str($this->dialplan_context)."', ";
$sql .= "dialplan_enabled = '".check_str($this->dialplan_enabled)."', ";
$sql .= "dialplan_description = '".check_str($this->dialplan_description)."' ";
- $sql .= "where domain_uuid = '".check_str($this->domain_uuid)."' ";
+ $sql .= "where (domain_uuid = '".check_str($this->domain_uuid)."' or domain_uuid is null) ";
$sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
//echo "sql: ".$sql."
";
$db->query($sql);
@@ -125,7 +130,12 @@ include "root.php";
$sql .= "values ";
$sql .= "( ";
$sql .= "'".$dialplan_detail_uuid."', ";
- $sql .= "'".check_str($this->domain_uuid)."', ";
+ if (strlen($this->domain_uuid) == 0) {
+ $sql .= "null, ";
+ }
+ else {
+ $sql .= "'".check_str($this->domain_uuid)."', ";
+ }
$sql .= "'".check_str($this->dialplan_uuid)."', ";
$sql .= "'".check_str($this->dialplan_detail_tag)."', ";
$sql .= "'".check_str($this->dialplan_detail_order)."', ";
@@ -171,7 +181,7 @@ include "root.php";
$sql .= "dialplan_detail_group = '".check_str($this->dialplan_detail_group)."', ";
}
$sql .= "dialplan_detail_tag = '".check_str($this->dialplan_detail_tag)."' ";
- $sql .= "where domain_uuid = '".check_str($this->domain_uuid)."' ";
+ $sql .= "where (domain_uuid = '".check_str($this->domain_uuid)."' or domain_uuid is null) ";
$sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
//echo "sql: ".$sql."
";
$db->query($sql);
@@ -227,7 +237,7 @@ include "root.php";
public function dialplan_exists() {
global $db;
$sql = "select count(*) as num_rows from v_dialplans ";
- $sql .= "where domain_uuid = '".$this->domain_uuid."' ";
+ $sql .= "where (domain_uuid = '".$this->domain_uuid."' or domain_uuid is null)";
$sql .= "and dialplan_uuid = '".$this->dialplan_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
@@ -262,7 +272,7 @@ include "root.php";
$dialplan = json_decode($json, true);
}
- //ensure the condition array uniform
+ //ensure the condition array is uniform
if (is_array($dialplan)) {
if (!is_array($dialplan['extension']['condition'][0])) {
$tmp = $dialplan['extension']['condition'];
@@ -283,6 +293,11 @@ include "root.php";
$this->dialplan_name = $dialplan['extension']['@attributes']['name'];
$this->dialplan_number = $dialplan['extension']['@attributes']['number'];
$this->dialplan_context = $dialplan['@attributes']['name'];
+ if (strlen($dialplan['extension']['@attributes']['global']) > 0) {
+ if ($dialplan['extension']['@attributes']['global'] == "true") {
+ $this->domain_uuid = null;
+ }
+ }
if ($this->display_type == "text") {
echo " ".$this->dialplan_name.": added\n";
}