Queues: Preserve query string parameters across list and edit pages (#7901)
* Queues: Preserve query string parameters across list and edit pages * Update fifo_edit.php * Update fifo.php
This commit is contained in:
+51
-46
@@ -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) 2018-2024
|
||||
Portions created by the Initial Developer are Copyright (C) 2018-2026
|
||||
the Initial Developer. All Rights Reserved.
|
||||
*/
|
||||
|
||||
@@ -42,10 +42,35 @@
|
||||
//set from session variables
|
||||
$list_row_edit_button = $settings->get('theme', 'list_row_edit_button', 'false');
|
||||
|
||||
// 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'] ?? 'fifo_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('fifo_all')) {
|
||||
$param['show'] = $show;
|
||||
}
|
||||
$query_string = http_build_query($param);
|
||||
|
||||
//get the http post data
|
||||
if (!empty($_POST['fifo']) && is_array($_POST['fifo'])) {
|
||||
$action = $_POST['action'];
|
||||
$search = $_POST['search'] ?? '';
|
||||
$fifo = $_POST['fifo'];
|
||||
}
|
||||
|
||||
@@ -56,7 +81,7 @@
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: fifo.php');
|
||||
header('Location: fifo.php'.($query_string ? '?'.$query_string : ''));
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -83,29 +108,13 @@
|
||||
}
|
||||
|
||||
//redirect the user
|
||||
header('Location: fifo.php'.($search != '' ? '?search='.urlencode($search) : ''));
|
||||
header('Location: fifo.php'.($query_string ? '?'.$query_string : ''));
|
||||
exit;
|
||||
}
|
||||
|
||||
//get order and order by
|
||||
$order_by = $_GET["order_by"] ?? null;
|
||||
$order = $_GET["order"] ?? null;
|
||||
|
||||
//define the variables
|
||||
$search = '';
|
||||
$show = '';
|
||||
$list_row_url = '';
|
||||
|
||||
//add the search variable
|
||||
if (!empty($_GET["search"])) {
|
||||
$search = strtolower($_GET["search"]);
|
||||
}
|
||||
|
||||
//add the show variable
|
||||
if (!empty($_GET["show"])) {
|
||||
$show = $_GET["show"];
|
||||
}
|
||||
|
||||
//get the count
|
||||
$sql = "select count(fifo_uuid) ";
|
||||
$sql .= "from v_fifo ";
|
||||
@@ -122,18 +131,15 @@
|
||||
$sql .= " or lower(fifo_extension) like :search ";
|
||||
$sql .= " or lower(fifo_description) like :search ";
|
||||
$sql .= ") ";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
$parameters['search'] = '%'.lower_case($search).'%';
|
||||
}
|
||||
$num_rows = $database->select($sql, $parameters ?? null, 'column');
|
||||
unset($sql, $parameters);
|
||||
|
||||
//prepare to page the results
|
||||
$rows_per_page = $settings->get('domain', 'paging', 50);
|
||||
$param = !empty($search) ? "&search=".$search : null;
|
||||
$param .= (!empty($_GET['page']) && $show == 'all' && permission_exists('fifo_all')) ? "&show=all" : null;
|
||||
$page = !empty($_GET['page']) && is_numeric($_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 the list
|
||||
@@ -163,7 +169,7 @@
|
||||
$sql .= " or lower(fifo_extension) like :search ";
|
||||
$sql .= " or lower(fifo_description) like :search ";
|
||||
$sql .= ") ";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
$parameters['search'] = '%'.lower_case($search).'%';
|
||||
}
|
||||
$sql .= "and u.domain_uuid = d.domain_uuid ";
|
||||
$sql .= order_by($order_by, $order, '', '');
|
||||
@@ -184,7 +190,7 @@
|
||||
echo " <div class='heading'><b>".$text['title-fifos']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
if (permission_exists('fifo_add')) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','name'=>'btn_add','link'=>'fifo_edit.php']);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','name'=>'btn_add','link'=>'fifo_edit.php'.($query_string ? '?'.$query_string : '')]);
|
||||
}
|
||||
// if (permission_exists('fifo_add') && $fifo) {
|
||||
// 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');"]);
|
||||
@@ -195,19 +201,19 @@
|
||||
if (permission_exists('fifo_delete') && $fifo) {
|
||||
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');"]);
|
||||
}
|
||||
echo "<form id='form_search' class='inline' method='get'>\n";
|
||||
if (permission_exists('fifo_all')) {
|
||||
if ($show == 'all') {
|
||||
echo " <input type='hidden' name='show' value='all'>\n";
|
||||
}
|
||||
else {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-show_all'],'icon'=>$settings->get('theme', 'button_icon_all'),'link'=>'?show=all&search='.$search]);
|
||||
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 "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
|
||||
if ($show !== 'all' && permission_exists('fifo_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 button::create(['label'=>$text['button-search'],'icon'=>$settings->get('theme', 'button_icon_search'),'type'=>'submit','id'=>'btn_search']);
|
||||
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>\n";
|
||||
}
|
||||
echo " </form>\n";
|
||||
echo " </div>\n";
|
||||
@@ -229,7 +235,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";
|
||||
@@ -240,14 +245,14 @@
|
||||
echo " </th>\n";
|
||||
}
|
||||
if ($show == 'all' && permission_exists('fifo_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('fifo_name', $text['label-fifo_name'], $order_by, $order);
|
||||
echo th_order_by('fifo_extension', $text['label-fifo_extension'], $order_by, $order);
|
||||
echo th_order_by('fifo_agent_status', $text['label-fifo_agent_status'], $order_by, $order);
|
||||
echo th_order_by('fifo_agent_queue', $text['label-fifo_agent_queue'], $order_by, $order);
|
||||
echo th_order_by('fifo_order', $text['label-fifo_order'], $order_by, $order);
|
||||
echo th_order_by('fifo_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'");
|
||||
echo th_order_by('fifo_name', $text['label-fifo_name'], $order_by, $order, null, null, $query_string);
|
||||
echo th_order_by('fifo_extension', $text['label-fifo_extension'], $order_by, $order, null, null, $query_string);
|
||||
echo th_order_by('fifo_agent_status', $text['label-fifo_agent_status'], $order_by, $order, null, null, $query_string);
|
||||
echo th_order_by('fifo_agent_queue', $text['label-fifo_agent_queue'], $order_by, $order, null, null, $query_string);
|
||||
echo th_order_by('fifo_order', $text['label-fifo_order'], $order_by, $order, null, null, $query_string);
|
||||
echo th_order_by('fifo_enabled', $text['label-enabled'], $order_by, $order, null, "class='center'", $query_string);
|
||||
echo " <th class='hide-sm-dn'>".$text['label-fifo_description']."</th>\n";
|
||||
if (permission_exists('fifo_edit') && $list_row_edit_button == 'true') {
|
||||
echo " <td class='action-button'> </td>\n";
|
||||
@@ -258,7 +263,7 @@
|
||||
$x = 0;
|
||||
foreach ($fifo as $row) {
|
||||
if (permission_exists('fifo_edit')) {
|
||||
$list_row_url = "fifo_edit.php?id=".urlencode($row['fifo_uuid']);
|
||||
$list_row_url = "fifo_edit.php?id=".urlencode($row['fifo_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
@@ -18,7 +18,7 @@
|
||||
|
||||
The Initial Developer of the Original Code is
|
||||
Mark J Crane <markjcrane@fusionpbx.com>
|
||||
Portions created by the Initial Developer are Copyright (C) 2024-2025
|
||||
Portions created by the Initial Developer are Copyright (C) 2024-2026
|
||||
the Initial Developer. All Rights Reserved.
|
||||
*/
|
||||
|
||||
@@ -54,6 +54,32 @@
|
||||
$button_icon_save = $settings->get('theme', 'button_icon_save', '');
|
||||
$input_toggle_style = $settings->get('theme', 'input_toggle_style', 'switch round');
|
||||
|
||||
// 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'] ?? 'fifo_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('fifo_all')) {
|
||||
$param['show'] = $show;
|
||||
}
|
||||
$query_string = http_build_query($param);
|
||||
|
||||
//action add or update
|
||||
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
|
||||
$action = "update";
|
||||
@@ -90,7 +116,7 @@
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: fifo.php');
|
||||
header('Location: fifo.php'.($query_string ? '?'.$query_string : ''));
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -130,7 +156,7 @@
|
||||
|
||||
//redirect the user
|
||||
if (in_array($_POST['action'], array('copy', 'delete', 'toggle'))) {
|
||||
header('Location: fifo_edit.php?id='.$id);
|
||||
header('Location: fifo_edit.php?id='.$id.($query_string ? '&'.$query_string : ''));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -376,7 +402,7 @@
|
||||
}
|
||||
|
||||
//header('Location: fifo.php');
|
||||
header('Location: fifo_edit.php?id='.urlencode($fifo_uuid));
|
||||
header('Location: fifo_edit.php?id='.urlencode($fifo_uuid).($query_string ? '&'.$query_string : ''));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -510,7 +536,7 @@
|
||||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
echo " <div class='heading'><b>".$text['title-fifo']."</b></div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$button_icon_back,'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'fifo.php']);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$button_icon_back,'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'fifo.php'.($query_string ? '?'.$query_string : '')]);
|
||||
if ($action == 'update') {
|
||||
if (permission_exists('fifo_member_delete')) {
|
||||
echo button::create(['type'=>'submit','label'=>$text['button-delete'],'icon'=>$button_icon_delete,'id'=>'btn_delete','name'=>'action','value'=>'delete','style'=>'display: none; margin-right: 15px;']);
|
||||
|
||||
Reference in New Issue
Block a user