$value) { unset($this->$key); } } /** * Get the destination array * @var null */ public function get_array() { //set the global variables global($db); //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) { include($config_path); $x++; } $i = 0; foreach ($apps as $x => &$app) { foreach ($app['destinations'] as &$row) { $switch[destinations][] = $row; } } //put the array in order foreach ($switch[destinations] as $row) { $option_groups[] = $row['label']; } array_multisort($option_groups, SORT_ASC, $switch[destinations]); //add the sql and data to the array $x = 0; foreach ($switch[destinations] as $row) { if ($row['type'] = 'sql') { 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) { if ($field_count != $c) { $delimiter = ','; } else { $delimiter = ''; } $fields .= $value." as ".$key.$delimiter." "; $c++; } $sql = "select ".$fields; $sql .= " from v_".$row['name']." "; } if (isset($row['where'])) { $sql .= trim($row['where'])." "; } if (isset($row['sql'])) { $sql .= "order by ".trim($row['order_by']); } $sql = str_replace("\${domain_name}", $_SESSION['domain_uuid'], $sql); $sql = trim($sql); $statement = $db->prepare($sql); $statement->execute(); $result = $statement->fetchAll(PDO::FETCH_NAMED); unset($statement); $switch['destinations'][$x]['result']['sql'] = $sql; $switch['destinations'][$x]['result']['data'] = $result; } $x++; } //return the destination array return $switch['destinations']; } /** * Get a specific item from the cache * @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 $destinations = $this->get_array(); //remove special characters from the name $destination_id = str_replace("]", "", $destination_name); $destination_id = str_replace("[", "_", $destination_id); //add additional if (if_group("superadmin")) { $response = "\n"; $response .= "\n"; } //default selection found to false $selection_found = false; //print_r($switch); $response .= " \n"; if (if_group("superadmin")) { $response .= ""; } //return the formatted destinations return $response; } } //$obj = new destinations; //echo $obj->select('dialplan', 'example', 'value'); ?>