Update destinations.php

This commit is contained in:
FusionPBX 2019-05-05 19:34:56 -06:00 committed by GitHub
parent d8d98989b8
commit cd5dd78c25
1 changed files with 34 additions and 24 deletions

View File

@ -479,7 +479,7 @@ class destinations {
} }
/** /**
* delete destinations * delete destinations and related dialplan
*/ */
public function delete($destinations) { public function delete($destinations) {
if (permission_exists('destination_delete')) { if (permission_exists('destination_delete')) {
@ -496,36 +496,46 @@ class destinations {
//delete the checked rows //delete the checked rows
if ($action == 'delete') { if ($action == 'delete') {
//add the dialplan permission
$p = new permissions;
$p->add('dialplan_delete', 'temp');
$p->add('dialplan_detail_delete', 'temp');
//loop through selected destinations
foreach($destinations as $row) { foreach($destinations as $row) {
if ($row['action'] == 'delete' or $row['checked'] == 'true') { if ($row['action'] == 'delete' or $row['checked'] == 'true') {
//get the list destinations
$sql = "select * from v_destinations ";
$sql .= "where destination_uuid = '".$row['destination_uuid']."';";
$prep_statement = $this->db->prepare($sql);
$prep_statement->execute();
$destinations = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$row = $destinations[0];
//delete th dialplan //get the dialplan uuid and context
$sql = "delete from v_dialplan_details "; $sql = "select * from v_destinations ";
$sql .= "where dialplan_uuid = '".$row['dialplan_uuid']."';"; $sql .= "where destination_uuid = :destination_uuid ";
$this->db->query($sql); $database = new database;
unset($sql); $parameters['destination_uuid'] = $row['destination_uuid'];
$destinations = $database->select($sql,$parameters);
$row = $destinations[0];
//delete th dialplan //prepare and then delete the selected data
$sql = "delete from v_dialplans "; if (isset($row["dialplan_uuid"]) && is_uuid($row["dialplan_uuid"])) {
$sql .= "where dialplan_uuid = '".$row['dialplan_uuid']."';"; $array['dialplan_details'][]['dialplan_uuid'] = $row["dialplan_uuid"];
$this->db->query($sql); $array['dialplans'][]['dialplan_uuid'] = $row["dialplan_uuid"];
unset($sql); }
$array['destinations'][]['destination_uuid'] = $row['destination_uuid'];
$database->app_name = 'destinations';
$database->app_uuid = '5ec89622-b19c-3559-64f0-afde802ab139';
$database->delete($array);
//$message = $database->message;
//clear the cache
$cache = new cache;
$cache->delete("dialplan:".$row['destination_context']);
//delete the destinations
$sql = "delete from v_destinations ";
$sql .= "where destination_uuid = '".$row['destination_uuid']."';";
$this->db->query($sql);
unset($sql);
} }
} }
unset($destinations); unset($destinations, $row);
//remove the temporary permission
$p->delete('dialplan_delete', 'temp');
$p->delete('dialplan_detail_delete', 'temp');
} }
} }
} }