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