Call Forward: Preserve query string parameters across list and edit pages (#7884)
* Call Forward: Preserve query string parameters across list and edit pages * Update call_forward_edit.php
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
The Initial Developer of the Original Code is
|
The Initial Developer of the Original Code is
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
Portions created by the Initial Developer are Copyright (C) 2008-2025
|
Portions created by the Initial Developer are Copyright (C) 2008-2026
|
||||||
the Initial Developer. All Rights Reserved.
|
the Initial Developer. All Rights Reserved.
|
||||||
|
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
@@ -43,9 +43,35 @@
|
|||||||
$language = new text;
|
$language = new text;
|
||||||
$text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/call_forward');
|
$text = $language->get($settings->get('domain', 'language', 'en-us'), 'app/call_forward');
|
||||||
|
|
||||||
|
// Set variables from GET parameters
|
||||||
|
$page = is_numeric($_GET['page'] ?? '') ? $_GET['page'] : 0;
|
||||||
|
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', ($_GET['order_by'] ?? 'extension'));
|
||||||
|
$order = ($_GET['order'] ?? '') === 'desc' ? 'desc' : 'asc';
|
||||||
|
$sort = $order_by == 'extension' ? 'natural' : null;
|
||||||
|
$search = $_GET['search'] ?? '';
|
||||||
|
$show = $_GET['show'] ?? '';
|
||||||
|
|
||||||
|
// Build the query string
|
||||||
|
$param = [];
|
||||||
|
if (!empty($page)) {
|
||||||
|
$param['page'] = $page;
|
||||||
|
}
|
||||||
|
if (!empty($_GET['order_by'])) {
|
||||||
|
$param['order_by'] = $order_by;
|
||||||
|
}
|
||||||
|
if (!empty($_GET['order'])) {
|
||||||
|
$param['order'] = $order;
|
||||||
|
}
|
||||||
|
if (!empty($search)) {
|
||||||
|
$param['search'] = $search;
|
||||||
|
}
|
||||||
|
if (!empty($show) && $show == 'all' && permission_exists('call_forward_all')) {
|
||||||
|
$param['show'] = $show;
|
||||||
|
}
|
||||||
|
$query_string = http_build_query($param);
|
||||||
|
|
||||||
//get posted data and set defaults
|
//get posted data and set defaults
|
||||||
$action = $_POST['action'] ?? '';
|
$action = $_POST['action'] ?? '';
|
||||||
$search = $_POST['search'] ?? '';
|
|
||||||
$extensions = $_POST['extensions'] ?? [];
|
$extensions = $_POST['extensions'] ?? [];
|
||||||
|
|
||||||
//process the http post data by action
|
//process the http post data by action
|
||||||
@@ -71,20 +97,18 @@
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: call_forward.php' . ($search != '' ? '?search=' . urlencode($search) : null));
|
header('Location: call_forward.php'.($query_string ? '?'.$query_string : ''));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get order and order by
|
//add the search string
|
||||||
$order_by = $_GET["order_by"] ?? 'extension';
|
if (!empty($search)) {
|
||||||
$order = $_GET["order"] ?? 'asc';
|
$sql_search = " (";
|
||||||
$sort = $order_by == 'extension' ? 'natural' : null;
|
$sql_search .= " extension like :search ";
|
||||||
|
$sql_search .= " or lower(description) like :search ";
|
||||||
//get the search
|
$sql_search .= ") ";
|
||||||
$search = strtolower($_GET["search"] ?? '');
|
$parameters['search'] = '%'.lower_case($search).'%';
|
||||||
|
}
|
||||||
//set the show variable
|
|
||||||
$show = $_GET['show'] ?? '';
|
|
||||||
|
|
||||||
//define select count query
|
//define select count query
|
||||||
$sql = "select count(*) from v_extensions ";
|
$sql = "select count(*) from v_extensions ";
|
||||||
@@ -95,12 +119,8 @@
|
|||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
}
|
}
|
||||||
if (!empty($search)) {
|
if (!empty($sql_search)) {
|
||||||
$sql .= "and ( ";
|
$sql .= "and ".$sql_search;
|
||||||
$sql .= "extension like :search ";
|
|
||||||
$sql .= "or lower(description) like :search ";
|
|
||||||
$sql .= ") ";
|
|
||||||
$parameters['search'] = '%' . $search . '%';
|
|
||||||
}
|
}
|
||||||
$sql .= "and enabled = 'true' ";
|
$sql .= "and enabled = 'true' ";
|
||||||
if (!permission_exists('extension_edit')) {
|
if (!permission_exists('extension_edit')) {
|
||||||
@@ -121,32 +141,11 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$num_rows = $database->select($sql, $parameters ?? null, 'column');
|
$num_rows = $database->select($sql, $parameters ?? null, 'column');
|
||||||
unset($parameters);
|
|
||||||
|
|
||||||
//prepare the paging
|
//prepare the paging
|
||||||
$rows_per_page = !empty($settings->get('domain', 'paging')) ? $settings->get('domain', 'paging') : 50;
|
$rows_per_page = !empty($settings->get('domain', 'paging')) ? $settings->get('domain', 'paging') : 50;
|
||||||
|
list($paging_controls, $rows_per_page) = paging($num_rows, $query_string, $rows_per_page);
|
||||||
if ($search) {
|
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $query_string, $rows_per_page, true);
|
||||||
$params[] = "search=" . $search;
|
|
||||||
}
|
|
||||||
if ($order_by) {
|
|
||||||
$params[] = "order_by=" . $order_by;
|
|
||||||
}
|
|
||||||
if ($order) {
|
|
||||||
$params[] = "order=" . $order;
|
|
||||||
}
|
|
||||||
if ($show == "all" && permission_exists('call_forward_all')) {
|
|
||||||
$params[] = "show=all";
|
|
||||||
}
|
|
||||||
$param = !empty($params) ? implode('&', $params) : '';
|
|
||||||
unset($params);
|
|
||||||
$page = $_GET['page'] ?? '';
|
|
||||||
if (empty($page)) {
|
|
||||||
$page = 0;
|
|
||||||
$_GET['page'] = 0;
|
|
||||||
}
|
|
||||||
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;
|
$offset = $rows_per_page * $page;
|
||||||
|
|
||||||
//get the list
|
//get the list
|
||||||
@@ -158,12 +157,8 @@
|
|||||||
$sql .= "where domain_uuid = :domain_uuid ";
|
$sql .= "where domain_uuid = :domain_uuid ";
|
||||||
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
$parameters['domain_uuid'] = $_SESSION['domain_uuid'];
|
||||||
}
|
}
|
||||||
if (!empty($search)) {
|
if (!empty($sql_search)) {
|
||||||
$sql .= "and ( ";
|
$sql .= "and ".$sql_search;
|
||||||
$sql .= "extension like :search ";
|
|
||||||
$sql .= "or lower(description) like :search ";
|
|
||||||
$sql .= ") ";
|
|
||||||
$parameters['search'] = '%' . $search . '%';
|
|
||||||
}
|
}
|
||||||
$sql .= "and enabled = 'true' ";
|
$sql .= "and enabled = 'true' ";
|
||||||
if (!permission_exists('extension_edit')) {
|
if (!permission_exists('extension_edit')) {
|
||||||
@@ -204,9 +199,6 @@
|
|||||||
}
|
}
|
||||||
require_once "resources/header.php";
|
require_once "resources/header.php";
|
||||||
|
|
||||||
//set the back button
|
|
||||||
$_SESSION['call_forward_back'] = $_SERVER['PHP_SELF'];
|
|
||||||
|
|
||||||
//show the content
|
//show the content
|
||||||
if ($is_included) {
|
if ($is_included) {
|
||||||
echo "<div class='action_bar sub'>\n";
|
echo "<div class='action_bar sub'>\n";
|
||||||
@@ -235,12 +227,14 @@
|
|||||||
echo button::create(['type' => 'button', 'label' => $text['label-dnd'], 'icon' => $settings->get('theme', 'button_icon_toggle'), 'collapse' => false, 'name' => 'btn_toggle_dnd', 'onclick' => "list_action_set('toggle_do_not_disturb'); modal_open('modal-toggle','btn_toggle');"]);
|
echo button::create(['type' => 'button', 'label' => $text['label-dnd'], 'icon' => $settings->get('theme', 'button_icon_toggle'), 'collapse' => false, 'name' => 'btn_toggle_dnd', 'onclick' => "list_action_set('toggle_do_not_disturb'); modal_open('modal-toggle','btn_toggle');"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($show !== 'all' && permission_exists('call_forward_all')) {
|
|
||||||
echo button::create(['type' => 'button', 'label' => $text['button-show_all'], 'icon' => $settings->get('theme', 'button_icon_all'), 'link' => '?show=all' . (!empty($params) ? '&'.implode('&', $params) : null)]);
|
|
||||||
}
|
|
||||||
echo "<form id='form_search' class='inline' method='get'>\n";
|
echo "<form id='form_search' class='inline' method='get'>\n";
|
||||||
if ($show == 'all' && permission_exists('call_forward_all')) {
|
foreach ($param as $key => $value) {
|
||||||
echo " <input type='hidden' name='show' value='all'>";
|
if ($key !== 'search' && $key !== 'page') {
|
||||||
|
echo " <input type='hidden' name='".escape($key)."' value='".escape($value)."'>\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($show !== 'all' && permission_exists('call_forward_all')) {
|
||||||
|
echo button::create(['type' => 'button', 'label' => $text['button-show_all'], 'icon' => $settings->get('theme', 'button_icon_all'), 'link' => '?show=all']);
|
||||||
}
|
}
|
||||||
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"" . escape($search) . "\" placeholder=\"" . $text['label-search'] . "\" onkeydown=''>";
|
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"" . escape($search) . "\" placeholder=\"" . $text['label-search'] . "\" onkeydown=''>";
|
||||||
echo button::create(['label' => $text['button-search'], 'icon' => $settings->get('theme', 'button_icon_search'), 'type' => 'submit', 'id' => 'btn_search']);
|
echo button::create(['label' => $text['button-search'], 'icon' => $settings->get('theme', 'button_icon_search'), 'type' => 'submit', 'id' => 'btn_search']);
|
||||||
@@ -300,7 +294,7 @@
|
|||||||
if (!empty($extensions)) {
|
if (!empty($extensions)) {
|
||||||
$x = 0;
|
$x = 0;
|
||||||
foreach ($extensions as $row) {
|
foreach ($extensions as $row) {
|
||||||
$list_row_url = PROJECT_PATH . "/app/call_forward/call_forward_edit.php?id=".$row['extension_uuid'];
|
$list_row_url = PROJECT_PATH . "/app/call_forward/call_forward_edit.php?id=".$row['extension_uuid'].($query_string ? '&'.$query_string : '');
|
||||||
if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
|
if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
|
||||||
$list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
|
$list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
The Initial Developer of the Original Code is
|
The Initial Developer of the Original Code is
|
||||||
Mark J Crane <markjcrane@fusionpbx.com>
|
Mark J Crane <markjcrane@fusionpbx.com>
|
||||||
Portions created by the Initial Developer are Copyright (C) 2008-2025
|
Portions created by the Initial Developer are Copyright (C) 2008-2026
|
||||||
the Initial Developer. All Rights Reserved.
|
the Initial Developer. All Rights Reserved.
|
||||||
|
|
||||||
Contributor(s):
|
Contributor(s):
|
||||||
@@ -48,6 +48,32 @@
|
|||||||
$language = new text;
|
$language = new text;
|
||||||
$text = $language->get();
|
$text = $language->get();
|
||||||
|
|
||||||
|
// Set variables from GET parameters
|
||||||
|
$page = is_numeric($_GET['page'] ?? '') ? $_GET['page'] : 0;
|
||||||
|
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', ($_GET['order_by'] ?? 'extension'));
|
||||||
|
$order = ($_GET['order'] ?? '') === 'desc' ? 'desc' : 'asc';
|
||||||
|
$search = $_GET['search'] ?? '';
|
||||||
|
$show = $_GET['show'] ?? '';
|
||||||
|
|
||||||
|
// Build the query string
|
||||||
|
$param = [];
|
||||||
|
if (!empty($page)) {
|
||||||
|
$param['page'] = $page;
|
||||||
|
}
|
||||||
|
if (!empty($_GET['order_by'])) {
|
||||||
|
$param['order_by'] = $order_by;
|
||||||
|
}
|
||||||
|
if (!empty($_GET['order'])) {
|
||||||
|
$param['order'] = $order;
|
||||||
|
}
|
||||||
|
if (!empty($search)) {
|
||||||
|
$param['search'] = $search;
|
||||||
|
}
|
||||||
|
if (!empty($show) && $show == 'all' && permission_exists('call_forward_all')) {
|
||||||
|
$param['show'] = $show;
|
||||||
|
}
|
||||||
|
$query_string = http_build_query($param);
|
||||||
|
|
||||||
//define the destination_select function
|
//define the destination_select function
|
||||||
/**
|
/**
|
||||||
* Displays a select input element with options for destinations.
|
* Displays a select input element with options for destinations.
|
||||||
@@ -158,7 +184,7 @@
|
|||||||
$token = new token;
|
$token = new token;
|
||||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||||
message::add($text['message-invalid_token'],'negative');
|
message::add($text['message-invalid_token'],'negative');
|
||||||
header('Location: call_forward.php');
|
header('Location: call_forward.php'.($query_string ? '?'.$query_string : ''));
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -434,7 +460,7 @@
|
|||||||
message::add($text['confirm-update']);
|
message::add($text['confirm-update']);
|
||||||
|
|
||||||
// redirect
|
// redirect
|
||||||
header('Location: call_forward_edit.php?id='.$extension_uuid);
|
header('Location: call_forward_edit.php?id='.$extension_uuid.($query_string ? '&'.$query_string : ''));
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -526,16 +552,13 @@
|
|||||||
$object = new token;
|
$object = new token;
|
||||||
$token = $object->create($_SERVER['PHP_SELF']);
|
$token = $object->create($_SERVER['PHP_SELF']);
|
||||||
|
|
||||||
//save the back button location using referer
|
|
||||||
$back_destination = "window.location.href='" . ($_SESSION['call_forward_back'] ?? "/app/call_forward/call_forward.php") . "'";
|
|
||||||
|
|
||||||
//show the content
|
//show the content
|
||||||
echo "<form method='post' name='frm' id='frm'>\n";
|
echo "<form method='post' name='frm' id='frm'>\n";
|
||||||
|
|
||||||
echo "<div class='action_bar' id='action_bar'>\n";
|
echo "<div class='action_bar' id='action_bar'>\n";
|
||||||
echo " <div class='heading'><b>".$text['title-call_forward']."</b></div>\n";
|
echo " <div class='heading'><b>".$text['title-call_forward']."</b></div>\n";
|
||||||
echo " <div class='actions'>\n";
|
echo " <div class='actions'>\n";
|
||||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','onclick'=>$back_destination]);
|
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','link'=>'call_forward.php'.($query_string ? '?'.$query_string : '')]);
|
||||||
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme', 'button_icon_save'),'id'=>'btn_save','style'=>'margin-left: 15px;']);
|
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme', 'button_icon_save'),'id'=>'btn_save','style'=>'margin-left: 15px;']);
|
||||||
echo " </div>\n";
|
echo " </div>\n";
|
||||||
echo " <div style='clear: both;'></div>\n";
|
echo " <div style='clear: both;'></div>\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user