diff --git a/app/destinations/resources/classes/destinations.php b/app/destinations/resources/classes/destinations.php
index 0bbd9569e2..23cad5b809 100644
--- a/app/destinations/resources/classes/destinations.php
+++ b/app/destinations/resources/classes/destinations.php
@@ -155,6 +155,7 @@ if (!class_exists('destinations')) {
}
+
/**
* Build the destination select list
* @var string $destination_type can be ivr, dialplan, call_center_contact or bridge
@@ -173,252 +174,345 @@ if (!class_exists('destinations')) {
$database = new database;
$this->domain_name = $database->select($sql, $parameters, 'column');
- //get the destinations
- if (!is_array($this->destinations)) {
+ //create a single destination select list
+ if ($_SESSION['destinations']['select_mode']['text'] == 'default') {
+ //get the destinations
+ if (!is_array($this->destinations)) {
- //get the array from the app_config.php files
- $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
- $x = 0;
- foreach ($config_list as &$config_path) {
- try {
- include($config_path);
- }
- catch (Exception $e) {
- //echo 'Caught exception: ', $e->getMessage(), "\n";
- }
- $x++;
- }
- $i = 0;
- foreach ($apps as $x => &$app) {
- if (isset($app['destinations'])) foreach ($app['destinations'] as &$row) {
- if (permission_exists($this->singular($row["name"])."_destinations")) {
- $this->destinations[] = $row;
- }
- }
- }
- //put the array in order
- if ($this->destinations !== null && is_array($this->destinations)) {
- foreach ($this->destinations as $row) {
- $option_groups[] = $row['label'];
- }
- array_multisort($option_groups, SORT_ASC, $this->destinations);
- }
- //add the sql and data to the array
- if ($this->destinations !== null && is_array($this->destinations)) {
+ //get the array from the app_config.php files
+ $config_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/app_config.php");
$x = 0;
- foreach ($this->destinations as $row) {
- if ($row['type'] === 'sql') {
- $table_name = preg_replace('#[^a-zA-Z0-9_]#', '', $row['name']);
- if (isset($row['sql'])) {
- if (is_array($row['sql'])) {
- $sql = trim($row['sql'][$db_type])." ";
- }
- else {
- $sql = trim($row['sql'])." ";
- }
- }
- else {
- $field_count = count($row['field']);
- $fields = '';
- $c = 1;
- foreach ($row['field'] as $key => $value) {
- $key = preg_replace('#[^a-zA-Z0-9_]#', '', $key);
- $value = preg_replace('#[^a-zA-Z0-9_]#', '', $value);
- if ($field_count != $c) { $delimiter = ','; } else { $delimiter = ''; }
- $fields .= $value." as ".$key.$delimiter." ";
- $c++;
- }
- $sql = "select ".$fields;
- $sql .= " from v_".$table_name." ";
- }
- if (isset($row['where'])) {
- $sql .= trim($row['where'])." ";
- }
- $sql .= "order by ".trim($row['order_by']);
- $sql = str_replace("\${domain_uuid}", $this->domain_uuid, $sql);
- $database = new database;
- $result = $database->select($sql, null, 'all');
-
- $this->destinations[$x]['result']['sql'] = $sql;
- $this->destinations[$x]['result']['data'] = $result;
+ foreach ($config_list as &$config_path) {
+ try {
+ include($config_path);
}
- if ($row['type'] === 'array') {
- $this->destinations[$x] = $row;
+ catch (Exception $e) {
+ //echo 'Caught exception: ', $e->getMessage(), "\n";
}
$x++;
}
- }
-
- $this->destinations[$x]['type'] = 'array';
- $this->destinations[$x]['label'] = 'other';
- $this->destinations[$x]['name'] = 'dialplans';
- $this->destinations[$x]['field']['name'] = "name";
- $this->destinations[$x]['field']['destination'] = "destination";
- $this->destinations[$x]['select_value']['dialplan'] = "transfer:\${destination}";
- $this->destinations[$x]['select_value']['ivr'] = "menu-exec-app:transfer \${destination}";
- $this->destinations[$x]['select_label'] = "\${name}";
- $y = 0;
- $this->destinations[$x]['result']['data'][$y]['label'] = 'check_voicemail';
- $this->destinations[$x]['result']['data'][$y]['name'] = '*98';
- $this->destinations[$x]['result']['data'][$y]['destination'] = '*98 XML ${context}';
- $y++;
- $this->destinations[$x]['result']['data'][$y]['label'] = 'company_directory';
- $this->destinations[$x]['result']['data'][$y]['name'] = '*411';
- $this->destinations[$x]['result']['data'][$y]['destination'] = '*411 XML ${context}';
- $y++;
- $this->destinations[$x]['result']['data'][$y]['label'] = 'hangup';
- $this->destinations[$x]['result']['data'][$y]['name'] = 'hangup';
- $this->destinations[$x]['result']['data'][$y]['application'] = 'hangup';
- $this->destinations[$x]['result']['data'][$y]['destination'] = '';
- $y++;
- $this->destinations[$x]['result']['data'][$y]['label'] = 'record';
- $this->destinations[$x]['result']['data'][$y]['name'] = '*732';
- $this->destinations[$x]['result']['data'][$y]['destination'] = '*732 XML ${context}';
- $y++;
- }
-
- //remove special characters from the name
- $destination_id = str_replace("]", "", $destination_name);
- $destination_id = str_replace("[", "_", $destination_id);
-
- //set the css style
- $select_style = 'width: 200px;';
-
- //add additional
- if (if_group("superadmin")) {
- $response = "\n";
- $response .= "\n";
- }
-
- //set default to false
- $select_found = false;
-
- $response .= " \n";
+ if (if_group("superadmin")) {
+ $response .= "";
}
}
- if (!$select_found) {
- $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 ".$this->domain_name, "", $destination_label);
- if ($destination_value != '' || $destination_label != '') {
- $response .= " \n";
+
+ //create a dynamic destination select list
+ if ($_SESSION['destinations']['select_mode']['text'] == 'dynamic') {
+
+ //remove special characters from the name
+ $destination_id = str_replace("]", "", $destination_name);
+ $destination_id = str_replace("[", "_", $destination_id);
+ //$destination_id = preg_replace('/[^a-zA-Z_,.]/', '', $destination_name);
+
+ ?>
+
+ get($destination_type);
}
- }
- $response .= " \n";
- if (if_group("superadmin")) {
- $response .= "";
+
+ //get the destination label
+ foreach($_SESSION['destinations'][$destination_type] as $key => $value) {
+ foreach($value as $k => $row) {
+ if ($destination_value == $row['destination']) {
+ $destination_key = $key;
+ $destination_label = $row['label'];
+ break;
+ }
+ }
+ }
+
+ //add the language object
+ $language2 = new text;
+
+ //build the destination select list in html
+ $response .= " \n";
+ $response .= " \n";
+
+ //debug information
+ //echo $response;
+ //echo "destination_key $destination_key\n";
+ //echo "destination_id $destination_id\n";
+ //echo "destination_type $destination_type\n";
+ //echo "destination_name $destination_name\n";
+ //echo "destination_value $destination_value\n";
+ //exit;
+
}
//return the formatted destinations
@@ -523,7 +617,7 @@ if (!class_exists('destinations')) {
$this->destinations[$x]['select_value']['dialplan'] = "transfer:\${destination}";
$this->destinations[$x]['select_value']['ivr'] = "menu-exec-app:transfer \${destination}";
$this->destinations[$x]['select_label'] = "\${name}";
- $y = 0;
+ $y=0;
$this->destinations[$x]['result']['data'][$y]['label'] = 'check_voicemail';
$this->destinations[$x]['result']['data'][$y]['name'] = '*98';
$this->destinations[$x]['result']['data'][$y]['destination'] = '*98 XML ${context}';
@@ -658,10 +752,10 @@ if (!class_exists('destinations')) {
$x = 0;
foreach ($config_list as &$config_path) {
try {
- include($config_path);
+ include($config_path);
}
catch (Exception $e) {
- //echo 'Caught exception: ', $e->getMessage(), "\n";
+ //echo 'Caught exception: ', $e->getMessage(), "\n";
}
$x++;
}
@@ -843,6 +937,7 @@ if (!class_exists('destinations')) {
$i++;
}
+
$i = 0;
unset($text);
}