From 7bcf5223854ed8229e100d6eade8bf89304b54a3 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Sun, 8 Mar 2020 00:29:31 -0700 Subject: [PATCH] Update destinations.php --- .../resources/classes/destinations.php | 51 +++++++++++-------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/app/destinations/resources/classes/destinations.php b/app/destinations/resources/classes/destinations.php index b72856e724..ea1a355f61 100644 --- a/app/destinations/resources/classes/destinations.php +++ b/app/destinations/resources/classes/destinations.php @@ -37,11 +37,12 @@ if (!class_exists('destinations')) { * destinations array */ public $destinations; - public $db; + public $domain_uuid; /** * declare private variables */ + private $domain_name; private $app_name; private $app_uuid; private $permission_prefix; @@ -53,12 +54,9 @@ if (!class_exists('destinations')) { * Called when the object is created */ public function __construct() { - //connect to the database if not connected - if (!$this->db) { - require_once "resources/classes/database.php"; - $database = new database; - $database->connect(); - $this->db = $database->db; + //set the domain details + if (is_null($this->domain_uuid)) { + $this->domain_uuid = $_SESSION['domain_uuid']; } //assign private variables @@ -91,6 +89,13 @@ if (!class_exists('destinations')) { //set the global variables global $db_type; + //get the domain_name + $sql = "select domain_name from v_domains "; + $sql .= "where domain_uuid = :domain_uuid "; + $parameters['domain_uuid'] = $this->domain_uuid; + $database = new database; + $this->domain_name = $database->select($sql, $parameters, 'column'); + //get the destinations if (!is_array($this->destinations)) { @@ -148,7 +153,7 @@ if (!class_exists('destinations')) { $sql .= trim($row['where'])." "; } $sql .= "order by ".trim($row['order_by']); - $sql = str_replace("\${domain_uuid}", $_SESSION['domain_uuid'], $sql); + $sql = str_replace("\${domain_uuid}", $this->domain_uuid, $sql); $database = new database; $result = $database->select($sql, null, 'all'); @@ -284,7 +289,6 @@ if (!class_exists('destinations')) { } } } - } else { $select_value = str_replace("\${".$key."}", $data[$key], $select_value); @@ -303,10 +307,10 @@ if (!class_exists('destinations')) { } } - $select_value = str_replace("\${domain_name}", $_SESSION['domain_name'], $select_value); - $select_value = str_replace("\${context}", $_SESSION['domain_name'], $select_value); - $select_label = str_replace("\${domain_name}", $_SESSION['domain_name'], $select_label); - $select_label = str_replace("\${context}", $_SESSION['domain_name'], $select_label); + $select_value = str_replace("\${domain_name}", $this->domain_name, $select_value); + $select_value = str_replace("\${context}", $this->domain_name, $select_value); + $select_label = str_replace("\${domain_name}", $this->domain_name, $select_label); + $select_label = str_replace("\${context}", $this->domain_name, $select_label); $select_label = str_replace("✉", 'email-icon', $select_label); $select_label = escape(trim($select_label)); $select_label = str_replace('email-icon', '✉', $select_label); @@ -322,7 +326,7 @@ if (!class_exists('destinations')) { $destination_label = str_replace(":", " ", $destination_value); $destination_label = str_replace("menu-exec-app", "", $destination_label); $destination_label = str_replace("transfer", "", $destination_label); - $destination_label = str_replace("XML ".$_SESSION['domain_name'], "", $destination_label); + $destination_label = str_replace("XML ".$this->domain_name, "", $destination_label); if ($destination_value != '' || $destination_label != '') { $response .= " \n"; } @@ -345,6 +349,13 @@ if (!class_exists('destinations')) { //set the global variables global $db_type; + //get the domain_name + $sql = "select domain_name from v_domains "; + $sql .= "where domain_uuid = :domain_uuid "; + $parameters['domain_uuid'] = $this->domain_uuid; + $database = new database; + $this->domain_name = $database->select($sql, $parameters, 'column'); + //get the destinations if (!is_array($this->destinations)) { @@ -401,7 +412,7 @@ if (!class_exists('destinations')) { $sql .= trim($row['where'])." "; } $sql .= "order by ".trim($row['order_by']); - $sql = str_replace("\${domain_uuid}", $_SESSION['domain_uuid'], $sql); + $sql = str_replace("\${domain_uuid}", $this->domain_uuid, $sql); $database = new database; $result = $database->select($sql, null, 'all'); @@ -503,10 +514,10 @@ if (!class_exists('destinations')) { } } - $select_value = str_replace("\${domain_name}", $_SESSION['domain_name'], $select_value); - $select_value = str_replace("\${context}", $_SESSION['domain_name'], $select_value); - $select_label = str_replace("\${domain_name}", $_SESSION['domain_name'], $select_label); - $select_label = str_replace("\${context}", $_SESSION['domain_name'], $select_label); + $select_value = str_replace("\${domain_name}", $this->domain_name, $select_value); + $select_value = str_replace("\${context}", $this->domain_name, $select_value); + $select_label = str_replace("\${domain_name}", $this->domain_name, $select_label); + $select_label = str_replace("\${context}", $this->domain_name, $select_label); $select_label = str_replace("✉", 'email-icon', $select_label); $select_label = escape(trim($select_label)); $select_label = str_replace('email-icon', '✉', $select_label); @@ -521,7 +532,7 @@ if (!class_exists('destinations')) { $destination_label = str_replace(":", " ", $destination_value); $destination_label = str_replace("menu-exec-app", "", $destination_label); $destination_label = str_replace("transfer", "", $destination_label); - $destination_label = str_replace("XML ".$_SESSION['domain_name'], "", $destination_label); + $destination_label = str_replace("XML ".$this->domain_name, "", $destination_label); $array[$label][$destination_label] = $destination_value; }