Update ring_group_delete.php

This commit is contained in:
FusionPBX 2019-05-08 08:50:19 -06:00 committed by GitHub
parent a4834e391b
commit 1d163db6c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 34 additions and 46 deletions

View File

@ -43,59 +43,47 @@
$text = $language->get(); $text = $language->get();
//get the http value and set it as a php variable //get the http value and set it as a php variable
if (count($_GET)>0) { if (is_array($_GET)) {
$id = check_str($_GET["id"]); $id = $_GET["id"];
} }
//delete the user data //delete the user data
if (strlen($id)>0) { if (is_uuid($id)) {
//get the dialplan
$sql = "select dialplan_uuid from v_ring_groups "; //get the dialplan_uuid
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql = "select * from v_ring_groups ";
$sql .= "and ring_group_uuid = '".$id."' "; $sql .= "where domain_uuid = :domain_uuid ";
$prep_statement = $db->prepare(check_sql($sql)); $sql .= "and ring_group_uuid = :ring_group_uuid ";
$prep_statement->execute(); $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
$result = $prep_statement->fetchAll(); $parameters['ring_group_uuid'] = $id;
foreach ($result as &$row) { $database = new database;
$dialplan_uuid = $row["dialplan_uuid"]; $result = $database->select($sql, $parameters);
$ring_group_context = $row["ring_group_context"]; if (is_array($result)) {
foreach ($result as &$row) {
$dialplan_uuid = $row["dialplan_uuid"];
$ring_group_context = $row["ring_group_context"];
}
} }
unset ($prep_statement); unset($database, $sql, $parameters);
//delete the ring group //add the dialplan permission
$sql = "delete from v_ring_groups "; $p = new permissions;
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $p->add('dialplan_delete', 'temp');
$sql .= "and ring_group_uuid = '".$id."' ";
$db->exec(check_sql($sql));
unset($sql);
//delete the ring group destinations //delete the data
$sql = "delete from v_ring_group_destinations "; $array['dialplan_details'][]['dialplan_uuid'] = $dialplan_uuid;
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $array['dialplans'][]['dialplan_uuid'] = $dialplan_uuid;
$sql .= "and ring_group_uuid = '".$id."' "; $array['ring_group_destinations'][]['ring_group_uuid'] = $id;
$db->exec(check_sql($sql)); $array['ring_group_users'][]['ring_group_uuid'] = $id;
unset($sql); $array['ring_groups'][]['ring_group_uuid'] = $id;
$database = new database;
$database->app_name = 'ring_groups';
$database->app_uuid = '1d61fb65-1eec-bc73-a6ee-a6203b4fe6f2';
$database->delete($array);
$message = $database->message;
//delete the ring group users //remove the temporary permission
$sql = "delete from v_ring_group_users "; $p->delete('dialplan_delete', 'temp');
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and ring_group_uuid = '".$id."' ";
$db->exec(check_sql($sql));
unset($sql);
//delete the dialplan details
$sql = "delete from v_dialplan_details ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and dialplan_uuid = '".$dialplan_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
//delete the dialplan
$sql = "delete from v_dialplans ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and dialplan_uuid = '".$dialplan_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
//save the xml //save the xml
save_dialplan_xml(); save_dialplan_xml();