Update domain_delete.php

This commit is contained in:
FusionPBX 2019-02-27 12:43:05 -07:00 committed by GitHub
parent a43c92195e
commit 7cf3dfae76
1 changed files with 121 additions and 115 deletions

View File

@ -17,7 +17,7 @@
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
Portions created by the Initial Developer are Copyright (C) 2008-2019
the Initial Developer. All Rights Reserved.
Contributor(s):
@ -43,21 +43,23 @@
$text = $language->get();
//get the id
if (count($_GET)>0) {
if (is_array($_GET)) {
$id = check_str($_GET["id"]);
}
//delete domain data and files
if (strlen($id) > 0) {
if (is_uuid($id)) {
//get the domain using the id
$sql = "select * from v_domains ";
$sql .= "where domain_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (isset($result)) foreach ($result as &$row) {
if (isset($result)) {
foreach ($result as &$row) {
$domain_name = $row["domain_name"];
}
}
unset ($prep_statement);
//get the domain settings
@ -101,16 +103,20 @@ if (strlen($id) > 0) {
$db->beginTransaction();
if (isset($apps)) foreach ($apps as &$app) {
if (isset($app['db'])) foreach ($app['db'] as $row) {
if (is_array($row['table'])) {
$table_name = $row['table']['name'];
if (is_array($row['table']['name'])) {
$table_name = $row['table']['name']['text'];
echo "<pre>";
print_r($table_name);
echo "<pre>\n";
}
else {
$table_name = $row['table'];
$table_name = $row['table']['name'];
}
if ($table_name !== "v" && isset($row['fields'])) {
foreach ($row['fields'] as $field) {
if ($field['name'] == "domain_uuid") {
$sql = "delete from $table_name where domain_uuid = '$id' ";
$sql = "delete from $table_name where domain_uuid = '$id'; ";
//echo $sql."<br />\n";
$db->query($sql);
}
}