outbound route to bridge add support for bridge failover
This commit is contained in:
parent
845b3c2e60
commit
963bbffc0f
|
|
@ -432,49 +432,50 @@ function outbound_route_to_bridge($domain_uuid, $destination_number, array $chan
|
||||||
$hostname = 'unknown';
|
$hostname = 'unknown';
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "select * from v_dialplans ";
|
$sql = "select d.dialplan_uuid, ";
|
||||||
if (is_uuid($domain_uuid)) {
|
$sql .= "d.dialplan_name, ";
|
||||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
$sql .= "dd.dialplan_detail_uuid, ";
|
||||||
}
|
$sql .= "dd.dialplan_detail_tag, ";
|
||||||
else {
|
$sql .= "dd.dialplan_detail_type, ";
|
||||||
$sql .= "where (domain_uuid is null) ";
|
$sql .= "dd.dialplan_detail_data , ";
|
||||||
}
|
$sql .= "d.dialplan_continue ";
|
||||||
$sql .= "and (hostname = :hostname or hostname is null) ";
|
$sql .= "from v_dialplans d, v_dialplan_details dd ";
|
||||||
$sql .= "and app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
|
$sql .= "where d.dialplan_uuid = dd.dialplan_uuid ";
|
||||||
$sql .= "and dialplan_enabled = 'true' ";
|
|
||||||
$sql .= "order by dialplan_order asc ";
|
|
||||||
if (is_uuid($domain_uuid)) {
|
if (is_uuid($domain_uuid)) {
|
||||||
|
$sql .= "and (d.domain_uuid = :domain_uuid or d.domain_uuid is null) ";
|
||||||
$parameters['domain_uuid'] = $domain_uuid;
|
$parameters['domain_uuid'] = $domain_uuid;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$sql .= "and (d.domain_uuid is null) ";
|
||||||
|
}
|
||||||
|
$sql .= "and (hostname = :hostname or hostname is null) ";
|
||||||
|
$sql .= "and d.app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
|
||||||
|
$sql .= "and d.dialplan_enabled = 'true' ";
|
||||||
|
$sql .= "order by d.domain_uuid, d.dialplan_order, dd.dialplan_detail_order ";
|
||||||
$parameters['hostname'] = $hostname;
|
$parameters['hostname'] = $hostname;
|
||||||
$database = new database;
|
$database = new database;
|
||||||
$result = $database->select($sql, $parameters, 'all');
|
$result = $database->select($sql, $parameters, 'all');
|
||||||
unset($sql, $parameters);
|
unset($sql, $parameters);
|
||||||
|
|
||||||
if (is_array($result) && @sizeof($result) != 0) {
|
if (is_array($result) && @sizeof($result) != 0) {
|
||||||
$x = 0;
|
|
||||||
foreach ($result as &$row) {
|
foreach ($result as &$row) {
|
||||||
//set as variables
|
$dialplan_uuid = $row["dialplan_uuid"];
|
||||||
$dialplan_uuid = $row['dialplan_uuid'];
|
$dialplan_detail_uuid = $row["dialplan_detail_uuid"];
|
||||||
$dialplan_detail_tag = $row["dialplan_detail_tag"];
|
$outbound_routes[$dialplan_uuid][$dialplan_detail_uuid]["dialplan_detail_tag"] = $row["dialplan_detail_tag"];
|
||||||
$dialplan_detail_type = $row['dialplan_detail_type'];
|
$outbound_routes[$dialplan_uuid][$dialplan_detail_uuid]["dialplan_detail_type"] = $row["dialplan_detail_type"];
|
||||||
$dialplan_continue = $row['dialplan_continue'];
|
$outbound_routes[$dialplan_uuid][$dialplan_detail_uuid]["dialplan_detail_data"] = $row["dialplan_detail_data"];
|
||||||
|
$outbound_routes[$dialplan_uuid]["dialplan_continue"] = $row["dialplan_continue"];
|
||||||
//get the extension number using the dialplan_uuid
|
}
|
||||||
$sql = "select * ";
|
}
|
||||||
$sql .= "from v_dialplan_details ";
|
|
||||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
|
||||||
$sql .= "order by dialplan_detail_order asc ";
|
|
||||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
|
||||||
$database = new database;
|
|
||||||
$sub_result = $database->select($sql, $parameters, 'all');
|
|
||||||
unset($sql, $parameters);
|
|
||||||
|
|
||||||
|
if (is_array($outbound_routes) && @sizeof($outbound_routes) != 0) {
|
||||||
|
$x = 0;
|
||||||
|
foreach ($outbound_routes as &$dialplan) {
|
||||||
$condition_match = false;
|
$condition_match = false;
|
||||||
if (is_array($sub_result) && @sizeof($sub_result) != 0) {
|
foreach ($dialplan as &$dialplan_details) {
|
||||||
foreach ($sub_result as &$sub_row) {
|
if ($dialplan_details['dialplan_detail_tag'] == "condition") {
|
||||||
if ($sub_row['dialplan_detail_tag'] == "condition") {
|
if ($dialplan_details['dialplan_detail_type'] == "destination_number") {
|
||||||
if ($sub_row['dialplan_detail_type'] == "destination_number") {
|
$pattern = '/'.$dialplan_details['dialplan_detail_data'].'/';
|
||||||
$pattern = '/'.$sub_row['dialplan_detail_data'].'/';
|
|
||||||
preg_match($pattern, $destination_number, $matches, PREG_OFFSET_CAPTURE);
|
preg_match($pattern, $destination_number, $matches, PREG_OFFSET_CAPTURE);
|
||||||
if (count($matches) == 0) {
|
if (count($matches) == 0) {
|
||||||
$condition_match[] = 'false';
|
$condition_match[] = 'false';
|
||||||
|
|
@ -488,8 +489,8 @@ function outbound_route_to_bridge($domain_uuid, $destination_number, array $chan
|
||||||
$regex_match_5 = $matches[5][0];
|
$regex_match_5 = $matches[5][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($sub_row['dialplan_detail_type'] == "\${toll_allow}") {
|
elseif ($dialplan_details['dialplan_detail_type'] == "\${toll_allow}") {
|
||||||
$pattern = '/'.$sub_row['dialplan_detail_data'].'/';
|
$pattern = '/'.$dialplan_details['dialplan_detail_data'].'/';
|
||||||
preg_match($pattern, $channel_variables['toll_allow'], $matches, PREG_OFFSET_CAPTURE);
|
preg_match($pattern, $channel_variables['toll_allow'], $matches, PREG_OFFSET_CAPTURE);
|
||||||
if (count($matches) == 0) {
|
if (count($matches) == 0) {
|
||||||
$condition_match[] = 'false';
|
$condition_match[] = 'false';
|
||||||
|
|
@ -500,13 +501,11 @@ function outbound_route_to_bridge($domain_uuid, $destination_number, array $chan
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!in_array('false', $condition_match)) {
|
if (!in_array('false', $condition_match)) {
|
||||||
$x = 0;
|
foreach ($dialplan as &$dialplan_details) {
|
||||||
foreach ($sub_result as &$sub_row) {
|
$dialplan_detail_data = $dialplan_details['dialplan_detail_data'];
|
||||||
$dialplan_detail_data = $sub_row['dialplan_detail_data'];
|
if ($dialplan_details['dialplan_detail_tag'] == "action" && $dialplan_details['dialplan_detail_type'] == "bridge" && $dialplan_detail_data != "\${enum_auto_route}") {
|
||||||
if ($sub_row['dialplan_detail_tag'] == "action" && $sub_row['dialplan_detail_type'] == "bridge" && $dialplan_detail_data != "\${enum_auto_route}") {
|
|
||||||
$dialplan_detail_data = str_replace("\$1", $regex_match_1, $dialplan_detail_data);
|
$dialplan_detail_data = str_replace("\$1", $regex_match_1, $dialplan_detail_data);
|
||||||
$dialplan_detail_data = str_replace("\$2", $regex_match_2, $dialplan_detail_data);
|
$dialplan_detail_data = str_replace("\$2", $regex_match_2, $dialplan_detail_data);
|
||||||
$dialplan_detail_data = str_replace("\$3", $regex_match_3, $dialplan_detail_data);
|
$dialplan_detail_data = str_replace("\$3", $regex_match_3, $dialplan_detail_data);
|
||||||
|
|
@ -514,15 +513,15 @@ function outbound_route_to_bridge($domain_uuid, $destination_number, array $chan
|
||||||
$dialplan_detail_data = str_replace("\$5", $regex_match_5, $dialplan_detail_data);
|
$dialplan_detail_data = str_replace("\$5", $regex_match_5, $dialplan_detail_data);
|
||||||
$bridge_array[$x] = $dialplan_detail_data;
|
$bridge_array[$x] = $dialplan_detail_data;
|
||||||
$x++;
|
$x++;
|
||||||
if ($dialplan_continue == "false") {
|
}
|
||||||
break 2;
|
}
|
||||||
|
|
||||||
|
if ($dialplan["dialplan_continue"] == "false") {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($result, $row);
|
|
||||||
return $bridge_array;
|
return $bridge_array;
|
||||||
}
|
}
|
||||||
//$destination_number = '1231234';
|
//$destination_number = '1231234';
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue