From 8762a4d4fbae44b200923485dd5af00ba53a56f8 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Thu, 26 Jul 2012 20:10:59 +0000 Subject: [PATCH] If there is more than one domain (multi-tenant) then set the default context to the domain name. Several people have approached me on IRC wondering what was wrong with their new multi-tenant system the problem was the dialplan context this change addresses that need. --- app/dialplan/app_defaults.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/dialplan/app_defaults.php b/app/dialplan/app_defaults.php index 00adde9592..6d9f478df7 100644 --- a/app/dialplan/app_defaults.php +++ b/app/dialplan/app_defaults.php @@ -24,6 +24,26 @@ Mark J Crane */ +//if there is more than one domain then set the default context to the domain name + if (count($_SESSION['domains']) > 1) { + $sql = "select * from v_dialplans "; + $sql .= "where dialplan_context = 'default' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $domain_uuid = $row["domain_uuid"]; + $dialplan_uuid = $row["dialplan_uuid"]; + $dialplan_context = $_SESSION['domains'][$domain_uuid]['domain_name']; + $sql = "update v_dialplans set "; + $sql .= "dialplan_context = '$dialplan_context' "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and dialplan_uuid = '$dialplan_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + } + } + //only run the following code if the directory exists if (is_dir($_SESSION['switch']['dialplan']['dir'])) { //write the dialplan/default.xml if it does not exist