Rename the directory app/dialplan to app/dialplans to make it more consistent.

This commit is contained in:
markjcrane
2017-09-24 15:56:04 +00:00
parent 1ea9cdb696
commit 2206c2f97c
82 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,189 @@
<?php
//application details
$apps[$x]['name'] = "Dialplan Manager";
$apps[$x]['uuid'] = "742714e5-8cdf-32fd-462c-cbe7e3d655db";
$apps[$x]['category'] = "Switch";
$apps[$x]['subcategory'] = "";
$apps[$x]['version'] = "1.0";
$apps[$x]['license'] = "Mozilla Public License 1.1";
$apps[$x]['url'] = "http://www.fusionpbx.com";
$apps[$x]['description']['en-us'] = "The dialplan is used to setup call destinations based on conditions and context. You can use the dialplan to send calls to gateways, auto attendants, external numbers, to scripts, or any destination.";
$apps[$x]['description']['ar-eg'] = "";
$apps[$x]['description']['de-at'] = "Der Wählplan wird verwendet um Anruf-Ziele anhand von Bedingungen und Kontext fest zu legen. Sie können den Wählplan verwenden, um Anrufe an Gateways, Automatische Zentralen, externe Rufnummern, Skripte oder andere Ziele weiterzuleiten.";
$apps[$x]['description']['de-ch'] = "";
$apps[$x]['description']['de-de'] = "Der Wählplan wird verwendet um Anruf-Ziele anhand von Bedingungen und Kontext fest zu legen. Sie können den Wählplan verwenden, um Anrufe an Gateways, Automatische Zentralen, externe Rufnummern, Skripte oder andere Ziele weiterzuleiten.";
$apps[$x]['description']['es-cl'] = "El plan de marcado es usado para configurar los destinos de llamadas basados en condiciones y contexto. Usted puede usar los planes de marcado para enviar hacia pasarelas, IVR, números externos, scripts o cualquier otro destino.";
$apps[$x]['description']['es-mx'] = "El plan de marcado es usado para configurar los destinos de llamadas basados en condiciones y contexto. Usted puede usar los planes de marcado para enviar hacia pasarelas, IVR, números externos, scripts o cualquier otro destino.";
$apps[$x]['description']['fr-ca'] = "";
$apps[$x]['description']['fr-fr'] = "Les dialplans son utilisés pour configurer les destinations d'appels selon des conditions et contextes. Vous pouvez en utiliser pour diriger les appels vers les passerelles, IVR, numéross exterieurs ou tout autre destination.";
$apps[$x]['description']['he-il'] = "";
$apps[$x]['description']['it-it'] = "";
$apps[$x]['description']['nl-nl'] = "";
$apps[$x]['description']['pl-pl'] = "";
$apps[$x]['description']['pt-br'] = "";
$apps[$x]['description']['pt-pt'] = "O dialplan é usado para configurar destinos de chamada com base nas condições e contexto. Você pode usar o dialplan para enviar chamadas para gateways, atendedores automáticos, números externos, para scripts, ou qualquer destino.";
$apps[$x]['description']['ro-ro'] = "";
$apps[$x]['description']['ru-ru'] = "";
$apps[$x]['description']['sv-se'] = "";
$apps[$x]['description']['uk-ua'] = "";
//permission details
$y=0;
$apps[$x]['permissions'][$y]['name'] = "dialplan_view";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "b94e8bd9-9eb5-e427-9c26-ff7a6c21552a";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "dialplan_add";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "dialplan_edit";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "dialplan_delete";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "dialplan_xml";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "dialplan_detail_view";
$apps[$x]['permissions'][$y]['menu']['uuid'] = "b94e8bd9-9eb5-e427-9c26-ff7a6c21552a";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "dialplan_detail_add";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "dialplan_detail_edit";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "dialplan_detail_delete";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['permissions'][$y]['name'] = "dialplan_domain";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
//schema details
$y=0;
$apps[$x]['db'][$y]['table']['name'] = "v_dialplans";
$apps[$x]['db'][$y]['table']['parent'] = "";
$z=0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "app_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "hostname";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_context";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_name";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_number";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_continue";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_xml";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_order";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_enabled";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_description";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$y++;
$apps[$x]['db'][$y]['table']['name'] = "v_dialplan_details";
$apps[$x]['db'][$y]['table']['parent'] = "v_dialplans";
$z=0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_dialplans";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "dialplan_uuid";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_detail_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_detail_tag";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_detail_type";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_detail_data";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_detail_break";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_detail_inline";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_detail_group";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "dialplan_detail_order";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "numeric";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
?>

View File

@@ -0,0 +1,139 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2014
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//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
//set the path
if (file_exists('/usr/share/examples/fusionpbx/resources/templates/conf')) {
$path = "/usr/share/examples/fusionpbx/resources/templates/conf";
}
else {
$path = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/conf';
}
//get the contents of the dialplan/default.xml
$file_default_path = $path.'/dialplan/default.xml';
$file_default_contents = file_get_contents($file_default_path);
//prepare the file contents and the path
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
$file_default_contents = str_replace("{v_domain}", $context, $file_default_contents);
//set the file path
$file_path = $_SESSION['switch']['conf']['dir'].'/dialplan/'.$context.'.xml';
//write the default dialplan
if (!file_exists($file_path)) {
$fh = fopen($file_path,'w') or die('Unable to write to '.$file_path.'. Make sure the path exists and permissions are set correctly.');
fwrite($fh, $file_default_contents);
fclose($fh);
}
}
*/
//get the $apps array from the installed apps from the core and mod directories
if ($domains_processed == 1) {
//get the array of xml files
$xml_list = glob($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH . "/*/*/resources/switch/conf/dialplan/*.xml");
//dialplan class
$dialplan = new dialplan;
//process the xml files
foreach ($xml_list as &$xml_file) {
//get and parse the xml
$xml_string = file_get_contents($xml_file);
//get the order number prefix from the file name
$name_array = explode('_', basename($xml_file));
if (is_numeric($name_array[0])) {
$dialplan_order = $name_array[0];
}
else {
$dialplan_order = 0;
}
$dialplan->dialplan_order = $dialplan_order;
if ($display_type == "text") {
$dialplan->display_type = 'text';
}
$dialplan->xml = $xml_string;
$dialplan->import();
}
//update the dialplan order
$sql = "update v_dialplans set dialplan_order = '870' where dialplan_order = '980' and dialplan_name = 'cidlookup';\n";
$db->query($sql);
$sql = "update v_dialplans set dialplan_order = '880' where dialplan_order = '990' and dialplan_name = 'call_screen';\n";
$db->query($sql);
$sql = "update v_dialplans set dialplan_order = '890' where dialplan_order = '999' and dialplan_name = 'local_extension';\n";
$db->query($sql);
unset($sql);
}
//add xml for each dialplan where the dialplan xml is empty
if ($domains_processed == 1) {
$dialplans = new dialplan;
$dialplans->source = "details";
$dialplans->destination = "database";
$dialplans->is_empty = "dialplan_xml";
$array = $dialplans->xml();
//print_r($array);
}
//add not found dialplan to inbound routes
/*
if ($domains_processed == 1) {
if (is_readable($_SESSION['switch']['dialplan']['dir'])) {
$sql = "select count(*) as num_rows from v_dialplans ";
$sql .= "where dialplan_uuid = 'ea5339de-1982-46ca-9695-c35176165314' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] == 0) {
$sql = "INSERT INTO v_dialplans ";
$sql .= "(dialplan_uuid, app_uuid, dialplan_context, dialplan_name, dialplan_continue, dialplan_order, dialplan_enabled) ";
$sql .= "VALUES ('ea5339de-1982-46ca-9695-c35176165314', 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4', 'public', 'not-found', 'false', '999', 'false');";
$db->query($sql);
$sql = "INSERT INTO v_dialplan_details ";
$sql .= "(dialplan_uuid, dialplan_detail_uuid, dialplan_detail_tag, dialplan_detail_type, dialplan_detail_data, dialplan_detail_order) ";
$sql .= "VALUES ('ea5339de-1982-46ca-9695-c35176165314', '8a21744d-b381-4cb0-9930-55b776e4e461', 'condition', 'context', 'public', '10');";
$db->query($sql);
$sql = "INSERT INTO v_dialplan_details ";
$sql .= "(dialplan_uuid, dialplan_detail_uuid, dialplan_detail_tag, dialplan_detail_type, dialplan_detail_data, dialplan_detail_order) ";
$sql .= "VALUES ('ea5339de-1982-46ca-9695-c35176165314', 'e391530c-4078-4b49-bc11-bda4a23ad566', 'action', 'log', '[inbound routes] 404 not found \${sip_network_ip}', '20');";
$db->query($sql);
unset($sql);
}
unset($prep_statement);
}
}
}
*/
?>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
<?php
$y=0;
$apps[$x]['menu'][$y]['title']['en-us'] = "Dialplan";
$apps[$x]['menu'][$y]['title']['ar-eg'] = "";
$apps[$x]['menu'][$y]['title']['de-at'] = "Wählplan";
$apps[$x]['menu'][$y]['title']['de-ch'] = "";
$apps[$x]['menu'][$y]['title']['de-de'] = "Wählplan";
$apps[$x]['menu'][$y]['title']['es-cl'] = "Plan de Marcado";
$apps[$x]['menu'][$y]['title']['es-mx'] = "Plan de Marcado";
$apps[$x]['menu'][$y]['title']['fr-ca'] = "";
$apps[$x]['menu'][$y]['title']['fr-fr'] = "Dialplan";
$apps[$x]['menu'][$y]['title']['he-il'] = "";
$apps[$x]['menu'][$y]['title']['it-it'] = "Piano Numerazioni";
$apps[$x]['menu'][$y]['title']['nl-nl'] = "";
$apps[$x]['menu'][$y]['title']['pl-pl'] = "Dialplan";
$apps[$x]['menu'][$y]['title']['pt-br'] = "Dialplan";
$apps[$x]['menu'][$y]['title']['pt-pt'] = "Dialplan";
$apps[$x]['menu'][$y]['title']['ro-ro'] = "";
$apps[$x]['menu'][$y]['title']['ru-ru'] = "План нумерации";
$apps[$x]['menu'][$y]['title']['sv-se'] = "Nummerplan";
$apps[$x]['menu'][$y]['title']['uk-ua'] = "Маршрутизація";
$apps[$x]['menu'][$y]['uuid'] = "b94e8bd9-9eb5-e427-9c26-ff7a6c21552a";
$apps[$x]['menu'][$y]['parent_uuid'] = "";
$apps[$x]['menu'][$y]['category'] = "internal";
$apps[$x]['menu'][$y]['icon'] = "glyphicon-transfer";
$apps[$x]['menu'][$y]['path'] = "";
$apps[$x]['menu'][$y]['order'] = "15";
$apps[$x]['menu'][$y]['groups'][] = "admin";
$apps[$x]['menu'][$y]['groups'][] = "superadmin";
$y++;
$apps[$x]['menu'][$y]['title']['en-us'] = "Dialplan Manager";
$apps[$x]['menu'][$y]['title']['ar-eg'] = "";
$apps[$x]['menu'][$y]['title']['de-at'] = "Wählplan Einstellungen";
$apps[$x]['menu'][$y]['title']['de-ch'] = "";
$apps[$x]['menu'][$y]['title']['de-de'] = "Wählplan Einstellungen";
$apps[$x]['menu'][$y]['title']['es-cl'] = "Gest. de Plan de Marcado";
$apps[$x]['menu'][$y]['title']['es-mx'] = "Administrador de Planes de Marcado";
$apps[$x]['menu'][$y]['title']['fr-ca'] = "Administrateur de Dialplan";
$apps[$x]['menu'][$y]['title']['fr-fr'] = "Gestion du Plan de Numérotation";
$apps[$x]['menu'][$y]['title']['he-il'] = "";
$apps[$x]['menu'][$y]['title']['it-it'] = "";
$apps[$x]['menu'][$y]['title']['nl-nl'] = "";
$apps[$x]['menu'][$y]['title']['pl-pl'] = "Menadżer dialplanu";
$apps[$x]['menu'][$y]['title']['pt-br'] = "Gerenciador de Dialplan";
$apps[$x]['menu'][$y]['title']['pt-pt'] = "Gestor de Dialplan";
$apps[$x]['menu'][$y]['title']['ro-ro'] = "";
$apps[$x]['menu'][$y]['title']['ru-ru'] = "Управление планом нумерации";
$apps[$x]['menu'][$y]['title']['sv-se'] = "Nummerplan Inställningar";
$apps[$x]['menu'][$y]['title']['uk-ua'] = "Керування маршрутизацією";
$apps[$x]['menu'][$y]['uuid'] = "52929fee-81d3-4d94-50b7-64842d9393c2";
$apps[$x]['menu'][$y]['parent_uuid'] = "b94e8bd9-9eb5-e427-9c26-ff7a6c21552a";
$apps[$x]['menu'][$y]['category'] = "internal";
$apps[$x]['menu'][$y]['path'] = "/app/dialplan/dialplans.php";
$apps[$x]['menu'][$y]['groups'][] = "admin";
$apps[$x]['menu'][$y]['groups'][] = "superadmin";
?>

View File

