From 278ae0376b4de0ac626894f4d03a8ee9310f742f Mon Sep 17 00:00:00 2001 From: markjcrane Date: Sat, 15 Jul 2023 18:32:25 -0600 Subject: [PATCH] When using dialplan details with the public context ensure call_direction, domain_name and domain_uuids is added to each dialplan detail group --- app/dialplans/resources/classes/dialplan.php | 34 +++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/app/dialplans/resources/classes/dialplan.php b/app/dialplans/resources/classes/dialplan.php index 1d698924d1..872ac5bb57 100644 --- a/app/dialplans/resources/classes/dialplan.php +++ b/app/dialplans/resources/classes/dialplan.php @@ -649,6 +649,19 @@ //get the dialplans from the dialplan details if ($this->source == "details") { + //get the domains + if (!isset($domains)) { + $sql = "select * from v_domains "; + $database = new database; + $result = $database->select($sql, null, 'all'); + if (!empty($result)) { + foreach($result as $row) { + $domains[$row['domain_uuid']] = $row['domain_name']; + } + } + unset($sql, $result, $row); + } + //get the data using a join between the dialplans and dialplan details tables $sql = "select \n"; $sql .= "p.domain_uuid, p.dialplan_uuid, p.app_uuid, p.dialplan_context, p.dialplan_name, p.dialplan_number, \n"; @@ -691,6 +704,10 @@ $results = $database->select($sql, $parameters ?? null, 'all'); unset($sql, $parameters); + //define the values before they are used + $previous_dialplan_uuid = null; + $previous_dialplan_detail_group = null; + //loop through the results to get the xml from the dialplan_xml field or from dialplan details table $x = 0; if (!empty($results)) { @@ -902,18 +919,6 @@ if ($this->context == "public" || substr($this->context, 0, 7) == "public@" || substr($this->context, -7) == ".public") { if ($dialplan_detail_tag == "action") { if ($first_action) { - //get the domains - if (!isset($domains)) { - $sql = "select * from v_domains "; - $database = new database; - $result = $database->select($sql, null, 'all'); - if (!empty($result)) { - foreach($result as $row) { - $domains[$row['domain_uuid']] = $row['domain_name']; - } - } - unset($sql, $result, $row); - } //add the call direction and domain name and uuid $xml .= " \n"; if (!empty($domain_uuid)) { @@ -934,6 +939,11 @@ $xml .= " \n"; } + //reset back to first action if the group has changed + if ($previous_dialplan_detail_group != $dialplan_detail_group) { + $first_action = true; + } + //save the previous values $previous_dialplan_uuid = $dialplan_uuid; $previous_dialplan_detail_group = $dialplan_detail_group;