fusionpbx/app/dialplans/dialplans.php

659 lines
32 KiB
PHP
Raw Normal View History

<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2023
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
2022-10-10 21:18:34 +02:00
//includes files
Use magic constant dir (#6711) * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ * use magic constant __DIR__ to load only functions.php * replace spaces with tab character * update dirname command to use levels instead of nesting * use magic constant __DIR__ * update dirname command to use levels instead of nesting * Update access_control_edit.php * Update access_control_import.php * Update access_controls.php * Update dnd.php * Update access_controls_reload.php * Update call_center_agents.php * Update call_center_agents.php * Update fax_queue.php * Update login.php * Update pdo.php * Update pdo_vm.php * Update switch.php * Update index.php * Update css.php * Update v_mailto.php * Update fax_to_email.php --------- Co-authored-by: FusionPBX <markjcrane@gmail.com>
2023-06-15 19:28:23 +02:00
require_once dirname(__DIR__, 2) . "/resources/require.php";
require_once "resources/check_auth.php";
2019-11-08 07:05:38 +01:00
require_once "resources/paging.php";
//check permissions
2023-05-13 05:21:32 +02:00
if (permission_exists('dialplan_view') || permission_exists('inbound_route_view') || permission_exists('outbound_route_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//drop app uuid from the query if not from specific apps
$allowed_app_uuids = [
'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4', //inbound routes
'8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3', //outbound routes
'16589224-c876-aeb3-f59f-523a1c0801f7', //fifo queues
'4b821450-926b-175a-af93-a03c441818b1', //time conditions
];
if (!empty($_GET['app_uuid']) && is_uuid($_GET['app_uuid']) && !in_array($_GET['app_uuid'], $allowed_app_uuids)) {
unset($_GET['app_uuid']);
header('Location: dialplans.php'.(!empty($_GET) ? '?'.http_build_query($_GET) : null));
exit;
}
2019-11-08 07:05:38 +01:00
//get posted data
2023-05-09 06:55:00 +02:00
if (!empty($_POST['dialplans'])) {
2019-11-08 07:05:38 +01:00
$action = $_POST['action'];
$dialplans = $_POST['dialplans'];
$context = $_POST['context'];
2019-11-08 07:05:38 +01:00
$search = $_POST['search'];
$order_by = $_POST['order_by'];
$order = $_POST['order'];
}
2019-11-28 10:30:09 +01:00
//get the app uuid
2023-05-13 05:21:32 +02:00
$app_uuid = (!empty($_REQUEST["app_uuid"]) && is_uuid($_REQUEST["app_uuid"])) ? $_REQUEST["app_uuid"] : '';
2019-11-28 10:30:09 +01:00
2019-11-30 22:18:00 +01:00
//process the http post data by action
2023-05-09 06:55:00 +02:00
if (!empty($action) && is_array($dialplans) && @sizeof($dialplans) != 0) {
2019-11-08 07:05:38 +01:00
//define redirect parameters and url
2023-05-13 05:21:32 +02:00
if (!empty($app_uuid)) { $params[] = "app_uuid=".urlencode($app_uuid); }
if ($context) { $params[] = "context=".urlencode($context); }
2019-11-08 07:05:38 +01:00
if ($search) { $params[] = "search=".urlencode($search); }
if ($order_by) { $params[] = "order_by=".urlencode($order_by); }
if ($order) { $params[] = "order=".urlencode($order); }
2023-05-21 01:57:44 +02:00
$list_page = 'dialplans.php'.(!empty($params) ? '?'.implode('&', $params) : null);
2019-11-08 07:05:38 +01:00
unset($params);
2019-11-30 19:12:41 +01:00
//process action
switch ($action) {
case 'copy':
if (permission_exists('dialplan_add')) {
2019-11-30 22:18:00 +01:00
$obj = new dialplan;
$obj->app_uuid = $app_uuid;
$obj->list_page = $list_page;
2019-11-30 19:12:41 +01:00
$obj->copy($dialplans);
}
break;
case 'toggle':
if (permission_exists('dialplan_edit')) {
2019-11-30 22:18:00 +01:00
$obj = new dialplan;
$obj->app_uuid = $app_uuid;
$obj->list_page = $list_page;
2019-11-30 19:12:41 +01:00
$obj->toggle($dialplans);
}
break;
case 'delete':
if (permission_exists('dialplan_delete')) {
2019-11-30 22:18:00 +01:00
$obj = new dialplan;
$obj->app_uuid = $app_uuid;
$obj->list_page = $list_page;
2019-11-30 19:12:41 +01:00
$obj->delete($dialplans);
}
break;
2019-11-08 07:05:38 +01:00
}
2016-12-13 16:49:33 +01:00
2019-11-08 07:05:38 +01:00
//redirect
2019-11-30 22:18:00 +01:00
header('Location: '.$list_page);
2019-11-08 07:05:38 +01:00
exit;
}
2019-11-08 07:05:38 +01:00
//get order and order by and sanatize the values
2023-05-13 05:21:32 +02:00
$order_by = (!empty($_GET["order_by"])) ? $_GET["order_by"] : '';
$order = (!empty($_GET["order"])) ? $_GET["order"] : '';
2019-11-08 07:05:38 +01:00
//make sure all dialplans with context of public have the inbound route app_uuid
2023-05-13 05:21:32 +02:00
if (!empty($app_uuid) && $app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
$sql = "update v_dialplans set ";
$sql .= "app_uuid = 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ";
$sql .= "where dialplan_context = 'public' ";
$sql .= "and app_uuid is null; ";
2019-08-06 03:18:21 +02:00
$database = new database;
$database->execute($sql);
unset($sql);
}
2023-05-13 05:21:32 +02:00
//set additional variables
$context = !empty($_GET["context"]) ? $_GET["context"] : '';
$search = !empty($_GET["search"]) ? $_GET["search"] : '';
$show = !empty($_GET["show"]) ? $_GET["show"] : '';
//set from session variables
$list_row_edit_button = filter_var($_SESSION['theme']['list_row_edit_button']['boolean'] ?? false, FILTER_VALIDATE_BOOL);
$button_icon_add = $_SESSION['theme']['button_icon_add'] ?? '';
$button_icon_copy = $_SESSION['theme']['button_icon_copy'] ?? '';
$button_icon_toggle = $_SESSION['theme']['button_icon_toggle'] ?? '';
$button_icon_all = $_SESSION['theme']['button_icon_all'] ?? '';
$button_icon_delete = $_SESSION['theme']['button_icon_delete'] ?? '';
$button_icon_search = $_SESSION['theme']['button_icon_search'] ?? '';
$button_icon_edit = $_SESSION['theme']['button_icon_edit'] ?? '';
$button_icon_reset = $_SESSION['theme']['button_icon_reset'] ?? '';
2019-11-08 07:05:38 +01:00
//get the number of rows in the dialplan
2019-11-05 05:13:32 +01:00
$sql = "select count(*) from v_dialplans ";
2023-05-13 05:21:32 +02:00
if ($show == "all" && permission_exists('dialplan_all')) {
2019-11-05 05:13:32 +01:00
$sql .= "where true ";
2019-06-27 16:08:41 +02:00
}
else {
$sql .= "where domain_uuid = :domain_uuid ";
2019-08-06 03:18:21 +02:00
$parameters['domain_uuid'] = $domain_uuid;
2019-06-27 16:08:41 +02:00
}
2023-05-13 05:21:32 +02:00
if (empty($app_uuid)) {
//hide inbound routes
2019-11-05 05:13:32 +01:00
$sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ";
$sql .= "and dialplan_context <> 'public' ";
//hide outbound routes
//$sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
}
else {
2023-05-13 05:21:32 +02:00
if (!empty($app_uuid) && $app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
2019-11-05 05:13:32 +01:00
$sql .= "and (app_uuid = :app_uuid or dialplan_context = 'public') ";
2019-08-06 03:18:21 +02:00
}
else {
2019-11-05 05:13:32 +01:00
$sql .= "and app_uuid = :app_uuid ";
2019-08-06 03:18:21 +02:00
}
$parameters['app_uuid'] = $app_uuid;
}
2023-05-13 05:21:32 +02:00
if (!empty($context)) {
$sql .= "and dialplan_context = :dialplan_context ";
$parameters['dialplan_context'] = $context;
}
2023-05-13 05:21:32 +02:00
if (!empty($search)) {
2023-01-12 04:21:14 +01:00
$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 ";
$sql .= " or lower(dialplan_enabled) like :search ";
$sql .= " or lower(dialplan_description) like :search ";
if (is_numeric($search)) {
$sql .= " or dialplan_order = :search_numeric ";
2023-01-12 04:21:14 +01:00
$parameters['search_numeric'] = $search;
}
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
2019-08-06 03:18:21 +02:00
$database = new database;
2023-05-13 05:21:32 +02:00
$num_rows = $database->select($sql, $parameters ?? null, 'column');
2019-11-05 05:13:32 +01:00
//prepare the paging
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
2023-05-13 05:21:32 +02:00
if (!empty($app_uuid)) { $params[] = "app_uuid=".urlencode($app_uuid); }
if (!empty($context)) { $params[] = "context=".urlencode($context); }
if (!empty($search)) { $params[] = "search=".urlencode($search); }
if (!empty($order_by)) { $params[] = "order_by=".urlencode($order_by); }
if (!empty($order)) { $params[] = "order=".urlencode($order); }
if ($show == "all" && permission_exists('dialplan_all')) {
$params[] = "show=all";
2019-06-27 16:08:41 +02:00
}
2023-05-09 06:55:00 +02:00
if (!empty($params)) {
$param = $params ? implode('&', $params) : null;
}
else {
$param = null;
}
2019-11-08 07:05:38 +01:00
unset($params);
2023-05-09 06:55:00 +02:00
if (empty($_GET['page'])) { $page = 0; } else { $page = $_GET['page']; }
2019-11-08 07:05:38 +01:00
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
2023-01-12 04:21:14 +01:00
$sql = "select * from v_dialplans ";
2023-05-13 05:21:32 +02:00
if ($show == "all" && permission_exists('dialplan_all')) {
2023-01-12 04:21:14 +01:00
$sql .= "where true ";
}
else {
$sql .= "where (";
$sql .= " domain_uuid = :domain_uuid ";
if (permission_exists('dialplan_global')) {
$sql .= " or domain_uuid is null ";
}
$sql .= ") ";
2023-01-12 04:21:14 +01:00
$parameters['domain_uuid'] = $domain_uuid;
}
if (!is_uuid($app_uuid)) {
//hide inbound routes
$sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ";
$sql .= "and dialplan_context <> 'public' ";
//hide outbound routes
//$sql .= "and app_uuid <> '8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3' ";
}
else {
if ($app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4') {
$sql .= "and (app_uuid = :app_uuid or dialplan_context = 'public') ";
}
else {
$sql .= "and app_uuid = :app_uuid ";
}
$parameters['app_uuid'] = $app_uuid;
}
2023-05-13 05:21:32 +02:00
if (!empty($context)) {
$sql .= "and dialplan_context = :dialplan_context ";
$parameters['dialplan_context'] = $context;
}
2023-05-13 05:21:32 +02:00
if (!empty($search)) {
2023-01-12 04:21:14 +01:00
$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 ";
$sql .= " or lower(dialplan_enabled) like :search ";
$sql .= " or lower(dialplan_description) like :search ";
2023-01-12 04:21:14 +01:00
if (is_numeric($search)) {
$sql .= " or dialplan_order = :search_numeric ";
2023-01-12 04:21:14 +01:00
$parameters['search_numeric'] = $search;
}
$sql .= ") ";
$parameters['search'] = '%'.$search.'%';
}
2023-05-13 05:21:32 +02:00
if (!empty($order_by)) {
2019-11-08 07:05:38 +01:00
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 ";
}
2019-11-05 06:04:22 +01:00
$sql .= limit_offset($rows_per_page, $offset);
2019-08-06 03:18:21 +02:00
$database = new database;
2023-05-13 05:21:32 +02:00
$dialplans = $database->select($sql, $parameters ?? null, 'all');
2019-08-06 03:18:21 +02:00
unset($sql, $parameters);
//get the list of all dialplan contexts
$sql = "select dc.* from ( ";
$sql .= "select distinct dialplan_context from v_dialplans ";
2023-05-13 05:21:32 +02:00
if ($show == "all" && permission_exists('dialplan_all')) {
$sql .= "where true ";
}
else {
$sql .= "where (domain_uuid = :domain_uuid or domain_uuid is null) ";
$parameters['domain_uuid'] = $domain_uuid;
}
if (!is_uuid($app_uuid)) {
//hide inbound routes
$sql .= "and app_uuid <> 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ";
$sql .= "and dialplan_context <> 'public' ";
}
else {
$sql .= "and (app_uuid = :app_uuid ".($app_uuid == 'c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4' ? "or dialplan_context = 'public'" : null).") ";
$parameters['app_uuid'] = $app_uuid;
}
$sql .= ") as dc ";
$database = new database;
2023-05-13 05:21:32 +02:00
$rows = $database->select($sql, $parameters ?? null, 'all');
if (is_array($rows) && @sizeof($rows) != 0) {
foreach ($rows as $row) {
//reverse the array's (string) values in preparation to sort
$dialplan_contexts[] = strrev($row['dialplan_context']);
}
//sort the reversed context values, now grouping them by the domain
sort($dialplan_contexts, SORT_NATURAL);
//create new array
foreach ($dialplan_contexts as $dialplan_context) {
//if no subcontext (doesn't contain '@'), create new key in array with a null value
if (!substr_count($dialplan_context, '@') || strrev($dialplan_context) == 'global' || strrev($dialplan_context) == 'public') {
$array[strrev($dialplan_context)] = null;
}
//subcontext (contains '@'), create new key in array, and place subcontext in subarray
else {
$dialplan_context_parts = explode('@', $dialplan_context);
$array[strrev($dialplan_context_parts[0])][] = strrev($dialplan_context_parts[1]);
}
}
// sort array by key (domain)
ksort($array, SORT_NATURAL);
// move global and public to beginning of array
if (array_key_exists('global', $array)) {
unset($array['global']);
$array = array_merge(['global'=>null], $array);
}
if (array_key_exists('public', $array)) {
unset($array['public']);
$array = array_merge(['public'=>null], $array);
}
$dialplan_contexts = $array;
unset($dialplan_context, $array, $dialplan_context_parts);
}
unset($sql, $parameters, $rows, $row);
2019-11-08 07:05:38 +01:00
//create token
$object = new token;
$token = $object->create($_SERVER['PHP_SELF']);
2019-11-08 07:05:38 +01:00
//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'];
}
2019-11-08 07:05:38 +01:00
require_once "resources/header.php";
//show the content
2019-11-08 07:05:38 +01:00
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'];
}
2024-09-07 00:43:42 +02:00
echo "</b><div class='count'>".number_format($num_rows)."</div>";
2019-11-08 07:05:38 +01:00
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) {
2023-05-13 05:21:32 +02:00
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$button_icon_add,'id'=>'btn_add','link'=>$button_add_url]);
2019-11-08 07:05:38 +01:00
}
2023-05-13 05:21:32 +02:00
if (!empty($dialplans)) {
2019-11-08 07:05:38 +01:00
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')
) {
2023-05-13 05:21:32 +02:00
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$button_icon_copy,'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
2019-11-08 07:05:38 +01:00
}
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')
) {
2023-05-13 05:21:32 +02:00
echo button::create(['type'=>'button','label'=>$text['button-toggle'],'icon'=>$button_icon_toggle,'id'=>'btn_toggle','name'=>'btn_toggle','style'=>'display: none;','onclick'=>"modal_open('modal-toggle','btn_toggle');"]);
2019-11-08 07:05:38 +01:00
}
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')
) {
2023-05-13 05:21:32 +02:00
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$button_icon_delete,'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
2019-11-08 07:05:38 +01:00
}
}
2019-11-08 07:05:38 +01:00
echo "<form id='form_search' class='inline' method='get'>\n";
2019-06-27 16:08:41 +02:00
if (permission_exists('dialplan_all')) {
2023-05-13 05:21:32 +02:00
if ($show == 'all' && permission_exists('dialplan_all')) {
2019-06-27 16:08:41 +02:00
echo " <input type='hidden' name='show' value='all'>";
}
else {
2023-05-13 05:21:32 +02:00
if (!empty($app_uuid)) { $params[] = "app_uuid=".urlencode($app_uuid); }
if (!empty($context)) { $params[] = "context=".urlencode($context); }
if (!empty($search)) { $params[] = "search=".urlencode($search); }
if (!empty($order_by)) { $params[] = "order_by=".urlencode($order_by); }
if (!empty($order)) { $params[] = "order=".urlencode($order); }
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$button_icon_all,'link'=>'?show=all'.(!empty($params) ? '&'.implode('&', $params) : null)]);
2019-11-08 07:05:38 +01:00
unset($params);
2019-06-27 16:08:41 +02:00
}
}
2023-05-13 05:21:32 +02:00
if (!empty($app_uuid)) {
2019-11-08 07:05:38 +01:00
echo "<input type='hidden' name='app_uuid' value='".escape($app_uuid)."'>";
}
2023-05-13 05:21:32 +02:00
if (!empty($order_by)) {
2019-11-08 07:05:38 +01:00
echo "<input type='hidden' name='order_by' value='".escape($order_by)."'>";
}
2023-05-13 05:21:32 +02:00
if (!empty($order)) {
2019-11-08 07:05:38 +01:00
echo "<input type='hidden' name='order' value='".escape($order)."'>";
}
if (permission_exists('dialplan_context')) {
2023-05-13 05:21:32 +02:00
echo "<select name='context' id='context' class='formfld' style='max-width: ".(empty($context) || $context == 'global' ? '80px' : '140px')."; margin-left: 18px;' onchange=\"$('#form_search').submit();\">\n";
echo "<option value='' ".(!$context ? "selected='selected'" : null)." disabled='disabled'>".$text['label-context']."...</option>\n";
echo "<option value=''></option>\n";
2023-05-25 22:57:05 +02:00
if (!empty($dialplan_contexts) && is_array($dialplan_contexts) && @sizeof($dialplan_contexts) != 0) {
foreach ($dialplan_contexts as $dialplan_context => $dialplan_subcontexts) {
if (is_array($dialplan_subcontexts) && @sizeof($dialplan_subcontexts) != 0) {
echo "<option value='".$dialplan_context."' ".($context == $dialplan_context ? "selected='selected'" : null).">".escape($dialplan_context)."</option>\n";
foreach ($dialplan_subcontexts as $dialplan_subcontext) {
echo "<option value='".$dialplan_subcontext."@".$dialplan_context."' ".($context == $dialplan_subcontext."@".$dialplan_context ? "selected='selected'" : null).">&nbsp;&nbsp;&nbsp;".escape($dialplan_subcontext)."@</option>\n";
}
}
else {
$dialplan_context_label = in_array($dialplan_context, ['global','public']) ? ucwords($dialplan_context) : $dialplan_context;
echo "<option value='".$dialplan_context."' ".($context == $dialplan_context ? "selected='selected'" : null).">".escape($dialplan_context_label)."</option>\n";
}
}
}
echo "</select>\n";
}
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
2023-05-13 05:21:32 +02:00
echo button::create(['label'=>$text['button-search'],'icon'=>$button_icon_search,'type'=>'submit','id'=>'btn_search']);
$params[] = "app_uuid=".urlencode($app_uuid);
if (!empty($order_by)) { $params[] = "order_by=".urlencode($order_by); }
if (!empty($order)) { $params[] = "order=".urlencode($order); }
if (!empty($show) && permission_exists('dialplan_all')) { $params[] = "show=".urlencode($show); }
//echo button::create(['label'=>$text['button-reset'],'icon'=>$button_icon_reset,'type'=>'button','id'=>'btn_reset','link'=>'dialplans.php'.($params ? '?'.implode('&', $params) : null),'style'=>($search == '' ? 'display: none;' : null)]);
2019-11-08 07:05:38 +01:00
unset($params);
2023-05-13 05:21:32 +02:00
if (!empty($paging_controls_mini)) {
2019-11-08 07:05:38 +01:00
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
}
echo " </form>\n";
2019-11-08 07:05:38 +01:00
echo " </div>\n";
echo " <div style='clear: both;'></div>\n";
echo "</div>\n";
2023-05-13 05:21:32 +02:00
if (!empty($dialplans)) {
2020-03-26 16:06:12 +01:00
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 modal::create(['id'=>'modal-copy','type'=>'copy','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_copy','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('copy'); list_form_submit('form_list');"])]);
}
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 modal::create(['id'=>'modal-toggle','type'=>'toggle','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_toggle','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); 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 modal::create(['id'=>'modal-delete','type'=>'delete','actions'=>button::create(['type'=>'button','label'=>$text['button-continue'],'icon'=>'check','id'=>'btn_delete','style'=>'float: right; margin-left: 15px;','collapse'=>'never','onclick'=>"modal_close(); list_action_set('delete'); list_form_submit('form_list');"])]);
}
}
2019-11-08 07:05:38 +01:00
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'.(permission_exists('dialplan_edit') ? '-superadmin' : '')];
2019-11-08 07:05:38 +01:00
}
echo "\n<br /><br />\n";
2024-09-06 07:37:34 +02:00
2019-11-08 07:05:38 +01:00
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='context' value=\"".escape($context)."\">\n";
2019-11-08 07:05:38 +01:00
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";
2024-09-06 07:37:34 +02:00
echo "<div class='card'>\n";
2019-11-08 07:05:38 +01:00
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";
2023-05-13 05:21:32 +02:00
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(!empty($dialplans) ?: "style='visibility: hidden;'").">\n";
2019-11-08 07:05:38 +01:00
echo " </th>\n";
}
2023-05-13 05:21:32 +02:00
if ($show == "all" && permission_exists('dialplan_all')) {
2019-11-08 07:05:38 +01:00
echo "<th>".$text['label-domain']."</th>\n";
2019-06-27 16:35:31 +02:00
}
if ($context) { $params[] = "context=".urlencode($context); }
2019-11-08 07:05:38 +01:00
if ($search) { $params[] = "search=".urlencode($search); }
2023-05-13 05:21:32 +02:00
if ($show == 'all' && permission_exists('dialplan_all')) { $params[] = "show=all"; }
echo th_order_by('dialplan_name', $text['label-name'], $order_by, $order, $app_uuid, null, (!empty($params) ? implode('&', $params) : null));
echo th_order_by('dialplan_number', $text['label-number'], $order_by, $order, $app_uuid, null, (!empty($params) ? implode('&', $params) : null));
2019-08-06 23:00:51 +02:00
if (permission_exists('dialplan_context')) {
2023-05-13 05:21:32 +02:00
echo th_order_by('dialplan_context', $text['label-context'], $order_by, $order, $app_uuid, null, (!empty($params) ? implode('&', $params) : null));
2019-11-08 07:05:38 +01:00
}
2023-05-13 05:21:32 +02:00
echo th_order_by('dialplan_order', $text['label-order'], $order_by, $order, $app_uuid, "class='center shrink'", (!empty($params) ? implode('&', $params) : null));
echo th_order_by('dialplan_enabled', $text['label-enabled'], $order_by, $order, $app_uuid, "class='center'", (!empty($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;'", (!empty($params) ? implode('&', $params) : null));
2019-11-08 07:05:38 +01:00
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')) && $list_row_edit_button
2019-11-08 07:05:38 +01:00
) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
echo "</tr>\n";
2023-05-13 05:21:32 +02:00
if (!empty($dialplans)) {
2019-11-08 07:05:38 +01:00
$x = 0;
foreach ($dialplans as $row) {
$list_row_url = '';
2020-03-30 19:58:17 +02:00
if ($row['app_uuid'] == "4b821450-926b-175a-af93-a03c441818b1") {
if (permission_exists('time_condition_edit') || permission_exists('dialplan_edit')) {
$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);
if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
$list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
}
2020-03-30 19:58:17 +02:00
}
2015-02-25 10:52:12 +01:00
}
2019-11-08 07:05:38 +01:00
else if (
2020-03-30 19:58:17 +02:00
($row['app_uuid'] == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_edit')) ||
($row['app_uuid'] == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_edit')) ||
($row['app_uuid'] == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) ||
permission_exists('dialplan_edit')
) {
2019-11-08 07:05:38 +01:00
$list_row_url = "dialplan_edit.php?id=".urlencode($row['dialplan_uuid']).(is_uuid($app_uuid) ? "&app_uuid=".urlencode($app_uuid) : null);
if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
$list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
}
}
2020-03-30 19:58:17 +02:00
else {
unset($list_row_url);
}
2019-11-08 07:05:38 +01:00
echo "<tr class='list-row' href='".$list_row_url."'>\n";
if (
2020-03-30 19:58:17 +02:00
(!is_uuid($app_uuid) && (permission_exists('dialplan_add') || permission_exists('dialplan_edit') || permission_exists('dialplan_delete'))) ||
2019-11-08 07:05:38 +01:00
($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'))) ||
2020-03-30 19:58:17 +02:00
($app_uuid == "4b821450-926b-175a-af93-a03c441818b1" && (permission_exists('time_condition_add') || permission_exists('time_condition_edit') || permission_exists('time_condition_delete')))
2019-11-08 07:05:38 +01:00
) {
echo " <td class='checkbox'>\n";
echo " <input type='checkbox' name='dialplans[$x][checked]' id='checkbox_".$x."' value='true' onclick=\"checkbox_on_change(this); if (!this.checked) { document.getElementById('checkbox_all').checked = false; }\">\n";
2019-11-08 07:05:38 +01:00
echo " <input type='hidden' name='dialplans[$x][uuid]' value='".escape($row['dialplan_uuid'])."' />\n";
echo " </td>\n";
}
2023-05-13 05:21:32 +02:00
if ($show == "all" && permission_exists('dialplan_all')) {
if (!empty($_SESSION['domains'][$row['domain_uuid']]['domain_name'])) {
$domain = $_SESSION['domains'][$row['domain_uuid']]['domain_name'];
2019-06-27 16:35:31 +02:00
}
else {
$domain = $text['label-global'];
}
2019-11-08 07:05:38 +01:00
echo " <td>".escape($domain)."</td>\n";
2019-06-27 16:35:31 +02:00
}
2019-11-08 07:05:38 +01:00
echo " <td>";
if ($list_row_url) {
echo "<a href='".$list_row_url."'>".escape($row['dialplan_name'])."</a>";
}
else {
2018-06-04 01:42:57 +02:00
echo escape($row['dialplan_name']);
}
echo " </td>\n";
echo " <td>".((!empty($row['dialplan_number'])) ? escape(format_phone($row['dialplan_number'])) : "&nbsp;")."</td>\n";
2019-08-06 23:00:51 +02:00
if (permission_exists('dialplan_context')) {
2019-11-08 07:05:38 +01:00
echo " <td>".escape($row['dialplan_context'])."</td>\n";
2019-08-06 23:00:51 +02:00
}
2019-11-08 07:05:38 +01:00
echo " <td class='center'>".escape($row['dialplan_order'])."</td>\n";
if (
2020-03-30 19:58:17 +02:00
(!is_uuid($app_uuid) && permission_exists('dialplan_edit')) ||
($row['app_uuid'] == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_edit')) ||
($row['app_uuid'] == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_edit')) ||
($row['app_uuid'] == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) ||
($row['app_uuid'] == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit'))
) {
2019-11-08 07:05:38 +01:00
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')"]);
}
2019-11-08 07:05:38 +01:00
else {
echo " <td class='center'>";
echo $text['label-'.$row['dialplan_enabled']];
}
echo " </td>\n";
2019-11-08 07:05:38 +01:00
echo " <td class='description overflow hide-sm-dn'>".escape($row['dialplan_description'])."&nbsp;</td>\n";
if ($list_row_edit_button && (
2020-03-30 19:58:17 +02:00
(!is_uuid($app_uuid) && permission_exists('dialplan_edit')) ||
($row['app_uuid'] == "c03b422e-13a8-bd1b-e42b-b6b9b4d27ce4" && permission_exists('inbound_route_edit')) ||
($row['app_uuid'] == "8c914ec3-9fc0-8ab5-4cda-6c9288bdc9a3" && permission_exists('outbound_route_edit')) ||
($row['app_uuid'] == "16589224-c876-aeb3-f59f-523a1c0801f7" && permission_exists('fifo_edit')) ||
($row['app_uuid'] == "4b821450-926b-175a-af93-a03c441818b1" && permission_exists('time_condition_edit'))
)) {
2019-11-08 07:05:38 +01:00
echo " <td class='action-button'>";
2023-05-13 05:21:32 +02:00
echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$button_icon_edit,'link'=>$list_row_url]);
2019-11-08 07:05:38 +01:00
echo " </td>\n";
}
echo "</tr>\n";
2019-11-08 07:05:38 +01:00
$x++;
2019-08-06 03:18:21 +02:00
}
2019-11-08 07:05:38 +01:00
unset($dialplans);
2019-08-06 03:18:21 +02:00
}
2019-11-08 07:05:38 +01:00
echo "</table>\n";
2024-09-06 07:37:34 +02:00
echo "</div>\n";
2019-11-08 07:05:38 +01:00
echo "<br />\n";
echo "<div align='center'>".$paging_controls."</div>\n";
2019-11-08 07:05:38 +01:00
echo "<input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
2019-10-05 17:50:28 +02:00
2019-11-08 07:05:38 +01:00
echo "</form>\n";
2019-10-05 17:50:28 +02:00
//include the footer
require_once "resources/footer.php";
2023-05-09 06:55:00 +02:00
?>