mirror of
https://github.com/fusionpbx/fusionpbx.git
synced 2025-12-30 00:53:50 +00:00
Dialplans: List view updates.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
include "root.php";
|
||||
require_once "resources/require.php";
|
||||
require_once "resources/check_auth.php";
|
||||
require_once "resources/paging.php";
|
||||
|
||||
//check permissions
|
||||
if (permission_exists('dialplan_view')) {
|
||||
@@ -42,55 +43,63 @@
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//handle enable toggle
|
||||
$dialplan_uuid = $_REQUEST['id'];
|
||||
$dialplan_enabled = $_REQUEST['enabled'];
|
||||
if (is_uuid($dialplan_uuid) && $dialplan_enabled != '') {
|
||||
//make sure enabled is only true or false
|
||||
if ($dialplan_enabled == "true") {
|
||||
$dialplan_enabled = 'true';
|
||||
}
|
||||
else {
|
||||
$dialplan_enabled == 'false';
|
||||
}
|
||||
|
||||
//get the dialplan context
|
||||
$sql = "select dialplan_context from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||
$parameters['dialplan_uuid'] = $dialplan_uuid;
|
||||
$database = new database;
|
||||
$dialplan_context = $database->select($sql, $parameters, 'column');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//change the status
|
||||
$array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
|
||||
$array['dialplans'][0]['dialplan_enabled'] = $dialplan_enabled;
|
||||
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_edit', 'temp');
|
||||
|
||||
$database = new database;
|
||||
$database->app_name = 'dialplans';
|
||||
$database->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db';
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
$p->delete('dialplan_edit', 'temp');
|
||||
|
||||
//clear the cache
|
||||
$cache = new cache;
|
||||
$cache->delete("dialplan:".$dialplan_context);
|
||||
|
||||
//set the message
|
||||
message::add($text['message-update']);
|
||||
//get posted data
|
||||
if (is_array($_POST['dialplans'])) {
|
||||
$app_uuid = $_POST['app_uuid'];
|
||||
$action = $_POST['action'];
|
||||
$dialplans = $_POST['dialplans'];
|
||||
$search = $_POST['search'];
|
||||
$order_by = $_POST['order_by'];
|
||||
$order = $_POST['order'];
|
||||
}
|
||||
|
||||
//set the http values as php variables
|
||||
$search = $_REQUEST["search"];
|
||||
$order_by = $_REQUEST["order_by"];
|
||||
$order = $_REQUEST["order"];
|
||||
$dialplan_context = $_REQUEST["dialplan_context"];
|
||||
$app_uuid = $_REQUEST["app_uuid"];
|
||||
//process action
|
||||
if ($action && is_array($dialplans) && @sizeof($dialplans) != 0) {
|
||||
|
||||
//define redirect parameters and url
|
||||
if (is_uuid($app_uuid)) { $params[] = "app_uuid=".urlencode($app_uuid); }
|
||||
if ($search) { $params[] = "search=".urlencode($search); }
|
||||
if ($order_by) { $params[] = "order_by=".urlencode($order_by); }
|
||||
if ($order) { $params[] = "order=".urlencode($order); }
|
||||
$redirect_url = 'dialplans.php'.($params ? '?'.implode('&', $params) : null);
|
||||
unset($params);
|
||||
|
||||
//copy the dialplans
|
||||
if ($action == 'copy') {
|
||||
$obj = new dialplan;
|
||||
$obj->app_uuid = $app_uuid;
|
||||
$obj->list_page = $redirect_url;
|
||||
$obj->copy($dialplans);
|
||||
}
|
||||
|
||||
//toggle the dialplans
|
||||
if ($action == 'toggle') {
|
||||
$obj = new dialplan;
|
||||
$obj->app_uuid = $app_uuid;
|
||||
$obj->list_page = $redirect_url;
|
||||
$obj->toggle($dialplans);
|
||||
}
|
||||
|
||||
//delete the dialplans
|
||||
if ($action == 'delete') {
|
||||
$obj = new dialplan;
|
||||
$obj->app_uuid = $app_uuid;
|
||||
$obj->list_page = $redirect_url;
|
||||
$obj->delete($dialplans);
|
||||
}
|
||||
|
||||
//redirect
|
||||
header('Location: '.$redirect_url);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
//get order and order by and sanatize the values
|
||||
$order_by = $_GET["order_by"];
|
||||
$order = $_GET["order"];
|
||||
|
||||
//get the app uuid
|
||||
$app_uuid = $_GET["app_uuid"];
|
||||
|
||||
//make sure all dialplans with context of public have the inbound route app_uuid
|
||||
if ($app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
|
||||
@@ -103,11 +112,25 @@
|
||||
unset($sql);
|
||||
}
|
||||
|
||||
//includes
|
||||
require_once "resources/header.php";
|
||||
require_once "resources/paging.php";
|
||||
//add the search term
|
||||
$search = strtolower($_GET["search"]);
|
||||
if (strlen($search) > 0) {
|
||||
$sql_search = "and (";
|
||||
$sql_search .= " lower(dialplan_context) like :search ";
|
||||
$sql_search .= " or lower(dialplan_name) like :search ";
|
||||
$sql_search .= " or lower(dialplan_number) like :search ";
|
||||
$sql_search .= " or lower(dialplan_continue) like :search ";
|
||||
$sql_search .= " or lower(dialplan_enabled) like :search ";
|
||||
$sql_search .= " or lower(dialplan_description) like :search ";
|
||||
if (is_numeric($search)) {
|
||||
$sql_search .= " or dialplan_order = :search_numeric ";
|
||||
$parameters['search_numeric'] = $search;
|
||||
}
|
||||
$sql_search .= ") ";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
|
||||
//prepare the sql
|
||||
//get the number of rows in the dialplan
|
||||
$sql = "select count(*) from v_dialplans ";
|
||||
if ($_GET['show'] == "all" && permission_exists('dialplan_all')) {
|
||||
$sql .= "where true ";
|
||||
@@ -132,222 +155,243 @@
|
||||
}
|
||||
$parameters['app_uuid'] = $app_uuid;
|
||||
}
|
||||
if (strlen($search) > 0) {
|
||||
$search = strtolower($search);
|
||||
$sql .= "and (";
|
||||
$sql .= " lower(dialplan_context) like :search ";
|
||||
$sql .= " or lower(dialplan_name) like :search ";
|
||||
$sql .= " or lower(dialplan_number) like :search ";
|
||||
$sql .= " or lower(dialplan_continue) like :search ";
|
||||
if (is_numeric($search)) {
|
||||
$sql .= " or dialplan_order = :search_numeric ";
|
||||
}
|
||||
$sql .= " or lower(dialplan_enabled) like :search ";
|
||||
$sql .= " or lower(dialplan_description) like :search ";
|
||||
$sql .= ") ";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
if (is_numeric($search)) {
|
||||
$parameters['search_numeric'] = $search;
|
||||
}
|
||||
}
|
||||
|
||||
//get the number of rows in the dialplan
|
||||
$sql .= $sql_search;
|
||||
$database = new database;
|
||||
$num_rows = $database->select($sql, $parameters, 'column');
|
||||
|
||||
//prepare the paging
|
||||
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
|
||||
$param = "&search=".escape($search);
|
||||
if ($_GET['show'] == "all" && permission_exists('destination_all')) {
|
||||
$param .= "&show=all";
|
||||
if (is_uuid($app_uuid)) { $params[] = "app_uuid=".$app_uuid; }
|
||||
if ($search) { $params[] = "search=".$search; }
|
||||
if ($order_by) { $params[] = "order_by=".$order_by; }
|
||||
if ($order) { $params[] = "order=".$order; }
|
||||
if ($_GET['show'] == "all" && permission_exists('dialplan_all')) {
|
||||
$params[] .= "show=all";
|
||||
}
|
||||
if (strlen($app_uuid) > 0 && is_uuid($app_uuid)) { $param = "&app_uuid=".$app_uuid; }
|
||||
$param = $params ? implode('&', $params) : null;
|
||||
unset($params);
|
||||
$page = $_GET['page'];
|
||||
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
|
||||
list($paging_controls_mini, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page, true);
|
||||
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
|
||||
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
|
||||
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true);
|
||||
$offset = $rows_per_page * $page;
|
||||
|
||||
//get the list of dialplans
|
||||
$sql = str_replace('count(*)', '*', $sql);
|
||||
$sql .= ($order_by != '' ? order_by($order_by, $order) : 'order by dialplan_order asc, dialplan_name asc ');
|
||||
if ($order_by != '') {
|
||||
if ($order_by == 'dialplan_name' || $order_by == 'dialplan_description') {
|
||||
$sql .= 'order by lower('.$order_by.') '.$order.' ';
|
||||
}
|
||||
else {
|
||||
$sql .= order_by($order_by, $order);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$sql .= "order by dialplan_order asc, lower(dialplan_name) asc ";
|
||||
}
|
||||
$sql .= limit_offset($rows_per_page, $offset);
|
||||
$database = new database;
|
||||
$dialplans = $database->select($sql, $parameters, 'all');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//set the alternating row style
|
||||
$c = 0;
|
||||
$row_style["0"] = "row_style0";
|
||||
$row_style["1"] = "row_style1";
|
||||
//create token
|
||||
$object = new token;
|
||||
$token = $object->create($_SERVER['PHP_SELF']);
|
||||
|
||||
//set the title
|
||||
if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") {
|
||||
$document['title'] = $text['title-inbound_routes'];
|
||||
}
|
||||
elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") {
|
||||
$document['title'] = $text['title-outbound_routes'];
|
||||
}
|
||||
elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") {
|
||||
$document['title'] = $text['title-queues'];
|
||||
}
|
||||
elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") {
|
||||
$document['title'] = $text['title-time_conditions'];
|
||||
}
|
||||
else {
|
||||
$document['title'] = $text['title-dialplan_manager'];
|
||||
//include the header
|
||||
switch ($app_uuid) {
|
||||
case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": $document['title'] = $text['title-inbound_routes']; break;
|
||||
case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": $document['title'] = $text['title-outbound_routes']; break;
|
||||
case "16589224-c876-aeb3-f59f-523a1c0801f7": $document['title'] = $text['title-queues']; break;
|
||||
case "4b821450-926b-175a-af93-a03c441818b1": $document['title'] = $text['title-time_conditions']; break;
|
||||
default: $document['title'] = $text['title-dialplan_manager'];
|
||||
}
|
||||
require_once "resources/header.php";
|
||||
|
||||
//show the content
|
||||
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
||||
echo "<tr>\n";
|
||||
echo " <td align='left' valign='top'>\n";
|
||||
echo " <span class='title'>\n";
|
||||
if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") {
|
||||
echo " ".$text['header-inbound_routes']."\n";
|
||||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
echo " <div class='heading'><b>";
|
||||
switch ($app_uuid) {
|
||||
case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": echo $text['header-inbound_routes']; break;
|
||||
case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": echo $text['header-outbound_routes']; break;
|
||||
case "16589224-c876-aeb3-f59f-523a1c0801f7": echo $text['header-queues']; break;
|
||||
case "4b821450-926b-175a-af93-a03c441818b1": echo $text['header-time_conditions']; break;
|
||||
default: echo $text['header-dialplan_manager'];
|
||||
}
|
||||
elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") {
|
||||
echo " ".$text['header-outbound_routes']."\n";
|
||||
echo " (".$num_rows.")</b>";
|
||||
echo "</div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_add')) { $button_add_url = PROJECT_PATH."/app/dialplan_inbound/dialplan_inbound_add.php"; }
|
||||
else if ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_add')) { $button_add_url = PROJECT_PATH."/app/dialplan_outbound/dialplan_outbound_add.php"; }
|
||||
else if ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_add')) { $button_add_url = PROJECT_PATH."/app/fifo/fifo_add.php"; }
|
||||
else if ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_add')) { $button_add_url = PROJECT_PATH."/app/time_conditions/time_condition_edit.php"; }
|
||||
else if (permission_exists('dialplan_add')) { $button_add_url = PROJECT_PATH."/app/dialplans/dialplan_add.php"; }
|
||||
if ($button_add_url) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$_SESSION['theme']['button_icon_add'],'link'=>$button_add_url]);
|
||||
}
|
||||
elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") {
|
||||
echo " ".$text['header-queues']."\n";
|
||||
if ($dialplans) {
|
||||
if (
|
||||
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_copy')) ||
|
||||
($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_copy')) ||
|
||||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_add')) ||
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_add')) ||
|
||||
permission_exists('dialplan_add')
|
||||
) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$_SESSION['theme']['button_icon_copy'],'onclick'=>"if (confirm('".$text['confirm-copy']."')) { list_action_set('copy'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
||||
}
|
||||
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')) ||
|
||||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) ||
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) ||
|
||||
permission_exists('dialplan_edit')
|
||||
) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$_SESSION['theme']['button_icon_toggle'],'onclick'=>"if (confirm('".$text['confirm-toggle']."')) { list_action_set('toggle'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
||||
}
|
||||
if (
|
||||
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_delete')) ||
|
||||
($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_delete')) ||
|
||||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_delete')) ||
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_delete')) ||
|
||||
permission_exists('dialplan_delete')
|
||||
) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$_SESSION['theme']['button_icon_delete'],'onclick'=>"if (confirm('".$text['confirm-delete']."')) { list_action_set('delete'); list_form_submit('form_list'); } else { this.blur(); return false; }"]);
|
||||
}
|
||||
}
|
||||
elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") {
|
||||
echo " ".$text['header-time_conditions']."\n";
|
||||
}
|
||||
else {
|
||||
echo " ".$text['header-dialplan_manager']."\n";
|
||||
}
|
||||
echo " </span>\n";
|
||||
echo " <br><br>\n";
|
||||
echo " </td>\n";
|
||||
echo " <td align='right' valign='top' nowrap='nowrap' style='padding-left: 50px;'>\n";
|
||||
echo " <form name='frm_search' method='get' action=''>\n";
|
||||
echo "<form id='form_search' class='inline' method='get'>\n";
|
||||
if (permission_exists('dialplan_all')) {
|
||||
if ($_GET['show'] == 'all') {
|
||||
if ($_GET['show'] == 'all' && permission_exists('dialplan_all')) {
|
||||
echo " <input type='hidden' name='show' value='all'>";
|
||||
}
|
||||
else {
|
||||
echo " <input type='button' class='btn' value='".$text['button-show_all']."' onclick=\"window.location='dialplans.php?show=all&search=".escape($search)."&app_uuid=".escape($app_uuid)."';\">\n";
|
||||
if (is_uuid($app_uuid)) { $params[] = "app_uuid=".urlencode($app_uuid); }
|
||||
if ($search) { $params[] = "search=".urlencode($search); }
|
||||
if ($order_by) { $params[] = "order_by=".urlencode($order_by); }
|
||||
if ($order) { $params[] = "order=".urlencode($order); }
|
||||
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$_SESSION['theme']['button_icon_all'],'link'=>'?show=all'.($params ? '&'.implode('&', $params) : null)]);
|
||||
unset($params);
|
||||
}
|
||||
}
|
||||
echo " <input type='text' class='txt' style='width: 150px' name='search' value='".escape($search)."'>";
|
||||
if (is_uuid($app_uuid)) {
|
||||
echo " <input type='hidden' class='txt' name='app_uuid' value='".escape($app_uuid)."'>";
|
||||
echo "<input type='hidden' name='app_uuid' value='".escape($app_uuid)."'>";
|
||||
}
|
||||
if (strlen($order_by) > 0) {
|
||||
echo " <input type='hidden' class='txt' name='order_by' value='".escape($order_by)."'>";
|
||||
echo " <input type='hidden' class='txt' name='order' value='".escape($order)."'>";
|
||||
if ($order_by) {
|
||||
echo "<input type='hidden' name='order_by' value='".escape($order_by)."'>";
|
||||
}
|
||||
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>";
|
||||
if ($order) {
|
||||
echo "<input type='hidden' name='order' value='".escape($order)."'>";
|
||||
}
|
||||
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
|
||||
echo button::create(['label'=>$text['button-search'],'icon'=>$_SESSION['theme']['button_icon_search'],'type'=>'submit','id'=>'btn_search','style'=>($search != '' ? 'display: none;' : null)]);
|
||||
if (is_uuid($app_uuid)) { $params[] = "app_uuid=".urlencode($app_uuid); }
|
||||
if ($order_by) { $params[] = "order_by=".urlencode($order_by); }
|
||||
if ($order) { $params[] = "order=".urlencode($order); }
|
||||
if ($_GET['show'] && permission_exists('dialplan_all')) { $params[] = "show=".urlencode($_GET['show']); }
|
||||
echo button::create(['label'=>$text['button-reset'],'icon'=>$_SESSION['theme']['button_icon_reset'],'type'=>'button','id'=>'btn_reset','link'=>'dialplans.php'.($params ? '?'.implode('&', $params) : null),'style'=>($search == '' ? 'display: none;' : null)]);
|
||||
unset($params);
|
||||
if ($paging_controls_mini != '') {
|
||||
echo " <span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
|
||||
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
|
||||
}
|
||||
echo " </form>\n";
|
||||
echo " </td>\n";
|
||||
echo " </tr>\n";
|
||||
echo " </div>\n";
|
||||
echo " <div style='clear: both;'></div>\n";
|
||||
echo "</div>\n";
|
||||
|
||||
echo " <tr>\n";
|
||||
echo " <td colspan='2'>\n";
|
||||
echo " <span class='vexpl'>\n";
|
||||
if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4") {
|
||||
echo $text['description-inbound_routes'];
|
||||
switch ($app_uuid) {
|
||||
case "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4": echo $text['description-inbound_routes']; break;
|
||||
case "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3": echo $text['description-outbound_routes']; break;
|
||||
case "16589224-c876-aeb3-f59f-523a1c0801f7": echo $text['description-queues']; break;
|
||||
case "4b821450-926b-175a-af93-a03c441818b1": echo $text['description-time_conditions']; break;
|
||||
default: echo $text['description-dialplan_manager'.(if_group("superadmin") ? '-superadmin' : null)];
|
||||
}
|
||||
elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3") {
|
||||
echo $text['description-outbound_routes'];
|
||||
}
|
||||
elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7") {
|
||||
echo $text['description-queues'];
|
||||
}
|
||||
elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1") {
|
||||
echo $text['description-time_conditions'];
|
||||
}
|
||||
else {
|
||||
if (if_group("superadmin")) {
|
||||
echo $text['description-dialplan_manager-superadmin'];
|
||||
}
|
||||
else {
|
||||
echo $text['description-dialplan_manager'];
|
||||
}
|
||||
}
|
||||
echo " </span>\n";
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "</table>";
|
||||
echo "<br />";
|
||||
echo "\n<br /><br />\n";
|
||||
|
||||
echo "<form name='frm_delete' method='post' action='dialplan_delete.php'>\n";
|
||||
echo "<input type='hidden' name='app_uuid' value='".escape($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') && @sizeof($dialplans) != 0) {
|
||||
echo "<th style='width: 30px; text-align: center; padding: 3px 0px 0px 0px;' width='1'><input type='checkbox' id='chk_all' style='margin: 0px 0px 0px 2px;' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
|
||||
echo "<form id='form_list' method='post'>\n";
|
||||
echo "<input type='hidden' id='app_uuid' name='app_uuid' value='".escape($app_uuid)."'>\n";
|
||||
echo "<input type='hidden' id='action' name='action' value=''>\n";
|
||||
echo "<input type='hidden' name='search' value=\"".escape($search)."\">\n";
|
||||
echo "<input type='hidden' name='order_by' value=\"".escape($order_by)."\">\n";
|
||||
echo "<input type='hidden' name='order' value=\"".escape($order)."\">\n";
|
||||
|
||||
echo "<table class='list'>\n";
|
||||
echo "<tr class='list-header'>\n";
|
||||
if (
|
||||
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && (permission_exists('inbound_route_copy') || permission_exists('inbound_route_edit') || permission_exists('inbound_route_delete'))) ||
|
||||
($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && (permission_exists('outbound_route_copy') || permission_exists('outbound_route_edit') || permission_exists('outbound_route_delete'))) ||
|
||||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && (permission_exists('fifo_add') || permission_exists('fifo_edit') || permission_exists('fifo_delete'))) ||
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && (permission_exists('time_condition_add') || permission_exists('time_condition_edit') || permission_exists('time_condition_delete'))) ||
|
||||
permission_exists('dialplan_add') || permission_exists('dialplan_edit') || permission_exists('dialplan_delete')
|
||||
) {
|
||||
echo " <th class='checkbox'>\n";
|
||||
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".($dialplans ?: "style='visibility: hidden;'").">\n";
|
||||
echo " </th>\n";
|
||||
}
|
||||
if ($_GET['show'] == "all" && permission_exists('destination_all')) {
|
||||
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, $param);
|
||||
if ($_GET['show'] == "all" && permission_exists('dialplan_all')) {
|
||||
echo "<th>".$text['label-domain']."</th>\n";
|
||||
}
|
||||
echo th_order_by('dialplan_name', $text['label-name'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".escape($search) : null));
|
||||
echo th_order_by('dialplan_number', $text['label-number'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".escape($search) : null));
|
||||
if ($search) { $params[] = "search=".urlencode($search); }
|
||||
if ($_GET['show'] == 'all' && permission_exists('dialplan_all')) { $params[] = "show=all"; }
|
||||
echo th_order_by('dialplan_name', $text['label-name'], $order_by, $order, $app_uuid, null, ($params ? implode('&', $params) : null));
|
||||
echo th_order_by('dialplan_number', $text['label-number'], $order_by, $order, $app_uuid, null, ($params ? implode('&', $params) : null));
|
||||
if (permission_exists('dialplan_context')) {
|
||||
echo th_order_by('dialplan_context', $text['label-context'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".escape($search) : null));
|
||||
echo th_order_by('dialplan_context', $text['label-context'], $order_by, $order, $app_uuid, null, ($params ? implode('&', $params) : null));
|
||||
}
|
||||
echo th_order_by('dialplan_order', $text['label-order'], $order_by, $order, $app_uuid, "style='text-align: center;'", (($search != '') ? "search=".escape($search) : null));
|
||||
echo th_order_by('dialplan_enabled', $text['label-enabled'], $order_by, $order, $app_uuid, "style='text-align: center;'", (($search != '') ? "search=".escape($search) : null));
|
||||
echo th_order_by('dialplan_description', $text['label-description'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".escape($search) : null));
|
||||
echo "<td class='list_control_icons'>";
|
||||
if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_add')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/dialplan_inbound/dialplan_inbound_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
echo th_order_by('dialplan_order', $text['label-order'], $order_by, $order, $app_uuid, "class='center shrink'", ($params ? implode('&', $params) : null));
|
||||
echo th_order_by('dialplan_enabled', $text['label-enabled'], $order_by, $order, $app_uuid, "class='center'", ($params ? implode('&', $params) : null));
|
||||
echo th_order_by('dialplan_description', $text['label-description'], $order_by, $order, $app_uuid, "class='hide-sm-dn' style='min-width: 100px;'", ($params ? implode('&', $params) : null));
|
||||
unset($params);
|
||||
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')) ||
|
||||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) ||
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) ||
|
||||
permission_exists('dialplan_edit')) && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true'
|
||||
) {
|
||||
echo " <td class='action-button'> </td>\n";
|
||||
}
|
||||
elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_add')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/dialplan_outbound/dialplan_outbound_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_add')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/fifo/fifo_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_add')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
elseif (permission_exists('dialplan_add')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/dialplans/dialplan_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
if (permission_exists('dialplan_delete') && @sizeof($dialplans) != 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";
|
||||
|
||||
if (is_array($dialplans) && @sizeof($dialplans) != 0) {
|
||||
foreach($dialplans as $row) {
|
||||
$x = 0;
|
||||
foreach ($dialplans as $row) {
|
||||
|
||||
//get the application id
|
||||
$app_uuid = $row['app_uuid'];
|
||||
|
||||
// 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
|
||||
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 :
|
||||
default:
|
||||
unset($app_uuid);
|
||||
}
|
||||
|
||||
if ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) {
|
||||
$tr_link = "href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php?id=".escape($row['dialplan_uuid']).(($app_uuid != '') ? "&app_uuid=".escape($app_uuid) : null)."'";
|
||||
$list_row_url = PROJECT_PATH."/app/time_conditions/time_condition_edit.php?id=".urlencode($row['dialplan_uuid']).(is_uuid($app_uuid) ? "&app_uuid=".urlencode($app_uuid) : null);
|
||||
}
|
||||
elseif (
|
||||
else 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')) ||
|
||||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) ||
|
||||
permission_exists('dialplan_edit')
|
||||
) {
|
||||
$tr_link = "href='dialplan_edit.php?id=".escape($row['dialplan_uuid']).(($app_uuid != '') ? "&app_uuid=".escape($app_uuid) : null)."'";
|
||||
$list_row_url = "dialplan_edit.php?id=".urlencode($row['dialplan_uuid']).(is_uuid($app_uuid) ? "&app_uuid=".urlencode($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_".escape($row['dialplan_uuid'])."' value='".escape($row['dialplan_uuid'])."'></td>\n";
|
||||
$dialplan_ids[] = 'checkbox_'.escape($row['dialplan_uuid']);
|
||||
echo "<tr class='list-row' href='".$list_row_url."'>\n";
|
||||
if (
|
||||
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && (permission_exists('inbound_route_copy') || permission_exists('inbound_route_edit') || permission_exists('inbound_route_delete'))) ||
|
||||
($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && (permission_exists('outbound_route_copy') || permission_exists('outbound_route_edit') || permission_exists('outbound_route_delete'))) ||
|
||||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && (permission_exists('fifo_add') || permission_exists('fifo_edit') || permission_exists('fifo_delete'))) ||
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && (permission_exists('time_condition_add') || permission_exists('time_condition_edit') || permission_exists('time_condition_delete'))) ||
|
||||
permission_exists('dialplan_add') || permission_exists('dialplan_edit') || permission_exists('dialplan_delete')
|
||||
) {
|
||||
echo " <td class='checkbox'>\n";
|
||||
echo " <input type='checkbox' name='dialplans[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
|
||||
echo " <input type='hidden' name='dialplans[$x][uuid]' value='".escape($row['dialplan_uuid'])."' />\n";
|
||||
echo " </td>\n";
|
||||
}
|
||||
if ($_GET['show'] == "all" && permission_exists('dialplan_all')) {
|
||||
if (strlen($_SESSION['domains'][$row['domain_uuid']]['domain_name']) > 0) {
|
||||
@@ -356,113 +400,63 @@
|
||||
else {
|
||||
$domain = $text['label-global'];
|
||||
}
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($domain)."</td>\n";
|
||||
echo " <td>".escape($domain)."</td>\n";
|
||||
}
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>";
|
||||
if ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php?id=".escape($row['dialplan_uuid']).(($app_uuid != '') ? "&app_uuid=".$app_uuid : null)."'>".escape($row['dialplan_name'])."</a>";
|
||||
}
|
||||
elseif (
|
||||
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_edit')) ||
|
||||
($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_edit')) ||
|
||||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) ||
|
||||
permission_exists('dialplan_edit')
|
||||
) {
|
||||
echo "<a href='dialplan_edit.php?id=".escape($row['dialplan_uuid']).(($app_uuid != '') ? "&app_uuid=".escape($app_uuid) : null)."'>".escape($row['dialplan_name'])."</a>";
|
||||
echo " <td>";
|
||||
if ($list_row_url) {
|
||||
echo "<a href='".$list_row_url."'>".escape($row['dialplan_name'])."</a>";
|
||||
}
|
||||
else {
|
||||
echo escape($row['dialplan_name']);
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".((strlen($row['dialplan_number']) > 0) ? escape(format_phone($row['dialplan_number'])) : " ")."</td>\n";
|
||||
echo " <td>".((strlen($row['dialplan_number']) > 0) ? escape(format_phone($row['dialplan_number'])) : " ")."</td>\n";
|
||||
if (permission_exists('dialplan_context')) {
|
||||
echo " <td valign='top' class='".$row_style[$c]."'>".escape($row['dialplan_context'])."</td>\n";
|
||||
echo " <td>".escape($row['dialplan_context'])."</td>\n";
|
||||
}
|
||||
echo " <td valign='top' class='".$row_style[$c]."' style='text-align: center;'>".escape($row['dialplan_order'])."</td>\n";
|
||||
echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='text-align: center;'>";
|
||||
echo " <a href='?id=".escape($row['dialplan_uuid'])."&enabled=".(($row['dialplan_enabled'] == 'true') ? 'false' : 'true').(($app_uuid != '') ? "&app_uuid=".escape($app_uuid) : null).(($search != '') ? "&search=".escape($search) : null).(($order_by != '') ? "&order_by=".escape($order_by)."&order=".escape($order) : null)."'>".$text['label-'.$row['dialplan_enabled']]."</a>\n";
|
||||
echo " </td>\n";
|
||||
echo " <td valign='top' class='row_stylebg' width='30%'>".((strlen($row['dialplan_description']) > 0) ? escape($row['dialplan_description']) : " ")."</td>\n";
|
||||
echo " <td class='list_control_icons'>\n";
|
||||
if ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php?id=".escape($row['dialplan_uuid']).(($app_uuid != '') ? "&app_uuid=".escape($app_uuid) : null)."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
|
||||
}
|
||||
elseif (
|
||||
echo " <td class='center'>".escape($row['dialplan_order'])."</td>\n";
|
||||
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')) ||
|
||||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) ||
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) ||
|
||||
permission_exists('dialplan_edit')
|
||||
) {
|
||||
echo "<a href='dialplan_edit.php?id=".escape($row['dialplan_uuid']).(($app_uuid != '') ? "&app_uuid=".escape($app_uuid) : null)."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
|
||||
echo " <td class='no-link center'>";
|
||||
echo button::create(['type'=>'submit','class'=>'link','label'=>$text['label-'.$row['dialplan_enabled']],'title'=>$text['button-toggle'],'onclick'=>"list_self_check('checkbox_".$x."'); list_action_set('toggle'); list_form_submit('form_list')"]);
|
||||
}
|
||||
if (
|
||||
($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_delete')) ||
|
||||
($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_delete')) ||
|
||||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_delete')) ||
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_delete')) ||
|
||||
permission_exists('dialplan_delete')
|
||||
) {
|
||||
echo "<a href=\"dialplan_delete.php?id[]=".escape($row['dialplan_uuid']).(($app_uuid != '') ? "&app_uuid=".escape($app_uuid) : null)."\" alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
|
||||
else {
|
||||
echo " <td class='center'>";
|
||||
echo $text['label-'.$row['dialplan_enabled']];
|
||||
}
|
||||
echo " </td>\n";
|
||||
echo "</tr>\n";
|
||||
$c = $c == 0 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
echo "<tr>\n";
|
||||
echo "<td colspan='9'>\n";
|
||||
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
|
||||
echo " <tr>\n";
|
||||
echo " <td width='33.3%'> </td>\n";
|
||||
echo " <td width='33.3%'> </td>\n";
|
||||
echo " <td class='list_control_icons'>";
|
||||
if ($app_uuid == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_add')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/dialplan_inbound/dialplan_inbound_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
elseif ($app_uuid == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_add')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/dialplan_outbound/dialplan_outbound_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
elseif ($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_add')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/fifo/fifo_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
elseif ($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_add')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/time_conditions/time_condition_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
elseif (permission_exists('dialplan_add')) {
|
||||
echo "<a href='".PROJECT_PATH."/app/dialplans/dialplan_add.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
|
||||
}
|
||||
if (permission_exists('dialplan_delete') && @sizeof($dialplans) != 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";
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
echo "</table>";
|
||||
echo "</form>";
|
||||
|
||||
if (strlen($paging_controls) > 0) {
|
||||
echo "<br />";
|
||||
echo $paging_controls."\n";
|
||||
}
|
||||
echo "<br><br>";
|
||||
|
||||
if (!empty($dialplan_ids) && sizeof($dialplan_ids) > 0) {
|
||||
echo "<script>\n";
|
||||
echo " function check(what) {\n";
|
||||
echo " document.getElementById('chk_all').checked = (what == 'all') ? true : false;\n";
|
||||
foreach ($dialplan_ids as $checkbox_id) {
|
||||
echo "document.getElementById('$checkbox_id').checked = (what == 'all') ? true : false;\n";
|
||||
echo " <td class='description overflow hide-sm-dn'>".escape($row['dialplan_description'])." </td>\n";
|
||||
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')) ||
|
||||
($app_uuid == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) ||
|
||||
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit')) ||
|
||||
permission_exists('dialplan_edit')) && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true'
|
||||
) {
|
||||
echo " <td class='action-button'>";
|
||||
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
|
||||
echo " </td>\n";
|
||||
}
|
||||
echo " }\n";
|
||||
echo "</script>\n";
|
||||
echo "</tr>\n";
|
||||
$x++;
|
||||
}
|
||||
unset($dialplans);
|
||||
}
|
||||
|
||||
unset($dialplans, $row);
|
||||
echo "</table>\n";
|
||||
echo "<br />\n";
|
||||
echo "<div align='center'>".$paging_controls."</div>\n";
|
||||
|
||||
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
||||
|
||||
echo "</form>\n";
|
||||
|
||||
//include the footer
|
||||
require_once "resources/footer.php";
|
||||
|
||||
?>
|
||||
?>
|
||||
@@ -68,10 +68,32 @@ include "root.php";
|
||||
public $is_empty;
|
||||
public $array;
|
||||
|
||||
/**
|
||||
* declare public/private properties
|
||||
*/
|
||||
private $app_name;
|
||||
public $app_uuid;
|
||||
private $permission_prefix;
|
||||
public $list_page;
|
||||
private $table;
|
||||
private $uuid_prefix;
|
||||
private $toggle_field;
|
||||
private $toggle_values;
|
||||
|
||||
//class constructor
|
||||
public function __construct() {
|
||||
//set the default value
|
||||
$this->dialplan_global = false;
|
||||
|
||||
//assign property defaults
|
||||
$this->app_name = 'dialplans';
|
||||
$this->app_uuid = '742714e5-8cdf-32fd-462c-cbe7e3d655db'; //dialplans
|
||||
$this->permission_prefix = 'dialplan_';
|
||||
$this->list_page = 'dialplans.php';
|
||||
$this->table = 'dialplans';
|
||||
$this->uuid_prefix = 'dialplan_';
|
||||
$this->toggle_field = 'dialplan_enabled';
|
||||
$this->toggle_values = ['true','false'];
|
||||
}
|
||||
|
||||
public function dialplan_add() {
|
||||
@@ -998,7 +1020,360 @@ include "root.php";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* delete records
|
||||
*/
|
||||
public function delete($records) {
|
||||
|
||||
//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['dialplan_details'][$x]['dialplan_uuid'] = $record['uuid'];
|
||||
|
||||
//get the dialplan context
|
||||
$sql = "select dialplan_context from v_dialplans ";
|
||||
$sql .= "where dialplan_uuid = :dialplan_uuid ";
|
||||
$parameters['dialplan_uuid'] = $record['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_delete', 'temp');
|
||||
$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);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('dialplan_delete', 'temp');
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
//set message
|
||||
message::add($text['message-delete'].': '.@sizeof($array[$this->table]));
|
||||
|
||||
}
|
||||
unset($records);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* toggle records
|
||||
*/
|
||||
public function toggle($records) {
|
||||
|
||||
//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.'edit')) {
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
//toggle the checked records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//get current toggle state
|
||||
foreach($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
if (is_array($record_uuids) && @sizeof($record_uuids) != 0) {
|
||||
$sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as toggle, dialplan_context from v_".$this->table." ";
|
||||
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
|
||||
$sql .= "and ( ".implode(' or ', $record_uuids)." ) ";
|
||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
foreach ($rows as $row) {
|
||||
$states[$row['uuid']] = $row['toggle'];
|
||||
$dialplan_contexts[] = $row['dialplan_context'];
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//build update array
|
||||
$x = 0;
|
||||
foreach($states as $uuid => $state) {
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $uuid;
|
||||
$array[$this->table][$x][$this->toggle_field] = $state == $this->toggle_values[0] ? $this->toggle_values[1] : $this->toggle_values[0];
|
||||
$x++;
|
||||
}
|
||||
|
||||
//save the changes
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_edit', 'temp');
|
||||
|
||||
//save the array
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('dialplan_edit', '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);
|
||||
}
|
||||
}
|
||||
|
||||
//set message
|
||||
message::add($text['message-toggle']);
|
||||
}
|
||||
unset($records, $states);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* copy records
|
||||
*/
|
||||
public function copy($records) {
|
||||
|
||||
//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.'add')) {
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
//copy the checked records
|
||||
if (is_array($records) && @sizeof($records) != 0) {
|
||||
|
||||
//get checked records
|
||||
foreach($records as $x => $record) {
|
||||
if ($record['checked'] == 'true' && is_uuid($record['uuid'])) {
|
||||
$record_uuids[] = $this->uuid_prefix."uuid = '".$record['uuid']."'";
|
||||
}
|
||||
}
|
||||
|
||||
//create insert array from existing data
|
||||
if (is_array($record_uuids) && @sizeof($record_uuids) != 0) {
|
||||
|
||||
//primary table
|
||||
$sql = "select * from v_".$this->table." ";
|
||||
$sql .= "where ".implode(' or ', $record_uuids)." ";
|
||||
$database = new database;
|
||||
$rows = $database->select($sql, $parameters, 'all');
|
||||
if (is_array($rows) && @sizeof($rows) != 0) {
|
||||
$y = 0;
|
||||
foreach ($rows as $x => $row) {
|
||||
$primary_uuid = uuid();
|
||||
|
||||
//copy data
|
||||
$array[$this->table][$x] = $row;
|
||||
|
||||
//overwrite
|
||||
$array[$this->table][$x][$this->uuid_prefix.'uuid'] = $primary_uuid;
|
||||
$array[$this->table][$x]['dialplan_description'] = trim($row['dialplan_description'].' ('.$text['label-copy'].')');
|
||||
|
||||
//details sub table
|
||||
$sql_2 = "select * from v_dialplan_details where dialplan_uuid = :dialplan_uuid";
|
||||
$parameters_2['dialplan_uuid'] = $row['dialplan_uuid'];
|
||||
$database = new database;
|
||||
$rows_2 = $database->select($sql_2, $parameters_2, 'all');
|
||||
if (is_array($rows_2) && @sizeof($rows_2) != 0) {
|
||||
foreach ($rows_2 as $row_2) {
|
||||
|
||||
//copy data
|
||||
$array['dialplan_details'][$y] = $row_2;
|
||||
|
||||
//overwrite
|
||||
$array['dialplan_details'][$y]['dialplan_detail_uuid'] = uuid();
|
||||
$array['dialplan_details'][$y]['dialplan_uuid'] = $primary_uuid;
|
||||
|
||||
//increment
|
||||
$y++;
|
||||
|
||||
}
|
||||
}
|
||||
unset($sql_2, $parameters_2, $rows_2, $row_2);
|
||||
|
||||
//get dialplan contexts
|
||||
$dialplan_contexts[] = $row['dialplan_context'];
|
||||
}
|
||||
}
|
||||
unset($sql, $parameters, $rows, $row);
|
||||
}
|
||||
|
||||
//save the changes and set the message
|
||||
if (is_array($array) && @sizeof($array) != 0) {
|
||||
|
||||
//grant temporary permissions
|
||||
$p = new permissions;
|
||||
$p->add('dialplan_detail_add', 'temp');
|
||||
|
||||
//save the array
|
||||
$database = new database;
|
||||
$database->app_name = $this->app_name;
|
||||
$database->app_uuid = $this->app_uuid;
|
||||
$database->save($array);
|
||||
unset($array);
|
||||
|
||||
//revoke temporary permissions
|
||||
$p->delete('dialplan_detail_add', '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);
|
||||
}
|
||||
}
|
||||
|
||||
//set message
|
||||
message::add($text['message-copy']);
|
||||
|
||||
}
|
||||
unset($records);
|
||||
}
|
||||
|
||||
}
|
||||
} //method
|
||||
|
||||
|
||||
} //class
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
Reference in New Issue
Block a user