diff --git a/app/bridges/bridge_edit.php b/app/bridges/bridge_edit.php index b69ffd3b64..9d6bd985ea 100644 --- a/app/bridges/bridge_edit.php +++ b/app/bridges/bridge_edit.php @@ -114,35 +114,43 @@ return; } - //add the bridge_uuid + //add the bridge_uuid if (empty($bridge_uuid)) { $bridge_uuid = uuid(); } - //create the main bridge statement - $bridge_base = ''; - if (!empty($bridge_gateways)) { - foreach($bridge_gateways as $gateway) { - if (!empty($gateway)) { - $gateway_array = explode(':', $gateway); - $bridge_base .= ',sofia/gateway/'.$gateway_array[0].'/'.$destination_number; - } - } - if (!empty($bridge_base)) { - $bridge_destination = trim($bridge_base, ','); - } + //build the bridge statement for action user + if ($bridge_action == 'user' || $bridge_action == 'loopback') { + $bridge_destination = $bridge_action.'/'.$destination_number; } - //add the variables back into the bridg_destination value - if (!empty($bridge_variables)) { - $variables = ''; - foreach($bridge_variables as $key => $value) { - if (!empty($value)) { - $variables .= ','.$key.'='.$value; + //build the bridge statement for gateway, or profiles - build the bridge statement + if ($bridge_action == 'gateway' || $bridge_action == 'profile') { + //create the main bridge statement + $bridge_base = ''; + if (!empty($bridge_gateways)) { + foreach($bridge_gateways as $gateway) { + if (!empty($gateway)) { + $gateway_array = explode(':', $gateway); + $bridge_base .= ',sofia/gateway/'.$gateway_array[0].'/'.$destination_number; + } + } + if (!empty($bridge_base)) { + $bridge_destination = trim($bridge_base, ','); } } - if (!empty($variables)) { - $bridge_destination = '{'.trim($variables, ',').'}'.$bridge_destination; + + //add the variables back into the bridg_destination value + if (!empty($bridge_variables)) { + $variables = ''; + foreach($bridge_variables as $key => $value) { + if (!empty($value)) { + $variables .= ','.$key.'='.$value; + } + } + if (!empty($variables)) { + $bridge_destination = '{'.trim($variables, ',').'}'.$bridge_destination; + } } } @@ -215,6 +223,36 @@ $i++; } +//get the bridge_action from the bridge_destination + if (!empty($bridge_destination)) { + if (substr($bridge_destination, 0, 1) == '{') { + $parts = explode('}', $bridge_destination); + $bridge_destination = $parts[1]; + } + $bridge_array = explode("/", $bridge_destination); + if ($bridge_array[0] == 'sofia') { + if ($bridge_array[1] == 'gateway') { + $bridge_action = 'gateway'; + } + else { + $bridge_action = 'profile'; + $bridge_profile = $bridge_array[1]; + $destination_number = $bridge_array[2]; + } + } + elseif ($bridge_array[0] == 'user') { + $bridge_action = 'user'; + $destination_number = $bridge_array[1]; + } + elseif ($bridge_array[0] == 'loopback') { + $bridge_action = 'loopback'; + $destination_number = $bridge_array[1]; + } + } + +//create a variables array from the comma delimitted string + $variables = explode(",", $matches[1]); + //get the bridge variables from the database bridge_destination value $database_variables = []; $x = 0; if (!empty($bridge_destination)) { @@ -257,7 +295,9 @@ $i++; } if (!$found) { - $bridge_variables[] = $row; + if (!empty($row['name'])) { + $bridge_variables[] = $row; + } } } @@ -312,6 +352,37 @@ $document['title'] = $text['title-bridge']; require_once "resources/header.php"; +//show or hide form elements based on the bridge action + echo "\n"; + //show the content echo "