diff --git a/app/dialplans/dialplan_edit.php b/app/dialplans/dialplan_edit.php
index f76f9011c2..eac80df91f 100644
--- a/app/dialplans/dialplan_edit.php
+++ b/app/dialplans/dialplan_edit.php
@@ -63,8 +63,8 @@
}
//set the app_uuid
- if (is_uuid($_GET["app_uuid"])) {
- $app_uuid = $_GET["app_uuid"];
+ if (is_uuid($_REQUEST["app_uuid"])) {
+ $app_uuid = $_REQUEST["app_uuid"];
}
//get the http post values and set them as php variables
@@ -78,6 +78,7 @@
$dialplan_context = $_POST["dialplan_context"];
$dialplan_enabled = $_POST["dialplan_enabled"];
$dialplan_description = $_POST["dialplan_description"];
+ $dialplan_details_delete = $_POST["dialplan_details_delete"];
}
//get the list of applications
@@ -99,7 +100,25 @@
//get the dialplan uuid
if ($action == "update") {
- $dialplan_uuid = check_str($_POST["dialplan_uuid"]);
+ $dialplan_uuid = $_POST["dialplan_uuid"];
+ }
+
+ //process the http post data by submitted action
+ if ($_POST['action'] != '' && is_uuid($_POST['dialplan_uuid'])) {
+ $array[0]['checked'] = 'true';
+ $array[0]['uuid'] = $_POST['dialplan_uuid'];
+
+ switch ($_POST['action']) {
+ case 'delete':
+ if (permission_exists('dialplan_delete')) {
+ $obj = new dialplan;
+ $obj->delete($array);
+ }
+ break;
+ }
+
+ header('Location: dialplans.php');
+ exit;
}
//validate the token
@@ -190,13 +209,24 @@
}
//add or update the database
- if ($_POST["persistformvar"] != "true") {
- $database = new database;
- $database->app_name = 'dialplans';
- $database->app_uuid = $app_uuid;
- $database->uuid($dialplan_uuid);
- $database->save($array);
- unset($array);
+ $database = new database;
+ $database->app_name = 'dialplans';
+ $database->app_uuid = $app_uuid;
+ $database->uuid($dialplan_uuid);
+ $database->save($array);
+ unset($array);
+
+ //remove checked dialplan details
+ if (
+ $action == 'update'
+ && permission_exists('dialplan_detail_delete')
+ && is_array($dialplan_details_delete)
+ && @sizeof($dialplan_details_delete) != 0
+ ) {
+ $obj = new dialplan;
+ $obj->dialplan_uuid = $dialplan_uuid;
+ $obj->app_uuid = $app_uuid;
+ $obj->delete_details($dialplan_details_delete);
}
//update the dialplan xml
@@ -403,9 +433,17 @@
echo "
\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$_SESSION['theme']['button_icon_back'],'link'=>'dialplans.php'.(is_uuid($app_uuid) ? "?app_uuid=".urlencode($app_uuid) : null)]);
if ($action == 'update') {
- echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'style'=>'margin-left: 15px;','link'=>'dialplan_copy.php?id='.urlencode($dialplan_uuid),'onclick'=>"if (!confirm('".$text['confirm-copy']."')) { this.blur(); return false; }"]);
if (permission_exists('dialplan_xml')) {
- echo button::create(['type'=>'button','label'=>$text['button-xml'],'icon'=>'code','link'=>'dialplan_xml.php?id='.urlencode($dialplan_uuid).(is_uuid($app_uuid) ? "&app_uuid=".urlencode($app_uuid) : null)]);
+ echo button::create(['type'=>'button','label'=>$text['button-xml'],'icon'=>'code','style'=>'margin-left: 15px;','link'=>'dialplan_xml.php?id='.urlencode($dialplan_uuid).(is_uuid($app_uuid) ? "&app_uuid=".urlencode($app_uuid) : null)]);
+ }
+ $button_margin = 'margin-left: 15px;';
+ if (permission_exists('dialplan_add')) {
+ echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'style'=>$button_margin,'link'=>'dialplan_copy.php?id='.urlencode($dialplan_uuid),'onclick'=>"if (!confirm('".$text['confirm-copy']."')) { this.blur(); return false; }"]);
+ unset($button_margin);
+ }
+ if (permission_exists('dialplan_delete')) {
+ echo button::create(['type'=>'submit','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'id'=>'btn_delete','name'=>'action','value'=>'delete','style'=>$button_margin,'onclick'=>"if (!confirm('".$text['confirm-delete']."')) { this.blur(); return false; }"]);
+ unset($button_margin);
}
}
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$_SESSION['theme']['button_icon_save'],'style'=>'margin-left: 15px;']);
@@ -641,7 +679,9 @@
echo "
".$text['label-inline']." | \n";
echo "
".$text['label-group']." | \n";
echo "
".$text['label-order']." | \n";
- echo "
| \n";
+ if (permission_exists('dialplan_detail_delete')) {
+ echo "
".$text['label-delete']." | \n";
+ }
echo "\n";
if (is_array($group) && @sizeof($group) != 0) {
@@ -856,12 +896,15 @@
*/
echo "\n";
//tools
- echo "
\n";
- if ($element['hidden']) {
- //echo " $v_link_label_edit\n";
- echo " $v_link_label_delete\n";
+ if (permission_exists('dialplan_detail_delete')) {
+ echo " | ";
+ if (is_uuid($dialplan_detail_uuid)) {
+ echo " \n";
+ echo " \n";
+// echo " $v_link_label_delete\n";
+ }
+ echo " | \n";
}
- echo " \n";
//end the row
echo "\n";
//increment the value
diff --git a/app/dialplans/resources/classes/dialplan.php b/app/dialplans/resources/classes/dialplan.php
index f8b3bd96fc..afab0fbeed 100644
--- a/app/dialplans/resources/classes/dialplan.php
+++ b/app/dialplans/resources/classes/dialplan.php
@@ -83,7 +83,7 @@ include "root.php";
//class constructor
public function __construct() {
//set the default value
- $this->dialplan_global = false;
+ $this->dialplan_global = false;
//assign property defaults
$this->app_name = 'dialplans';
@@ -1122,6 +1122,103 @@ include "root.php";
}
}
+ public function delete_details($records) {
+ //set private variables
+ $this->table = 'dialplan_details';
+ $this->uuid_prefix = 'dialplan_detail_';
+
+ //determine app and permission prefix
+ if ($this->app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
+ $this->app_name = 'dialplan_inbound';
+ $this->permission_prefix = 'inbound_route_';
+ }
+ else if ($this->app_uuid == '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3') {
+ $this->app_name = 'dialplan_outbound';
+ $this->permission_prefix = 'outbound_route_';
+ }
+ else if ($this->app_uuid == '16589224-c876-aeb3-f59f-523a1c0801f7') {
+ $this->app_name = 'fifo';
+ $this->permission_prefix = 'fifo_';
+ }
+ else if ($this->app_uuid == '4b821450-926b-175a-af93-a03c441818b1') {
+ $this->app_name = 'time_conditions';
+ $this->permission_prefix = 'time_condition_';
+ }
+ else {
+ //use default in constructor
+ }
+
+ if (permission_exists($this->permission_prefix.'delete')) {
+
+ //add multi-lingual support
+ $language = new text;
+ $text = $language->get();
+
+ //validate the token
+ $token = new token;
+ if (!$token->validate($_SERVER['PHP_SELF'])) {
+ message::add($text['message-invalid_token'],'negative');
+ header('Location: '.$this->list_page);
+ exit;
+ }
+
+ //delete multiple records
+ if (is_array($records) && @sizeof($records) != 0) {
+
+ //build the delete array
+ foreach ($records as $x => $record) {
+ if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
+
+ //build delete array
+ $array[$this->table][$x][$this->uuid_prefix.'uuid'] = $record['uuid'];
+ $array[$this->table][$x]['dialplan_uuid'] = $this->dialplan_uuid;
+
+ //get the dialplan context
+ $sql = "select dialplan_context from v_dialplans ";
+ $sql .= "where dialplan_uuid = :dialplan_uuid ";
+ $parameters['dialplan_uuid'] = $this->dialplan_uuid;
+ $database = new database;
+ $dialplan_contexts[] = $database->select($sql, $parameters, 'column');
+ unset($sql, $parameters);
+
+ }
+ }
+
+ //delete the checked rows
+ if (is_array($array) && @sizeof($array) != 0) {
+
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('dialplan_detail_delete', 'temp');
+
+ //execute delete
+ $database = new database;
+ $database->app_name = $this->app_name;
+ $database->app_uuid = $this->app_uuid;
+ $database->delete($array);
+
+ //revoke temporary permissions
+ $p->delete('dialplan_detail_delete', 'temp');
+
+ //synchronize the xml config
+ save_dialplan_xml();
+
+ //clear the cache
+ if (is_array($dialplan_contexts) && @sizeof($dialplan_contexts) != 0) {
+ $dialplan_contexts = array_unique($dialplan_contexts, SORT_STRING);
+ $cache = new cache;
+ foreach ($dialplan_contexts as $dialplan_context) {
+ $cache->delete("dialplan:".$dialplan_context);
+ }
+ }
+
+ }
+ unset($records, $array);
+
+ }
+ }
+ }
+
/**
* toggle records
*/