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
+14 -8
View File
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> 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. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
@@ -43,21 +43,23 @@
$text = $language->get(); $text = $language->get();
//get the id //get the id
if (count($_GET)>0) { if (is_array($_GET)) {
$id = check_str($_GET["id"]); $id = check_str($_GET["id"]);
} }
//delete domain data and files //delete domain data and files
if (strlen($id) > 0) { if (is_uuid($id)) {
//get the domain using the id //get the domain using the id
$sql = "select * from v_domains "; $sql = "select * from v_domains ";
$sql .= "where domain_uuid = '$id' "; $sql .= "where domain_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $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"]; $domain_name = $row["domain_name"];
} }
}
unset ($prep_statement); unset ($prep_statement);
//get the domain settings //get the domain settings
@@ -101,16 +103,20 @@ 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) {
if (is_array($row['table'])) { if (is_array($row['table']['name'])) {
$table_name = $row['table']['name']; $table_name = $row['table']['name']['text'];
echo "<pre>";
print_r($table_name);
echo "<pre>\n";
} }
else { else {
$table_name = $row['table']; $table_name = $row['table']['name'];
} }
if ($table_name !== "v" && isset($row['fields'])) { if ($table_name !== "v" && isset($row['fields'])) {
foreach ($row['fields'] as $field) { 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'; ";
//echo $sql."<br />\n";
$db->query($sql); $db->query($sql);
} }
} }