@@ -0,0 +1,639 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('dialplan_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//additional includes
require_once "resources/header.php";
$document['title'] = $text['title-dialplan_add'];
require_once "resources/paging.php";
//set the variables
if (count($_POST) > 0) {
$dialplan_name = check_str($_POST["dialplan_name"]);
$condition_field_1 = check_str($_POST["condition_field_1"]);
$condition_expression_1 = check_str($_POST["condition_expression_1"]);
$condition_field_2 = check_str($_POST["condition_field_2"]);
$condition_expression_2 = check_str($_POST["condition_expression_2"]);
$action_1 = check_str($_POST["action_1"]);
//$action_1 = "transfer:1001 XML default";
$action_1_array = explode(":", $action_1);
$action_application_1 = array_shift($action_1_array);
$action_data_1 = join(':', $action_1_array);
$action_2 = check_str($_POST["action_2"]);
//$action_2 = "transfer:1001 XML default";
$action_2_array = explode(":", $action_2);
$action_application_2 = array_shift($action_2_array);
$action_data_2 = join(':', $action_2_array);
//$action_application_1 = check_str($_POST["action_application_1"]);
//$action_data_1 = check_str($_POST["action_data_1"]);
//$action_application_2 = check_str($_POST["action_application_2"]);
//$action_data_2 = check_str($_POST["action_data_2"]);
$dialplan_context = check_str($_POST["dialplan_context"]);
$dialplan_order = check_str($_POST["dialplan_order"]);
$dialplan_enabled = check_str($_POST["dialplan_enabled"]);
$dialplan_description = check_str($_POST["dialplan_description"]);
if (strlen($dialplan_enabled) == 0) { $dialplan_enabled = "true"; } //set default to enabled
}
//set the default
if (strlen($dialplan_context) == 0) { $dialplan_context = $_SESSION['context']; }
//add or update data from http post
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//check for all required data
if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']."domain_uuid<br>\n"; }
if (strlen($dialplan_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
if (strlen($condition_field_1) == 0) { $msg .= $text['message-required'].$text['label-condition_1']." ".$text['label-field']."<br>\n"; }
if (strlen($condition_expression_1) == 0) { $msg .= $text['message-required'].$text['label-condition_1']." ".$text['label-expression']."<br>\n"; }
if (strlen($action_application_1) == 0) { $msg .= $text['message-required'].$text['label-action_1']."<br>\n"; }
//if (strlen($dialplan_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
//if (strlen($dialplan_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//remove the invalid characters from the extension name
$dialplan_name = str_replace(" ", "_", $dialplan_name);
$dialplan_name = str_replace("/", "", $dialplan_name);
//start the atomic transaction
$db->exec("BEGIN;"); //returns affected rows
//add the main dialplan include entry
$dialplan_uuid = uuid();
$sql = "insert into v_dialplans ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "dialplan_uuid, ";
$sql .= "app_uuid, ";
$sql .= "dialplan_name, ";
$sql .= "dialplan_order, ";
$sql .= "dialplan_continue, ";
$sql .= "dialplan_context, ";
$sql .= "dialplan_enabled, ";
$sql .= "dialplan_description ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'$domain_uuid', ";
$sql .= "'$dialplan_uuid', ";
$sql .= "'742714e5-8cdf-32fd-462c-cbe7e3d655db', ";
$sql .= "'$dialplan_name', ";
$sql .= "'$dialplan_order', ";
$sql .= "'false', ";
$sql .= "'$dialplan_context', ";
$sql .= "'$dialplan_enabled', ";
$sql .= "'$dialplan_description' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
//add condition 1
$dialplan_detail_uuid = uuid();
$sql = "insert into v_dialplan_details ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "dialplan_uuid, ";
$sql .= "dialplan_detail_uuid, ";
$sql .= "dialplan_detail_tag, ";
$sql .= "dialplan_detail_type, ";
$sql .= "dialplan_detail_data, ";
$sql .= "dialplan_detail_order ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'$domain_uuid', ";
$sql .= "'$dialplan_uuid', ";
$sql .= "'$dialplan_detail_uuid', ";
$sql .= "'condition', ";
$sql .= "'$condition_field_1', ";
$sql .= "'$condition_expression_1', ";
$sql .= "'1' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
//add condition 2
if (strlen($condition_field_2) > 0) {
$dialplan_detail_uuid = uuid();
$sql = "insert into v_dialplan_details ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "dialplan_uuid, ";
$sql .= "dialplan_detail_uuid, ";
$sql .= "dialplan_detail_tag, ";
$sql .= "dialplan_detail_type, ";
$sql .= "dialplan_detail_data, ";
$sql .= "dialplan_detail_order ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'$domain_uuid', ";
$sql .= "'$dialplan_uuid', ";
$sql .= "'$dialplan_detail_uuid', ";
$sql .= "'condition', ";
$sql .= "'$condition_field_2', ";
$sql .= "'$condition_expression_2', ";
$sql .= "'2' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
}
//add action 1
$dialplan_detail_uuid = uuid();
$sql = "insert into v_dialplan_details ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "dialplan_uuid, ";
$sql .= "dialplan_detail_uuid, ";
$sql .= "dialplan_detail_tag, ";
$sql .= "dialplan_detail_type, ";
$sql .= "dialplan_detail_data, ";
$sql .= "dialplan_detail_order ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'$domain_uuid', ";
$sql .= "'$dialplan_uuid', ";
$sql .= "'$dialplan_detail_uuid', ";
$sql .= "'action', ";
$sql .= "'$action_application_1', ";
$sql .= "'$action_data_1', ";
$sql .= "'3' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
//add action 2
if (strlen($action_application_2) > 0) {
$dialplan_detail_uuid = uuid();
$sql = "insert into v_dialplan_details ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "dialplan_uuid, ";
$sql .= "dialplan_detail_uuid, ";
$sql .= "dialplan_detail_tag, ";
$sql .= "dialplan_detail_type, ";
$sql .= "dialplan_detail_data, ";
$sql .= "dialplan_detail_order ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'$domain_uuid', ";
$sql .= "'$dialplan_uuid', ";
$sql .= "'$dialplan_detail_uuid', ";
$sql .= "'action', ";
$sql .= "'$action_application_2', ";
$sql .= "'$action_data_2', ";
$sql .= "'4' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
}
//commit the atomic transaction
$count = $db->exec("COMMIT;"); //returns affected rows
//synchronize the xml config
save_dialplan_xml();
//delete the dialplan context from memcache
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$switch_cmd = "memcache delete dialplan:".$dialplan_context;
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
}
messages::add($text['message-update']);
header("Location: ".PROJECT_PATH."/app/dialplan/dialplans.php");
return;
} //end if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//initialize the destinations object
$destination = new destinations;
//javascript type on change
?><script type="text/javascript">
<!--
function type_onchange(dialplan_detail_type) {
var field_value = document.getElementById(dialplan_detail_type).value;
if (dialplan_detail_type == "condition_field_1") {
if (field_value == "destination_number") {
document.getElementById("desc_condition_expression_1").innerHTML = "expression: ^12081231234$";
}
else if (field_value == "zzz") {
document.getElementById("desc_condition_expression_1").innerHTML = "";
}
else {
document.getElementById("desc_condition_expression_1").innerHTML = "";
}
}
if (dialplan_detail_type == "condition_field_2") {
if (field_value == "destination_number") {
document.getElementById("desc_condition_expression_2").innerHTML = "expression: ^12081231234$";
}
else if (field_value == "zzz") {
document.getElementById("desc_condition_expression_2").innerHTML = "";
}
else {
document.getElementById("desc_condition_expression_2").innerHTML = "";
}
}
-->
</script>
<?php
//show the content
echo "<form method='post' name='frm' action=''>\n";
echo " <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <td align='left'>\n";
echo " <span class=\"title\">".$text['header-dialplan-add']."</span>\n";
echo " </td>\n";
echo " <td align='right'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-advanced']."' onclick=\"window.location='dialplan_edit.php'\" value='".$text['button-advanced']."'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='dialplans.php'\" value='".$text['button-back']."'>\n";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' colspan='2'>\n";
echo " <br><span class=\"vexpl\">".$text['description-dialplan_manager-superadmin']."</span>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>";
echo "<br />\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-name']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='dialplan_name' maxlength='255' value=\"$dialplan_name\">\n";
echo "<br />\n";
echo "\n";
echo "</td>\n";
echo "</tr>\n";
//echo "<tr>\n";
//echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
//echo " Continue\n";
//echo "</td>\n";
//echo "<td class='vtable' align='left'>\n";
//echo " <select class='formfld' name='dialplan_continue' style='width: 60%;'>\n";
//echo " <option value=''></option>\n";
//if ($dialplan_continue == "true") {
// echo " <option value='true' SELECTED >true</option>\n";
//}
//else {
// echo " <option value='true'>true</option>\n";
//}
//if ($dialplan_continue == "false") {
// echo " <option value='false' SELECTED >false</option>\n";
//}
//else {
// echo " <option value='false'>false</option>\n";
//}
//echo " </select>\n";
//echo "<br />\n";
//echo "Extension Continue in most cases this is false. default: false\n";
//echo "</td>\n";
//echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-condition_1']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
?>
<script>
var Objs;
function changeToInput_condition_field_1(obj){
tb=document.createElement('INPUT');
tb.type='text';
tb.name=obj.name;
tb.className='formfld';
tb.setAttribute('id', 'condition_field_1');
tb.setAttribute('style', 'width: 85%;');
tb.value=obj.options[obj.selectedIndex].value;
document.getElementById('btn_select_to_input_condition_field_1').style.visibility = 'hidden';
tbb=document.createElement('INPUT');
tbb.setAttribute('class', 'btn');
tbb.setAttribute('style', 'margin-left: 4px;');
tbb.type='button';
tbb.value=$("<div />").html('&#9665;').text();
tbb.objs=[obj,tb,tbb];
tbb.onclick=function(){ Replace_condition_field_1(this.objs); }
obj.parentNode.insertBefore(tb,obj);
obj.parentNode.insertBefore(tbb,obj);
obj.parentNode.removeChild(obj);
Replace_condition_field_1(this.objs);
}
function Replace_condition_field_1(obj){
obj[2].parentNode.insertBefore(obj[0],obj[2]);
obj[0].parentNode.removeChild(obj[1]);
obj[0].parentNode.removeChild(obj[2]);
document.getElementById('btn_select_to_input_condition_field_1').style.visibility = 'visible';
}
</script>
<?php
echo " <table border='0'>\n";
echo " <tr>\n";
//echo " <td nowrap='nowrap'>".$text['label-field']."</td>\n";
echo " <td nowrap='nowrap'>\n";
echo " <select class='formfld' name='condition_field_1' id='condition_field_1' onchange='changeToInput_condition_field_1(this);this.style.visibility = \"hidden\";' style='width:85%'>\n";
echo " <option value=''></option>\n";
if (strlen($condition_field_1) > 0) {
echo " <option value='$condition_field_1' selected='selected'>$condition_field_1</option>\n";
}
echo " <optgroup label='Field'>\n";
echo " <option value='context'>".$text['option-context']."</option>\n";
echo " <option value='username'>".$text['option-username']."</option>\n";
echo " <option value='rdnis'>".$text['option-rdnis']."</option>\n";
echo " <option value='destination_number'>".$text['option-destination_number']."</option>\n";
echo " <option value='public'>".$text['option-public']."</option>\n";
echo " <option value='caller_id_name'>".$text['option-caller_id_name']."</option>\n";
echo " <option value='caller_id_number'>".$text['option-caller_id_number']."</option>\n";
echo " <option value='ani'>".$text['option-ani']."</option>\n";
echo " <option value='ani2'>".$text['option-ani2']."</option>\n";
echo " <option value='uuid'>".$text['option-uuid']."</option>\n";
echo " <option value='source'>".$text['option-source']."</option>\n";
echo " <option value='chan_name'>".$text['option-chan_name']."</option>\n";
echo " <option value='network_addr'>".$text['option-network_addr']."</option>\n";
echo " </optgroup>\n";
echo " <optgroup label='Time'>\n";
echo " <option value='hour'>".$text['option-hour']."</option>\n";
echo " <option value='minute'>".$text['option-minute']."</option>\n";
echo " <option value='minute-of-day'>".$text['option-minute_of_day']."</option>\n";
echo " <option value='mday'>".$text['option-day_of_month']."</option>\n";
echo " <option value='mweek'>".$text['option-week_of_month']."</option>\n";
echo " <option value='mon'>".$text['option-month']."</option>\n";
echo " <option value='yday'>".$text['option-day_of_year']."</option>\n";
echo " <option value='year'>".$text['option-year']."</option>\n";
echo " <option value='wday'>".$text['option-day_of_week']."</option>\n";
echo " <option value='week'>".$text['option-week']."</option>\n";
echo " </optgroup>\n";
echo " </select>\n";
echo " <input type='button' id='btn_select_to_input_condition_field_1' class='btn' name='' alt='".$text['button-back']."' onclick='changeToInput_condition_field_1(document.getElementById(\"condition_field_1\"));this.style.visibility = \"hidden\";' value='&#9665;'>\n";
echo " <br />\n";
echo " </td>\n";
//echo " <td>&nbsp;&nbsp;&nbsp;".$text['label-expression']."</td>\n";
echo " <td>\n";
echo " &nbsp;<input class='formfld' type='text' name='condition_expression_1' maxlength='255' value=\"$condition_expression_1\">\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " <div id='desc_condition_expression_1'></div>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-condition_2']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <table border='0'>\n";
echo " <tr>\n";
//echo " <td align='left'>".$text['label-field']."</td>\n";
echo " <td nowrap='nowrap'>\n";
?>
<script>
var Objs;
function changeToInput_condition_field_2(obj){
tb=document.createElement('INPUT');
tb.type='text';
tb.name=obj.name;
tb.className='formfld';
tb.setAttribute('id', 'condition_field_2');
tb.setAttribute('style', 'width: 85%;');
tb.value=obj.options[obj.selectedIndex].value;
document.getElementById('btn_select_to_input_condition_field_2').style.visibility = 'hidden';
tbb=document.createElement('INPUT');
tbb.setAttribute('class', 'btn');
tbb.setAttribute('style', 'margin-left: 4px;');
tbb.type='button';
tbb.value=$("<div />").html('&#9665;').text();
tbb.objs=[obj,tb,tbb];
tbb.onclick=function(){ Replace_condition_field_2(this.objs); }
obj.parentNode.insertBefore(tb,obj);
obj.parentNode.insertBefore(tbb,obj);
obj.parentNode.removeChild(obj);
Replace_condition_field_2(this.objs);
}
function Replace_condition_field_2(obj){
obj[2].parentNode.insertBefore(obj[0],obj[2]);
obj[0].parentNode.removeChild(obj[1]);
obj[0].parentNode.removeChild(obj[2]);
document.getElementById('btn_select_to_input_condition_field_2').style.visibility = 'visible';
}
</script>
<?php
echo " <select class='formfld' name='condition_field_2' id='condition_field_2' onchange='changeToInput_condition_field_2(this);this.style.visibility = \"hidden\";'>\n";
echo " <option value=''></option>\n";
if (strlen($condition_field_2) > 0) {
echo " <option value='$condition_field_2' selected>$condition_field_2</option>\n";
}
echo " <optgroup label='Field'>\n";
echo " <option value='context'>".$text['option-context']."</option>\n";
echo " <option value='username'>".$text['option-username']."</option>\n";
echo " <option value='rdnis'>".$text['option-rdnis']."</option>\n";
echo " <option value='destination_number'>".$text['option-destination_number']."</option>\n";
echo " <option value='public'>".$text['option-public']."</option>\n";
echo " <option value='caller_id_name'>".$text['option-caller_id_name']."</option>\n";
echo " <option value='caller_id_number'>".$text['option-caller_id_number']."</option>\n";
echo " <option value='ani'>".$text['option-ani']."</option>\n";
echo " <option value='ani2'>".$text['option-ani2']."</option>\n";
echo " <option value='uuid'>".$text['option-uuid']."</option>\n";
echo " <option value='source'>".$text['option-source']."</option>\n";
echo " <option value='chan_name'>".$text['option-chan_name']."</option>\n";
echo " <option value='network_addr'>".$text['option-network_addr']."</option>\n";
echo " </optgroup>\n";
echo " <optgroup label='Time'>\n";
echo " <option value='hour'>".$text['option-hour']."</option>\n";
echo " <option value='minute'>".$text['option-minute']."</option>\n";
echo " <option value='minute-of-day'>".$text['option-minute_of_day']."</option>\n";
echo " <option value='mday'>".$text['option-day_of_month']."</option>\n";
echo " <option value='mweek'>".$text['option-week_of_month']."</option>\n";
echo " <option value='mon'>".$text['option-month']."</option>\n";
echo " <option value='yday'>".$text['option-day_of_year']."</option>\n";
echo " <option value='year'>".$text['option-year']."</option>\n";
echo " <option value='wday'>".$text['option-day_of_week']."</option>\n";
echo " <option value='week'>".$text['option-week']."</option>\n";
echo " </optgroup>\n";
echo " </select>\n";
echo " <input type='button' id='btn_select_to_input_condition_field_2' class='btn' name='' alt='".$text['button-back']."' onclick='changeToInput_condition_field_2(document.getElementById(\"condition_field_2\"));this.style.visibility = \"hidden\";' value='&#9665;'>\n";
echo " <br />\n";
echo " </td>\n";
//echo " <td>&nbsp;&nbsp;&nbsp;".$text['label-expression']."</td>\n";
echo " <td>\n";
echo " &nbsp;<input class='formfld' type='text' name='condition_expression_2' maxlength='255' value=\"$condition_expression_2\">\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " <div id='desc_condition_expression_2'></div>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-action_1']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo $destination->select('dialplan', 'action_1', $action_1);
echo "</td>\n";
echo "</tr>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-action_2']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo $destination->select('dialplan', 'action_2', $action_2);
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-context']."\n";
echo " </td>\n";
echo " <td colspan='4' class='vtable' align='left'>\n";
echo " <input class='formfld' style='width: 60%;' type='text' name='dialplan_context' maxlength='255' value=\"$dialplan_context\">\n";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-order']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select name='dialplan_order' class='formfld'>\n";
//echo " <option></option>\n";
if (strlen(htmlspecialchars($dialplan_order)) > 0) {
echo " <option selected='selected' value='".htmlspecialchars($dialplan_order)."'>".htmlspecialchars($dialplan_order)."</option>\n";
}
$i = 200;
while($i <= 999) {
echo " <option value='$i'>$i</option>\n";
$i = $i + 10;
}
echo " </select>\n";
echo " <br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-enabled']."\n";
echo " </td>\n";
echo " <td class='vtable' align='left'>\n";
echo " <select class='formfld' name='dialplan_enabled'>\n";
if ($dialplan_enabled == "true") {
echo " <option value='true' selected='selected' >".$text['option-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['option-true']."</option>\n";
}
if ($dialplan_enabled == "false") {
echo " <option value='false' selected='selected' >".$text['option-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['option-false']."</option>\n";
}
echo " </select>\n";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-description']."\n";
echo " </td>\n";
echo " <td colspan='4' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='dialplan_description' maxlength='255' value=\"$dialplan_description\">\n";
echo " <br />\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td colspan='5' align='right'>\n";
if ($action == "update") {
echo " <input type='hidden' name='dialplan_uuid' value='$dialplan_uuid'>\n";
}
echo " <br>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo "</tr>";
echo "</table>";
echo "<br><br>";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>

View File

@@ -0,0 +1,166 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
require_once "resources/classes/logging.php";
//check permissions
if (permission_exists('dialplan_add')
|| permission_exists('inbound_route_add')
|| permission_exists('outbound_route_add')
|| permission_exists('fifo_add')
|| permission_exists('time_condition_add')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//logger
$log = new Logging();
//set the http get/post variable(s) to a php variable
if (isset($_REQUEST["id"])) {
$id = check_str($_REQUEST["id"]);
$log->log("debug", "isset id.");
$log->log("debug", $id);
}
//get the dialplan data
if (is_uuid($id)) {
$sql = "select * from v_dialplans ";
$sql .= "where dialplan_uuid = '$id' ";
$log->log("debug", check_sql($sql));
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$dialplans = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$log->log("debug", $result);
foreach ($dialplans as &$row) {
//create a new primary key for the new row
$dialplan_uuid = uuid();
$row['dialplan_uuid'] = $dialplan_uuid;
//get the app_uuid
if (is_uuid($row["app_uuid"])) {
//get the app uuid
$app_uuid = $row["app_uuid"];
//create a new app_uuid when copying a dialplan except for these exceptions
switch ($app_uuid) {
case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": break; //inbound routes
case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": break; //outbound routes
case "4b821450-926b-175a-af93-a03c441818b1": break; //time conditions
default:
$app_uuid = uuid();
}
//set the app uuid
$row['app_uuid'] = $app_uuid;
}
//add copy to the name and description
//$row['dialplan_name'] = $row['dialplan_name'].'-copy';
if (strlen($row['dialplan_description']) == 0) {
$dialplan_description = 'copy';
}
else {
$dialplan_description = $row['dialplan_description'].'-copy';
}
$row['dialplan_description'] = $dialplan_description;
}
unset ($prep_statement);
}
//get the the dialplan details
if (is_uuid($id)) {
$sql = "select * from v_dialplan_details ";
$sql .= "where dialplan_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$dialplan_details = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($dialplan_details as &$row) {
//create a new primary key for the new row
$row['dialplan_detail_uuid'] = uuid();
//update the foreign relation uuid
$row['dialplan_uuid'] = $dialplan_uuid;
}
unset ($prep_statement);
}
//build the array
$array['dialplans'] = $dialplans;
if (count($dialplan_details) > 0) {
$array['dialplans'][0]['dialplan_details'] = $dialplan_details;
}
//debug info
//echo "<pre>".print_r($array, true)."</pre>\n";
//exit;
//add or update the database
$database = new database;
$database->app_name = 'dialplans';
$database->app_uuid = $app_uuid;
$database->uuid($dialplan_uuid);
$database->save($array);
//$message = $database->message;
//update the dialplan xml
$dialplans = new dialplan;
$dialplans->source = "details";
$dialplans->destination = "database";
$dialplans->uuid = $dialplan_uuid;
$dialplans->xml();
//clear the cache
$cache = new cache;
$cache->delete("dialplan:".$dialplan_context);
//synchronize the xml config
save_dialplan_xml();
//send a redirect
messages::add($text['message-copy']);
switch ($app_uuid) {
case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": //inbound routes
case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": //outbound routes
case "4b821450-926b-175a-af93-a03c441818b1": //time conditions
$redirect_url = PROJECT_PATH."/app/dialplan/dialplans.php?app_uuid=".$app_uuid;
break;
default:
$redirect_url = PROJECT_PATH."/app/dialplan/dialplans.php";
}
header("Location: ".$redirect_url);
return;
?>

View File

@@ -0,0 +1,114 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('dialplan_delete')
|| permission_exists('inbound_route_delete')
|| permission_exists('outbound_route_delete')
|| permission_exists('fifo_delete')
|| permission_exists('time_condition_delete')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the dialplan uuid
$dialplan_uuids = $_REQUEST["id"];
$app_uuid = check_str($_REQUEST['app_uuid']);
//delete the dialplans
if (sizeof($dialplan_uuids) > 0) {
//get dialplan contexts
foreach ($dialplan_uuids as $dialplan_uuid) {
//check each
$dialplan_uuid = check_str($dialplan_uuid);
//get the dialplan data
$sql = "select * from v_dialplans ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$database_dialplan_uuid = $row["dialplan_uuid"];
$dialplan_contexts[] = $row["dialplan_context"];
}
unset($prep_statement);
}
//start the atomic transaction
$db->beginTransaction();
//delete dialplan and details
$dialplans_deleted = 0;
foreach ($dialplan_uuids as $dialplan_uuid) {
//delete child data
$sql = "delete from v_dialplan_details ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
$db->query($sql);
unset($sql);
//delete parent data
$sql = "delete from v_dialplans ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
$db->query($sql);
unset($sql);
$dialplans_deleted++;
}
//commit the atomic transaction
$db->commit();
//synchronize the xml config
save_dialplan_xml();
//strip duplicate contexts
$dialplan_contexts = array_unique($dialplan_contexts, SORT_STRING);
//clear the cache
$cache = new cache;
if (sizeof($dialplan_contexts) > 0) {
foreach($dialplan_contexts as $dialplan_context) {
$cache->delete("dialplan:".$dialplan_context);
}
}
}
//redirect the browser
$_SESSION["message"] = $text['message-delete'].(($dialplans_deleted > 1) ? ": ".$dialplans_deleted : null);
header("Location: ".PROJECT_PATH."/app/dialplan/dialplans.php".(($app_uuid != '') ? "?app_uuid=".$app_uuid : null));
?>

View File

@@ -0,0 +1,90 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2014
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('dialplan_delete')
|| permission_exists('inbound_route_delete')
|| permission_exists('outbound_route_delete')
|| permission_exists('fifo_delete')
|| permission_exists('time_condition_delete')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the variables
if (count($_GET) > 0) {
$dialplan_detail_uuid = check_str($_GET["id"]);
$dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]);
$app_uuid = check_str($_REQUEST["app_uuid"]);
}
//delete the dialplan detail
if (strlen($dialplan_detail_uuid) > 0) {
//delete child data
$sql = "delete from v_dialplan_details ";
//$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "where dialplan_detail_uuid = '$dialplan_detail_uuid' ";
$db->query($sql);
unset($sql);
//synchronize the xml config
save_dialplan_xml();
//delete the dialplan context from memcache
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$switch_cmd = "memcache delete dialplan:".$_SESSION["context"];
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
}
//update the dialplan xml
$dialplans = new dialplan;
$dialplans->source = "details";
$dialplans->destination = "database";
$dialplans->uuid = $dialplan_uuid;
$dialplans->xml();
}
//save the message to a session variable
messages::add($text['message-delete']);
//redirect the browser
header("Location: dialplan_edit.php?id=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null));
exit;
?>

View File

@@ -0,0 +1,487 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2013
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('dialplan_add')
|| permission_exists('dialplan_edit')
|| permission_exists('inbound_route_add')
|| permission_exists('inbound_route_edit')
|| permission_exists('outbound_route_add')
|| permission_exists('outbound_route_edit')
|| permission_exists('fifo_edit')
|| permission_exists('fifo_add')
|| permission_exists('time_condition_add')
|| permission_exists('time_condition_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the action as an add or update
if (isset($_REQUEST["id"])) {
$action = "update";
$dialplan_detail_uuid = check_str($_REQUEST["id"]);
}
else {
$action = "add";
}
$dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]);
//get the http values and set them as php variables
$app_uuid = check_str($_REQUEST["app_uuid"]);
if (count($_POST)>0) {
$dialplan_uuid = check_str($_POST["dialplan_uuid"]);
$dialplan_detail_tag = check_str($_POST["dialplan_detail_tag"]);
$dialplan_detail_order = check_str($_POST["dialplan_detail_order"]);
$dialplan_detail_type = check_str($_POST["dialplan_detail_type"]);
$dialplan_detail_data = check_str($_POST["dialplan_detail_data"]);
$dialplan_detail_break = check_str($_POST["dialplan_detail_break"]);
$dialplan_detail_inline = check_str($_POST["dialplan_detail_inline"]);
$dialplan_detail_group = check_str($_POST["dialplan_detail_group"]);
}
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$msg = '';
if ($action == "update") {
$dialplan_detail_uuid = check_str($_POST["dialplan_detail_uuid"]);
}
//check for all required data
if (strlen($dialplan_detail_tag) == 0) { $msg .= $text['message-required'].$text['label-tag']."<br>\n"; }
if (strlen($dialplan_detail_order) == 0) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
//if (strlen($dialplan_detail_type) == 0) { $msg .= $text['message-required'].$text['label-type']."<br>\n"; }
//if (strlen($dialplan_detail_data) == 0) { $msg .= $text['message-required'].$text['label-data']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//add or update the database
if ($_POST["persistformvar"] != "true") {
if ($action == "add" && permission_exists('dialplan_add')) {
$dialplan_detail_uuid = uuid();
$sql = "insert into v_dialplan_details ";
$sql .= "(";
$sql .= "dialplan_uuid, ";
$sql .= "dialplan_detail_uuid, ";
$sql .= "dialplan_detail_tag, ";
$sql .= "dialplan_detail_order, ";
$sql .= "dialplan_detail_type, ";
$sql .= "dialplan_detail_data, ";
$sql .= "dialplan_detail_break, ";
$sql .= "dialplan_detail_inline, ";
$sql .= "dialplan_detail_group, ";
$sql .= "domain_uuid ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'$dialplan_uuid', ";
$sql .= "'$dialplan_detail_uuid', ";
$sql .= "'$dialplan_detail_tag', ";
$sql .= "'$dialplan_detail_order', ";
$sql .= "'$dialplan_detail_type', ";
$sql .= "'$dialplan_detail_data', ";
$sql .= "'$dialplan_detail_break', ";
$sql .= "'$dialplan_detail_inline', ";
if (strlen($dialplan_detail_group) == 0) {
$sql .= "null, ";
}
else {
$sql .= "'$dialplan_detail_group', ";
}
$sql .= "'".$_SESSION['domain_uuid']."' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
//synchronize the xml config
save_dialplan_xml();
//delete the dialplan context from memcache
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$switch_cmd = "memcache delete dialplan:".$_SESSION["context"];
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
}
messages::add($text['message-add']);
header("Location: dialplan_edit.php?id=".$dialplan_uuid."&app_uuid=".$app_uuid);
return;
} //if ($action == "add")
if ($action == "update" && permission_exists('dialplan_edit')) {
$sql = "update v_dialplan_details set ";
$sql .= "dialplan_uuid = '$dialplan_uuid', ";
$sql .= "dialplan_detail_tag = '$dialplan_detail_tag', ";
$sql .= "dialplan_detail_order = '$dialplan_detail_order', ";
$sql .= "dialplan_detail_type = '$dialplan_detail_type', ";
$sql .= "dialplan_detail_data = '$dialplan_detail_data', ";
$sql .= "dialplan_detail_break = '$dialplan_detail_break', ";
$sql .= "dialplan_detail_inline = '$dialplan_detail_inline', ";
if (strlen($dialplan_detail_group) == 0) {
$sql .= "dialplan_detail_group = null ";
}
else {
$sql .= "dialplan_detail_group = '$dialplan_detail_group' ";
}
$sql .= "where (domain_uuid = '".$_SESSION['domain_uuid']."' or domain_uuid is null) ";
$sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid'";
$db->exec(check_sql($sql));
unset($sql);
//synchronize the xml config
save_dialplan_xml();
//delete the dialplan context from memcache
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$switch_cmd = "memcache delete dialplan:".$_SESSION["context"]."@".$_SESSION['domain_name'];
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
}
messages::add($text['message-update']);
header("Location: dialplan_edit.php?id=".$dialplan_uuid."&app_uuid=".$app_uuid);
return;
} //if ($action == "update")
} //if ($_POST["persistformvar"] != "true") {
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form
if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
$dialplan_detail_uuid = $_GET["id"];
$sql = "select * from v_dialplan_details ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and dialplan_detail_uuid = '$dialplan_detail_uuid' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$dialplan_uuid = $row["dialplan_uuid"];
$dialplan_detail_tag = $row["dialplan_detail_tag"];
$dialplan_detail_order = $row["dialplan_detail_order"];
$dialplan_detail_type = $row["dialplan_detail_type"];
$dialplan_detail_data = $row["dialplan_detail_data"];
$dialplan_detail_break = $row["dialplan_detail_break"];
$dialplan_detail_inline = $row["dialplan_detail_inline"];
$dialplan_detail_group = $row["dialplan_detail_group"];
}
unset ($prep_statement);
}
//show the header
require_once "resources/header.php";
$document['title'] = $text['title-dialplan_detail'];
//show the content
echo "<form method='post' name='frm' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td align='left' width='30%' nowrap=\"nowrap\"><span class=\"title\">".$text['header-dialplan_detail']."</span></td>\n";
echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='dialplan_edit.php?id=".$dialplan_uuid."&app_uuid=".$app_uuid."';\" value='".$text['button-back']."'></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo " <td>\n";
echo " &nbsp;\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-tag']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select name='dialplan_detail_tag' class='formfld' id='form_tag'>\n";
echo " <option></option>\n";
echo " <option value='condition' ".($dialplan_detail_tag == "condition" ? $selected:"").">".$text['option-condition']."</option>\n";
echo " <option value='regex' ".($dialplan_detail_tag == "regex" ? $selected:"").">".$text['option-regex']."</option>\n";
echo " <option value='action' ".($dialplan_detail_tag == "action" ? $selected:"").">".$text['option-condition']."</option>\n";
echo " <option value='anti-action' ".($dialplan_detail_tag == "anti-action" ? $selected:"").">".$text['option-condition']."</option>\n";
echo " <option value='param' ".($dialplan_detail_tag == "param" ? $selected:"").">".$text['option-condition']."</option>\n";
echo " <option value='condition' ".($dialplan_detail_tag == "condition" ? $selected:"").">".$text['option-condition']."</option>\n";
echo " </select>\n";
echo "<br />\n";
echo "\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-order']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select name='dialplan_detail_order' class='formfld'>\n";
if (strlen($dialplan_detail_order)> 0) {
echo " <option selected='selected' value='".htmlspecialchars($dialplan_detail_order)."'>".htmlspecialchars($dialplan_detail_order)."</option>\n";
}
$i=0;
while($i<=999) {
if (strlen($i) == 1) {
echo " <option value='00$i'>00$i</option>\n";
}
if (strlen($i) == 2) {
echo " <option value='0$i'>0$i</option>\n";
}
if (strlen($i) == 3) {
echo " <option value='$i'>$i</option>\n";
}
$i++;
}
echo " </select>\n";
echo "<br />\n";
echo "\n";
echo "</td>\n";
echo "</tr>\n";
?>
<script language="javascript">
var Objs;
function change_to_input(obj){
tb=document.createElement('INPUT');
tb.type='text';
tb.name=obj.name;
tb.className='formfld';
tb.setAttribute('id', 'ivr_menu_option_param');
tb.setAttribute('style', '');
tb.value=obj.options[obj.selectedIndex].value;
document.getElementById('btn_select_to_input_dialplan_detail_type').style.visibility = 'hidden';
tbb=document.createElement('INPUT');
tbb.setAttribute('class', 'btn');
tbb.setAttribute('style', 'margin-left: 4px;');
tbb.type='button';
tbb.value=$("<div />").html('&#9665;').text();
tbb.objs=[obj,tb,tbb];
tbb.onclick=function(){ replace_param(this.objs); }
obj.parentNode.insertBefore(tb,obj);
obj.parentNode.insertBefore(tbb,obj);
obj.parentNode.removeChild(obj);
replace_param(this.objs);
}
function replace_param(obj){
obj[2].parentNode.insertBefore(obj[0],obj[2]);
obj[0].parentNode.removeChild(obj[1]);
obj[0].parentNode.removeChild(obj[2]);
document.getElementById('btn_select_to_input_dialplan_detail_type').style.visibility = 'visible';
}
</script>
<?php
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-type']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo "<select name='dialplan_detail_type' id='dialplan_detail_type' class='formfld' onchange='change_to_input(this);'>\n";
if (strlen($dialplan_detail_type) > 0) {
echo "<optgroup label='selected'>\n";
echo " <option value='".htmlspecialchars($dialplan_detail_type)."'>".htmlspecialchars($dialplan_detail_type)."</option>\n";
echo "</optgroup>\n";
}
else {
echo " <option value=''></option>\n";
}
if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "condition" || $dialplan_detail_tag == "regex") {
echo " <optgroup label='".$text['optgroup-conditions_or_regular_expressions']."'>\n";
echo " <option value='context'>".$text['option-context']."</option>\n";
echo " <option value='username'>".$text['option-username']."</option>\n";
echo " <option value='rdnis'>".$text['option-rdnis']."</option>\n";
echo " <option value='destination_number'>".$text['option-destination_number']."</option>\n";
echo " <option value='dialplan'>".$text['option-dialplan']."</option>\n";
echo " <option value='caller_id_name'>".$text['option-caller_id_name']."</option>\n";
echo " <option value='caller_id_number'>".$text['option-caller_id_number']."</option>\n";
echo " <option value='ani'>".$text['option-ani']."</option>\n";
echo " <option value='ani2'>".$text['option-ani2']."</option>\n";
echo " <option value='uuid'>".$text['option-uuid']."</option>\n";
echo " <option value='source'>".$text['option-source']."</option>\n";
echo " <option value='chan_name'>".$text['option-chan_name']."</option>\n";
echo " <option value='network_addr'>".$text['option-network_addr']."</option>\n";
echo " <option value='\${number_alias}'>\${number_alias}</option>\n";
echo " <option value='\${sip_from_uri}'>\${sip_from_uri}</option>\n";
echo " <option value='\${sip_from_user}'>\${sip_from_user}</option>\n";
echo " <option value='\${sip_from_host}'>\${sip_from_host}</option>\n";
echo " <option value='\${sip_contact_uri}'>\${sip_contact_uri}</option>\n";
echo " <option value='\${sip_contact_user}'>\${sip_contact_user}</option>\n";
echo " <option value='\${sip_contact_host}'>\${sip_contact_host}</option>\n";
echo " <option value='\${sip_to_uri}'>\${sip_to_uri}</option>\n";
echo " <option value='\${sip_to_user}'>\${sip_to_user}</option>\n";
echo " <option value='\${sip_to_host}'>\${sip_to_host}</option>\n";
echo "</optgroup>\n";
}
if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") {
echo "<optgroup label='".$text['optgroup-applications']."'>\n";
//get the list of applications
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
$result = event_socket_request($fp, 'api show application');
$tmp = explode("\n\n", $result);
$tmp = explode("\n", $tmp[0]);
foreach ($tmp as $row) {
if (strlen($row) > 0) {
$application = explode(",", $row);
if ($application[0] != "name" && stristr($application[0], "[") != true) {
echo " <option value='".$application[0]."'>".$application[0]."</option>\n";
}
}
}
echo "</optgroup>\n";
}
echo "<input type='button' id='btn_select_to_input_dialplan_detail_type' class='btn' name='' alt='".$text['button-back']."' onclick='change_to_input(document.getElementById(\"dialplan_detail_type\"));this.style.visibility = \"hidden\";' value='&#9665;'>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-data']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='dialplan_detail_data' value=\"".htmlspecialchars($dialplan_detail_data)."\">\n";
echo "<br />\n";
echo "\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-group']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select name='dialplan_detail_group' class='formfld'>\n";
echo " <option value=''></option>\n";
if (strlen($dialplan_detail_group)> 0) {
echo " <option selected='selected' value='".htmlspecialchars($dialplan_detail_group)."'>".htmlspecialchars($dialplan_detail_group)."</option>\n";
}
$i=0;
while($i<=999) {
echo " <option value='$i'>$i</option>\n";
$i++;
}
echo " </select>\n";
echo "<br />\n";
echo "\n";
echo "</td>\n";
echo "</tr>\n";
if ($action == "update") {
if ($dialplan_detail_tag == "condition") {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-break']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select name='dialplan_detail_break' class='formfld'>\n";
echo " <option></option>\n";
if ($dialplan_detail_break == "on-true") {
echo " <option selected='selected' value='on-true'>".$text['option-on_true']."</option>\n";
}
else {
echo " <option value='on-true'>".$text['option-on_true']."</option>\n";
}
if ($dialplan_detail_break == "on-false") {
echo " <option selected='selected' value='on-false'>".$text['option-on_false']."</option>\n";
}
else {
echo " <option value='on-false'>".$text['option-on_false']."</option>\n";
}
if ($dialplan_detail_break == "always") {
echo " <option selected='selected' value='always'>".$text['option-always']."</option>\n";
}
else {
echo " <option value='always'>".$text['option-always']."</option>\n";
}
if ($dialplan_detail_break == "never") {
echo " <option selected='selected' value='never'>".$text['option-never']."</option>\n";
}
else {
echo " <option value='never'>".$text['option-never']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo "\n";
echo "</td>\n";
echo "</tr>\n";
}
if ($dialplan_detail_tag == "action") {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap>\n";
echo " ".$text['label-inline']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <select name='dialplan_detail_inline' class='formfld'>\n";
echo " <option></option>\n";
if ($dialplan_detail_inline == "true") {
echo " <option selected='selected' value='true'>".$text['option-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['option-true']."</option>\n";
}
if ($dialplan_detail_inline == "false") {
echo " <option selected='selected' value='false'>".$text['option-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['option-false']."</option>\n";
}
echo " </select>\n";
echo "<br />\n";
echo "\n";
echo "</td>\n";
echo "</tr>\n";
}
}
echo " <tr>\n";
echo " <td colspan='2' align='right'>\n";
echo " <input type='hidden' name='dialplan_uuid' value='$dialplan_uuid'>\n";
echo " <input type='hidden' name='app_uuid' value='$app_uuid'>\n";
if ($action == "update") {
echo " <input type='hidden' name='dialplan_detail_uuid' value='$dialplan_detail_uuid'>\n";
}
echo " <br>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>";
echo "</table>";
echo "<br><br>";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>

View File

@@ -0,0 +1,829 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
require_once "resources/paging.php";
//check permissions
if (permission_exists('dialplan_add')
|| permission_exists('dialplan_edit')
|| permission_exists('inbound_route_add')
|| permission_exists('inbound_route_edit')
|| permission_exists('outbound_route_add')
|| permission_exists('outbound_route_edit')
|| permission_exists('fifo_edit')
|| permission_exists('fifo_add')
|| permission_exists('time_condition_add')
|| permission_exists('time_condition_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//set the action as an add or an update
if (is_uuid($_REQUEST["id"])) {
$action = "update";
$dialplan_uuid = $_REQUEST["id"];
}
else {
$action = "add";
}
if (strlen($_REQUEST["app_uuid"]) > 0) {
$app_uuid = $_REQUEST["app_uuid"];
}
//get the http post values and set them as php variables
if (count($_POST) > 0) {
$hostname = check_str($_POST["hostname"]);
$dialplan_name = check_str($_POST["dialplan_name"]);
$dialplan_number = check_str($_POST["dialplan_number"]);
$dialplan_order = check_str($_POST["dialplan_order"]);
$dialplan_continue = check_str($_POST["dialplan_continue"]);
$dialplan_details = $_POST["dialplan_details"];
if (strlen($dialplan_continue) == 0) { $dialplan_continue = "false"; }
$dialplan_context = check_str($_POST["dialplan_context"]);
$dialplan_enabled = check_str($_POST["dialplan_enabled"]);
$dialplan_description = check_str($_POST["dialplan_description"]);
}
//get the list of applications
if (count($_SESSION['switch']['applications']) == 0) {
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$result = event_socket_request($fp, 'api show application');
$_SESSION['switch']['applications'] = explode("\n\n", $result);
$_SESSION['switch']['applications'] = explode("\n", $_SESSION['switch']['applications'][0]);
unset($result);
unset($fp);
} else {
$_SESSION['switch']['applications'] = Array();
}
}
//process and save the data
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//get the dialplan uuid
if ($action == "update") {
$dialplan_uuid = check_str($_POST["dialplan_uuid"]);
}
//check for all required data
$msg = '';
if (strlen($dialplan_name) == 0) { $msg .= $text['message-required'].$text['label-name']."<br>\n"; }
if (strlen($dialplan_order) == 0) { $msg .= $text['message-required'].$text['label-order']."<br>\n"; }
if (strlen($dialplan_continue) == 0) { $msg .= $text['message-required'].$text['label-continue']."<br>\n"; }
if (strlen($dialplan_context) == 0) { $msg .= $text['message-required'].$text['label-context']."<br>\n"; }
if (strlen($dialplan_enabled) == 0) { $msg .= $text['message-required'].$text['label-enabled']."<br>\n"; }
//if (strlen($dialplan_description) == 0) { $msg .= $text['message-required'].$text['label-description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "resources/footer.php";
return;
}
//remove the invalid characters from the dialplan name
$dialplan_name = $_POST["dialplan_name"];
$dialplan_name = str_replace(" ", "_", $dialplan_name);
$dialplan_name = str_replace("/", "", $dialplan_name);
//default app_uuid
if (strlen($app_uuid) == 0) {
$app_uuid = uuid();
}
//build the array
$x = 0;
if (isset($_POST["dialplan_uuid"])) {
$array['dialplans'][$x]['dialplan_uuid'] = $_POST["dialplan_uuid"];
}
else {
$dialplan_uuid = uuid();
$array['dialplans'][$x]['dialplan_uuid'] = $dialplan_uuid;
}
if (isset($_POST["domain_uuid"])) {
$array['dialplans'][$x]['domain_uuid'] = $_POST['domain_uuid'];
}
else {
$array['dialplans'][$x]['domain_uuid'] = $_SESSION['domain_uuid'];
}
$array['dialplans'][$x]['app_uuid'] = $app_uuid;
$array['dialplans'][$x]['hostname'] = $hostname;
$array['dialplans'][$x]['dialplan_name'] = $dialplan_name;
$array['dialplans'][$x]['dialplan_number'] = $_POST["dialplan_number"];
$array['dialplans'][$x]['dialplan_context'] = $_POST["dialplan_context"];
$array['dialplans'][$x]['dialplan_continue'] = $_POST["dialplan_continue"];
$array['dialplans'][$x]['dialplan_order'] = $_POST["dialplan_order"];
$array['dialplans'][$x]['dialplan_enabled'] = $_POST["dialplan_enabled"];
$array['dialplans'][$x]['dialplan_description'] = $_POST["dialplan_description"];
$y = 0;
if (is_array($_POST["dialplan_details"])) {
foreach ($_POST["dialplan_details"] as $row) {
if (strlen($row["dialplan_detail_tag"]) > 0) {
if (strlen($row["dialplan_detail_uuid"]) > 0) {
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = $row["dialplan_detail_uuid"];
}
$array['dialplans'][$x]['dialplan_details'][$y]['domain_uuid'] = $array['domain_uuid'];
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_tag'] = $row["dialplan_detail_tag"];
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_type'] = $row["dialplan_detail_type"];
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_data'] = $row["dialplan_detail_data"];
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_break'] = $row["dialplan_detail_break"];
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_inline'] = $row["dialplan_detail_inline"];
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_group'] = ($row["dialplan_detail_group"] != '') ? $row["dialplan_detail_group"] : '0';
$array['dialplans'][$x]['dialplan_details'][$y]['dialplan_detail_order'] = $row["dialplan_detail_order"];
}
$y++;
}
}
//add or update the database
if ($_POST["persistformvar"] != "true") {
$database = new database;
$database->app_name = 'dialplans';
$database->app_uuid = $app_uuid;
$database->uuid($dialplan_uuid);
$database->save($array);
$message = $database->message;
}
//update the dialplan xml
$dialplans = new dialplan;
$dialplans->source = "details";
$dialplans->destination = "database";
$dialplans->uuid = $dialplan_uuid;
$dialplans->xml();
//clear the cache
$cache = new cache;
$cache->delete("dialplan:".$dialplan_context);
//synchronize the xml config
save_dialplan_xml();
//set the message
if ($action == "add") {
messages::add($text['message-add']);
}
else if ($action == "update") {
messages::add($text['message-update']);
}
header("Location: ?id=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null));
exit;
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
$sql = "select * from v_dialplans ";
$sql .= "where dialplan_uuid = '$dialplan_uuid' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (is_array($result)) foreach ($result as &$row) {
$domain_uuid = $row["domain_uuid"];
//$app_uuid = $row["app_uuid"];
$hostname = $row["hostname"];
$dialplan_name = $row["dialplan_name"];
$dialplan_number = $row["dialplan_number"];
$dialplan_order = $row["dialplan_order"];
$dialplan_continue = $row["dialplan_continue"];
$dialplan_context = $row["dialplan_context"];
$dialplan_enabled = $row["dialplan_enabled"];
$dialplan_description = $row["dialplan_description"];
}
unset ($prep_statement);
}
//set the defaults
if (strlen($dialplan_context) == 0) {
$dialplan_context = $_SESSION['domain_name'];
}
if (strlen($dialplan_order) == 0) {
$dialplan_order = '200';
}
//get the dialplan details in an array
$sql = "select * from v_dialplan_details ";
$sql .= "where dialplan_uuid = '$dialplan_uuid' ";
$sql .= "order by dialplan_detail_group asc, dialplan_detail_order asc";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
unset ($prep_statement, $sql);
//create a new array that is sorted into groups and put the tags in order conditions, actions, anti-actions
//set the array index
$x = 0;
//define the array
$details = array();
//conditions
if (is_array($result)) foreach($result as $row) {
if ($row['dialplan_detail_tag'] == "condition") {
$group = $row['dialplan_detail_group'];
foreach ($row as $key => $val) {
$details[$group][$x][$key] = $val;
}
}
$x++;
}
//regex
if (is_array($result)) foreach($result as $row) {
if ($row['dialplan_detail_tag'] == "regex") {
$group = $row['dialplan_detail_group'];
foreach ($row as $key => $val) {
$details[$group][$x][$key] = $val;
}
}
$x++;
}
//actions
if (is_array($result)) foreach($result as $row) {
if ($row['dialplan_detail_tag'] == "action") {
$group = $row['dialplan_detail_group'];
foreach ($row as $key => $val) {
$details[$group][$x][$key] = $val;
}
}
$x++;
}
//anti-actions
if (is_array($result)) foreach($result as $row) {
if ($row['dialplan_detail_tag'] == "anti-action") {
$group = $row['dialplan_detail_group'];
foreach ($row as $key => $val) {
$details[$group][$x][$key] = $val;
}
}
$x++;
}
unset($result);
//blank row
if (is_array($details)) foreach($details as $group => $row) {
//set the array key for the empty row
$x = "999";
//get the highest dialplan_detail_order
if (is_array($row)) foreach ($row as $key => $field) {
$dialplan_detail_order = 0;
if ($dialplan_detail_order < $field['dialplan_detail_order']) {
$dialplan_detail_order = $field['dialplan_detail_order'];
}
}
//increment the highest order by 5
$dialplan_detail_order = $dialplan_detail_order + 10;
//set the rest of the empty array
//$details[$group][$x]['domain_uuid'] = '';
//$details[$group][$x]['dialplan_uuid'] = '';
$details[$group][$x]['dialplan_detail_tag'] = '';
$details[$group][$x]['dialplan_detail_type'] = '';
$details[$group][$x]['dialplan_detail_data'] = '';
$details[$group][$x]['dialplan_detail_break'] = '';
$details[$group][$x]['dialplan_detail_inline'] = '';
$details[$group][$x]['dialplan_detail_group'] = $group;
$details[$group][$x]['dialplan_detail_order'] = $dialplan_detail_order;
}
//sort the details array by group number
if (is_array($details)) {
ksort($details);
}
//show the header
require_once "resources/header.php";
$document['title'] = $text['title-dialplan_edit'];
//javascript to change select to input and back again
?><script language="javascript">
var objs;
function change_to_input(obj){
tb=document.createElement('INPUT');
tb.type='text';
tb.name=obj.name;
tb.className='formfld';
//tb.setAttribute('id', 'ivr_menu_option_param');
tb.setAttribute('style', 'width:175px;');
tb.value=obj.options[obj.selectedIndex].value;
tbb=document.createElement('INPUT');
tbb.setAttribute('class', 'btn');
tbb.setAttribute('style', 'margin-left: 4px;');
tbb.type='button';
tbb.value=$("<div />").html('&#9665;').text();
tbb.objs=[obj,tb,tbb];
tbb.onclick=function(){ replace_param(this.objs); }
obj.parentNode.insertBefore(tb,obj);
obj.parentNode.insertBefore(tbb,obj);
obj.parentNode.removeChild(obj);
replace_param(this.objs);
}
function replace_param(obj){
obj[2].parentNode.insertBefore(obj[0],obj[2]);
obj[0].parentNode.removeChild(obj[1]);
obj[0].parentNode.removeChild(obj[2]);
}
</script>
<?php
//show the content
echo "<form method='post' name='frm' action=''>\n";
echo "<input type='hidden' name='app_uuid' value='".$app_uuid."'>\n";
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">\n";
echo " <tr>\n";
echo " <td align='left' width='30%'>\n";
echo" <span class=\"title\">".$text['title-dialplan_edit']."</span><br />\n";
echo " </td>\n";
echo " <td width='70%' align='right'>\n";
if (permission_exists('dialplan_xml')) {
echo " <input type='button' class='btn' name='' alt='".$text['button-xml']."' onclick=\"window.location='dialplan_xml.php?id=".$dialplan_uuid."&".((strlen($app_uuid) > 0) ? "app_uuid=".$app_uuid : null)."';\" value='".$text['button-xml']."'>\n";
}
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='dialplans.php".((strlen($app_uuid) > 0) ? "?app_uuid=".$app_uuid : null)."';\" value='".$text['button-back']."'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-copy']."' onclick=\"if (confirm('".$text['confirm-copy']."')){window.location='dialplan_copy.php?id=".$dialplan_uuid."';}\" value='".$text['button-copy']."'>\n";
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' colspan='2'>\n";
echo " ".$text['description-dialplan-edit']."\n";
echo " \n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>";
echo "<br />\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='50%' style='vertical-align: top;'>\n";
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td class='vncellreq' valign='top' align='left' nowrap='nowrap' width='30%'>\n";
echo " ".$text['label-name']."\n";
echo " </td>\n";
echo " <td class='vtable' width='70%' align='left'>\n";
echo " <input class='formfld' type='text' name='dialplan_name' maxlength='255' placeholder='' value=\"".htmlspecialchars($dialplan_name)."\" required='required'>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-number']."\n";
echo " </td>\n";
echo " <td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='dialplan_number' maxlength='255' placeholder='' value=\"".htmlspecialchars($dialplan_number)."\">\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-hostname']."\n";
echo " </td>\n";
echo " <td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='hostname' maxlength='255' value=\"$hostname\">\n";
echo " <br />\n";
echo " ".$text['description-hostname']."\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap' width='30%'>\n";
echo " ".$text['label-context']."\n";
echo " </td>\n";
echo " <td class='vtable' align='left' width='70%'>\n";
echo " <input class='formfld' type='text' name='dialplan_context' maxlength='255' placeholder='' value=\"$dialplan_context\">\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-continue']."\n";
echo " </td>\n";
echo " <td class='vtable' align='left'>\n";
echo " <select class='formfld' name='dialplan_continue'>\n";
if ($dialplan_continue == "true") {
echo " <option value='true' selected='selected'>".$text['option-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['option-true']."</option>\n";
}
if ($dialplan_continue == "false") {
echo " <option value='false' selected='selected'>".$text['option-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['option-false']."</option>\n";
}
echo " </select>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>";
echo "<td width='50%' style='vertical-align: top;'>\n";
echo " <table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td class='vncellreq' valign='top' align='left' nowrap='nowrap' width='30%'>\n";
echo " ".$text['label-order']."\n";
echo " </td>\n";
echo " <td class='vtable' align='left' width='70%'>\n";
echo " <select name='dialplan_order' class='formfld'>\n";
$i=0;
while($i<=999) {
$selected = ($i == $dialplan_order) ? "selected" : null;
if (strlen($i) == 1) {
echo " <option value='00$i' ".$selected.">00$i</option>\n";
}
if (strlen($i) == 2) {
echo " <option value='0$i' ".$selected.">0$i</option>\n";
}
if (strlen($i) == 3) {
echo " <option value='$i' ".$selected.">$i</option>\n";
}
$i++;
}
echo " </select>\n";
echo " <br />\n";
echo " </td>\n";
echo " </tr>\n";
if (permission_exists('dialplan_domain')) {
echo " <tr>\n";
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-domain']."\n";
echo " </td>\n";
echo " <td class='vtable' align='left'>\n";
echo " <select class='formfld' name='domain_uuid'>\n";
if (strlen($domain_uuid) == 0) {
echo " <option value='' selected='selected'>".$text['select-global']."</option>\n";
}
else {
echo " <option value=''>".$text['select-global']."</option>\n";
}
if (is_array($_SESSION['domains'])) foreach ($_SESSION['domains'] as $row) {
if ($row['domain_uuid'] == $domain_uuid) {
echo " <option value='".$row['domain_uuid']."' selected='selected'>".$row['domain_name']."</option>\n";
}
else {
echo " <option value='".$row['domain_uuid']."'>".$row['domain_name']."</option>\n";
}
}
echo " </select>\n";
echo " <br />\n";
echo " ".$text['description-domain_name']."\n";
echo " </td>\n";
echo " </tr>\n";
}
echo " <tr>\n";
echo " <td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-enabled']."\n";
echo " </td>\n";
echo " <td class='vtable' align='left'>\n";
echo " <select class='formfld' name='dialplan_enabled'>\n";
if ($dialplan_enabled == "true") {
echo " <option value='true' selected='selected'>".$text['option-true']."</option>\n";
}
else {
echo " <option value='true'>".$text['option-true']."</option>\n";
}
if ($dialplan_enabled == "false") {
echo " <option value='false' selected='selected'>".$text['option-false']."</option>\n";
}
else {
echo " <option value='false'>".$text['option-false']."</option>\n";
}
echo " </select>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td class='vncell' valign='top' align='left' nowrap='nowrap' width='30%'>\n";
echo " ".$text['label-description']."\n";
echo " </td>\n";
echo " <td class='vtable' align='left' width='70%'>\n";
echo " <textarea class='formfld' style='width: 250px; height: 68px;' name='dialplan_description'>".htmlspecialchars($dialplan_description)."</textarea>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<br><br>";
//dialplan details
if ($action == "update") {
?>
<!--javascript to change select to input and back again-->
<script language="javascript">
function label_to_form(label_id, form_id) {
if (document.getElementById(label_id) != null) {
label = document.getElementById(label_id);
label.parentNode.removeChild(label);
}
document.getElementById(form_id).style.display='';
}
</script>
<?php
//display the results
if ($result_count > 0) {
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0' style='margin: -2px; border-spacing: 2px;'>\n";
$x = 0;
if (is_array($details)) foreach($details as $group) {
if ($x != 0) {
echo "<tr><td colspan='7'><br><br></td></tr>";
}
echo "<tr>\n";
echo "<td class='vncellcolreq'>".$text['label-tag']."</td>\n";
echo "<td class='vncellcolreq'>".$text['label-type']."</td>\n";
echo "<td class='vncellcol' width='70%'>".$text['label-data']."</td>\n";
echo "<td class='vncellcol'>".$text['label-break']."</td>\n";
echo "<td class='vncellcol' style='text-align: center;'>".$text['label-inline']."</td>\n";
echo "<td class='vncellcolreq' style='text-align: center;'>".$text['label-group']."</td>\n";
echo "<td class='vncellcolreq' style='text-align: center;'>".$text['label-order']."</td>\n";
echo "<td>&nbsp;</td>\n";
echo "</tr>\n";
if (is_array($group)) foreach($group as $index => $row) {
//get the values from the database and set as variables
$dialplan_detail_uuid = $row['dialplan_detail_uuid'];
$dialplan_detail_tag = $row['dialplan_detail_tag'];
$dialplan_detail_type = $row['dialplan_detail_type'];
$dialplan_detail_data = $row['dialplan_detail_data'];
$dialplan_detail_break = $row['dialplan_detail_break'];
$dialplan_detail_inline = $row['dialplan_detail_inline'];
$dialplan_detail_group = $row['dialplan_detail_group'];
$dialplan_detail_order = $row['dialplan_detail_order'];
//no border on last row
$no_border = ($index == 999) ? "border: none;" : null;
//begin the row
echo "<tr>\n";
//determine whether to hide the element
if (strlen($dialplan_detail_tag) == 0) {
$element['hidden'] = false;
$element['visibility'] = "";
}
else {
$element['hidden'] = true;
$element['visibility'] = "display: none;";
}
//add the primary key uuid
if (strlen($dialplan_detail_uuid) > 0) {
echo " <input name='dialplan_details[".$x."][dialplan_detail_uuid]' type='hidden' value=\"".$dialplan_detail_uuid."\">\n";
}
//tag
$selected = "selected=\"selected\" ";
echo "<td class='vtablerow' style='".$no_border."' onclick=\"label_to_form('label_dialplan_detail_tag_".$x."','dialplan_detail_tag_".$x."');\" nowrap='nowrap'>\n";
if ($element['hidden']) {
echo " <label id=\"label_dialplan_detail_tag_".$x."\">".$dialplan_detail_tag."</label>\n";
}
echo " <select id='dialplan_detail_tag_".$x."' name='dialplan_details[".$x."][dialplan_detail_tag]' class='formfld' style='width: 97px; ".$element['visibility']."'>\n";
echo " <option></option>\n";
echo " <option value='condition' ".($dialplan_detail_tag == "condition" ? $selected : null).">".$text['option-condition']."</option>\n";
echo " <option value='regex' ".($dialplan_detail_tag == "regex" ? $selected : null).">".$text['option-regex']."</option>\n";
echo " <option value='action' ".($dialplan_detail_tag == "action" ? $selected : null).">".$text['option-action']."</option>\n";
echo " <option value='anti-action' ".($dialplan_detail_tag == "anti-action" ? $selected : null).">".$text['option-anti-action']."</option>\n";
echo " </select>\n";
echo "</td>\n";
//type
echo "<td class='vtablerow' style='".$no_border."' onclick=\"label_to_form('label_dialplan_detail_type_".$x."','dialplan_detail_type_".$x."');\" nowrap='nowrap'>\n";
if ($element['hidden']) {
echo " <label id=\"label_dialplan_detail_type_".$x."\">".$dialplan_detail_type."</label>\n";
}
echo " <select id='dialplan_detail_type_".$x."' name='dialplan_details[".$x."][dialplan_detail_type]' class='formfld' style='width: auto; ".$element['visibility']."' onchange='change_to_input(this);'>\n";
if (strlen($dialplan_detail_type) > 0) {
echo " <optgroup label='selected'>\n";
echo " <option value='".htmlspecialchars($dialplan_detail_type)."'>".htmlspecialchars($dialplan_detail_type)."</option>\n";
echo " </optgroup>\n";
}
else {
echo " <option value=''></option>\n";
}
//if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "condition" || $dialplan_detail_tag == "regex") {
echo " <optgroup label='".$text['optgroup-condition_or_regex']."'>\n";
echo " <option value='context'>".$text['option-context']."</option>\n";
echo " <option value='username'>".$text['option-username']."</option>\n";
echo " <option value='rdnis'>".$text['option-rdnis']."</option>\n";
echo " <option value='destination_number'>".$text['option-destination_number']."</option>\n";
echo " <option value='dialplan'>".$text['option-dialplan']."</option>\n";
echo " <option value='caller_id_name'>".$text['option-caller_id_name']."</option>\n";
echo " <option value='caller_id_number'>".$text['option-caller_id_number']."</option>\n";
echo " <option value='ani'>".$text['option-ani']."</option>\n";
echo " <option value='ani2'>".$text['option-ani2']."</option>\n";
echo " <option value='uuid'>".$text['option-uuid']."</option>\n";
echo " <option value='source'>".$text['option-source']."</option>\n";
echo " <option value='chan_name'>".$text['option-chan_name']."</option>\n";
echo " <option value='network_addr'>".$text['option-network_addr']."</option>\n";
echo " <option value='\${number_alias}'>\${number_alias}</option>\n";
echo " <option value='\${sip_from_uri}'>\${sip_from_uri}</option>\n";
echo " <option value='\${sip_from_user}'>\${sip_from_user}</option>\n";
echo " <option value='\${sip_from_host}'>\${sip_from_host}</option>\n";
echo " <option value='\${sip_contact_uri}'>\${sip_contact_uri}</option>\n";
echo " <option value='\${sip_contact_user}'>\${sip_contact_user}</option>\n";
echo " <option value='\${sip_contact_host}'>\${sip_contact_host}</option>\n";
echo " <option value='\${sip_to_uri}'>\${sip_to_uri}</option>\n";
echo " <option value='\${sip_to_user}'>\${sip_to_user}</option>\n";
echo " <option value='\${sip_to_host}'>\${sip_to_host}</option>\n";
echo " <option value='\${toll_allow}'>\${toll_allow}</option>\n";
echo " </optgroup>\n";
//}
//if (strlen($dialplan_detail_tag) == 0 || $dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") {
echo " <optgroup label='".$text['optgroup-applications']."'>\n";
if (is_array($_SESSION['switch']['applications'])) foreach ($_SESSION['switch']['applications'] as $row) {
if (strlen($row) > 0) {
$application = explode(",", $row);
if ($application[0] != "name" && stristr($application[0], "[") != true) {
echo " <option value='".$application[0]."'>".$application[0]."</option>\n";
}
}
}
echo " </optgroup>\n";
//}
echo " </select>\n";
//echo " <input type='button' id='btn_select_to_input_dialplan_detail_type' class='btn' style='visibility:hidden;' name='' alt='".$text['button-back']."' onclick='change_to_input(document.getElementById(\"dialplan_detail_type\"));this.style.visibility = \"hidden\";' value='&#9665;'>\n";
echo "</td>\n";
//data
echo "<td class='vtablerow' onclick=\"label_to_form('label_dialplan_detail_data_".$x."','dialplan_detail_data_".$x."');\" style='".$no_border." width: 100%; max-width: 150px; overflow: hidden; _text-overflow: ellipsis; white-space: nowrap;' nowrap='nowrap'>\n";
if ($element['hidden']) {
$dialplan_detail_data_mod = $dialplan_detail_data;
if ($dialplan_detail_type == 'bridge') {
// parse out gateway uuid
$bridge_statement = explode('/', $dialplan_detail_data);
if ($bridge_statement[0] == 'sofia' && $bridge_statement[1] == 'gateway' && is_uuid($bridge_statement[2])) {
// retrieve gateway name from db
$sql = "select gateway from v_gateways where gateway_uuid = '".$bridge_statement[2]."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (count($result) > 0) {
$gateway_name = $result[0]['gateway'];
$dialplan_detail_data_mod = str_replace($bridge_statement[2], $gateway_name, $dialplan_detail_data);
}
unset ($prep_statement, $sql, $bridge_statement);
}
}
echo " <label id=\"label_dialplan_detail_data_".$x."\">".htmlspecialchars($dialplan_detail_data_mod)."</label>\n";
}
echo " <input id='dialplan_detail_data_".$x."' name='dialplan_details[".$x."][dialplan_detail_data]' class='formfld' type='text' style='width: calc(100% - 2px); min-width: calc(100% - 2px); max-width: calc(100% - 2px); ".$element['visibility']."' placeholder='' value=\"".htmlspecialchars($dialplan_detail_data)."\">\n";
echo "</td>\n";
//break
echo "<td class='vtablerow' style='".$no_border."' onclick=\"label_to_form('label_dialplan_detail_break_".$x."','dialplan_detail_break_".$x."');\" nowrap='nowrap'>\n";
if ($element['hidden']) {
echo " <label id=\"label_dialplan_detail_break_".$x."\">".$dialplan_detail_break."</label>\n";
}
echo " <select id='dialplan_detail_break_".$x."' name='dialplan_details[".$x."][dialplan_detail_break]' class='formfld' style='width: auto; ".$element['visibility']."'>\n";
echo " <option></option>\n";
echo " <option value='on-true' ".($dialplan_detail_break == "on-true" ? $selected : null).">".$text['option-on_true']."</option>\n";
echo " <option value='on-false' ".($dialplan_detail_break == "on-false" ? $selected : null).">".$text['option-on_false']."</option>\n";
echo " <option value='always' ".($dialplan_detail_break == "always" ? $selected : null).">".$text['option-always']."</option>\n";
echo " <option value='never' ".($dialplan_detail_break == "never" ? $selected : null).">".$text['option-never']."</option>\n";
echo " </select>\n";
echo "</td>\n";
//inline
echo "<td class='vtablerow' style='".$no_border." text-align: center;' onclick=\"label_to_form('label_dialplan_detail_inline_".$x."','dialplan_detail_inline_".$x."');\" nowrap='nowrap'>\n";
if ($element['hidden']) {
echo " <label id=\"label_dialplan_detail_inline_".$x."\">".$dialplan_detail_inline."</label>\n";
}
echo " <select id='dialplan_detail_inline_".$x."' name='dialplan_details[".$x."][dialplan_detail_inline]' class='formfld' style='width: auto; ".$element['visibility']."'>\n";
echo " <option></option>\n";
echo " <option value='true' ".($dialplan_detail_inline == "true" ? $selected : null).">".$text['option-true']."</option>\n";
echo " <option value='false' ".($dialplan_detail_inline == "false" ? $selected : null).">".$text['option-false']."</option>\n";
echo " </select>\n";
echo "</td>\n";
//group
echo "<td class='vtablerow' style='".$no_border." text-align: center;' onclick=\"label_to_form('label_dialplan_detail_group_".$x."','dialplan_detail_group_".$x."');\" nowrap='nowrap'>\n";
if ($element['hidden']) {
echo " <label id=\"label_dialplan_detail_group_".$x."\">".$dialplan_detail_group."</label>\n";
}
echo " <input id='dialplan_detail_group_".$x."' name='dialplan_details[".$x."][dialplan_detail_group]' class='formfld' type='number' min='0' step='1' style='width: 30px; text-align: center; ".$element['visibility']."' placeholder='' value=\"".htmlspecialchars($dialplan_detail_group)."\" onclick='this.select();'>\n";
/*
echo " <select id='dialplan_detail_group_".$x."' name='dialplan_details[".$x."][dialplan_detail_group]' class='formfld' style='".$element['width']." ".$element['visibility']."'>\n";
echo " <option value=''></option>\n";
if (strlen($dialplan_detail_group)> 0) {
echo " <option $selected value='".htmlspecialchars($dialplan_detail_group)."'>".htmlspecialchars($dialplan_detail_group)."</option>\n";
}
$i=0;
while($i<=999) {
echo " <option value='$i'>$i</option>\n";
$i++;
}
echo " </select>\n";
*/
echo "</td>\n";
//order
echo "<td class='vtablerow' style='".$no_border." text-align: center;' onclick=\"label_to_form('label_dialplan_detail_order_".$x."','dialplan_detail_order_".$x."');\" nowrap='nowrap'>\n";
if ($element['hidden']) {
echo " <label id=\"label_dialplan_detail_order_".$x."\">".$dialplan_detail_order."</label>\n";
}
echo " <input id='dialplan_detail_order_".$x."' name='dialplan_details[".$x."][dialplan_detail_order]' class='formfld' type='number' min='0' step='1' style='width: 32px; text-align: center; ".$element['visibility']."' placeholder='' value=\"".htmlspecialchars($dialplan_detail_order)."\" onclick='this.select();'>\n";
/*
echo " <select id='dialplan_detail_order_".$x."' name='dialplan_details[".$x."][dialplan_detail_order]' class='formfld' style='".$element['width']." ".$element['visibility']."'>\n";
if (strlen($dialplan_detail_order)> 0) {
echo " <option $selected value='".htmlspecialchars($dialplan_detail_order)."'>".htmlspecialchars($dialplan_detail_order)."</option>\n";
}
$i=0;
while($i<=999) {
if (strlen($i) == 1) {
echo " <option value='00$i'>00$i</option>\n";
}
if (strlen($i) == 2) {
echo " <option value='0$i'>0$i</option>\n";
}
if (strlen($i) == 3) {
echo " <option value='$i'>$i</option>\n";
}
$i++;
}
echo " </select>\n";
*/
echo "</td>\n";
//tools
echo " <td class='list_control_icon'>\n";
if ($element['hidden']) {
//echo " <a href='dialplan_detail_edit.php?id=".$dialplan_detail_uuid."&dialplan_uuid=".$dialplan_uuid."&app_uuid=".$app_uuid."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
echo " <a href='dialplan_detail_delete.php?id=".$dialplan_detail_uuid."&dialplan_uuid=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
}
echo " </td>\n";
//end the row
echo "</tr>\n";
//increment the value
$x++;
}
$x++;
} //end foreach
unset($sql, $result, $row_count);
echo "</table>";
} //end if results
} //end if update
echo "<br>\n";
echo "<div align='right'>\n";
if ($action == "update") {
echo " <input type='hidden' name='dialplan_uuid' value='$dialplan_uuid'>\n";
}
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
echo "</div>\n";
echo "<br><br>\n";
echo "</form>";
if (file_exists($_SERVER["PROJECT_ROOT"]."/app/billing/app_config.php")){
echo "<p>".$text['billing-warning']."</p>";
}
//show the footer
require_once "resources/footer.php";
?>

View File

@@ -0,0 +1,149 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
Luis Daniel Lucio Quiroz <dlucio@okay.com.mx>
*/
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('dialplan_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//get the uuids
if (is_uuid($_REQUEST['id'])) {
$dialplan_uuid = $_REQUEST['id'];
}
if (is_uuid($_REQUEST['app_uuid'])) {
$app_uuid = $_REQUEST['app_uuid'];
}
//set the default app_uuid
if (strlen($app_uuid) == 0) {
$app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
}
//get the dialplan xml
if (is_uuid($dialplan_uuid)) {
$sql = "select * from v_dialplans ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
$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"];
//$app_uuid = $row["app_uuid"];
$dialplan_name = $row["dialplan_name"];
$dialplan_number = $row["dialplan_number"];
$dialplan_order = $row["dialplan_order"];
$dialplan_continue = $row["dialplan_continue"];
$dialplan_context = $row["dialplan_context"];
$dialplan_xml = $row["dialplan_xml"];
$dialplan_enabled = $row["dialplan_enabled"];
$dialplan_description = $row["dialplan_description"];
}
unset ($prep_statement);
}
//process the HTTP POST
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//build the dialplan array
$x = 0;
//$array['dialplans'][$x]["domain_uuid"] = $_SESSION['domain_uuid'];
$array['dialplans'][$x]["dialplan_uuid"] = $dialplan_uuid;
$array['dialplans'][$x]["dialplan_xml"] = $_REQUEST['dialplan_xml'];
//save to the data
$database = new database;
$database->app_name = 'dialplans';
$database->app_uuid = $app_uuid;
//if (strlen($dialplan_uuid) > 0) {
// $database->uuid($dialplan_uuid);
//}
$database->save($array);
$message = $database->message;
//debug info
//echo "<pre>\n";
//print_r($message);
//echo "</pre>\n";
//exit;
//clear the cache
$cache = new cache;
$cache->delete("dialplan:".$dialplan_context);
//save the message to a session variable
messages::add($text['message-update']);
//redirect the user
header("Location: dialplan_edit.php?id=".$dialplan_uuid."&".((strlen($app_uuid) > 0) ? "?app_uuid=".$app_uuid : null));
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//show the header
require_once "resources/header.php";
//show the content
echo "<form method='post' name='frm' action=''>\n";
echo " <input type='hidden' name='app_uuid' value='".$app_uuid."'>\n";
echo " <input type='hidden' name='dialplan_uuid' value='".$dialplan_uuid."'>\n";
echo " <table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">\n";
echo " <tr>\n";
echo " <td align='left' width='30%'>\n";
echo" <span class=\"title\">".$text['title-dialplan_edit']."</span><br />\n";
echo " </td>\n";
echo " <td width='70%' align='right'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='dialplan_edit.php?id=".$dialplan_uuid."&".((strlen($app_uuid) > 0) ? "?app_uuid=".$app_uuid : null)."';\" value='".$text['button-back']."'>\n";
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td align='left' colspan='2'>\n";
echo " ".$text['description-dialplan-edit']."\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>";
echo " <br />\n";
echo " <textarea name=\"dialplan_xml\" class=\"formfld\" style=\"width: 100%; max-width: 100%; height: 450px; padding:20px;\">$dialplan_xml</textarea>\n";
echo "</form>\n";
//show the footer
require_once "resources/footer.php";
?>

444
app/dialplans/dialplans.php Normal file
View File

@@ -0,0 +1,444 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
//includes
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('dialplan_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//handle enable toggle
$dialplan_uuid = check_str($_REQUEST['id']);
$dialplan_enabled = check_str($_REQUEST['enabled']);
if ($dialplan_uuid != '' && $dialplan_enabled != '') {
$sql = "update v_dialplans set ";
$sql .= "dialplan_enabled = '".$dialplan_enabled."' ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'";
$db->exec(check_sql($sql));
unset($sql);
messages::add($text['message-update']);
}
//delete the dialplan context from memcache
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) {
$switch_cmd = "memcache delete dialplan:".$_SESSION["context"];
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
}
//set the http values as php variables
if (isset($_REQUEST["search"])) { $search = check_str($_REQUEST["search"]); } else { $search = null; }
if (isset($_REQUEST["order_by"])) { $order_by = check_str($_REQUEST["order_by"]); } else { $order_by = null; }
if (isset($_REQUEST["order"])) { $order = check_str($_REQUEST["order"]); } else { $order = null; }
if (isset($_REQUEST["dialplan_context"])) { $dialplan_context = check_str($_REQUEST["dialplan_context"]); } else { $dialplan_context = null; }
if (isset($_REQUEST["app_uuid"])) { $app_uuid = check_str($_REQUEST["app_uuid"]); } else { $app_uuid = null; }
//make sure all dialplans with context of public have the inbound route app_uuid
if ($app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
$sql = "update v_dialplans set ";
$sql .= "app_uuid = 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ";
$sql .= "where dialplan_context = 'public' ";
$sql .= "and app_uuid is null; ";
$db->exec($sql);
unset($sql);
}
//includes
require_once "resources/header.php";
require_once "resources/paging.php";
//get the number of rows in the dialplan
$sql = "select count(*) as num_rows from v_dialplans ";
$sql .= "where (domain_uuid = '$domain_uuid' or domain_uuid is null) ";
if (strlen($app_uuid) == 0) {
//hide inbound routes
$sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ";
//hide outbound routes
$sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
}
else {
$sql .= "and app_uuid = '".$app_uuid."' ";
}
if (strlen($search) > 0) {
$sql .= "and (";
$sql .= " dialplan_context like '%".$search."%' ";
$sql .= " or dialplan_name like '%".$search."%' ";
$sql .= " or dialplan_number like '%".$search."%' ";
$sql .= " or dialplan_continue like '%".$search."%' ";
if (is_numeric($search)) {
$sql .= " or dialplan_order = '".$search."' ";
}
$sql .= " or dialplan_enabled like '%".$search."%' ";
$sql .= " or dialplan_description like '%".$search."%' ";
$sql .= ") ";
}
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] > 0) {
$num_rows = $row['num_rows'];
}
else {
$num_rows = '0';
}
}
unset($prep_statement, $result);
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = "";
if (strlen($app_uuid) > 0) { $param = "&app_uuid=".$app_uuid; }
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page;
//get the list of dialplans
$sql = "select * from v_dialplans ";
$sql .= "where (domain_uuid = '$domain_uuid' or domain_uuid is null) ";
if (strlen($app_uuid) == 0) {
//hide inbound routes
$sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ";
$sql .= "and dialplan_context <> 'public' ";
//hide outbound routes
$sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
}
else {
if ($app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
$sql .= "and (app_uuid = '".$app_uuid."' or dialplan_context = 'public') ";
}
else {
$sql .= "and app_uuid = '".$app_uuid."' ";
}
}
if (strlen($search) > 0) {
$sql .= "and (";
$sql .= " dialplan_context like '%".$search."%' ";
$sql .= " or dialplan_name like '%".$search."%' ";
$sql .= " or dialplan_number like '%".$search."%' ";
$sql .= " or dialplan_continue like '%".$search."%' ";
if (is_numeric($search)) {
$sql .= " or dialplan_order = '".$search."' ";
}
$sql .= " or dialplan_enabled like '%".$search."%' ";
$sql .= " or dialplan_description like '%".$search."%' ";
$sql .= ") ";
}
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } else { $sql .= "order by dialplan_order asc, dialplan_name asc "; }
$sql .= " limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$dialplans = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($dialplans);
unset ($prep_statement, $sql);
//set the alternating row style
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
//set the title
if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") {
$document['title'] = $text['title-inbound_routes'];
}
elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") {
$document['title'] = $text['title-outbound_routes'];
}
elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") {
$document['title'] = $text['title-queues'];
}
elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") {
$document['title'] = $text['title-time_conditions'];
}
else {
$document['title'] = $text['title-dialplan_manager'];
}
//show the content
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo " <td align='left' valign='top'>\n";
echo " <span class='title'>\n";
if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") {
echo " ".$text['header-inbound_routes']."\n";
}
elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") {
echo " ".$text['header-outbound_routes']."\n";
}
elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") {
echo " ".$text['header-queues']."\n";
}
elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") {
echo " ".$text['header-time_conditions']."\n";
}
else {
echo " ".$text['header-dialplan_manager']."\n";
}
echo " </span>\n";
echo " <br><br>\n";
echo " </td>\n";
echo " <td align='right' valign='top' nowrap='nowrap' style='padding-left: 50px;'>\n";
echo " <form name='frm_search' method='get' action=''>\n";
echo " <input type='text' class='txt' style='width: 150px' name='search' value='".$search."'>";
if (strlen($app_uuid) > 0) {
echo " <input type='hidden' class='txt' name='app_uuid' value='".$app_uuid."'>";
}
if (strlen($order_by) > 0) {
echo " <input type='hidden' class='txt' name='order_by' value='".$order_by."'>";
echo " <input type='hidden' class='txt' name='order' value='".$order."'>";
}
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>";
echo " </form>\n";
echo " </td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td colspan='2'>\n";
echo " <span class='vexpl'>\n";
if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") {
echo $text['description-inbound_routes'];
}
elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") {
echo $text['description-outbound_routes'];
}
elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") {
echo $text['description-queues'];
}
elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") {
echo $text['description-time_conditions'];
}
else {
if (if_group("superadmin")) {
echo $text['description-dialplan_manager-superadmin'];
}
else {
echo $text['description-dialplan_manager'];
}
}
echo " </span>\n";
echo " </td>\n";
//echo " <td align='right'>\n";
//if (permission_exists('dialplan_advanced_view') && strlen($app_uuid) == 0) {
// echo " <input type='button' class='btn' value='".$text['button-advanced']."' onclick=\"document.location.href='dialplan_advanced.php';\">\n";
//}
//else {
// echo "&nbsp;\n";
//}
//echo " </td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br />";
echo "<form name='frm_delete' method='post' action='dialplan_delete.php'>\n";
echo "<input type='hidden' name='app_uuid' value='".$app_uuid."'>\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
if (permission_exists('dialplan_delete') && $result_count > 0) {
echo "<th style='text-align: center; padding: 3px 0px 0px 0px;' width='1'><input type='checkbox' style='margin: 0px 0px 0px 2px;' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
}
echo th_order_by('dialplan_name', $text['label-name'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null));
echo th_order_by('dialplan_number', $text['label-number'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null));
echo th_order_by('dialplan_context', $text['label-context'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null));
echo th_order_by('dialplan_order', $text['label-order'], $order_by, $order, $app_uuid, "style='text-align: center;'", (($search != '') ? "search=".$search : null));
echo th_order_by('dialplan_enabled', $text['label-enabled'], $order_by, $order, $app_uuid, "style='text-align: center;'", (($search != '') ? "search=".$search : null));
echo th_order_by('dialplan_description', $text['label-description'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null));
echo "<td class='list_control_icons'>";
if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_add')) {
echo "<a href='".PROJECT_PATH."/app/dialplan_inbound/dialplan_inbound_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_add')) {
echo "<a href='".PROJECT_PATH."/app/dialplan_outbound/dialplan_outbound_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_add')) {
echo "<a href='".PROJECT_PATH."/app/fifo/fifo_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_add')) {
echo "<a href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
elseif (permission_exists('dialplan_add')) {
echo "<a href='dialplan_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
if (permission_exists('dialplan_delete') && $result_count > 0) {
echo "<a href='javascript:void(0);' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.forms.frm_delete.submit(); }\" alt='".$text['button-delete']."'>".$v_link_label_delete."</a>";
}
echo "</td>\n";
echo "</tr>\n";
if ($result_count > 0) {
foreach($dialplans as $row) {
//get the application id
$app_uuid = $row['app_uuid'];
// blank app id if doesn't match others, so will return to dialplan manager
switch ($app_uuid) {
case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" : // inbound route
case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" : // outbound route
case "16589224-c876-aeb3-f59f-523a1c0801f7" : // fifo
case "4b821450-926b-175a-af93-a03c441818b1" : // time condition
break;
default :
unset($app_uuid);
}
if ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) {
$tr_link = "href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."'";
}
elseif (
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_edit')) ||
($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_edit')) ||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) ||
permission_exists('dialplan_edit')
) {
$tr_link = "href='dialplan_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."'";
}
echo "<tr ".$tr_link.">\n";
if (permission_exists("dialplan_delete")) {
echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='text-align: center; padding: 3px 0px 0px 0px;'><input type='checkbox' name='id[]' id='checkbox_".$row['dialplan_uuid']."' value='".$row['dialplan_uuid']."'></td>\n";
$dialplan_ids[] = 'checkbox_'.$row['dialplan_uuid'];
}
echo " <td valign='top' class='".$row_style[$c]."'>";
if ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) {
echo "<a href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."'>".$row['dialplan_name']."</a>";
}
elseif (
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_edit')) ||
($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_edit')) ||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) ||
permission_exists('dialplan_edit')
) {
echo "<a href='dialplan_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."'>".$row['dialplan_name']."</a>";
}
else {
echo $row['dialplan_name'];
}
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".((strlen($row['dialplan_number']) > 0) ? format_phone($row['dialplan_number']) : "&nbsp;")."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['dialplan_context']."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: center;'>".$row['dialplan_order']."</td>\n";
echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='text-align: center;'>";
echo " <a href='?id=".$row['dialplan_uuid']."&enabled=".(($row['dialplan_enabled'] == 'true') ? 'false' : 'true').(($app_uuid != '') ? "&app_uuid=".$app_uuid : null).(($search != '') ? "&search=".$search : null).(($order_by != '') ? "&order_by=".$order_by."&order=".$order : null)."'>".$text['label-'.$row['dialplan_enabled']]."</a>\n";
echo " </td>\n";
echo " <td valign='top' class='row_stylebg' width='30%'>".((strlen($row['dialplan_description']) > 0) ? $row['dialplan_description'] : "&nbsp;")."</td>\n";
echo " <td class='list_control_icons'>\n";
if ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) {
echo "<a href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
}
elseif (
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_edit')) ||
($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_edit')) ||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) ||
permission_exists('dialplan_edit')
) {
echo "<a href='dialplan_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
}
if (
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_delete')) ||
($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_delete')) ||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_delete')) ||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_delete')) ||
permission_exists('dialplan_delete')
) {
echo "<a href=\"dialplan_delete.php?id[]=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."\" alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
}
echo " </td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
} //end foreach
unset($sql, $result, $row_count);
} //end if results
echo "<tr>\n";
echo "<td colspan='8'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap>".$paging_controls."</td>\n";
echo " <td class='list_control_icons'>";
if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_add')) {
echo "<a href='".PROJECT_PATH."/app/dialplan_inbound/dialplan_inbound_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_add')) {
echo "<a href='".PROJECT_PATH."/app/dialplan_outbound/dialplan_outbound_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_add')) {
echo "<a href='".PROJECT_PATH."/app/fifo/fifo_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_add')) {
echo "<a href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
elseif (permission_exists('dialplan_add')) {
echo "<a href='dialplan_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
}
if (permission_exists('dialplan_delete') && $result_count > 0) {
echo "<a href='javascript:void(0);' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.forms.frm_delete.submit(); }\" alt='".$text['button-delete']."'>".$v_link_label_delete."</a>";
}
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<br><br>";
echo "</form>";
if (sizeof($dialplan_ids) > 0) {
echo "<script>\n";
echo " function check(what) {\n";
foreach ($dialplan_ids as $checkbox_id) {
echo "document.getElementById('".$checkbox_id."').checked = (what == 'all') ? true : false;\n";
}
echo " }\n";
echo "</script>\n";
}
//include the footer
require_once "resources/footer.php";
//unset the variables
unset ($result_count);
unset ($result);
unset ($key);
unset ($val);
unset ($c);
?>

