2012-06-04 16:58:40 +02:00
|
|
|
<?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>
|
2019-02-06 02:33:50 +01:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2019
|
2012-06-04 16:58:40 +02:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
2016-10-03 00:31:44 +02:00
|
|
|
|
2022-10-11 00:35:14 +02:00
|
|
|
//includes files
|
2023-06-15 19:28:23 +02:00
|
|
|
require_once dirname(__DIR__, 2) . "/resources/require.php";
|
2016-10-03 00:31:44 +02:00
|
|
|
require_once "resources/check_auth.php";
|
|
|
|
|
require_once "resources/paging.php";
|
|
|
|
|
|
|
|
|
|
//check permissions
|
|
|
|
|
if (permission_exists('ivr_menu_edit')) {
|
|
|
|
|
//access granted
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2013-01-16 07:38:45 +01:00
|
|
|
//add multi-lingual support
|
2015-01-18 11:06:08 +01:00
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
2013-01-16 07:38:45 +01:00
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//set the http get/post variable(s) to a php variable
|
2019-08-09 15:06:59 +02:00
|
|
|
$ivr_menu_uuid = $_GET["id"];
|
|
|
|
|
|
|
|
|
|
if (is_uuid($ivr_menu_uuid)) {
|
|
|
|
|
|
|
|
|
|
//get the ivr_menus data
|
|
|
|
|
$sql = "select * from v_ivr_menus ";
|
|
|
|
|
$sql .= "where ivr_menu_uuid = :ivr_menu_uuid ";
|
|
|
|
|
$sql .= "and domain_uuid = :domain_uuid ";
|
|
|
|
|
$parameters['ivr_menu_uuid'] = $ivr_menu_uuid;
|
|
|
|
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
|
|
|
$database = new database;
|
|
|
|
|
$ivr_menus = $database->select($sql, $parameters, 'all');
|
|
|
|
|
if (!is_array($ivr_menus)) {
|
2020-10-22 10:57:57 +02:00
|
|
|
echo "access denied";
|
2019-08-09 15:06:59 +02:00
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
unset($sql, $parameters);
|
|
|
|
|
|
|
|
|
|
//get the the ivr menu options
|
|
|
|
|
$sql = "select * from v_ivr_menu_options ";
|
|
|
|
|
$sql .= "where ivr_menu_uuid = :ivr_menu_uuid ";
|
|
|
|
|
$sql .= "and domain_uuid = :domain_uuid ";
|
|
|
|
|
$sql .= "order by ivr_menu_uuid asc ";
|
|
|
|
|
$parameters['ivr_menu_uuid'] = $ivr_menu_uuid;
|
|
|
|
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
|
|
|
|
$database = new database;
|
|
|
|
|
$ivr_menu_options = $database->select($sql, $parameters, 'all');
|
|
|
|
|
unset($sql, $parameters);
|
|
|
|
|
|
|
|
|
|
//create the uuids
|
|
|
|
|
$ivr_menu_uuid = uuid();
|
|
|
|
|
$dialplan_uuid = uuid();
|
|
|
|
|
|
|
|
|
|
//set the row id
|
|
|
|
|
$x = 0;
|
|
|
|
|
|
|
|
|
|
//set the variables
|
|
|
|
|
$ivr_menu_name = $ivr_menus[$x]['ivr_menu_name'];
|
|
|
|
|
$ivr_menu_extension = $ivr_menus[$x]['ivr_menu_extension'];
|
|
|
|
|
$ivr_menu_ringback = $ivr_menus[$x]['ivr_menu_ringback'];
|
2020-12-01 20:25:25 +01:00
|
|
|
$ivr_menu_language = $ivr_menus[$x]['ivr_menu_language'];
|
|
|
|
|
$ivr_menu_dialect = $ivr_menus[$x]['ivr_menu_dialect'];
|
|
|
|
|
$ivr_menu_voice = $ivr_menus[$x]['ivr_menu_voice'];
|
|
|
|
|
$ivr_menu_cid_prefix = $ivr_menus[$x]['ivr_menu_cid_prefix'];
|
2020-10-22 10:57:57 +02:00
|
|
|
$ivr_menu_context = $ivr_menus[$x]['ivr_menu_context'];
|
2019-08-09 15:06:59 +02:00
|
|
|
$ivr_menu_description = $ivr_menus[$x]['ivr_menu_description'].' ('.$text['label-copy'].')';
|
|
|
|
|
|
|
|
|
|
//prepare the ivr menu array
|
|
|
|
|
$ivr_menus[$x]['ivr_menu_uuid'] = $ivr_menu_uuid;
|
|
|
|
|
$ivr_menus[$x]['dialplan_uuid'] = $dialplan_uuid;
|
|
|
|
|
$ivr_menus[$x]['ivr_menu_name'] = $ivr_menu_name;
|
|
|
|
|
$ivr_menus[$x]['ivr_menu_description'] = $ivr_menu_description;
|
|
|
|
|
|
|
|
|
|
//get the the ivr menu options
|
|
|
|
|
$y = 0;
|
2024-08-22 20:41:10 +02:00
|
|
|
foreach ($ivr_menu_options as $row) {
|
2019-08-09 15:06:59 +02:00
|
|
|
//update the uuids
|
|
|
|
|
$row['ivr_menu_uuid'] = $ivr_menu_uuid;
|
|
|
|
|
$row['ivr_menu_option_uuid'] = uuid();
|
|
|
|
|
//add the row to the array
|
|
|
|
|
$ivr_menus[$x]["ivr_menu_options"][$y] = $row;
|
|
|
|
|
//increment the ivr menu option row id
|
|
|
|
|
$y++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//build the xml dialplan
|
2023-03-30 20:46:36 +02:00
|
|
|
$dialplan_xml = "<extension name=\"".xml::sanitize($ivr_menu_name)."\" continue=\"\" uuid=\"".xml::sanitize($dialplan_uuid)."\">\n";
|
|
|
|
|
$dialplan_xml .= " <condition field=\"destination_number\" expression=\"^".xml::sanitize($ivr_menu_extension)."\">\n";
|
2020-12-01 20:25:25 +01:00
|
|
|
$dialplan_xml .= " <action application=\"ring_ready\" data=\"\"/>\n";
|
2019-08-09 15:06:59 +02:00
|
|
|
$dialplan_xml .= " <action application=\"answer\" data=\"\"/>\n";
|
|
|
|
|
$dialplan_xml .= " <action application=\"sleep\" data=\"1000\"/>\n";
|
|
|
|
|
$dialplan_xml .= " <action application=\"set\" data=\"hangup_after_bridge=true\"/>\n";
|
2023-03-30 20:46:36 +02:00
|
|
|
$dialplan_xml .= " <action application=\"set\" data=\"ringback=".xml::sanitize($ivr_menu_ringback)."\"/>\n";
|
|
|
|
|
$dialplan_xml .= " <action application=\"set\" data=\"transfer_ringback=".xml::sanitize($ivr_menu_ringback)."\"/>\n";
|
|
|
|
|
$dialplan_xml .= " <action application=\"set\" data=\"presence_id=".xml::sanitize($ivr_menu_extension)."@".$_SESSION['domain_name']."\"/>\n";
|
2023-05-05 18:46:37 +02:00
|
|
|
if (!empty($ivr_menu_language)) {
|
2023-03-30 20:46:36 +02:00
|
|
|
$dialplan_xml .= " <action application=\"set\" data=\"default_language=".xml::sanitize($ivr_menu_language)."\" inline=\"true\"/>\n";
|
|
|
|
|
$dialplan_xml .= " <action application=\"set\" data=\"default_dialect=".xml::sanitize($ivr_menu_dialect)."\" inline=\"true\"/>\n";
|
|
|
|
|
$dialplan_xml .= " <action application=\"set\" data=\"default_voice=".xml::sanitize($ivr_menu_voice)."\" inline=\"true\"/>\n";
|
2020-12-01 20:25:25 +01:00
|
|
|
}
|
2023-03-30 20:46:36 +02:00
|
|
|
$dialplan_xml .= " <action application=\"set\" data=\"ivr_menu_uuid=".xml::sanitize($ivr_menu_uuid)."\"/>\n";
|
2023-05-05 18:46:37 +02:00
|
|
|
if (!empty($ivr_menu_cid_prefix)) {
|
2023-03-30 20:46:36 +02:00
|
|
|
$dialplan_xml .= " <action application=\"set\" data=\"caller_id_name=".xml::sanitize($ivr_menu_cid_prefix)."#\${caller_id_name}\"/>\n";
|
2020-12-01 20:25:25 +01:00
|
|
|
$dialplan_xml .= " <action application=\"set\" data=\"effective_caller_id_name=\${caller_id_name}\"/>\n";
|
|
|
|
|
}
|
2023-03-30 20:46:36 +02:00
|
|
|
$dialplan_xml .= " <action application=\"ivr\" data=\"".xml::sanitize($ivr_menu_uuid)."\"/>\n";
|
2019-08-09 15:06:59 +02:00
|
|
|
$dialplan_xml .= " <action application=\"hangup\" data=\"\"/>\n";
|
|
|
|
|
$dialplan_xml .= " </condition>\n";
|
|
|
|
|
$dialplan_xml .= "</extension>\n";
|
|
|
|
|
|
|
|
|
|
//build the dialplan array
|
|
|
|
|
$dialplan[$x]["domain_uuid"] = $_SESSION['domain_uuid'];
|
|
|
|
|
$dialplan[$x]["dialplan_uuid"] = $dialplan_uuid;
|
|
|
|
|
$dialplan[$x]["dialplan_name"] = $ivr_menu_name;
|
|
|
|
|
$dialplan[$x]["dialplan_number"] = $ivr_menu_extension;
|
2020-10-22 10:57:57 +02:00
|
|
|
$dialplan[$x]["dialplan_context"] = $ivr_menu_context;
|
2019-08-09 15:06:59 +02:00
|
|
|
$dialplan[$x]["dialplan_continue"] = "false";
|
|
|
|
|
$dialplan[$x]["dialplan_xml"] = $dialplan_xml;
|
|
|
|
|
$dialplan[$x]["dialplan_order"] = "101";
|
|
|
|
|
$dialplan[$x]["dialplan_enabled"] = "true";
|
|
|
|
|
$dialplan[$x]["dialplan_description"] = $ivr_menu_description;
|
|
|
|
|
$dialplan[$x]["app_uuid"] = "a5788e9b-58bc-bd1b-df59-fff5d51253ab";
|
|
|
|
|
|
|
|
|
|
//prepare the array
|
|
|
|
|
$array['ivr_menus'] = $ivr_menus;
|
|
|
|
|
$array['dialplans'] = $dialplan;
|
|
|
|
|
|
|
|
|
|
//add the dialplan permission
|
2024-11-29 21:57:01 +01:00
|
|
|
$p = permissions::new();
|
2019-08-09 15:06:59 +02:00
|
|
|
$p->add("dialplan_add", "temp");
|
|
|
|
|
$p->add("dialplan_edit", "temp");
|
|
|
|
|
|
|
|
|
|
//save the array to the database
|
|
|
|
|
$database = new database;
|
|
|
|
|
$database->app_name = 'ivr_menus';
|
|
|
|
|
$database->app_uuid = 'a5788e9b-58bc-bd1b-df59-fff5d51253ab';
|
|
|
|
|
if (is_uuid($ivr_menu_uuid)) {
|
|
|
|
|
$database->uuid($ivr_menu_uuid);
|
|
|
|
|
}
|
|
|
|
|
$database->save($array);
|
|
|
|
|
$message = $database->message;
|
|
|
|
|
|
|
|
|
|
//remove the temporary permission
|
|
|
|
|
$p->delete("dialplan_add", "temp");
|
|
|
|
|
$p->delete("dialplan_edit", "temp");
|
|
|
|
|
|
|
|
|
|
//clear the cache
|
|
|
|
|
$cache = new cache;
|
2020-10-22 10:57:57 +02:00
|
|
|
$cache->delete("dialplan:".$ivr_menu_context);
|
2019-08-09 15:06:59 +02:00
|
|
|
|
|
|
|
|
//set message
|
|
|
|
|
message::add($text['message-copy']);
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2013-09-28 22:57:57 +02:00
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//redirect the user
|
2014-02-23 08:33:53 +01:00
|
|
|
header("Location: ivr_menus.php");
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2016-10-03 00:31:44 +02:00
|
|
|
?>
|