mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2026-01-06 19:53:56 +00:00
Dialplan: Implemented bulk-delete.
Default Settings: Minor fixes and enhancements.
This commit is contained in:
@@ -45,41 +45,51 @@ else {
|
||||
}
|
||||
|
||||
//set the dialplan uuid
|
||||
if (count($_GET) > 0) {
|
||||
$dialplan_uuid = check_str($_GET["id"]);
|
||||
}
|
||||
$dialplan_uuids = $_REQUEST["id"];
|
||||
$app_uuid = check_str($_REQUEST['app_uuid']);
|
||||
|
||||
if (strlen($dialplan_uuid) > 0) {
|
||||
//get the dialplan data
|
||||
$sql = "select * from v_dialplans ";
|
||||
//$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "where dialplan_uuid = '$dialplan_uuid' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$database_dialplan_uuid = $row["dialplan_uuid"];
|
||||
$dialplan_context = $row["dialplan_context"];
|
||||
$app_uuid = $row["app_uuid"];
|
||||
}
|
||||
unset ($prep_statement);
|
||||
if (sizeof($dialplan_uuids) > 0) {
|
||||
|
||||
//get dialplan contexts
|
||||
foreach ($dialplan_uuids as $dialplan_uuid) {
|
||||
|
||||
//check each
|
||||
$dialplan_uuid = check_str($dialplan_uuid);
|
||||
|
||||
//get the dialplan data
|
||||
$sql = "select * from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."' ";
|
||||
$prep_statement = $db->prepare(check_sql($sql));
|
||||
$prep_statement->execute();
|
||||
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
||||
foreach ($result as &$row) {
|
||||
$database_dialplan_uuid = $row["dialplan_uuid"];
|
||||
$dialplan_contexts[] = $row["dialplan_context"];
|
||||
}
|
||||
unset($prep_statement);
|
||||
}
|
||||
|
||||
//start the atomic transaction
|
||||
$db->beginTransaction();
|
||||
|
||||
//delete child data
|
||||
$sql = "delete from v_dialplan_details ";
|
||||
//$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "where dialplan_uuid = '$dialplan_uuid'; ";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
//delete dialplan and details
|
||||
$dialplans_deleted = 0;
|
||||
foreach ($dialplan_uuids as $dialplan_uuid) {
|
||||
|
||||
//delete parent data
|
||||
$sql = "delete from v_dialplans ";
|
||||
//$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
||||
$sql .= "where dialplan_uuid = '$dialplan_uuid'; ";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
//delete child data
|
||||
$sql = "delete from v_dialplan_details ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
|
||||
//delete parent data
|
||||
$sql = "delete from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = '".$dialplan_uuid."'; ";
|
||||
$db->query($sql);
|
||||
unset($sql);
|
||||
|
||||
$dialplans_deleted++;
|
||||
}
|
||||
|
||||
//commit the atomic transaction
|
||||
$db->commit();
|
||||
@@ -87,26 +97,22 @@ if (strlen($dialplan_uuid) > 0) {
|
||||
//synchronize the xml config
|
||||
save_dialplan_xml();
|
||||
|
||||
//delete the dialplan context from memcache
|
||||
//strip duplicate contexts
|
||||
$dialplan_contexts = array_unique($dialplan_contexts, SORT_STRING);
|
||||
|
||||
//delete the dialplan contexts from memcache
|
||||
if (sizeof($dialplan_contexts) > 0) {
|
||||
$fp = event_socket_create($_SESSION['event_socket_ip_address'], $_SESSION['event_socket_port'], $_SESSION['event_socket_password']);
|
||||
if ($fp) {
|
||||
$switch_cmd = "memcache delete dialplan:".$dialplan_context;
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
foreach($dialplan_contexts as $dialplan_context) {
|
||||
$switch_cmd = "memcache delete dialplan:".$dialplan_context;
|
||||
$switch_result = event_socket_request($fp, 'api '.$switch_cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$_SESSION["message"] = $text['message-delete'];
|
||||
switch ($app_uuid) {
|
||||
case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": //inbound routes
|
||||
case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": //outbound routes
|
||||
case "4b821450-926b-175a-af93-a03c441818b1": //time conditions
|
||||
$redirect_url = PROJECT_PATH."/app/dialplan/dialplans.php?app_uuid=".$app_uuid;
|
||||
break;
|
||||
default:
|
||||
$redirect_url = PROJECT_PATH."/app/dialplan/dialplans.php";
|
||||
}
|
||||
header("Location: ".$redirect_url);
|
||||
return;
|
||||
|
||||
$_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));
|
||||
?>
|
||||
@@ -47,8 +47,8 @@ else {
|
||||
//set the variables
|
||||
if (count($_GET) > 0) {
|
||||
$dialplan_detail_uuid = check_str($_GET["id"]);
|
||||
$app_uuid = check_str($_REQUEST["app_uuid"]);
|
||||
$dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]);
|
||||
$app_uuid = check_str($_REQUEST["app_uuid"]);
|
||||
}
|
||||
|
||||
//delete the dialplan detail
|
||||
@@ -75,7 +75,7 @@ else {
|
||||
$_SESSION['message'] = $text['message-delete'];
|
||||
|
||||
//redirect the browser
|
||||
header("Location: dialplan_edit.php?id=".$dialplan_uuid."&app_uuid=".$app_uuid);
|
||||
header("Location: dialplan_edit.php?id=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null));
|
||||
exit;
|
||||
|
||||
?>
|
||||
@@ -175,7 +175,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
else if ($action == "update") {
|
||||
$_SESSION['message'] = $text['message-update'];
|
||||
}
|
||||
header("Location: ?id=".$dialplan_uuid."&app_uuid=".$app_uuid);
|
||||
header("Location: ?id=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null));
|
||||
exit;
|
||||
|
||||
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
|
||||
@@ -190,7 +190,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
//$message = $orm->message;
|
||||
foreach ($result as &$row) {
|
||||
$domain_uuid = $row["domain_uuid"];
|
||||
$app_uuid = $row["app_uuid"];
|
||||
//$app_uuid = $row["app_uuid"];
|
||||
$dialplan_name = $row["dialplan_name"];
|
||||
$dialplan_number = $row["dialplan_number"];
|
||||
$dialplan_order = $row["dialplan_order"];
|
||||
@@ -325,6 +325,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo " <br>";
|
||||
|
||||
echo "<form method='post' name='frm' action=''>\n";
|
||||
echo "<input type='hidden' name='app_uuid' value='".$app_uuid."'>\n";
|
||||
echo "<div align='center'>\n";
|
||||
|
||||
echo "<table width=\"100%\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\">\n";
|
||||
@@ -333,12 +334,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo" <span class=\"title\">".$text['title-dialplan_edit']."</span><br />\n";
|
||||
echo " </td>\n";
|
||||
echo " <td width='70%' align='right'>\n";
|
||||
if (strlen($app_uuid) > 0) {
|
||||
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='dialplans.php?app_uuid=$app_uuid'\" value='".$text['button-back']."'>\n";
|
||||
}
|
||||
else {
|
||||
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='dialplans.php'\" value='".$text['button-back']."'>\n";
|
||||
}
|
||||
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='dialplans.php".((strlen($app_uuid) > 0) ? "?app_uuid=".$app_uuid : null)."';\" value='".$text['button-back']."'>\n";
|
||||
echo " <input type='button' class='btn' name='' alt='".$text['button-copy']."' onclick=\"if (confirm('".$text['confirm-copy']."')){window.location='dialplan_copy.php?id=".$dialplan_uuid."';}\" value='".$text['button-copy']."'>\n";
|
||||
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
|
||||
echo " </td>\n";
|
||||
@@ -764,7 +760,7 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
||||
echo " <td class='list_control_icon'>\n";
|
||||
if ($element['hidden']) {
|
||||
//echo " <a href='dialplan_detail_edit.php?id=".$dialplan_detail_uuid."&dialplan_uuid=".$dialplan_uuid."&app_uuid=".$app_uuid."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
|
||||
echo " <a href='dialplan_detail_delete.php?id=".$dialplan_detail_uuid."&dialplan_uuid=".$dialplan_uuid."&app_uuid=".$app_uuid."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
|
||||
echo " <a href='dialplan_detail_delete.php?id=".$dialplan_detail_uuid."&dialplan_uuid=".$dialplan_uuid.(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
|
||||
}
|
||||
echo " </td>\n";
|
||||
//end the row
|
||||
|
||||
@@ -95,7 +95,7 @@ else {
|
||||
echo " </span>\n";
|
||||
echo " </td>\n";
|
||||
|
||||
echo " <form method='get' action=''>\n";
|
||||
echo " <form name='frm_search' method='get' action=''>\n";
|
||||
echo " <td width='50%' align='right'>\n";
|
||||
echo " <input type='text' class='txt' style='width: 150px' name='search' value='$search'>";
|
||||
if (strlen($app_uuid) > 0) {
|
||||
@@ -231,8 +231,13 @@ else {
|
||||
$row_style["1"] = "row_style1";
|
||||
|
||||
echo "<div align='center'>\n";
|
||||
echo "<form name='frm_delete' method='post' action='dialplan_delete.php'>\n";
|
||||
echo "<input type='hidden' name='app_uuid' value='".$app_uuid."'>\n";
|
||||
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
if (permission_exists('dialplan_delete') && $result_count > 0) {
|
||||
echo "<th style='text-align: center;' style='text-align: center; padding: 3px 0px 0px 0px;'><input type='checkbox' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
|
||||
}
|
||||
echo th_order_by('dialplan_name', $text['label-name'], $order_by, $order, $app_uuid);
|
||||
echo th_order_by('dialplan_number', $text['label-number'], $order_by, $order, $app_uuid);
|
||||
echo th_order_by('dialplan_context', $text['label-context'], $order_by, $order, $app_uuid);
|
||||
@@ -255,6 +260,9 @@ else {
|
||||
elseif (permission_exists('dialplan_add')) {
|
||||
echo "<a href='dialplan_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
if (permission_exists('dialplan_delete') && $result_count > 0) {
|
||||
echo "<a href='javascript:void(0);' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.forms.frm_delete.submit(); }\" alt='".$text['button-delete']."'>".$v_link_label_delete."</a>";
|
||||
}
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
|
||||
@@ -286,6 +294,18 @@ else {
|
||||
}
|
||||
unset ($prep_statement);
|
||||
}
|
||||
|
||||
// blank app id if doesn't match others, so will return to dialplan manager
|
||||
switch ($app_uuid) {
|
||||
case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" : // inbound route
|
||||
case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" : // outbound route
|
||||
case "16589224-c876-aeb3-f59f-523a1c0801f7" : // fifo
|
||||
case "4b821450-926b-175a-af93-a03c441818b1" : // time condition
|
||||
break;
|
||||
default :
|
||||
unset($app_uuid);
|
||||
}
|
||||
|
||||
if (
|
||||
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_edit')) ||
|
||||
($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_edit')) ||
|
||||
@@ -293,9 +313,13 @@ else {
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) ||
|
||||
permission_exists('dialplan_edit')
|
||||
) {
|
||||
$tr_link = "href='dialplan_edit.php?id=".$row['dialplan_uuid']."&app_uuid=".$app_uuid."'";
|
||||
$tr_link = "href='dialplan_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."'";
|
||||
}
|
||||
echo "<tr ".$tr_link.">\n";
|
||||
if (permission_exists("dialplan_delete")) {
|
||||
echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='text-align: center; padding: 3px 0px 0px 0px;'><input type='checkbox' name='id[]' id='checkbox_".$row['dialplan_uuid']."' value='".$row['dialplan_uuid']."'></td>\n";
|
||||
$dialplan_ids[] = 'checkbox_'.$row['dialplan_uuid'];
|
||||
}
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>";
|
||||
if (
|
||||
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_edit')) ||
|
||||
@@ -304,7 +328,7 @@ else {
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) ||
|
||||
permission_exists('dialplan_edit')
|
||||
) {
|
||||
echo "<a href='dialplan_edit.php?id=".$row['dialplan_uuid']."&app_uuid=$app_uuid'>".$row['dialplan_name']."</a>";
|
||||
echo "<a href='dialplan_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."'>".$row['dialplan_name']."</a>";
|
||||
}
|
||||
else {
|
||||
echo $row['dialplan_name'];
|
||||
@@ -323,7 +347,7 @@ else {
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) ||
|
||||
permission_exists('dialplan_edit')
|
||||
) {
|
||||
echo "<a href='dialplan_edit.php?id=".$row['dialplan_uuid']."&app_uuid=$app_uuid' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
|
||||
echo "<a href='dialplan_edit.php?id=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
|
||||
}
|
||||
if (
|
||||
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_delete')) ||
|
||||
@@ -332,7 +356,7 @@ else {
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_delete')) ||
|
||||
permission_exists('dialplan_delete')
|
||||
) {
|
||||
echo "<a href='dialplan_delete.php?id=".$row['dialplan_uuid']."&app_uuid=$app_uuid' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
|
||||
echo "<a href=\"dialplan_delete.php?id[]=".$row['dialplan_uuid'].(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."\" alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
@@ -342,7 +366,7 @@ else {
|
||||
} //end if results
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td colspan='7'>\n";
|
||||
echo "<td colspan='8'>\n";
|
||||
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td width='33.3%' nowrap> </td>\n";
|
||||
@@ -363,6 +387,9 @@ else {
|
||||
elseif (permission_exists('dialplan_add')) {
|
||||
echo "<a href='dialplan_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
if (permission_exists('dialplan_delete') && $result_count > 0) {
|
||||
echo "<a href='javascript:void(0);' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.forms.frm_delete.submit(); }\" alt='".$text['button-delete']."'>".$v_link_label_delete."</a>";
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " </table>\n";
|
||||
@@ -377,9 +404,20 @@ else {
|
||||
echo "</td>";
|
||||
echo "</tr>";
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
echo "</div>";
|
||||
echo "<br><br>";
|
||||
|
||||
if (sizeof($dialplan_ids) > 0) {
|
||||
echo "<script>\n";
|
||||
echo " function check(what) {\n";
|
||||
foreach ($dialplan_ids as $checkbox_id) {
|
||||
echo "document.getElementById('".$checkbox_id."').checked = (what == 'all') ? true : false;\n";
|
||||
}
|
||||
echo " }\n";
|
||||
echo "</script>\n";
|
||||
}
|
||||
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user