Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('dialplan_edit')) { //access granted } else { echo "access denied"; exit; } //get the includes require_once "resources/header.php"; echo "
\n";

//get the domain, and gateway information
	$sql = "SELECT d.domain_uuid, d.domain_name, g.gateway_uuid, g.gateway FROM v_domains as d, v_gateways as g ";
	$sql .= "WHERE d.domain_uuid = g.domain_uuid \n";
	//echo $sql."
\n"; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $gateways = $prep_statement->fetchAll(PDO::FETCH_NAMED); //print_r($gateways); unset($prep_statement); //start the atomic transaction $db->exec("BEGIN;"); //migrate from gateway names to gateway uuids echo "
\n";
	$sql = "SELECT dialplan_detail_uuid, dialplan_detail_data FROM v_dialplan_details ";
	$sql .= "WHERE dialplan_detail_data LIKE 'sofia/gateway/%' \n";
	//echo $sql."
\n"; $prep_statement2 = $db->prepare(check_sql($sql)); $prep_statement2->execute(); $result = $prep_statement2->fetchAll(PDO::FETCH_NAMED); //unset($prep_statement2); //print_r($result); foreach($result as $field) { //set the variables $dialplan_detail_uuid = $field['dialplan_detail_uuid']; $dialplan_detail_data = $field['dialplan_detail_data']; //echo "dialplan_detail_data29: ".$dialplan_detail_data."
\n"; //parse the data //sofia/gateway/domain_name-gateway_name/1208$1 $data = substr($dialplan_detail_data, 14); //domain_name-gateway_name/1208$1 $data = explode("/", $data); $deprecated = $data[0]; //domain_name-gateway_name //print_r($gateways); //gateways foreach ($gateways as $row) { //set the variables $domain_uuid = $row["domain_uuid"]; $domain_name = $row["domain_name"]; $gateway = $row["gateway"]; //multi-tenant gateway name if (count($_SESSION['domains']) > 1) { $original_gateway_name = $domain_name."-".$gateway; } //single tenant gateway name if (count($_SESSION['domains']) == 1) { $original_gateway_name = $gateway; } //find a match if ($deprecated == $original_gateway_name) { //get the variables $domain_uuid = $row["domain_uuid"]; $gateway_uuid = $row["gateway_uuid"]; $postfix = substr($dialplan_detail_data, (strlen($deprecated) + 14)); //update the data $bridge = "sofia/gateway/".$gateway_uuid.$postfix; $sql = "update v_dialplan_details set "; $sql .= "dialplan_detail_data = '".$bridge."' "; $sql .= "where dialplan_detail_uuid = '$dialplan_detail_uuid'; "; $db->exec(check_sql($sql)); echo $sql."
\n"; unset($sql); //exit the loop break; } } } echo "completed"; echo "
\n";

//commit the atomic transaction
	$count = $db->exec("COMMIT;");

//show the footer
	echo "
\n"; require_once "resources/footer.php"; ?>