&$app) {
if (isset($app['destinations'])) foreach ($app['destinations'] as &$row) {
$this->destinations[] = $row;
}
}
//put the array in order
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
$x = 0;
foreach ($this->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'])." ";
}
$sql .= "order by ".trim($row['order_by']);
$sql = str_replace("\${domain_uuid}", $_SESSION['domain_uuid'], $sql);
$sql = trim($sql);
$statement = $db->prepare($sql);
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_NAMED);
unset($statement);
$this->destinations[$x]['result']['sql'] = $sql;
$this->destinations[$x]['result']['data'] = $result;
}
$x++;
}
$this->destinations[$x]['type'] = 'array';
$this->destinations[$x]['label'] = 'other';
$this->destinations[$x]['name'] = 'dialplan';
$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++;
}
/**
* 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) {
//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 .= "";
}
//return the formatted destinations
return $response;
}
}
/*
$obj = new destinations;
//$destinations = $obj->destinations;
echo $obj->select('ivr', 'example1', 'menu-exec-app:transfer 32 XML voip.fusionpbx.com');
echo $obj->select('ivr', 'example2', '');
echo $obj->select('ivr', 'example3', '');
echo $obj->select('ivr', 'example4', '');
echo $obj->select('ivr', 'example5', '');
echo $obj->select('ivr', 'example6', '');
*/
?>