From 8319533034dcbc8cc7514c4ccf2f1995b7d3e080 Mon Sep 17 00:00:00 2001 From: markjcrane Date: Thu, 6 Aug 2015 12:11:26 -0500 Subject: [PATCH] Move the destinations array generation into the constructor and add selected support. --- resources/classes/destinations.php | 73 +++++++++++++++--------------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/resources/classes/destinations.php b/resources/classes/destinations.php index 98a7cfc5fd..f9623fbe86 100644 --- a/resources/classes/destinations.php +++ b/resources/classes/destinations.php @@ -3,35 +3,22 @@ /** * destinations * - * @method array get the destinations + * @method get_array get the destinations + * @method select build the html select */ class destinations { + /** + * destinations array + */ + public $destinations; + /** * Called when the object is created */ public function __construct() { - //place holder - } - - /** - * Called when there are no references to a particular object - * unset the variables used in the class - */ - public function __destruct() { - foreach ($this as $key => $value) { - unset($this->$key); - } - } - - /** - * Get the destination array - * @var null - */ - public function get_array() { - //set the global variables - global $db; + global $db, $db_type; //get the array from the app_config.php files $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php"); @@ -43,19 +30,19 @@ class destinations { $i = 0; foreach ($apps as $x => &$app) { foreach ($app['destinations'] as &$row) { - $switch[destinations][] = $row; + $this->destinations[] = $row; } } //put the array in order - foreach ($switch[destinations] as $row) { + foreach ($this->destinations as $row) { $option_groups[] = $row['label']; } - array_multisort($option_groups, SORT_ASC, $switch[destinations]); + array_multisort($option_groups, SORT_ASC, $this->destinations); //add the sql and data to the array $x = 0; - foreach ($switch[destinations] as $row) { + foreach ($this->destinations as $row) { if ($row['type'] = 'sql') { if (isset($row['sql'])) { if (is_array($row['sql'])) { @@ -97,21 +84,27 @@ class destinations { } //return the destination array - return $switch['destinations']; - + $this->destinations = $switch['destinations']; } /** - * Get a specific item from the cache + * Called when there are no references to a particular object + * unset the variables used in the class + */ + public function __destruct() { + foreach ($this as $key => $value) { + unset($this->$key); + } + } + + /** + * Get the destination menu * @var string $destination_type can be ivr, dialplan, call_center_contact or bridge * @var string $destination_name - current name * @var string $destination_value - current value */ public function select($destination_type, $destination_name, $destination_value) { - //get the array - $switch['destinations'] = $this->get_array(); - //remove special characters from the name $destination_id = str_replace("]", "", $destination_name); $destination_id = str_replace("[", "_", $destination_id); @@ -165,7 +158,7 @@ class destinations { //print_r($switch); $response .= "