Fax Servers: Preserve query string parameters across list and edit pages (#7898)

* Fax Servers: Preserve query string parameters across list and edit pages

* Update fax_edit.php

* Update fax_advanced.php
This commit is contained in:
Alex
2026-04-22 20:57:24 +00:00
committed by GitHub
parent a4bda6730f
commit cc1adfb4ad
3 changed files with 114 additions and 51 deletions
+49 -38
View File
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2024
Portions created by the Initial Developer are Copyright (C) 2008-2026
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -39,10 +39,36 @@
$language = new text;
$text = $language->get();
// Set variables from http GET parameters
$page = is_numeric($_GET['page'] ?? '') ? $_GET['page'] : 0;
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', ($_GET['order_by'] ?? 'fax_name'));
$order = ($_GET['order'] ?? '') === 'desc' ? 'desc' : 'asc';
$sort = $order_by == 'fax_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('fax_extension_view_all')) {
$param['show'] = $show;
}
$query_string = http_build_query($param);
//get posted data
if (!empty($_POST['fax_servers']) && is_array($_POST['fax_servers'])) {
$action = $_POST['action'];
$search = $_POST['search'] ?? '';
$fax_servers = $_POST['fax_servers'];
}
@@ -63,19 +89,10 @@
break;
}
header('Location: fax.php'.($search != '' ? '?search='.urlencode($search) : ''));
header('Location: fax.php'.($query_string ? '?'.$query_string : ''));
exit;
}
//get order and order by
$order_by = $_GET["order_by"] ?? 'fax_name';
$order = $_GET["order"] ?? 'asc';
$sort = $order_by == 'fax_extension' ? 'natural' : null;
//add the search and show variables
$search = $_GET["search"] ?? '';
$show = $_GET["show"] ?? '';
//get record counts
if ($show == "all" && permission_exists('fax_extension_view_all')) {
//show all fax extensions
@@ -109,19 +126,14 @@
$sql .= "or lower(fax_caller_id_number) like :search ";
$sql .= "or lower(fax_forward_number) like :search ";
$sql .= "or lower(fax_description) like :search ";
$parameters['search'] = '%'.strtolower($search).'%';
$parameters['search'] = '%'.lower_case($search).'%';
}
$num_rows = $database->select($sql, $parameters ?? null, 'column');
//prepare paging
$rows_per_page = $settings->get('domain', 'paging', 50);
$param = "&search=".urlencode($search);
if ($show == "all" && permission_exists('fax_extension_view_all')) {
$param .= "&show=all";
}
$page = !empty($_GET['page']) ? $_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);
list($paging_controls, $rows_per_page) = paging($num_rows, $query_string, $rows_per_page);
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $query_string, $rows_per_page, true);
$offset = $rows_per_page * $page;
//get fax extensions
@@ -156,7 +168,7 @@
$sql .= "or lower(fax_caller_id_number) like :search ";
$sql .= "or lower(fax_forward_number) like :search ";
$sql .= "or lower(fax_description) like :search ";
$parameters['search'] = '%'.strtolower($search).'%';
$parameters['search'] = '%'.lower_case($search).'%';
}
$sql .= order_by($order_by, $order, 'fax_name', 'asc', $sort);
$sql .= limit_offset($rows_per_page, $offset);
@@ -176,7 +188,7 @@
echo " <div class='heading'><b>".$text['title-fax']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
echo " <div class='actions'>\n";
if (permission_exists('fax_extension_add')) {
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','link'=>'fax_edit.php']);
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','link'=>'fax_edit.php'.($query_string ? '?'.$query_string : '')]);
}
if (permission_exists('fax_extension_copy') && $result) {
echo button::create(['type'=>'button','label'=>$text['button-copy'],'icon'=>$settings->get('theme', 'button_icon_copy'),'id'=>'btn_copy','name'=>'btn_copy','style'=>'display: none;','onclick'=>"modal_open('modal-copy','btn_copy');"]);
@@ -184,20 +196,20 @@
if (permission_exists('fax_extension_delete') && $result) {
echo button::create(['type'=>'button','label'=>$text['button-delete'],'icon'=>$settings->get('theme', 'button_icon_delete'),'id'=>'btn_delete','name'=>'btn_delete','style'=>'display: none;','onclick'=>"modal_open('modal-delete','btn_delete');"]);
}
if (permission_exists('fax_extension_view_all')) {
if ($show == 'all') {
echo " <input type='hidden' name='show' value='all'>";
}
else {
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$settings->get('theme', 'button_icon_all'),'link'=>'?type=&show=all'.(!empty($search) ? "&search=".urlencode($search) : null)]);
echo " <form id='form_search' class='inline' method='get'>\n";
foreach ($param as $key => $value) {
if ($key !== 'search' && $key !== 'page') {
echo " <input type='hidden' name='".escape($key)."' value='".escape($value)."'>\n";
}
}
echo "<form id='form_search' class='inline' method='get'>\n";
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search ?? '')."\" placeholder=\"".$text['label-search']."\" onkeydown='list_search_reset();'>";
if ($show !== 'all' && permission_exists('fax_extension_view_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='list_search_reset();'>";
echo button::create(['label'=>$text['button-search'],'icon'=>$settings->get('theme', 'button_icon_search'),'type'=>'submit','id'=>'btn_search','style'=>(!empty($search) ? 'display: none;' : null)]);
echo button::create(['label'=>$text['button-reset'],'icon'=>$settings->get('theme', 'button_icon_search'),'type'=>'button','id'=>'btn_reset','link'=>'fax.php'.(!empty($_GET['show']) && $_GET['show'] == 'all' ? '?show=all' : null),'style'=>(empty($search) ? 'display: none;' : null)]);
if ($paging_controls_mini != '') {
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
echo " <span style='margin-left: 15px;'>".$paging_controls_mini."</span>";
}
echo " </form>\n";
echo " </div>\n";
@@ -216,7 +228,6 @@
echo "<form id='form_list' method='post'>\n";
echo "<input type='hidden' id='action' name='action' value=''>\n";
echo "<input type='hidden' name='search' value=\"".escape($search ?? '')."\">\n";
echo "<div class='card'>\n";
echo "<table class='list'>\n";
@@ -227,13 +238,13 @@
echo " </th>\n";
}
if (permission_exists('fax_extension_view_all') && !empty($_GET['show']) && $_GET['show'] == 'all') {
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order);
echo th_order_by('domain_name', $text['label-domain'], $order_by, $order, null, null, $query_string);
}
echo th_order_by('fax_name', $text['label-name'], $order_by, $order);
echo th_order_by('fax_extension', $text['label-extension'], $order_by, $order);
echo th_order_by('fax_email', $text['label-email'], $order_by, $order);
echo th_order_by('fax_name', $text['label-name'], $order_by, $order, null, null, $query_string);
echo th_order_by('fax_extension', $text['label-extension'], $order_by, $order, null, null, $query_string);
echo th_order_by('fax_email', $text['label-email'], $order_by, $order, null, null, $query_string);
echo " <th>".$text['label-tools']."</th>";
echo th_order_by('fax_description', $text['label-description'], $order_by, $order, null, "class='hide-sm-dn'");
echo th_order_by('fax_description', $text['label-description'], $order_by, $order, null, "class='hide-sm-dn'", $query_string);
if (permission_exists('fax_extension_edit') && $settings->get('theme', 'list_row_edit_button', false)) {
echo " <td class='action-button'>&nbsp;</td>\n";
}
@@ -244,7 +255,7 @@
foreach ($result as $row) {
$list_row_url = '';
if (permission_exists('fax_extension_edit')) {
$list_row_url = "fax_edit.php?id=".urlencode($row['fax_uuid']);
$list_row_url = "fax_edit.php?id=".urlencode($row['fax_uuid']).($query_string ? '&'.$query_string : '');
if ($row['domain_uuid'] != $_SESSION['domain_uuid'] && permission_exists('domain_select')) {
$list_row_url .= '&domain_uuid='.urlencode($row['domain_uuid']).'&domain_change=true';
}
+31 -5
View File
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2024
Portions created by the Initial Developer are Copyright (C) 2008-2026
the Initial Developer. All Rights Reserved.
Contributor(s):
@@ -38,6 +38,32 @@
$language = new text;
$text = $language->get();
// Set variables from http GET parameters
$page = is_numeric($_GET['page'] ?? '') ? $_GET['page'] : 0;
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', ($_GET['order_by'] ?? 'fax_name'));
$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('fax_extension_view_all')) {
$param['show'] = $show;
}
$query_string = http_build_query($param);
//set the action as an add or an update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
@@ -69,7 +95,7 @@
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: fax.php');
header('Location: fax.php'.($query_string ? '?'.$query_string : ''));
exit;
}
@@ -151,7 +177,7 @@
if ($action == "add" && permission_exists('fax_extension_add')) {
message::add($text['confirm-add']);
}
header("Location: fax_advanced.php?id=".$fax_uuid);
header("Location: fax_advanced.php?id=".$fax_uuid.($query_string ? '&'.$query_string : ''));
return;
}
@@ -244,7 +270,7 @@
echo "<div class='action_bar' id='action_bar'>\n";
echo " <div class='heading'><b>".$text['label-advanced_settings']."</b></div>\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','link'=>'fax_edit.php?id='.$fax_uuid]);
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','link'=>'fax_edit.php?id='.$fax_uuid.($query_string ? '&'.$query_string : '')]);
echo button::create(['type'=>'button','label'=>$text['button-test'],'icon'=>'tools','id'=>'test_button','style'=>'margin-left: 15px;','onclick'=>"this.blur(); fax_advanced_test();"]);
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";
@@ -478,7 +504,7 @@
echo " function fax_advanced_test() {\n";
echo " document.getElementById('test_button').innerHTML = \"<span class='fa-solid fa-gear fa-fw fa-spin'></span><span class='button-label pad'>".$text['label-testing']."</span>\";\n";
echo " $.ajax({\n";
echo " url: 'fax_advanced_test.php?id=".$fax_uuid."',\n";
echo " url: 'fax_advanced_test.php?id=".$fax_uuid.($query_string ? '&'.$query_string : '')."',\n";
echo " type: 'get',\n";
echo " processData: false,\n";
echo " contentType: false,\n";
+34 -8
View File
@@ -17,7 +17,7 @@
The Initial Developer of the Original Code is
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.
Contributor(s):
@@ -75,6 +75,32 @@
}
// Set variables from http GET parameters
$page = is_numeric($_GET['page'] ?? '') ? $_GET['page'] : 0;
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', ($_GET['order_by'] ?? 'fax_name'));
$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('fax_extension_view_all')) {
$param['show'] = $show;
}
$query_string = http_build_query($param);
//set the action as an add or an update
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
$action = "update";
@@ -108,7 +134,7 @@
break;
}
header('Location: fax.php');
header('Location: fax.php'.($query_string ? '?'.$query_string : ''));
exit;
}
@@ -185,7 +211,7 @@
//redirect the browser
message::add($text['message-delete']);
header("Location: fax_edit.php?id=".$fax_uuid);
header("Location: fax_edit.php?id=".$fax_uuid.($query_string ? '&'.$query_string : ''));
return;
}
@@ -210,7 +236,7 @@
//redirect the browser
message::add($text['confirm-add']);
header("Location: fax_edit.php?id=".$fax_uuid);
header("Location: fax_edit.php?id=".$fax_uuid.($query_string ? '&'.$query_string : ''));
return;
}
@@ -229,7 +255,7 @@
$token = new token;
if (!$token->validate($_SERVER['PHP_SELF'])) {
message::add($text['message-invalid_token'],'negative');
header('Location: fax.php');
header('Location: fax.php'.($query_string ? '?'.$query_string : ''));
exit;
}
@@ -401,7 +427,7 @@
if ($action == "add" && permission_exists('fax_extension_add')) {
message::add($text['confirm-add']);
}
header("Location: fax.php");
header("Location: fax.php".($query_string ? '?'.$query_string : ''));
return;
}
@@ -496,13 +522,13 @@
echo " <div class='heading'><b>".$text['header-fax_server_settings']."</b></div>\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','link'=>'fax.php']);
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','link'=>'fax.php'.($query_string ? '?'.$query_string : '')]);
if ($action == "update") {
$button_margin = 'margin-left: 15px;';
if (permission_exists('fax_extension_advanced')) {
$button_margin = 'margin-left: 15px;';
if (function_exists("imap_open") && file_exists("fax_files_remote.php")) {
echo button::create(['type'=>'button','label'=>$text['button-advanced'],'icon'=>'tools','style'=>($button_margin ?? ''),'link'=>'fax_advanced.php?id='.urlencode($fax_uuid)]);
echo button::create(['type'=>'button','label'=>$text['button-advanced'],'icon'=>'tools','style'=>($button_margin ?? ''),'link'=>'fax_advanced.php?id='.urlencode($fax_uuid).($query_string ? '&'.$query_string : '')]);
}
unset($button_margin);
}