Update domain_delete.php

Fix the domain delete.
This commit is contained in:
FusionPBX 2017-03-14 14:56:23 -06:00 committed by GitHub
parent e3fa90adec
commit d5fe9ba23b
1 changed files with 72 additions and 66 deletions

View File

@ -23,16 +23,20 @@
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('domain_delete')) {
//includes
require_once "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
//check permissions
if (permission_exists('domain_delete')) {
//access granted
}
else {
}
else {
echo "access denied";
exit;
}
}
//add multi-lingual support
$language = new text;
@ -43,6 +47,7 @@ else {
$id = check_str($_GET["id"]);
}
//delete domain data and files
if (strlen($id) > 0) {
//get the domain using the id
$sql = "select * from v_domains ";
@ -96,7 +101,7 @@ if (strlen($id) > 0) {
$db->beginTransaction();
if (isset($apps)) foreach ($apps as &$app) {
if (isset($app['db'])) foreach ($app['db'] as $row) {
$table_name = $row['table'];
$table_name = $row['table']['name'];
if (isset($row['fields'])) foreach ($row['fields'] as $field) {
if ($field['name'] == "domain_uuid") {
$sql = "delete from $table_name where domain_uuid = '$id' ";
@ -107,6 +112,7 @@ if (strlen($id) > 0) {
}
$db->commit();
//delete the directories
if (strlen($domain_name) > 0) {
//set the needle
if (count($_SESSION["domains"]) > 1) {
@ -194,7 +200,7 @@ if (strlen($id) > 0) {
unset($_SESSION["domain_name"]);
unset($_SESSION['domain']);
unset($_SESSION['switch']);
}
}
//redirect the browser
$_SESSION["message"] = $text['message-delete'];