View File

@@ -0,0 +1,932 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Copyright (C) 2010-2016
All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
//define the dialplan class
if (!class_exists('dialplan')) {
class dialplan {
//variables
public $db;
public $result;
public $domain_uuid;
public $dialplan_uuid;
public $xml;
public $json;
public $display_type;
public $default_context;
public $bridges;
public $variables;
//dialplans
public $dialplan_name;
public $dialplan_continue;
public $dialplan_order;
public $dialplan_context;
public $dialplan_global;
public $dialplan_enabled;
public $dialplan_description;
//dialplan_details
public $dialplan_detail_tag;
public $dialplan_detail_order;
public $dialplan_detail_type;
public $dialplan_detail_data;
public $dialplan_detail_break;
public $dialplan_detail_inline;
public $dialplan_detail_group;
//xml
public $uuid;
public $context;
public $source;
public $destination;
public $is_empty;
public $array;
//class constructor
public function __construct() {
//connect to the database if not connected
if (!$this->db) {
require_once "resources/classes/database.php";
$database = new database;
$database->connect();
$this->db = $database->db;
}
//set the default value
$this->dialplan_global = false;
}
public function dialplan_add() {
$sql = "insert into v_dialplans ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "app_uuid, ";
$sql .= "dialplan_uuid, ";
$sql .= "dialplan_name, ";
$sql .= "dialplan_number, ";
$sql .= "dialplan_continue, ";
$sql .= "dialplan_order, ";
$sql .= "dialplan_context, ";
$sql .= "dialplan_enabled, ";
$sql .= "dialplan_description ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
if ($this->dialplan_global) {
$sql .= "null, ";
}
else {
$sql .= "'".check_str($this->domain_uuid)."', ";
}
$sql .= "'".check_str($this->app_uuid)."', ";
$sql .= "'".check_str($this->dialplan_uuid)."', ";
$sql .= "'".check_str($this->dialplan_name)."', ";
$sql .= "'".check_str($this->dialplan_number)."', ";
$sql .= "'".check_str($this->dialplan_continue)."', ";
$sql .= "'".check_str($this->dialplan_order)."', ";
$sql .= "'".check_str($this->dialplan_context)."', ";
$sql .= "'".check_str($this->dialplan_enabled)."', ";
$sql .= "'".check_str($this->dialplan_description)."' ";
$sql .= ")";
$this->db->exec(check_sql($sql));
unset($sql);
} //end function
public function dialplan_update() {
$sql = "update v_dialplans set ";
$sql .= "dialplan_name = '".check_str($this->dialplan_name)."', ";
if (strlen($this->dialplan_continue) > 0) {
$sql .= "dialplan_continue = '".check_str($this->dialplan_continue)."', ";
}
$sql .= "dialplan_order = '".check_str($this->dialplan_order)."', ";
$sql .= "dialplan_context = '".check_str($this->dialplan_context)."', ";
$sql .= "dialplan_enabled = '".check_str($this->dialplan_enabled)."', ";
$sql .= "dialplan_description = '".check_str($this->dialplan_description)."' ";
$sql .= "where (domain_uuid = '".check_str($this->domain_uuid)."' or domain_uuid is null) ";
$sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
//echo "sql: ".$sql."<br />";
$this->db->query($sql);
unset($sql);
}
public function dialplan_detail_add() {
$dialplan_detail_uuid = uuid();
$sql = "insert into v_dialplan_details ";
$sql .= "(";
$sql .= "dialplan_detail_uuid, ";
$sql .= "domain_uuid, ";
$sql .= "dialplan_uuid, ";
$sql .= "dialplan_detail_tag, ";
$sql .= "dialplan_detail_order, ";
$sql .= "dialplan_detail_type, ";
$sql .= "dialplan_detail_data, ";
$sql .= "dialplan_detail_break, ";
$sql .= "dialplan_detail_inline, ";
$sql .= "dialplan_detail_group ";
$sql .= ") ";
$sql .= "values ";
$sql .= "( ";
$sql .= "'".$dialplan_detail_uuid."', ";
if ($this->dialplan_global) {
$sql .= "null, ";
}
else {
$sql .= "'".check_str($this->domain_uuid)."', ";
}
$sql .= "'".check_str($this->dialplan_uuid)."', ";
$sql .= "'".check_str($this->dialplan_detail_tag)."', ";
$sql .= "'".check_str($this->dialplan_detail_order)."', ";
$sql .= "'".check_str($this->dialplan_detail_type)."', ";
$sql .= "'".check_str($this->dialplan_detail_data)."', ";
if (strlen($this->dialplan_detail_break) == 0) {
$sql .= "null, ";
}
else {
$sql .= "'".check_str($this->dialplan_detail_break)."', ";
}
if (strlen($this->dialplan_detail_inline) == 0) {
$sql .= "null, ";
}
else {
$sql .= "'".check_str($this->dialplan_detail_inline)."', ";
}
if (strlen($this->dialplan_detail_group) == 0) {
$sql .= "null ";
}
else {
$sql .= "'".check_str($this->dialplan_detail_group)."' ";
}
$sql .= ")";
//echo $sql."\n\n";
$this->db->exec(check_sql($sql));
unset($sql);
} //end function
public function dialplan_detail_update() {
$sql = "update v_dialplans set ";
$sql .= "dialplan_detail_order = '".check_str($this->dialplan_detail_order)."', ";
$sql .= "dialplan_detail_type = '".check_str($this->dialplan_detail_type)."', ";
$sql .= "dialplan_detail_data = '".check_str($this->dialplan_detail_data)."', ";
if (strlen($this->dialplan_detail_break) > 0) {
$sql .= "dialplan_detail_break = '".check_str($this->dialplan_detail_break)."', ";
}
if (strlen($this->dialplan_detail_inline) > 0) {
$sql .= "dialplan_detail_inline = '".check_str($this->dialplan_detail_inline)."', ";
}
if (strlen($this->dialplan_detail_group) > 0) {
$sql .= "dialplan_detail_group = '".check_str($this->dialplan_detail_group)."', ";
}
$sql .= "dialplan_detail_tag = '".check_str($this->dialplan_detail_tag)."' ";
$sql .= "where (domain_uuid = '".check_str($this->domain_uuid)."' or domain_uuid is null) ";
$sql .= "and dialplan_uuid = '".check_str($this->dialplan_uuid)."' ";
//echo "sql: ".$sql."<br />";
$this->db->query($sql);
unset($sql);
} //end function
public function restore_advanced_xml() {
$switch_dialplan_dir = $this->switch_dialplan_dir;
if (is_dir($switch_dialplan_dir)) {
//copy resources/templates/conf to the freeswitch conf dir
if (file_exists('/usr/share/examples/fusionpbx/resources/templates/conf')){
$src_dir = "/usr/share/examples/fusionpbx/resources/templates/conf";
}
else {
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."/resources/templates/conf";
}
//get the contents of the dialplan/default.xml
$file_default_path = $src_dir.'/dialplan/default.xml';
$file_default_contents = file_get_contents($file_default_path);
//prepare the file contents and the path
//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
$file_default_contents = str_replace("{v_domain}", $_SESSION['domain_name'], $file_default_contents);
//set the file path
$file_path = $switch_dialplan_dir.'/'.$_SESSION['domain_name'].'.xml';
//write the default dialplan
$fh = fopen($file_path,'w') or die('Unable to write to '.$file_path.'. Make sure the path exists and permissons are set correctly.');
fwrite($fh, $file_default_contents);
fclose($fh);
//set the message
$this->result['dialplan']['restore']['msg'] = "Default Restored";
}
}
private function app_uuid_exists() {
$sql = "select domain_uuid from v_dialplans ";
$sql .= "where (domain_uuid = '".$this->domain_uuid."' or domain_uuid is null) ";
$sql .= "and app_uuid = '".$this->app_uuid."' ";
$prep_statement = $this->db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
if (count($result)) {
return true;
}
else {
return false;
}
}
unset($sql, $prep_statement, $result);
}
public function dialplan_exists() {
$sql = "select domain_uuid from v_dialplans ";
$sql .= "where (domain_uuid = '".$this->domain_uuid."' or domain_uuid is null)";
$sql .= "and dialplan_uuid = '".$this->dialplan_uuid."' ";
$prep_statement = $this->db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
if (count($result)) {
return true;
}
else {
return false;
}
}
unset($sql, $prep_statement, $result);
}
public function import() {
if (strlen($this->xml) > 0) {
//replace the variables
$length = (is_numeric($_SESSION["security"]["pin_length"]["var"])) ? $_SESSION["security"]["pin_length"]["var"] : 8;
//$this->xml = str_replace("{v_context}", $this->default_context, $this->xml);
$this->xml = str_replace("{v_pin_number}", generate_password($length, 1), $this->xml);
$this->xml = str_replace("{v_switch_recordings_dir}", $_SESSION['switch']['recordings']['dir'], $this->xml);
//convert the xml string to an xml object
$xml = simplexml_load_string($this->xml);
//convert to json
$json = json_encode($xml);
//convert to an array
$dialplan = json_decode($json, true);
}
if (strlen($this->json) > 0) {
//convert to an array
$dialplan = json_decode($json, true);
}
//ensure the condition array is uniform
if (is_array($dialplan)) {
if (!is_array($dialplan['extension']['condition'][0])) {
$tmp = $dialplan['extension']['condition'];
unset($dialplan['extension']['condition']);
$dialplan['extension']['condition'][0] = $tmp;
}
}
//get the app_uuid
$this->app_uuid = $dialplan['extension']['@attributes']['app_uuid'];
//get the list of domains
if (!isset($_SESSION['domains'])) {
$sql = "select * from v_domains; ";
$prep_statement = $this->db->prepare($sql);
$prep_statement->execute();
$_SESSION['domains'] = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
unset($sql, $prep_statement);
}
//check if the dialplan app uuid exists
foreach ($_SESSION['domains'] as $domain) {
//get the domain_uuid
$this->domain_uuid = $domain['domain_uuid'];
//set the dialplan_context
$this->dialplan_context = $dialplan['@attributes']['name'];
if ($this->dialplan_context == "{v_context}") {
$this->dialplan_context = $domain['domain_name'];
}
//check if the dialplan exists
if (!$this->app_uuid_exists()) {
//start the transaction
$this->db->beginTransaction();
//get the attributes
$this->dialplan_uuid = uuid();
$this->dialplan_name = $dialplan['extension']['@attributes']['name'];
$this->dialplan_number = $dialplan['extension']['@attributes']['number'];
$this->dialplan_global = false;
if (strlen($dialplan['extension']['@attributes']['global']) > 0) {
if ($dialplan['extension']['@attributes']['global'] == "true") {
$this->dialplan_global = true;
}
}
if ($this->display_type == "text") {
echo " ".$this->dialplan_name.": added\n";
}
if (strlen($dialplan['extension']['@attributes']['continue']) > 0) {
$this->dialplan_continue = $dialplan['extension']['@attributes']['continue'];
}
if (strlen($dialplan['extension']['@attributes']['enabled']) > 0) {
$this->dialplan_enabled = $dialplan['extension']['@attributes']['enabled'];
}
else {
$this->dialplan_enabled = "true";
}
$this->dialplan_description = '';
$this->dialplan_add();
//loop through the condition array
$x = 0;
$group = 0;
$order = 5;
if (isset($dialplan['extension']['condition'])) {
foreach ($dialplan['extension']['condition'] as &$row) {
unset($this->dialplan_detail_break);
unset($this->dialplan_detail_inline);
$this->dialplan_detail_tag = 'condition';
$this->dialplan_detail_type = $row['@attributes']['field'];
$this->dialplan_detail_data = $row['@attributes']['expression'];
$this->dialplan_detail_group = $group;
$this->dialplan_detail_order = $order;
if (strlen($row['@attributes']['break']) > 0) {
$this->dialplan_detail_break = $row['@attributes']['break'];
}
$this->dialplan_detail_add();
if (is_array($row['action']) || is_array($row['anti-action'])) {
$condition_self_closing_tag = false;
if (!is_array($row['action'][0])) {
if ($row['action']['@attributes']['application']) {
$tmp = $row['action'];
unset($row['action']);
$row['action'][0] = $tmp;
}
}
if (!is_array($row['anti-action'][0])) {
if ($row['anti-action']['@attributes']['application']) {
$tmp = $row['anti-action'];
unset($row['anti-action']);
$row['anti-action'][0] = $tmp;
}
}
$order = $order + 5;
unset($this->dialplan_detail_break);
unset($this->dialplan_detail_inline);
if (isset($row['action'])) {
foreach ($row['action'] as &$row2) {
$this->dialplan_detail_tag = 'action';
$this->dialplan_detail_type = $row2['@attributes']['application'];
$this->dialplan_detail_data = $row2['@attributes']['data'];
if (strlen($row2['@attributes']['inline']) > 0) {
$this->dialplan_detail_inline = $row2['@attributes']['inline'];
}
$this->dialplan_detail_group = $group;
$this->dialplan_detail_order = $order;
$this->dialplan_detail_add();
$order = $order + 5;
}
}
if (isset($row['anti-action'])) {
foreach ($row['anti-action'] as &$row2) {
$this->dialplan_detail_tag = 'anti-action';
$this->dialplan_detail_type = $row2['@attributes']['application'];
$this->dialplan_detail_data = $row2['@attributes']['data'];
$this->dialplan_detail_group = $group;
$this->dialplan_detail_order = $order;
$this->dialplan_detail_add();
$order = $order + 5;
}
}
}
else {
$condition_self_closing_tag = true;
}
//if not a self closing tag then increment the group
if (!$condition_self_closing_tag) {
$group++;
}
$row['group'] = $group;
$order = $order + 5;
$x++;
}
}
//end the transaction
$this->db->commit();
}
}
}
public function outbound_routes($destination_number) {
//normalize the destination number
$destination_number = trim($destination_number);
//check the session array if it doesn't exist then build the array
if (!is_array($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'])) {
//get the outbound routes from the database
$sql = "select * from v_dialplans as d, v_dialplan_details as s ";
$sql .= "where ";
$sql .= "( ";
$sql .= "d.domain_uuid = '".$this->domain_uuid."' ";
$sql .= "or d.domain_uuid is null ";
$sql .= ") ";
$sql .= "and d.app_uuid = '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
$sql .= "and d.dialplan_enabled = 'true' ";
$sql .= "and d.dialplan_uuid = s.dialplan_uuid ";
$sql .= "order by ";
$sql .= "d.dialplan_order asc, ";
$sql .= "d.dialplan_name asc, ";
$sql .= "d.dialplan_uuid asc, ";
$sql .= "s.dialplan_detail_group asc, ";
$sql .= "CASE s.dialplan_detail_tag ";
$sql .= "WHEN 'condition' THEN 1 ";
$sql .= "WHEN 'action' THEN 2 ";
$sql .= "WHEN 'anti-action' THEN 3 ";
$sql .= "ELSE 100 END, ";
$sql .= "s.dialplan_detail_order asc ";
$prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute();
$dialplans = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
unset($prep_statement, $sql);
$x = 0; $y = 0;
if (isset($dialplans)) foreach ($dialplans as &$row) {
//if the previous dialplan uuid has not been set then set it
if (!isset($previous_dialplan_uuid)) { $previous_dialplan_uuid = $row['dialplan_uuid']; }
//increment dialplan ordinal number
if ($previous_dialplan_uuid != $row['dialplan_uuid']) {
$x++; $y = 0;
}
//build the array
$array[$x]['dialplan_uuid'] = $row['dialplan_uuid'];
$array[$x]['dialplan_context'] = $row['dialplan_context'];
$array[$x]['dialplan_name'] = $row['dialplan_name'];
$array[$x]['dialplan_continue'] = $row['dialplan_continue'];
$array[$x]['dialplan_order'] = $row['dialplan_order'];
$array[$x]['dialplan_enabled'] = $row['dialplan_enabled'];
$array[$x]['dialplan_description'] = $row['dialplan_description'];
if (strlen($row['dialplan_detail_uuid']) > 0) {
$array[$x]['dialplan_details'][$y]['dialplan_uuid'] = $row['dialplan_uuid'];
$array[$x]['dialplan_details'][$y]['dialplan_detail_uuid'] = $row['dialplan_detail_uuid'];
$array[$x]['dialplan_details'][$y]['dialplan_detail_tag'] = $row['dialplan_detail_tag'];
$array[$x]['dialplan_details'][$y]['dialplan_detail_type'] = $row['dialplan_detail_type'];
$array[$x]['dialplan_details'][$y]['dialplan_detail_data'] = $row['dialplan_detail_data'];
$y++;
}
//set the previous dialplan_uuid
$previous_dialplan_uuid = $row['dialplan_uuid'];
}
unset ($prep_statement);
//set the session array
$_SESSION[$_SESSION['domain_uuid']]['outbound_routes'] = $array;
} //end if !is_array
//find the matching outbound routes
if (isset($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'])) foreach ($_SESSION[$_SESSION['domain_uuid']]['outbound_routes'] as $row) {
if (isset($row['dialplan_details'])) foreach ($row['dialplan_details'] as $field) {
if ($field['dialplan_detail_tag'] == "condition") {
if ($field['dialplan_detail_type'] == "destination_number") {
$dialplan_detail_data = $field['dialplan_detail_data'];
$pattern = '/'.$dialplan_detail_data.'/';
preg_match($pattern, $destination_number, $matches, PREG_OFFSET_CAPTURE);
if (count($matches) == 0) {
$regex_match = false;
}
else {
$regex_match = true;
$regex_match_1 = $matches[1][0];
$regex_match_2 = $matches[2][0];
$regex_match_3 = $matches[3][0];
}
}
}
if ($regex_match) {
//get the variables
if ($field[dialplan_detail_type] == "set" && $field[dialplan_detail_tag] == "action") {
//only set variables with values not variables
if (strpos($field[dialplan_detail_data], '$') === false) {
$this->variables .= $field[dialplan_detail_data].",";
}
}
//process the $x detail data variables
if ($field['dialplan_detail_tag'] == "action" && $field['dialplan_detail_type'] == "bridge" && $dialplan_detail_data != "\${enum_auto_route}") {
$dialplan_detail_data = $field['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("\$3", $regex_match_3, $dialplan_detail_data);
$this->bridges = $dialplan_detail_data;
}
}
}
} // end if isset
} // outbound_routes
//reads dialplan details from the database to build the xml
public function xml () {
//set the xml array and then concatenate the array to a string
/* $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; */
//$xml .= "<document type=\"freeswitch/xml\">\n";
//$xml .= " <section name=\"dialplan\" description=\"\">\n";
//$xml .= " <context name=\"" . $this->context . "\">\n";
//set defaults
$previous_dialplan_uuid = "";
$previous_dialplan_detail_group = "";
$dialplan_tag_status = "closed";
$condition_tag_status = "closed";
//get the dialplans from the dialplan_xml field in the dialplans table
if ($this->source == "dialplans") {
//get the data using a join between the dialplans and dialplan details tables
$sql = "select dialplan_uuid, dialplan_xml ";
$sql .= "from v_dialplans \n";
if (isset($this->uuid)) {
$sql .= "where dialplan_uuid = '".$this->uuid."' \n";
}
else {
if (isset($this->context)) {
if ($this->context == "public" || substr($this->context, 0, 7) == "public@" || substr($this->context, -7) == ".public") {
$sql .= "where dialplan_context = '" . $this->context . "' \n";
}
else {
$sql .= "where (dialplan_context = '" . $this->context . "' or dialplan_context = '\${domain_name}') \n";
}
$sql .= "and dialplan_enabled = 'true' \n";
}
}
if ($this->is_empty == "dialplan_xml") {
$sql .= "and p.dialplan_xml is null \n";
}
$sql .= "order by \n";
$sql .= "dialplan_context asc, \n";
$sql .= "dialplan_order asc \n";
//echo $sql;
$prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute();
$results = $prep_statement->fetchAll(PDO::FETCH_NAMED);
//echo $sql;
foreach ($results as $row) {
$dialplans[$row["dialplan_uuid"]] = $row["dialplan_xml"];
}
}
//get the dialplans from the dialplan details
if ($this->source == "details") {
//get the data using a join between the dialplans and dialplan details tables
$sql = "select ";
$sql .= "p.domain_uuid, p.dialplan_uuid, p.app_uuid, p.dialplan_context, p.dialplan_name, p.dialplan_number, \n";
$sql .= "p.dialplan_continue, p.dialplan_order, p.dialplan_enabled, p.dialplan_description, \n";
$sql .= "s.dialplan_detail_uuid, s.dialplan_detail_tag, s.dialplan_detail_type, s.dialplan_detail_data, \n";
$sql .= "s.dialplan_detail_break, s.dialplan_detail_inline, s.dialplan_detail_group, s.dialplan_detail_order \n";
$sql .= "from v_dialplans as p, v_dialplan_details as s \n";
$sql .= "where p.dialplan_uuid = s.dialplan_uuid \n";
if ($this->is_empty == "dialplan_xml") {
$sql .= "and p.dialplan_xml is null \n";
}
if (isset($this->context)) {
if ($this->context == "public" || substr($this->context, 0, 7) == "public@" || substr($this->context, -7) == ".public") {
$sql .= "and p.dialplan_context = '" . $this->context . "' \n";
}
else {
$sql .= "and (p.dialplan_context = '" . $this->context . "' or p.dialplan_context = '\${domain_name}') \n";
}
$sql .= "and p.dialplan_enabled = 'true' \n";
}
if (isset($this->uuid)) {
$sql .= "and p.dialplan_uuid = '".$this->uuid."' \n";
$sql .= "and s.dialplan_uuid = '".$this->uuid."' \n";
}
$sql .= "order by \n";
$sql .= "p.dialplan_order asc, \n";
$sql .= "p.dialplan_name asc, \n";
$sql .= "p.dialplan_uuid asc, \n";
$sql .= "s.dialplan_detail_group asc, \n";
$sql .= "CASE s.dialplan_detail_tag \n";
$sql .= "WHEN 'condition' THEN 1 \n";
$sql .= "WHEN 'action' THEN 2 \n";
$sql .= "WHEN 'anti-action' THEN 3 \n";
$sql .= "ELSE 100 END, \n";
$sql .= "s.dialplan_detail_order asc \n";
$prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute();
$results = $prep_statement->fetchAll(PDO::FETCH_NAMED);
//debug info
//echo "sql: $sql\n";
//echo "<pre>\n";
//print_r($results);
//echo "</pre>\n";
//exit;
//loop through the results to get the xml from the dialplan_xml field or from dialplan details table
$x = 0;
foreach ($results as $row) {
//clear flag pass
$pass = false;
//get the dialplan
$domain_uuid = $row["domain_uuid"];
$dialplan_uuid = $row["dialplan_uuid"];
//$app_uuid = $row["app_uuid"];
$this->context = $row["dialplan_context"];
$dialplan_name = $row["dialplan_name"];
//$dialplan_number = $row["dialplan_number"];
$dialplan_continue = $row["dialplan_continue"];
//$dialplan_order = $row["dialplan_order"];
//$dialplan_enabled = $row["dialplan_enabled"];
//$dialplan_description = $row["dialplan_description"];
//$get the dialplan details
//$dialplan_detail_uuid = $row["dialplan_detail_uuid"];
$dialplan_detail_tag = $row["dialplan_detail_tag"];
$dialplan_detail_type = $row["dialplan_detail_type"];
$dialplan_detail_data = $row["dialplan_detail_data"];
$dialplan_detail_break = $row["dialplan_detail_break"];
$dialplan_detail_inline = $row["dialplan_detail_inline"];
$dialplan_detail_group = $row["dialplan_detail_group"];
//$dialplan_detail_order = $row["dialplan_detail_order;
//remove $$ and replace with $
$dialplan_detail_data = str_replace("$$", "$", $dialplan_detail_data);
//get the dialplan detail inline
$detail_inline = "";
if ($dialplan_detail_inline) {
if (strlen($dialplan_detail_inline) > 0) {
$detail_inline = " inline=\"" . $dialplan_detail_inline . "\"";
}
}
//close the tags
if ($dialplan_tag_status != "closed") {
if (($previous_dialplan_uuid != $dialplan_uuid) || ($previous_dialplan_detail_group != $dialplan_detail_group)) {
if ($condition_tag_status != "closed") {
if ($condition_attribute && (strlen($condition_attribute) > 0)) {
$xml .= " <condition " . $condition_attribute . $condition_break . "/>\n";
$condition_attribute = "";
$condition_tag_status = "closed";
}
elseif ($condition && (strlen($condition) > 0)) {
$xml .= " ".$condition . "/>";
$condition = "";
$condition_tag_status = "closed";
}
elseif ($condition_tag_status != "closed") {
$xml .= " </condition>\n";
$condition_tag_status = "closed";
}
$condition_tag_status = "closed";
}
}
if ($previous_dialplan_uuid != $dialplan_uuid) {
$xml .= "</extension>\n";
//add to the dialplanss
$dialplans[$previous_dialplan_uuid] = $xml;
$xml = '';
$dialplan_tag_status = "closed";
}
}
//open the tags
if ($dialplan_tag_status == "closed") {
$xml = '';
$xml .= "<extension name=\"" . $dialplan_name . "\" continue=\"" . $dialplan_continue . "\" uuid=\"" . $dialplan_uuid . "\">\n";
$dialplan_tag_status = "open";
$first_action = true;
$condition = "";
$condition_attribute = "";
}
if ($dialplan_detail_tag == "condition") {
//determine the type of condition
if ($dialplan_detail_type == "hour") {
$condition_type = 'time';
}
elseif ($dialplan_detail_type == "minute") {
$condition_type = 'time';
}
elseif ($dialplan_detail_type == "minute-of-day") {
$condition_type = 'time';
}
elseif ($dialplan_detail_type == "mday") {
$condition_type = 'time';
}
elseif ($dialplan_detail_type == "mweek") {
$condition_type = 'time';
}
elseif ($dialplan_detail_type == "mon") {
$condition_type = 'time';
}
elseif ($dialplan_detail_type == "time-of-day") {
$condition_type = 'time';
}
elseif ($dialplan_detail_type == "yday") {
$condition_type = 'time';
}
elseif ($dialplan_detail_type == "year") {
$condition_type = 'time';
}
elseif ($dialplan_detail_type == "wday") {
$condition_type = 'time';
}
elseif ($dialplan_detail_type == "week") {
$condition_type = 'time';
}
elseif ($ialplan_detail_type == "date-time") {
$condition_type = 'time';
}
else {
$condition_type = 'default';
}
// finalize any previous pending condition statements
if ($condition_tag_status == "open") {
if (strlen($condition) > 0) {
$xml .= $condition . "/>\n";
$condition = '';
$condition_tag_status = "closed";
}
elseif (strlen($condition_attribute) > 0 && $condition_tag_status == "open") {
// previous condition(s) must have been of type time
// do not finalize if new condition is also of type time
if ($condition_type != 'time') {
// note: condition_break here is value from the previous loop
$xml .= " <condition " . $condition_attribute . $condition_break . "/>\n";
$condition_attribute = '';
$condition_tag_status = "closed";
}
//else {
// $xml .= " </condition>\n";
// $condition_tag_status = "closed";
//}
}
}
//get the condition break attribute
$condition_break = "";
if ($dialplan_detail_break) {
if (strlen($dialplan_detail_break) > 0) {
$condition_break = " break=\"" . $dialplan_detail_break . "\"";
}
}
//condition tag but leave off the ending
if ($condition_type == "default") {
$condition = " <condition field=\"" . $dialplan_detail_type . "\" expression=\"" . $dialplan_detail_data . "\"" . $condition_break;
}
elseif ($condition_type == "time") {
if ($condition_attribute) {
$condition_attribute = $condition_attribute . $dialplan_detail_type . "=\"" . $dialplan_detail_data . "\" ";
} else {
$condition_attribute = $dialplan_detail_type . "=\"" . $dialplan_detail_data . "\" ";
}
$condition = ""; //prevents a duplicate time condition
}
else {
$condition = " <condition field=\"" . $dialplan_detail_type . "\" expression=\"" . $dialplan_detail_data . "\"" . $condition_break;
}
$condition_tag_status = "open";
}
if ($dialplan_detail_tag == "action" || $dialplan_detail_tag == "anti-action") {
if ($condition_tag_status == "open") {
if ($condition_attribute && (strlen($condition_attribute) > 0)) {
$xml .= " <condition " . $condition_attribute . $condition_break . ">\n";
$condition_attribute = "";
}
elseif ($condition && (strlen($condition) > 0)) {
$xml .= $condition . ">\n";
$condition = "";
}
}
}
if ($this->context == "public" || substr($this->context, 0, 7) == "public@" || substr($this->context, -7) == ".public") {
if ($dialplan_detail_tag == "action") {
if ($first_action) {
//get the domains
if (!isset($domains)) {
$sql = "select * from v_domains; \n";
$prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach($result as $row) {
$domains[$row['domain_uuid']] = $row['domain_name'];
}
}
//add the call direction and domain name and uuid
$xml .= " <action application=\"set\" data=\"call_direction=inbound\" inline=\"true\"/>\n";
if ($domain_uuid != null and $domain_uuid != '') {
$domain_name = $domains[$domain_uuid];
$xml .= " <action application=\"set\" data=\"domain_uuid=" . $domain_uuid . "\" inline=\"true\"/>\n";
}
if ($domain_name != null and $domain_name != '') {
$xml .= " <action application=\"set\" data=\"domain_name=" . $domain_name . "\" inline=\"true\"/>\n";
}
$first_action = false;
}
}
}
if ($dialplan_detail_tag == "action") {
$xml .= " <action application=\"" . $dialplan_detail_type . "\" data=\"" . $dialplan_detail_data . "\"" . $detail_inline . "/>\n";
}
if ($dialplan_detail_tag == "anti-action") {
$xml .= " <anti-action application=\"" . $dialplan_detail_type . "\" data=\"" . $dialplan_detail_data . "\"" . $detail_inline . "/>\n";
}
//save the previous values
$previous_dialplan_uuid = $dialplan_uuid;
$previous_dialplan_detail_group = $dialplan_detail_group;
//increment the x
$x++;
//set flag pass
$pass = true;
}
// prevent partial dialplan (pass=nil may be error in sql or empty resultset)
if ($pass == false) {
if (count($results)) {
echo 'error while build context: ' . $this->context;
}
}
//close the extension tag if it was left open
if ($dialplan_tag_status == "open") {
if ($condition_tag_status == "open") {
if ($condition_attribute and (strlen($condition_attribute) > 0)) {
$xml .= " <condition " . $condition_attribute . $condition_break . "/>\n";
}
elseif ($condition && (strlen($condition) > 0)) {
$xml .= $condition . "/>\n";
} else {
$xml .= " </condition>\n";
}
}
$xml .= "</extension>\n";
//add to the dialplans array
$dialplans[$dialplan_uuid] = $xml;
}
//set the xml array and then concatenate the array to a string
//$xml .= " </context>\n";
///$xml .= " </section>\n";
//$xml .= "</document>\n";
} //end if source = details
//return the array
if ($this->destination == "array") {
return $dialplans;
}
//save the dialplan xml
if ($this->destination == "database") {
if (is_array($dialplans)) {
foreach ($dialplans as $key => $value) {
$sql = "update v_dialplans ";
//$sql .= "set dialplan_xml = ':xml' ";
$sql .= "set dialplan_xml = '".check_str($value)."' ";
//$sql .= "where dialplan_uuid=:dialplan_uuid ";
$sql .= "where dialplan_uuid = '$key';";
//$prep_statement = $this->db->prepare(check_sql($sql));
//$prep_statement->bindParam(':xml', $value );
//$prep_statement->bindParam(':dialplan_uuid', $key);
//$prep_statement->execute();
//$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
//print_r($result);
unset($prep_statement);
$this->db->query($sql);
unset($sql);
}
}
//return true;
}
}
} // end class
} // class_exists
?>

View File

@@ -0,0 +1,9 @@
<context name="public">
<extension name="caller-details" continue="true" app_uuid="b1cd7509-5576-469a-892d-d0cfb66a4197" global="true">
<condition field="" expression="" break="never">
<action application="set" data="caller_destination=${destination_number}" inline="true"/>
<action application="set" data="caller_id_name=${caller_id_name}" inline="true"/>
<action application="set" data="caller_id_number=${caller_id_number}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,25 @@
<context name="{v_context}">
<extension name="user_exists" number="" continue="true" app_uuid="897845b0-1f13-444c-84fe-432fd47338ca">
<condition field="" expression="" break="">
<action application="set" data="user_exists=${user_exists id ${destination_number} ${domain_name}}" inline="true"/>
</condition>
<condition field="${user_exists}" expression="^true$" break="">
<action application="set" data="extension_uuid=${user_data ${destination_number}@${domain_name} var extension_uuid}" inline="true"/>
<action application="set" data="hold_music=${user_data ${destination_number}@${domain_name} var hold_music}" inline="true"/>
<action application="set" data="forward_all_enabled=${user_data ${destination_number}@${domain_name} var forward_all_enabled}" inline="true"/>
<action application="set" data="forward_all_destination=${user_data ${destination_number}@${domain_name} var forward_all_destination}" inline="true"/>
<action application="set" data="forward_busy_enabled=${user_data ${destination_number}@${domain_name} var forward_busy_enabled}" inline="true"/>
<action application="set" data="forward_busy_destination=${user_data ${destination_number}@${domain_name} var forward_busy_destination}" inline="true"/>
<action application="set" data="forward_no_answer_enabled=${user_data ${destination_number}@${domain_name} var forward_no_answer_enabled}" inline="true"/>
<action application="set" data="forward_no_answer_destination=${user_data ${destination_number}@${domain_name} var forward_no_answer_destination}" inline="true"/>
<action application="set" data="forward_user_not_registered_enabled=${user_data ${destination_number}@${domain_name} var forward_user_not_registered_enabled}" inline="true"/>
<action application="set" data="forward_user_not_registered_destination=${user_data ${destination_number}@${domain_name} var forward_user_not_registered_destination}" inline="true"/>
<action application="set" data="do_not_disturb=${user_data ${destination_number}@${domain_name} var do_not_disturb}" inline="true"/>
<action application="set" data="call_timeout=${user_data ${destination_number}@${domain_name} var call_timeout}" inline="true"/>
<action application="set" data="missed_call_app=${user_data ${destination_number}@${domain_name} var missed_call_app}" inline="true"/>
<action application="set" data="missed_call_data=${user_data ${destination_number}@${domain_name} var missed_call_data}" inline="true"/>
<action application="set" data="toll_allow=${user_data ${destination_number}@${domain_name} var toll_allow}" inline="true"/>
<action application="set" data="call_screen_enabled=${user_data ${destination_number}@${domain_name} var call_screen_enabled}" inline="true"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,9 @@
<context name="{v_context}">
<extension name="caller-details" continue="true" app_uuid="5c491a3e-f587-44df-970a-cd4352aa6f64">
<condition field="${caller_destination}" expression="^$" break="never">
<action application="set" data="caller_destination=${destination_number}" inline="true"/>
<action application="set" data="caller_id_name=${caller_id_name}" inline="true"/>
<action application="set" data="caller_id_number=${caller_id_number}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,7 @@
<context name="{v_context}">
<extension name="call-direction" number="" continue="true" app_uuid="3780f814-5543-4350-b65d-563512d1fe71" enabled="true">
<condition field="${call_direction}" expression="^(inbound|outbound|local)$" break="never">
<anti-action application="set" data="call_direction=local" inline="true"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="{v_context}">
<extension name="variables" number="" continue="true" app_uuid="9f356fe7-8cf8-4c14-8fe2-6daf89304458">
<condition>
<action application="export" data="origination_callee_id_name=${destination_number}"/>
<action application="set" data="RFC2822_DATE=${strftime(%a, %d %b %Y %T %z)}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,7 @@
<context name="{v_context}">
<extension name="call-limit" number="" continue="true" app_uuid="4670c44c-45dd-4bae-97ba-b0dfe0aca639" enabled="false">
<condition field="${call_direction}" expression="^(inbound|outbound)$">
<action application="limit" data="hash inbound ${domain_uuid} ${max_calls} !USER_BUSY"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,7 @@
<context name="{v_context}">
<extension name="is_local" number="" continue="true" app_uuid="a1685b18-21aa-4d77-9f95-c0013b7286a3" enabled="false">
<condition field="${user_exists}" expression="false">
<action application="lua" data="app.lua is_local"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,7 @@
<context name="{v_context}">
<extension name="call_block" number="" continue="true" app_uuid="b1b31930-d0ee-4395-a891-04df94599f1f" enabled="false">
<condition field="${call_direction}" expression="^inbound$" >
<action application="lua" data="app.lua call_block"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,57 @@
<context name="{v_context}">
<extension name="user_record" number="" continue="true" app_uuid="43539dd3-d555-4498-835a-3245a0b184ca" enabled="true">
<condition field="" expression="">
<action application="set" data="user_record=${user_data ${destination_number}@${domain_name} var user_record}" inline="true"/>
<action application="set" data="from_user_exists=${user_exists id ${sip_from_user} ${sip_from_host}}" inline="true"/>
</condition>
<condition field="${user_exists}" expression="^true$" break="never"/>
<condition field="${user_record}" expression="^all$" break="never">
<action application="set" data="record_session=true" inline="true"/>
</condition>
<condition field="${user_exists}" expression="^true$" break="never"/>
<condition field="${call_direction}" expression="^inbound$" break="never"/>
<condition field="${user_record}" expression="^inbound$" break="never">
<action application="set" data="record_session=true" inline="true"/>
</condition>
<condition field="${user_exists}" expression="^true$" break="never"/>
<condition field="${call_direction}" expression="^outbound$" break="never"/>
<condition field="${user_record}" expression="^outbound$" break="never">
<action application="set" data="record_session=true" inline="true"/>
</condition>
<condition field="${user_exists}" expression="^true$" break="never"/>
<condition field="${call_direction}" expression="^local$" break="never"/>
<condition field="${user_record}" expression="^local$" break="never">
<action application="set" data="record_session=true" inline="true"/>
</condition>
<condition field="${from_user_exists}" expression="^true$" break="never">
<action application="set" data="from_user_record=${user_data ${sip_from_user}@${sip_from_host} var user_record}" inline="true"/>
</condition>
<condition field="${from_user_exists}" expression="^true$" break="never"/>
<condition field="${from_user_record}" expression="^all$" break="never">
<action application="set" data="record_session=true" inline="true"/>
</condition>
<condition field="${from_user_exists}" expression="^true$" break="never"/>
<condition field="${call_direction}" expression="^inbound$" break="never"/>
<condition field="${from_user_record}" expression="^inbound$" break="never">
<action application="set" data="record_session=true" inline="true"/>
</condition>
<condition field="${from_user_exists}" expression="^true$" break="never"/>
<condition field="${call_direction}" expression="^outbound$" break="never"/>
<condition field="${from_user_record}" expression="^outbound$" break="never">
<action application="set" data="record_session=true" inline="true"/>
</condition>
<condition field="${from_user_exists}" expression="^true$" break="never"/>
<condition field="${call_direction}" expression="^local$" break="never"/>
<condition field="${from_user_record}" expression="^local$" break="never">
<action application="set" data="record_session=true" inline="true"/>
</condition>
<condition field="${record_session}" expression="^true$">
<action application="set" data="record_path=${recordings_dir}/${domain_name}/archive/${strftime(%Y)}/${strftime(%b)}/${strftime(%d)}" inline="true"/>
<action application="set" data="record_name=${uuid}.${record_ext}" inline="true"/>
<!--<action application="set" data="record_name=${destination_number}-${caller_id_number}_${strftime(%Y-%m-%d %H:%M)}.${record_ext}" inline="true"/>-->
<action application="set" data="record_append=true" inline="true"/>
<action application="set" data="record_in_progress=true" inline="true"/>
<action application="record_session" data="${record_path}/${record_name}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,10 @@
<context name="{v_context}">
<extension name="redial" number="*870" continue="true" app_uuid="459da8c1-073a-458e-ae7e-8194342f9583">
<condition field="destination_number" expression="^(redial|\*870)$" break="on-true">
<action application="transfer" data="${hash(select/${domain_name}-last_dial/${caller_id_number})}"/>
</condition>
<condition field="" expression="" break="never">
<action application="hash" data="insert/${domain_name}-last_dial/${caller_id_number}/${destination_number}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,7 @@
<context name="{v_context}">
<extension name="speed_dial" number="*0[ext]" continue="false" app_uuid="1a4a2611-01e3-4582-982b-4ada4d314ea3" enabled="true">
<condition field="destination_number" expression="^\*0(.*)$">
<action application="lua" data="app.lua speed_dial $1"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,12 @@
<context name="{v_context}">
<extension name="default_caller_id" number="" continue="true" app_uuid="9660e536-976d-47cb-872e-85957c51bd3d">
<condition field="${emergency_caller_id_number}" expression="^$" break="never">
<action application="set" data="emergency_caller_id_name=${default_emergency_caller_id_name}" inline="true"/>
<action application="set" data="emergency_caller_id_number=${default_emergency_caller_id_number}" inline="true"/>
</condition>
<condition field="${outbound_caller_id_number}" expression="^$" break="never">
<action application="set" data="outbound_caller_id_name=${default_outbound_caller_id_name}" inline="true"/>
<action application="set" data="outbound_caller_id_number=${default_outbound_caller_id_number}" inline="true"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="{v_context}">
<extension name="agent_status" number="*22" continue="false" app_uuid="2eb032c5-c79d-4096-ac90-8a47fe40f411">
<condition field="destination_number" expression="^\*22$">
<action application="set" data="agent_id=${sip_from_user}"/>
<action application="lua" data="app.lua agent_status"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="{v_context}">
<extension name="agent_status_id" number="*23" continue="false" app_uuid="feb0ee6e-0ea5-41fc-a9c1-189daf2d4161">
<condition field="destination_number" expression="^\*23$">
<action application="set" data="agent_id="/>
<action application="lua" data="app.lua agent_status"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,12 @@
<context name="{v_context}">
<extension name="provision" number="*11,*12" continue="false" app_uuid="d31d267d-7235-4887-a01b-d59f3a1dfcca" enabled="false">
<condition field="destination_number" expression="^\*11$" break="on-true">
<action application="set" data="action=login"/>
<action application="lua" data="app.lua provision"/>
</condition>
<condition field="destination_number" expression="^\*12$">
<action application="set" data="action=logout"/>
<action application="lua" data="app.lua provision"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="{v_context}">
<extension name="group-intercept" number="*8" continue="false" app_uuid="15332e83-12f5-44d3-8472-633736eb4b9b">
<condition field="destination_number" expression="^\*8$">
<action application="answer"/>
<action application="lua" data="intercept_group.lua"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,15 @@
<context name="{v_context}">
<extension name="page" number="*724" continue="false" app_uuid="2011c518-696d-4878-a9b2-b217b6311311" enabled="false">
<condition field="destination_number" expression="^\*724$" >
<action application="set" data="caller_id_name=Page" />
<action application="set" data="caller_id_number=" />
<action application="set" data="pin_number={v_pin_number}" />
<action application="set" data="destinations=101-103,105" />
<action application="set" data="moderator=false" />
<action application="set" data="mute=true" />
<action application="set" data="set api_hangup_hook=conference page-${destination_number} kick all" />
<action application="lua" data="page.lua" />
</condition>
</extension>
</context>

View File

@@ -0,0 +1,72 @@
<!--
@usage
set `conf_xfer_number` and do transfer to `conf_xfer_from_dialplan`
<action application="export" data="conf_xfer_number=xfer-${create_uuid foo}-${domain_name}">
<action application="bind_digit_action" data="local,*0,exec:execute_extension,conf_xfer_from_dialplan XML conf-xfer@${domain_name},${bind_target}"/>
Control DTMF sequence
`*0` transfer `self` to enter number and `peer` leg to conference room
`##` transfer `self` to enter number and hangup `peer` leg
`*#` transfer `self` to conference room and hangup `peer` leg
-->
<context name="conf-xfer@{v_context}">
<extension name="conf-xfer" number="" continue="false" app_uuid="04e6a380-a27e-4032-bedf-f5b2249ea54d" enabled="false">
<condition field="destination_number" expression="^conf_add_begin$" break="on-true">
<action application="set" data="api_result=${conference(${conf_xfer_number} unmute ${conference_member_id} quiet)}"/>
<action application="bind_digit_action" data="conf-xfer,*0,api:lua,transfer2.lua ${uuid} conf_enter_number::XML::conf-xfer@${domain_name} conf_enter_to::XML::conf-xfer@${domain_name}"/>
<action application="bind_digit_action" data="conf-xfer,##,api:lua,transfer2.lua ${uuid} conf_enter_number::XML::conf-xfer@${domain_name} ::KILL::"/>
<action application="bind_digit_action" data="conf-xfer,*#,api:lua,transfer2.lua ${uuid} conf_add_end::XML::conf-xfer@${domain_name} ::KILL::"/>
<action application="bind_digit_action" data="conf,*#,exec:execute_extension,conf_add_begin XML conf-xfer@${domain_name}"/>
<action application="bind_digit_action" data="none,NONE,api:sleep,1"/>
<action application="set" data="continue_on_fail=true"/>
<action application="transfer" data="conf_enter_number XML conf-xfer@${domain_name}"/>
</condition>
<condition field="destination_number" expression="^conf_add_end$" break="on-true">
<action application="digit_action_set_realm" data="conf"/>
<action application="set" data="api_result=${conference(${conf_xfer_number} mute ${conference_member_id})}"/>
<action application="conference" data="${conf_xfer_number}@page"/>
</condition>
<condition field="destination_number" expression="^conf_enter_number$" break="on-true">
<action application="digit_action_set_realm" data="none"/>
<action application="read" data="2 11 'tone_stream://%(10000,0,350,440)' target_num 30000 #"/>
<action application="execute_extension" data="conf_bridge_${target_num} XML conf-xfer@${domain_name}"/>
</condition>
<condition field="destination_number" expression="^conf_bridge_$" break="on-true">
<action application="execute_extension" data="conf_add_end XML conf-xfer@${domain_name}"/>
</condition>
<condition field="destination_number" expression="^conf_bridge_\*$" break="on-true">
<action application="execute_extension" data="conf_add_end XML conf-xfer@${domain_name}"/>
</condition>
<condition field="destination_number" expression="^conf_bridge_(\d{2,7})$" break="on-true">
<action application="digit_action_set_realm" data="conf-xfer"/>
<action application="bridge" data="{conf_xfer_number=${conf_xfer_number},transfer_after_bridge=conf_enter_to:XML:conf-xfer@${domain_name}}user/$1@${domain_name}"/>
<action application="execute_extension" data="conf_enter_number XML conf-xfer@${domain_name}"/>
</condition>
<condition field="destination_number" expression="^conf_bridge_" break="on-true">
<action application="playback" data="voicemail/vm-that_was_an_invalid_ext.wav"/>
<action application="execute_extension" data="conf_enter_number XML conf-xfer@${domain_name}"/>
</condition>
<condition field="destination_number" expression="^conf_enter_to$" break="on-true">
<action application="unbind_meta_app" data=""/>
<action application="bind_digit_action" data="conf,*#,exec:execute_extension,conf_add_begin XML conf-xfer@${domain_name}"/>
<action application="digit_action_set_realm" data="conf"/>
<action application="answer" data=""/>
<action application="playback" data="tone_stream://L=1;%(500, 0, 640)"/>
<action application="conference" data="${conf_xfer_number}@page"/>
</condition>
<condition field="destination_number" expression="^conf_xfer_from_dialplan$">
<action application="lua" data="transfer2.lua ${uuid} conf_add_begin::XML::conf-xfer@${domain_name} conf_enter_to::XML::conf-xfer@${domain_name}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,11 @@
<context name="{v_context}">
<extension name="page-extension" number="*8[ext]" continue="false" app_uuid="1b224444-de8b-448d-b2d1-19feaac3effa">
<condition field="destination_number" expression="^\*8(\d{2,7})$">
<action application="set" data="destinations=$1"/>
<action application="set" data="pin_number={v_pin_number}"/>
<action application="set" data="mute=true"/>
<action application="set" data="moderator=false" />
<action application="lua" data="page.lua"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,9 @@
<context name="{v_context}">
<extension name="eavesdrop" number="*33[ext]" continue="false" app_uuid="e944af7e-8fcc-429b-a32f-0dcdce1585d8">
<condition field="destination_number" expression="^\*33(\d{2,7})$">
<action application="answer"/>
<action application="set" data="pin_number={v_pin_number}"/>
<action application="lua" data="eavesdrop.lua $1"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,10 @@
<context name="{v_context}">
<extension name="call_privacy" number="*67[d+]" continue="false" app_uuid="eb478e66-f637-4ae7-b1eb-9a7b87a1bd9e">
<condition field="destination_number" expression="^\*67(\d+)$">
<action application="privacy" data="full"/>
<action application="set" data="sip_h_Privacy=id"/>
<action application="set" data="privacy=yes"/>
<action application="transfer" data="$1 XML ${context}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,7 @@
<context name="{v_context}">
<extension name="call_return" number="*69" continue="false" app_uuid="fa516204-920f-4802-8bb1-04c6a010bfe1">
<condition field="destination_number" expression="^\*69$">
<action application="transfer" data="${hash(select/${domain_name}-call_return/${caller_id_number})}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,14 @@
<context name="{v_context}">
<extension name="extension_queue" number="*800[ext]" app_uuid="eb837d10-890d-11e3-baa8-0800200c9a66">
<condition field="destination_number" expression="^\*800(.*)$" >
<action application="set" data="fifo_music=$${hold_music}" />
<action application="set" data="extension_queue=queue_$1@\${domain_name}" />
<action application="set" data="fifo_simo=1" />
<action application="set" data="fifo_timeout=30" />
<action application="set" data="fifo_lag=10" />
<action application="set" data="fifo_destroy_after_use=true" />
<action application="set" data="fifo_extension_member=$1@\${domain_name}" />
<action application="lua" data="extension_queue.lua" />
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="${domain_name}">
<extension name="intercept-ext-polycom" number="*97[ext]" continue="false" app_uuid="07493266-2b99-400a-8fde-3e1a9d11f575" global="true">
<condition field="destination_number" expression="^\*97(\d+)$">
<action application="answer"/>
<action application="lua" data="intercept.lua $1"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="{v_context}">
<extension name="intercept-ext" number="**[ext]" continue="false" app_uuid="2b7b2f82-edfe-4339-8cc5-7d0cf36e1e68">
<condition field="destination_number" expression="^\*\*(\d+)$">
<action application="answer"/>
<action application="lua" data="intercept.lua $1"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,10 @@
<!-- In call Transfer for phones without a transfer button -->
<context name="{v_context}">
<extension name="dx" number="dx" continue="false" app_uuid="ddcf7740-78ca-4035-8c19-e2df10cebf67">
<condition field="destination_number" expression="^dx$">
<action application="answer"/>
<action application="read" data="11 11 'tone_stream://%(10000,0,350,440)' digits 5000 #"/>
<action application="transfer" data="-bleg ${digits}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,12 @@
<context name="{v_context}">
<extension name="att_xfer" number="att_xfer" continue="false" app_uuid="7bd7a113-0afc-406a-b4a7-33077c22ac39">
<condition field="destination_number" expression="^att_xfer$">
<action application="read" data="2 6 'tone_stream://%(10000,0,350,440)' digits 30000 #"/>
<action application="set" data="origination_cancel_key=#"/>
<!-- sends it to the correct domain but public context-->
<!--<action application="set" data="domain_name=${transfer_context}"/>-->
<!--<action application="att_xfer" data="sofia/internal/${digits}@${transfer_context}"/>-->
<action application="att_xfer" data="user/${digits}@${domain_name}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,15 @@
<context name="{v_context}">
<extension name="extension-to-voicemail" number="[ext]" continue="false" app_uuid="8a2e7b81-996c-4d6b-87df-b879b972a572">
<condition field="${user_exists}" expression="^true$" />
<condition field="username" expression="^${caller_id_number}$" />
<condition field="destination_number" expression="^${caller_id_number}$">
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="set" data="voicemail_action=check"/>
<action application="set" data="voicemail_id=${caller_id_number}"/>
<action application="set" data="voicemail_profile=default"/>
<action application="lua" data="app.lua voicemail"/>
<!--<action application="voicemail" data="default ${domain_name} ${caller_id_number}"/>-->
</condition>
</extension>
</context>

View File

@@ -0,0 +1,14 @@
<context name="{v_context}">
<extension name="send_to_voicemail" number="*99[ext]" continue="false" app_uuid="001d5dab-e0c6-4352-8f06-e9986ee7b0d8">
<condition field="destination_number" expression="^\*99(\d{2,10})$">
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="set" data="voicemail_action=save"/>
<action application="set" data="voicemail_id=$1"/>
<action application="set" data="voicemail_profile=default"/>
<action application="set" data="send_to_voicemail=true" />
<action application="lua" data="app.lua voicemail"/>
<!--<action application="voicemail" data="default ${domain_name} ${dialed_extension}"/>-->
</condition>
</extension>
</context>

View File

@@ -0,0 +1,22 @@
<!-- voicemail main extension, used when * is pressed from an external number -->
<context name="{v_context}">
<extension name="vmain" number="*98" continue="false" app_uuid="d085a1e3-c53a-4480-9ca6-6a362899a681">
<condition field="destination_number" expression="^vmain$|^\*4000$|^\*98$" break="never">
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="set" data="voicemail_action=check"/>
<action application="set" data="voicemail_profile=default"/>
<action application="lua" data="app.lua voicemail"/>
<!--<action application="voicemail" data="check default ${domain_name}"/>-->
</condition>
<condition field="destination_number" expression="^(vmain$|^\*4000$|^\*98)(\d{2,12})$">
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="set" data="voicemail_action=check"/>
<action application="set" data="voicemail_id=$2"/>
<action application="set" data="voicemail_profile=default"/>
<action application="set" data="voicemail_authorized=false"/>
<action application="lua" data="app.lua voicemail"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,11 @@
<context name="{v_context}">
<extension name="xfer_vm" number="xfer_vm" continue="false" app_uuid="44a4b26d-9e13-41dc-8405-7ff2e4a215e0">
<condition field="destination_number" expression="^xfer_vm$">
<action application="read" data="2 6 'tone_stream://%(10000,0,350,440)' digits 30000 #"/>
<action application="set" data="origination_cancel_key=#"/>
<action application="set" data="domain_name=${transfer_context}"/>
<action application="export" data="domain_name=${transfer_context}"/>
<action application="transfer" data="-bleg *99${digits} XML ${transfer_context}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,9 @@
<context name="{v_context}">
<extension name="is_transfer" number="is_transfer" continue="false" app_uuid="da8e22c7-9e07-4ff5-a28b-faf35ba8d411">
<condition field="destination_number" expression="^is_transfer$"/>
<condition field="${digits}" expression="^(\d+)$">
<action application="transfer" data="-aleg ${digits} XML ${context}"/>
<anti-action application="eval" data="cancel transfer"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,14 @@
<!-- voicemail provide user extension -->
<context name="{v_context}">
<extension name="vmain_user" number="*97" continue="false" app_uuid="5d47ab13-f25d-4f62-a68e-2a7d945d05b7">
<condition field="destination_number" expression="^\*97$">
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="set" data="voicemail_action=check"/>
<action application="set" data="voicemail_id=${caller_id_number}"/>
<action application="set" data="voicemail_profile=default"/>
<action application="lua" data="app.lua voicemail"/>
<!--<action application="voicemail" data="check default ${domain_name} ${caller_id_number}"/>-->
</condition>
</extension>
</context>

View File

@@ -0,0 +1,9 @@
<!-- Used to transfer both legs into a conference -->
<context name="{v_context}">
<extension name="cf" number="cf" continue="false" app_uuid="f13df3df-bfb4-4c11-bee1-6548cd983729">
<condition field="destination_number" expression="^cf$">
<action application="answer"/>
<action application="transfer" data="-both 30${dialed_extension:2} XML ${context}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="{v_context}">
<extension name="delay_echo" number="*9195" continue="false" app_uuid="fe638409-b347-46d7-9aca-489561df8b35">
<condition field="destination_number" expression="^\*9195$">
<action application="answer"/>
<action application="delay_echo" data="5000"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="{v_context}">
<extension name="echo" number="*9196" continue="false" app_uuid="1f894dfb-0567-4e20-9026-d538bbaa5261">
<condition field="destination_number" expression="^\*9196$">
<action application="answer"/>
<action application="echo"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,10 @@
<context name="{v_context}">
<extension name="please_hold" number="" continue="true" app_uuid="c3ea29d1-db41-421e-91b7-b0984e50bcae" enabled="false">
<condition field="${user_exists}" expression="^true$">
<action application="set" data="transfer_ringback=$${hold_music}"/>
<action application="answer"/>
<action application="sleep" data="1500"/>
<action application="playback" data="ivr/ivr-hold_connect_call.wav"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,9 @@
<context name="{v_context}">
<extension name="is_zrtp_secure" number="" continue="true" app_uuid="951808c2-b778-404d-bd17-50b5df4b88f4">
<condition field="${zrtp_secure_media_confirmed}" expression="^true$">
<action application="sleep" data="1000"/>
<action application="playback" data="misc/call_secured.wav"/>
<anti-action application="eval" data="not_secure"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="{v_context}">
<extension name="milliwatt" number="*9197" continue="false" app_uuid="296acca3-d30f-42a0-ba90-5af2208ad7f8">
<condition field="destination_number" expression="^\*9197$">
<action application="answer"/>
<action application="playback" data="{loops=-1}tone_stream://%(251,0,1004)"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,11 @@
<!-- Only Truly consider it secure if its TLS and SRTP -->
<context name="{v_context}">
<extension name="is_secure" number="is_secure" continue="true" app_uuid="b57306e0-36df-4048-b182-7ad0f69d8c03">
<condition field="${sip_via_protocol}" expression="tls"/>
<condition field="${sip_secure_media_confirmed}" expression="^true$">
<action application="sleep" data="1000"/>
<action application="playback" data="misc/call_secured.wav"/>
<anti-action application="eval" data="not_secure"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="{v_context}">
<extension name="tone_stream" number="*9198" continue="false" app_uuid="98ccdb0b-c074-4f74-b28a-9528372faa7d">
<condition field="destination_number" expression="^\*9198$">
<action application="answer"/>
<action application="playback" data="{loops=10}tone_stream://path=${base_dir}/conf/tetris.ttml"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,15 @@
<context name="{v_context}">
<extension name="hold_music" number="*9664" continue="false" app_uuid="b824b88a-e6da-486e-9f17-7b93cbaa318e">
<condition field="destination_number" expression="^\*9664$"/>
<condition field="${sip_has_crypto}" expression="^(AES_CM_128_HMAC_SHA1_32|AES_CM_128_HMAC_SHA1_80)$">
<action application="answer"/>
<action application="execute_extension" data="is_secure XML ${context}"/>
<action application="playback" data="$${hold_music}"/>
<anti-action application="set" data="zrtp_secure_media=true"/>
<anti-action application="answer"/>
<anti-action application="playback" data="silence_stream://2000"/>
<anti-action application="execute_extension" data="is_zrtp_secure XML ${context}"/>
<anti-action application="playback" data="$${hold_music}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,11 @@
<context name="{v_context}">
<extension name="recordings" number="*732" continue="false" app_uuid="430737df-5385-42d1-b933-22600d3fb79e">
<condition field="destination_number" expression="^\*(732)$">
<action application="answer"/>
<action application="set" data="pin_number={v_pin_number}"/>
<action application="set" data="recording_slots=true"/>
<action application="set" data="recording_prefix=recording"/>
<action application="lua" data="recordings.lua"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,16 @@
<context name="{v_context}">
<extension name="freeswitch_conference" number="*9888" continue="false" app_uuid="8e3ad78e-4b48-4d36-af7e-4920a9757043" enabled="false">
<condition field="destination_number" expression="^\*9(888|8888|1616|3232)$">
<action application="export" data="hold_music=silence"/>
<!--
This will take the SAS from the b-leg and send it to the display on the a-leg phone.
Known working with Polycom and Snom maybe others.
-->
<!--
<action application="set" data="exec_after_bridge_app=${sched_api(+4 zrtp expand uuid_display ${uuid} \${uuid_getvar(\${uuid_getvar(${uuid} signal_bond)} zrtp_sas1_string )} \${uuid_getvar(\${uuid_getvar(${uuid} signal_bond)} zrtp_sas2_string )} )}"/>
<action application="export" data="nolocal:zrtp_secure_media=true"/>
-->
<action application="bridge" data="sofia/${use_profile}/$1@conference.freeswitch.org"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,10 @@
<context name="{v_context}">
<extension name="disa" number="*3472" continue="false" app_uuid="3ade2d9a-f55d-4240-bb60-b4a3ab36951c" enabled="false">
<condition field="destination_number" expression="^\*(3472)$">
<action application="answer"/>
<action application="set" data="pin_number={v_pin_number}"/>
<action application="set" data="dialplan_context=${context}"/>
<action application="lua" data="disa.lua"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,7 @@
<context name="{v_context}">
<extension name="directory" number="*411" continue="false" app_uuid="a223dc70-28a1-4979-834e-8af813cd8ea6">
<condition field="destination_number" expression="^\*411$">
<action application="lua" data="directory.lua"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,10 @@
<context name="{v_context}">
<extension name="wake-up" number="*925" continue="false" app_uuid="e27abe68-41c0-4188-bb0f-67d93de0c610">
<condition field="destination_number" expression="^\*(925)$">
<action application="answer"/>
<action application="set" data="pin_number={v_pin_number}"/>
<action application="set" data="time_zone_offset=-7"/>
<action application="lua" data="wakeup.lua"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,23 @@
<context name="{v_context}">
<extension name="valet_park" number="park+*5901-*5999" continue="false" app_uuid="3cc8363d-5ce3-48aa-8ac1-143cf297c4f7" enabled="true">
<condition field="destination_number" expression="^(park\+)?(\*59[0-9][0-9])$" break="never"/>
<condition field="${sip_h_Referred-By}" expression="sip:(.*)@.*" break="never">
<action application="set" data="referred_by_user=$1"/>
</condition>
<condition field="destination_number" expression="^(park\+)?(\*59[0-9][0-9])$" break="never">
<action application="set" data="park_in_use=false" inline="true"/>
<action application="set" data="park_lot=$2" inline="true"/>
</condition>
<condition field="destination_number" expression="^(park\+)?(\*59[0-9][0-9])$"/>
<condition field="${cond ${sip_h_Referred-By} == '' ? false : true}" expression="true" break="never">
<action application="set" data="park_in_use=${regex ${valet_info park@${domain_name}}|${park_lot}}" inline="true"/>
</condition>
<condition field="${park_in_use}" expression="true" break="never">
<action application="transfer" data="${referred_by_user} XML ${context}"/>
<anti-action application="set" data="valet_parking_timeout=90"/>
<anti-action application="set" data="valet_hold_music=${hold_music}"/>
<anti-action application="set" data="valet_parking_orbit_exten=${referred_by_user}"/>
<anti-action application="valet_park" data="park@${domain_name} ${park_lot}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,7 @@
<context name="{v_context}">
<extension name="valet_park_in" number="park+*5900" continue="false" app_uuid="c192ee50-084d-40d8-8d9a-6959369382c8" enabled="false">
<condition field="destination_number" expression="^(park\+)?(\*5900)$">
<action application="valet_park" data="park@${domain_name} auto in 5901 5999"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="{v_context}">
<extension name="valet_park_out" number="park+*5901-*5999" continue="false" app_uuid="242130d4-61d6-4daf-9dd1-b139a2b3b166" enabled="false">
<condition field="destination_number" expression="^(park\+)?\*(59[0-9][0-9])$">
<action application="answer"/>
<action application="valet_park" data="park@${domain_name} $2"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,11 @@
<context name="{v_context}">
<extension name="operator" number="0" continue="false" app_uuid="0e1cd2d7-9d84-4959-8b6c-0cb23de4de59">
<condition field="destination_number" expression="^0$|^operator$">
<action application="export" data="transfer_context={v_context}" />
<action application="bind_meta_app" data="4 ab s execute_extension::att_xfer XML ${context}" />
<action application="bind_meta_app" data="5 ab s execute_extension::xfer_vm XML ${context}" />
<action application="set" data="domain_name={v_context}" />
<action application="transfer" data="1001 XML {v_context}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,10 @@
<context name="{v_context}">
<extension name="operator-forward" number="*000" continue="false" app_uuid="a90d3639-3b82-4905-a65d-85f58b6c4a19" enabled="true">
<condition field="destination_number" expression="^\*000$" >
<action application="set" data="dial_string=loopback/operator/{v_context}/XML" />
<action application="set" data="direction=both" />
<action application="set" data="extension=true" />
<action application="lua" data="dial_string.lua" />
</condition>
</extension>
</context>

View File

@@ -0,0 +1,20 @@
<context name="{v_context}">
<extension name="do-not-disturb" number="*77,*78,*79" continue="false" app_uuid="df32d982-e39e-4ae5-a46d-aed1893873f2" enabled="true">
<condition field="destination_number" expression="^\*77$" break="on-true">
<action application="set" data="enabled=toggle"/>
<action application="lua" data="do_not_disturb.lua"/>
</condition>
<condition field="destination_number" expression="^\*78$|\*363$" break="on-true">
<action application="set" data="enabled=true"/>
<action application="lua" data="do_not_disturb.lua"/>
</condition>
<condition field="destination_number" expression="^\*79$" break="on-true">
<action application="set" data="enabled=false"/>
<action application="lua" data="do_not_disturb.lua"/>
</condition>
<condition field="destination_number" expression="^dnd\+${caller_id_number}$" break="on-true">
<action application="set" data="enabled=toggle"/>
<action application="lua" data="do_not_disturb.lua"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,22 @@
<context name="{v_context}">
<extension name="call-forward" number="*72,*73,*74" continue="false" app_uuid="b4b32fb4-0181-4876-9bec-b9dff1299d60" enabled="true">
<condition field="destination_number" expression="^\*72$" break="on-true">
<action application="set" data="enabled=true"/>
<action application="lua" data="call_forward.lua"/>
</condition>
<condition field="destination_number" expression="^\*73$" break="on-true">
<action application="set" data="enabled=false"/>
<action application="lua" data="call_forward.lua"/>
</condition>
<condition field="destination_number" expression="^\*74$" break="on-true">
<action application="set" data="request_id=true"/>
<action application="set" data="enabled=toggle"/>
<action application="lua" data="call_forward.lua"/>
</condition>
<condition field="destination_number" expression="^forward\+(\Q${caller_id_number}\E)(?:\/(\d+))?$" break="on-true">
<action application="set" data="enabled=toggle"/>
<action application="set" data="forward_all_destination=$2"/>
<action application="lua" data="call_forward.lua"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="${domain_name}">
<extension name="call forward all" number="" app_uuid="57cf8f1f-9a2e-4996-bd80-d9300249b1ca" global="true">
<condition field="${user_exists}" expression="^true"/>
<condition field="${forward_all_enabled}" expression="^true">
<action application="transfer" data="${forward_all_destination} XML ${domain_name}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="{v_context}">
<extension name="follow-me" number="*21" continue="false" app_uuid="b8c28c75-1a03-4dad-9a53-980ca5f487f0" enabled="true">
<condition field="destination_number" expression="^\*21$">
<action application="answer"/>
<action application="lua" data="follow_me.lua"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,9 @@
<context name="{v_context}">
<extension name="clear_sip_auto_answer" app_uuid="90c51470-dc31-11e3-9c1a-0800200c9a66" continue="true" >
<condition field="${click_to_call}" expression="true" />
<condition field="${sip_h_Call-Info}" expression="answer-after=0" >
<action application="unset" data="sip_h_Call-Info" />
</condition>
</extension>
</context>

View File

@@ -0,0 +1,10 @@
<context name="${domain_name}">
<extension name="talking clock date and time" number="*9172" app_uuid="3ce3d9a1-c7bd-45f6-a81f-37f526b4fe73" global="true">
<condition field="destination_number" expression="^\*9172$">
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="say" data="${default_language} CURRENT_DATE_TIME pronounced ${strepoch()}"/>
<action application="hangup"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,10 @@
<context name="${domain_name}">
<extension name="talking clock time" number="*9170" app_uuid="ce1786ff-1965-4c18-998a-27a381623534" global="true">
<condition field="destination_number" expression="^\*9170$">
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="say" data="${default_language} CURRENT_TIME pronounced ${strepoch()}"/>
<action application="hangup"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,10 @@
<context name="${domain_name}">
<extension name="talking clock date" number="*9171" app_uuid="780e174b-a645-478e-b53c-0eb08b9a043c" global="true">
<condition field="destination_number" expression="^\*9171$">
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="say" data="${default_language} CURRENT_DATE pronounced ${strepoch()}"/>
<action application="hangup"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,14 @@
<context name="{v_context}">
<extension name="extension_queue" continue="false" app_uuid="854df474-bf40-419e-9ba7-3bd27a52d98a" enabled="false">
<condition field="${user_exists}" expression="^true$">
<action application="answer" data=""/>
<action application="set" data="fifo_simo=1"/>
<action application="set" data="fifo_timeout=1"/>
<action application="set" data="fifo_lag=1"/>
<action application="set" data="fifo_destroy_after_use=true"/>
<action application="set" data="fifo_music=local_stream://default"/>
<action application="set" data="result=${fifo_member(add ${destination_number}@${domain_name} {fifo_member_wait=nowait}user/${destination_number}@${domain_name}"/>
<action application="fifo" data="${destination_number}@${domain_name} in"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,7 @@
<context name="{v_context}">
<extension name="nway_conference" number="nway" continue="false" app_uuid="20617852-b069-4ace-9137-3d6a16588f6f" enabled="false">
<condition field="destination_number" expression="^nway">
<action application="conference" data="${destination_number}@${domain_name}+flags{mintwo}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,19 @@
<context name="{v_context}">
<extension name="bind_digit_action" number="" continue="true" app_uuid="7e007a4d-886b-4cdf-81f4-da9eb4689f1c" enabled="false">
<condition field="${sip_authorized}" expression="true" break="never">
<action application="set" data="bind_target=both" inline="true"/>
<!-- set to peer to prevent manipulate of call by caller -->
<anti-action application="set" data="bind_target=peer" inline="true"/>
</condition>
<condition>
<!-- <action application="export" data="conf_xfer_number=xfer-${create_uuid foo}-${domain_name}"/>-->
<action application="bind_digit_action" data="local,*1,exec:execute_extension,dx XML ${context},${bind_target}"/>
<action application="bind_digit_action" data="local,*2,exec:record_session,$${recordings_dir}/${domain_name}/archive/${strftime(%Y)}/${strftime(%b)}/${strftime(%d)}/${uuid}.${record_ext},${bind_target}"/>
<action application="bind_digit_action" data="local,*3,exec:execute_extension,cf XML ${context},${bind_target}"/>
<action application="bind_digit_action" data="local,*4,exec:execute_extension,att_xfer XML ${context},${bind_target}"/>
<!-- <action application="bind_digit_action" data="local,*0,exec:execute_extension,conf_xfer_from_dialplan XML conf-xfer@${domain_name},${bind_target}"/> -->
<action application="digit_action_set_realm" data="local"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,9 @@
<context name="{v_context}">
<extension name="cidlookup" number="" continue="true" app_uuid="a0cb498c-6e09-441f-83ea-a7684565c44e" enabled="false">
<condition field="${user_exists}" expression="^true$"/>
<condition field="${call_direction}" expression="^inbound$">
<condition field="${module_exists(mod_cidlookup)}" expression="^true$"/>
<action application="set" data="effective_caller_id_name=${cidlookup(${caller_id_number})}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,17 @@
<context name="{v_context}">
<extension name="call_screen" number="[ext]" continue="true" app_uuid="b26a08a5-a062-42ca-b90f-d47f905dd876">
<condition field="${call_screen_enabled}" expression="^true$"/>
<condition field="${call_direction}" expression="^inbound$">
<action application="set" data="call_screen_file=/tmp/${domain_name}-${caller_id_number}.${record_ext}"/>
<action application="answer"/>
<action application="sleep" data="1000"/>
<action application="phrase" data="voicemail_record_name"/>
<action application="playback" data="tone_stream://%(500, 0, 640)"/>
<action application="set" data="playback_terminators=#*0123456789"/>
<action application="record" data="${call_screen_file} 7 200 2"/>
<action application="set" data="group_confirm_key=1"/>
<action application="set" data="fail_on_single_reject=true"/>
<action application="set" data="group_confirm_file=phrase:screen_confirm:${call_screen_file}"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,30 @@
<context name="{v_context}">
<extension name="local_extension" number="[ext]" continue="true" app_uuid="71cf1310-b6e3-415b-8745-3cbdc8e15212">
<condition field="${user_exists}" expression="true">
<!--<action application="pre_answer"/>-->
<action application="export" data="dialed_extension=${destination_number}" inline="true"/>
<action application="limit" data="hash ${domain_name} ${destination_number} ${limit_max} ${limit_destination}" inline="false" />
</condition>
<condition>
<!--<action application="set" data="ringback=${ringback}"/>-->
<action application="set" data="hangup_after_bridge=true"/>
<!--<action application="set" data="continue_on_fail=NORMAL_TEMPORARY_FAILURE,USER_BUSY,NO_ANSWER,TIMEOUT,NO_ROUTE_DESTINATION"/> -->
<action application="set" data="continue_on_fail=true"/>
<action application="hash" data="insert/${domain_name}-call_return/${dialed_extension}/${caller_id_number}"/>
<action application="hash" data="insert/${domain_name}-last_dial_ext/${dialed_extension}/${uuid}"/>
<action application="set" data="called_party_call_group=${user_data(${dialed_extension}@${domain_name} var call_group)}"/>
<!--<action application="export" data="nolocal:sip_secure_media=${user_data(${dialed_extension}@${domain_name} var sip_secure_media)}"/>-->
<action application="hash" data="insert/${domain_name}-last_dial/${called_party_call_group}/${uuid}"/>
<action application="set" data="api_hangup_hook=lua app.lua hangup"/>
<action application="export" data="domain_name=${domain_name}"/>
<!-- standard method -->
<action application="bridge" data="user/${destination_number}@${domain_name}"/>
<!-- sofia contact -->
<!--<action application="bridge" data="${sofia_contact(${dialed_extension}@${domain_name})}"/>-->
<!-- number-alias / https://confluence.freeswitch.org/display/FREESWITCH/XML+User+Directory -->
<!--<action application="bridge" data="user/${user_data(${destination_number}@${domain_name} attr id)}@${domain_name}"/> -->
<!-- handles bridge failures before answer -->
<action application="lua" data="app.lua failure_handler"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,13 @@
<context name="{v_context}">
<extension name="voicemail" number="[ext]" continue="false" app_uuid="e3c14f2f-7697-4b5d-9c62-2443c0e22bf2">
<condition field="${user_exists}" expression="true">
<action application="answer"/>
<action application="sleep" data="1000"/>
<!--<action application="voicemail" data="default ${domain_name} ${dialed_extension}"/>-->
<action application="set" data="voicemail_action=save"/>
<action application="set" data="voicemail_id=${destination_number}"/>
<action application="set" data="voicemail_profile=default"/>
<action application="lua" data="app.lua voicemail"/>
</condition>
</extension>
</context>

View File

@@ -0,0 +1,8 @@
<context name="public">
<extension name="not-found" continue="false" app_uuid="23d198e5-7a8e-4af7-b573-2d166c1c24ff" global="true">
<condition field="" expression="">
<action application="set" data="call_direction=inbound" inline="true"/>
<action application="log" data="[inbound routes] 404 not found ${sip_network_ip}"/>
</condition>
</extension>
</context>

90
app/dialplans/root.php Normal file
View File

@@ -0,0 +1,90 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
// make sure the PATH_SEPARATOR is defined
umask(2);
if (!defined("PATH_SEPARATOR")) {
if (strpos($_ENV["OS"], "Win") !== false) {
define("PATH_SEPARATOR", ";");
} else {
define("PATH_SEPARATOR", ":");
}
}
if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
// make sure the document_root is set
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
if(PHP_SAPI == 'cli'){
chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
if (file_exists('/project_root.php')) {
$path = '/';
} else {
$i = 1;
$path = '';
while ($i < count($dirs)) {
$path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) {
break;
}
$i++;
}
}
$_SERVER["DOCUMENT_ROOT"] = $path;
}else{
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
}
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
// try to detect if a project path is being used
if (!defined('PROJECT_PATH')) {
if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) {
define('PROJECT_PATH', '/fusionpbx');
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) {
define('PROJECT_PATH', '');
} else {
$dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME)));
$i = 1;
$path = $_SERVER["DOCUMENT_ROOT"];
while ($i < count($dirs)) {
$path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) {
break;
}
$i++;
}
if(!file_exists($path. '/project_root.php')){
die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance");
}
$project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path);
define('PROJECT_PATH', $project_path);
}
$_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
}
?>