2012-06-04 16:58:40 +02:00
|
|
|
<?php
|
2012-10-23 12:00:03 +02:00
|
|
|
/*
|
|
|
|
|
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>
|
2017-04-05 07:32:10 +02:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2017
|
2012-10-23 12:00:03 +02:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
2016-10-23 07:14:28 +02:00
|
|
|
|
|
|
|
|
//includes
|
|
|
|
|
require_once "root.php";
|
|
|
|
|
require_once "resources/require.php";
|
|
|
|
|
require_once "resources/check_auth.php";
|
|
|
|
|
|
|
|
|
|
//check permissions
|
|
|
|
|
if (permission_exists('destination_delete')) {
|
|
|
|
|
//access granted
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2013-05-08 01:38:12 +02:00
|
|
|
//add multi-lingual support
|
2015-01-18 11:06:08 +01:00
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
2013-05-08 01:38:12 +02:00
|
|
|
|
2014-04-24 11:32:36 +02:00
|
|
|
//get the ID
|
2017-04-05 07:32:10 +02:00
|
|
|
if (is_array($_GET)) {
|
2014-04-24 11:32:36 +02:00
|
|
|
$id = check_str($_GET["id"]);
|
|
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2014-04-24 11:39:27 +02:00
|
|
|
//if the ID is not set then exit
|
2017-04-05 07:32:10 +02:00
|
|
|
if (!is_uuid($id)) {
|
2014-04-24 11:35:37 +02:00
|
|
|
echo "ID is required.";
|
2014-04-24 11:32:36 +02:00
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-30 01:22:36 +02:00
|
|
|
//add the dialplan permission
|
|
|
|
|
$permission = "dialplan_delete";
|
|
|
|
|
$p = new permissions;
|
|
|
|
|
$p->add($permission, 'temp');
|
|
|
|
|
|
2016-10-23 07:14:28 +02:00
|
|
|
//get the dialplan uuid and context
|
|
|
|
|
$sql = "select * from v_destinations ";
|
|
|
|
|
$sql .= "where destination_uuid = '$id' ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
2014-04-24 11:35:37 +02:00
|
|
|
foreach ($result as &$row) {
|
2015-03-31 04:53:36 +02:00
|
|
|
if (permission_exists('destination_domain')) {
|
|
|
|
|
$domain_uuid = $row["domain_uuid"];
|
|
|
|
|
}
|
2014-04-24 11:35:37 +02:00
|
|
|
$dialplan_uuid = $row["dialplan_uuid"];
|
2014-04-25 04:56:41 +02:00
|
|
|
$destination_context = $row["destination_context"];
|
2014-04-24 11:35:37 +02:00
|
|
|
}
|
|
|
|
|
unset ($prep_statement);
|
2015-04-30 01:22:36 +02:00
|
|
|
|
|
|
|
|
//remove the temporary permission
|
|
|
|
|
$p->delete($permission, 'temp');
|
2014-04-24 11:32:36 +02:00
|
|
|
|
2014-04-25 05:04:24 +02:00
|
|
|
//start the atomic transaction
|
2014-04-25 07:52:00 +02:00
|
|
|
$db->beginTransaction();
|
2014-04-25 05:04:24 +02:00
|
|
|
|
2014-04-24 11:32:36 +02:00
|
|
|
//delete the dialplan
|
|
|
|
|
if (isset($dialplan_uuid)) {
|
|
|
|
|
$sql = "delete from v_dialplan_details ";
|
2017-04-05 07:32:10 +02:00
|
|
|
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
|
|
|
|
//echo $sql."<br />\n";
|
2014-04-24 11:32:36 +02:00
|
|
|
$db->exec(check_sql($sql));
|
|
|
|
|
unset($sql);
|
|
|
|
|
|
2014-04-25 07:52:00 +02:00
|
|
|
$sql = "delete from v_dialplans ";
|
2017-04-05 07:32:10 +02:00
|
|
|
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
|
|
|
|
//echo $sql."<br />\n";
|
2014-04-24 11:32:36 +02:00
|
|
|
$db->exec(check_sql($sql));
|
2012-10-23 12:00:03 +02:00
|
|
|
unset($sql);
|
2014-04-25 07:52:00 +02:00
|
|
|
}
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2014-04-24 11:32:36 +02:00
|
|
|
//delete the destination
|
|
|
|
|
$sql = "delete from v_destinations ";
|
2017-04-05 07:32:10 +02:00
|
|
|
$sql .= "where destination_uuid = '".$id."' ";
|
|
|
|
|
echo $sql."<br />\n";
|
2014-04-24 11:32:36 +02:00
|
|
|
$db->exec(check_sql($sql));
|
|
|
|
|
unset($sql);
|
|
|
|
|
|
2014-04-25 05:04:24 +02:00
|
|
|
//commit the atomic transaction
|
2014-04-25 07:52:00 +02:00
|
|
|
$db->commit();
|
2014-04-25 05:04:24 +02:00
|
|
|
|
2014-04-25 04:56:41 +02:00
|
|
|
//synchronize the xml config
|
|
|
|
|
save_dialplan_xml();
|
|
|
|
|
|
2015-01-16 01:21:02 +01:00
|
|
|
//clear the cache
|
|
|
|
|
$cache = new cache;
|
|
|
|
|
$cache->delete("dialplan:".$destination_context);
|
2014-04-25 04:56:41 +02:00
|
|
|
|
2014-04-24 11:32:36 +02:00
|
|
|
//redirect the user
|
2017-06-10 04:13:40 +02:00
|
|
|
messages::add($text['message-delete']);
|
2014-04-24 11:32:36 +02:00
|
|
|
header("Location: destinations.php");
|
|
|
|
|
return;
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2016-10-23 07:14:28 +02:00
|
|
|
?>
|