Make the indentation on the dialplan delete more consistent with the rest of the code base.

This commit is contained in:
Mark Crane 2015-01-09 22:09:58 +00:00
parent bb1886ad63
commit dd51a8237b
1 changed files with 56 additions and 55 deletions

View File

@ -48,71 +48,72 @@ else {
$dialplan_uuids = $_REQUEST["id"]; $dialplan_uuids = $_REQUEST["id"];
$app_uuid = check_str($_REQUEST['app_uuid']); $app_uuid = check_str($_REQUEST['app_uuid']);
if (sizeof($dialplan_uuids) > 0) { //delete the dialplans
if (sizeof($dialplan_uuids) > 0) {
//get dialplan contexts //get dialplan contexts
foreach ($dialplan_uuids as $dialplan_uuid) { foreach ($dialplan_uuids as $dialplan_uuid) {
//check each
$dialplan_uuid = check_str($dialplan_uuid);
//check each //get the dialplan data
$dialplan_uuid = check_str($dialplan_uuid); $sql = "select * from v_dialplans ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
//get the dialplan data $prep_statement = $db->prepare(check_sql($sql));
$sql = "select * from v_dialplans "; $prep_statement->execute();
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' "; $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$prep_statement = $db->prepare(check_sql($sql)); foreach ($result as &$row) {
$prep_statement->execute(); $database_dialplan_uuid = $row["dialplan_uuid"];
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $dialplan_contexts[] = $row["dialplan_context"];
foreach ($result as &$row) { }
$database_dialplan_uuid = $row["dialplan_uuid"]; unset($prep_statement);
$dialplan_contexts[] = $row["dialplan_context"];
} }
unset($prep_statement);
}
//start the atomic transaction //start the atomic transaction
$db->beginTransaction(); $db->beginTransaction();
//delete dialplan and details //delete dialplan and details
$dialplans_deleted = 0; $dialplans_deleted = 0;
foreach ($dialplan_uuids as $dialplan_uuid) { foreach ($dialplan_uuids as $dialplan_uuid) {
//delete child data //delete child data
$sql = "delete from v_dialplan_details "; $sql = "delete from v_dialplan_details ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; "; $sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
$db->query($sql); $db->query($sql);
unset($sql); unset($sql);
//delete parent data //delete parent data
$sql = "delete from v_dialplans "; $sql = "delete from v_dialplans ";
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; "; $sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
$db->query($sql); $db->query($sql);
unset($sql); unset($sql);
$dialplans_deleted++; $dialplans_deleted++;
} }
//commit the atomic transaction //commit the atomic transaction
$db->commit(); $db->commit();
//synchronize the xml config //synchronize the xml config
save_dialplan_xml(); save_dialplan_xml();
//strip duplicate contexts //strip duplicate contexts
$dialplan_contexts = array_unique($dialplan_contexts, SORT_STRING); $dialplan_contexts = array_unique($dialplan_contexts, SORT_STRING);
//delete the dialplan contexts from memcache //delete the dialplan contexts from memcache
if (sizeof($dialplan_contexts) > 0) { if (sizeof($dialplan_contexts) > 0) {
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']); $fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
if ($fp) { if ($fp) {
foreach($dialplan_contexts as $dialplan_context) { foreach($dialplan_contexts as $dialplan_context) {
$switch_cmd = "memcache delete dialplan:".$dialplan_context; $switch_cmd = "memcache delete dialplan:".$dialplan_context;
$switch_result = event_socket_request($fp, 'api '.$switch_cmd); $switch_result = event_socket_request($fp, 'api '.$switch_cmd);
}
}
} }
}
} }
}
//redirect the browser
$_SESSION["message"] = $text['message-delete'].(($dialplans_deleted > 1) ? ": ".$dialplans_deleted : null);
header("Location: ".PROJECT_PATH."/app/dialplan/dialplans.php".(($app_uuid != '') ? "?app_uuid=".$app_uuid : null));
$_SESSION["message"] = $text['message-delete'].(($dialplans_deleted > 1) ? ": ".$dialplans_deleted : null);
header("Location: ".PROJECT_PATH."/app/dialplan/dialplans.php".(($app_uuid != '') ? "?app_uuid=".$app_uuid : null));
?> ?>