Conference Controls: Preserve query string parameters across list and edit pages (#7887)
* Conference Controls: Preserve query string parameters across list and edit pages * Update conference_control_edit.php * Update conference_control_details.php * Update conference_control_detail_edit.php
This commit is contained in:
@@ -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-2025
|
||||
Portions created by the Initial Developer are Copyright (C) 2018-2026
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
@@ -43,6 +43,28 @@
|
||||
$control_action = '';
|
||||
$control_data = '';
|
||||
|
||||
// Set variables from GET parameters
|
||||
$page = is_numeric($_GET['page'] ?? '') ? $_GET['page'] : 0;
|
||||
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', ($_GET['order_by'] ?? 'control_name'));
|
||||
$order = ($_GET['order'] ?? '') === 'desc' ? 'desc' : 'asc';
|
||||
$search = $_GET['search'] ?? '';
|
||||
|
||||
// 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;
|
||||
}
|
||||
$query_string = http_build_query($param);
|
||||
|
||||
//action add or update
|
||||
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
|
||||
$action = "update";
|
||||
@@ -124,7 +146,7 @@
|
||||
unset($array);
|
||||
}
|
||||
|
||||
header('Location: conference_control_edit.php?id='.$conference_control_uuid);
|
||||
header('Location: conference_control_edit.php?id='.$conference_control_uuid.($query_string ? '&'.$query_string : ''));
|
||||
exit;
|
||||
|
||||
}
|
||||
@@ -165,7 +187,7 @@
|
||||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
echo " <div class='heading'><b>".$text['title-conference_control_detail']."</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','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'conference_control_edit.php?id='.urlencode($conference_control_uuid ?? '')]);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'conference_control_edit.php?id='.urlencode($conference_control_uuid ?? '').($query_string ? '&'.$query_string : '')]);
|
||||
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme', 'button_icon_save'),'id'=>'btn_save','collapse'=>'hide-xs']);
|
||||
echo " </div>\n";
|
||||
echo " <div style='clear: both;'></div>\n";
|
||||
|
||||
@@ -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-2025
|
||||
Portions created by the Initial Developer are Copyright (C) 2018-2026
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
@@ -39,6 +39,28 @@
|
||||
$language = new text;
|
||||
$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'] ?? ''));
|
||||
$order = ($_GET['order'] ?? '') === 'desc' ? 'desc' : 'asc';
|
||||
$search = $_GET['search'] ?? '';
|
||||
|
||||
// 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;
|
||||
}
|
||||
$query_string = http_build_query($param);
|
||||
|
||||
//set from session variables
|
||||
$list_row_edit_button = $settings->get('theme', 'list_row_edit_button', false);
|
||||
|
||||
@@ -68,44 +90,18 @@
|
||||
break;
|
||||
}
|
||||
|
||||
header('Location: conference_control_edit.php?id='.urlencode($conference_control_uuid));
|
||||
header('Location: conference_control_edit.php?id='.urlencode($conference_control_uuid).($query_string ? '&'.$query_string : ''));
|
||||
exit;
|
||||
}
|
||||
|
||||
//get variables used to control the order
|
||||
$order_by = $_GET["order_by"] ?? '';
|
||||
$order = $_GET["order"] ?? '';
|
||||
|
||||
//add the search term
|
||||
$search = $_GET["search"] ?? '';
|
||||
if (!empty($search)) {
|
||||
$sql_search = "and (";
|
||||
$sql_search .= "control_digits like :search";
|
||||
$sql_search .= "or control_action like :search";
|
||||
$sql_search .= "or control_data like :search";
|
||||
$sql_search .= "or control_enabled like :search";
|
||||
$sql_search .= ")";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
|
||||
//prepare to page the results
|
||||
$sql = "select count(conference_control_detail_uuid) ";
|
||||
$sql .= "from v_conference_control_details ";
|
||||
$sql .= "where conference_control_uuid = :conference_control_uuid ";
|
||||
$sql .= $sql_search ?? '';
|
||||
$parameters['conference_control_uuid'] = $conference_control_uuid ?? '';
|
||||
$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 = "&id=".!empty($conference_control_uuid);
|
||||
if (isset($_GET['page'])) {
|
||||
$page = isset($_GET['page']) ? $_GET['page'] : 0;
|
||||
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page);
|
||||
$offset = $rows_per_page * $page;
|
||||
}
|
||||
|
||||
//get the list
|
||||
$sql = "select ";
|
||||
$sql .= "conference_control_detail_uuid, ";
|
||||
@@ -115,8 +111,7 @@
|
||||
$sql .= "control_data, ";
|
||||
$sql .= "cast(control_enabled as text) ";
|
||||
$sql .= "from v_conference_control_details ";
|
||||
$sql .= $sql_search ?? '';
|
||||
$sql .= order_by($order_by, $order, 'control_digits', 'asc');
|
||||
$sql .= order_by(null, null, 'control_digits', 'asc');
|
||||
$sql .= limit_offset($rows_per_page, !empty($offset));
|
||||
$result = $database->select($sql, $parameters ?? null, 'all');
|
||||
unset($sql, $parameters);
|
||||
@@ -162,10 +157,10 @@
|
||||
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle();' ".(!empty($result) ?: "style='visibility: hidden;'").">\n";
|
||||
echo " </th>\n";
|
||||
}
|
||||
echo th_order_by('control_digits', $text['label-control_digits'], $order_by, $order, null, "class='pct-5 center'", $param);
|
||||
echo th_order_by('control_action', $text['label-control_action'], $order_by, $order, null, null, $param);
|
||||
echo th_order_by('control_data', $text['label-control_data'], $order_by, $order, null, "class='pct-50 hide-xs'", $param);
|
||||
echo th_order_by('control_enabled', $text['label-control_enabled'], $order_by, $order, null, "class='center'", $param);
|
||||
echo "<th class='pct-5 center'>".$text['label-control_digits']."</th>\n";
|
||||
echo "<th>".$text['label-control_action']."</th>\n";
|
||||
echo "<th class='pct-50 hide-xs'>".$text['label-control_data']."</th>\n";
|
||||
echo "<th class='center'>".$text['label-control_enabled']."</th>\n";
|
||||
if (permission_exists('conference_control_detail_edit') && $list_row_edit_button) {
|
||||
echo " <td class='action-button'> </td>\n";
|
||||
}
|
||||
@@ -175,7 +170,7 @@
|
||||
$x = 0;
|
||||
foreach ($result as $row) {
|
||||
if (permission_exists('conference_control_detail_edit')) {
|
||||
$list_row_url = 'conference_control_detail_edit.php?conference_control_uuid='.urlencode($row['conference_control_uuid']).'&id='.urlencode($row['conference_control_detail_uuid']);
|
||||
$list_row_url = 'conference_control_detail_edit.php?conference_control_uuid='.urlencode($row['conference_control_uuid']).'&id='.urlencode($row['conference_control_detail_uuid']).($query_string ? '&'.$query_string : '');
|
||||
}
|
||||
echo "<tr class='list-row' href='".$list_row_url."'>\n";
|
||||
if (permission_exists('conference_control_detail_edit') || permission_exists('conference_control_detail_delete')) {
|
||||
|
||||
@@ -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-2025
|
||||
Portions created by the Initial Developer are Copyright (C) 2018-2026
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
@@ -42,6 +42,28 @@
|
||||
$control_name = '';
|
||||
$control_description = '';
|
||||
|
||||
// Set variables from GET parameters
|
||||
$page = is_numeric($_GET['page'] ?? '') ? $_GET['page'] : 0;
|
||||
$order_by = preg_replace('#[^a-zA-Z0-9_\-]#', '', ($_GET['order_by'] ?? 'control_name'));
|
||||
$order = ($_GET['order'] ?? '') === 'desc' ? 'desc' : 'asc';
|
||||
$search = $_GET['search'] ?? '';
|
||||
|
||||
// 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;
|
||||
}
|
||||
$query_string = http_build_query($param);
|
||||
|
||||
//action add or update
|
||||
if (!empty($_REQUEST["id"]) && is_uuid($_REQUEST["id"])) {
|
||||
$action = "update";
|
||||
@@ -70,7 +92,7 @@
|
||||
$token = new token;
|
||||
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
||||
message::add($text['message-invalid_token'],'negative');
|
||||
header('Location: conference_controls.php');
|
||||
header('Location: conference_controls.php'.($query_string ? '?'.$query_string : ''));
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -119,7 +141,7 @@
|
||||
if ($action == "update") {
|
||||
message::add($text['message-update']);
|
||||
}
|
||||
header("Location: conference_controls.php");
|
||||
header("Location: conference_controls.php".($query_string ? '?'.$query_string : ''));
|
||||
return;
|
||||
}
|
||||
} //(is_array($_POST) && empty($_POST["persistformvar"]))
|
||||
@@ -157,7 +179,7 @@
|
||||
echo "<div class='action_bar' id='action_bar'>\n";
|
||||
echo " <div class='heading'><b>".$text['title-conference_control']."</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','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'conference_controls.php']);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'id'=>'btn_back','collapse'=>'hide-xs','style'=>'margin-right: 15px;','link'=>'conference_controls.php'.($query_string ? '?'.$query_string : '')]);
|
||||
echo button::create(['type'=>'submit','label'=>$text['button-save'],'icon'=>$settings->get('theme', 'button_icon_save'),'id'=>'btn_save','collapse'=>'hide-xs']);
|
||||
echo " </div>\n";
|
||||
echo " <div style='clear: both;'></div>\n";
|
||||
|
||||
@@ -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-2025
|
||||
Portions created by the Initial Developer are Copyright (C) 2018-2026
|
||||
the Initial Developer. All Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
@@ -39,13 +39,34 @@
|
||||
$language = new text;
|
||||
$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'] ?? 'control_name'));
|
||||
$order = ($_GET['order'] ?? '') === 'desc' ? 'desc' : 'asc';
|
||||
$search = $_GET['search'] ?? '';
|
||||
|
||||
// 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;
|
||||
}
|
||||
$query_string = http_build_query($param);
|
||||
|
||||
//set from session variables
|
||||
$list_row_edit_button = $settings->get('theme', 'list_row_edit_button', false);
|
||||
|
||||
//get the http post data
|
||||
if (!empty($_POST['conference_controls'])) {
|
||||
$action = $_POST['action'];
|
||||
$search = $_POST['search'] ?? '';
|
||||
$conference_controls = $_POST['conference_controls'];
|
||||
}
|
||||
|
||||
@@ -72,36 +93,26 @@
|
||||
break;
|
||||
}
|
||||
|
||||
header('Location: conference_controls.php'.(!empty($search) ? '?search='.urlencode($search) : ''));
|
||||
header('Location: conference_controls.php'.($query_string ? '?'.$query_string : ''));
|
||||
exit;
|
||||
}
|
||||
|
||||
//get order and order by
|
||||
$order_by = $_GET["order_by"] ?? '';
|
||||
$order = $_GET["order"] ?? '';
|
||||
|
||||
//add the search string
|
||||
$search = strtolower($_GET["search"] ?? '');
|
||||
if (!empty($search)) {
|
||||
$sql_search = "where (";
|
||||
$sql_search .= " lower(control_name) like :search ";
|
||||
$sql_search .= " or lower(control_description) like :search ";
|
||||
$sql_search .= ") ";
|
||||
$parameters['search'] = '%'.$search.'%';
|
||||
}
|
||||
|
||||
//get the count
|
||||
$sql = "select count(conference_control_uuid) from v_conference_controls ";
|
||||
$sql .= $sql_search ?? '';
|
||||
if (!empty($search)) {
|
||||
$sql .= "where (";
|
||||
$sql .= " lower(control_name) like :search ";
|
||||
$sql .= " or lower(control_description) like :search ";
|
||||
$sql .= ") ";
|
||||
$parameters['search'] = '%'.lower_case($search).'%';
|
||||
}
|
||||
$num_rows = $database->select($sql, $parameters ?? null, 'column');
|
||||
unset($sql);
|
||||
|
||||
//prepare to page the results
|
||||
$rows_per_page = $settings->get('domain', 'paging', 50);
|
||||
$param = $search ? "&search=".$search : null;
|
||||
$page = isset($_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
|
||||
@@ -111,7 +122,13 @@
|
||||
$sql .= "cast(control_enabled as text), ";
|
||||
$sql .= "control_description ";
|
||||
$sql .= "from v_conference_controls ";
|
||||
$sql .= $sql_search ?? '';
|
||||
if (!empty($search)) {
|
||||
$sql .= "where (";
|
||||
$sql .= " lower(control_name) like :search ";
|
||||
$sql .= " or lower(control_description) like :search ";
|
||||
$sql .= ") ";
|
||||
$parameters['search'] = '%'.lower_case($search).'%';
|
||||
}
|
||||
$sql .= order_by($order_by, $order, 'control_name', 'asc');
|
||||
$sql .= limit_offset($rows_per_page, $offset);
|
||||
$conference_controls = $database->select($sql, $parameters ?? null, 'all');
|
||||
@@ -130,7 +147,7 @@
|
||||
echo " <div class='heading'><b>".$text['title-conference_controls']."</b><div class='count'>".number_format($num_rows)."</div></div>\n";
|
||||
echo " <div class='actions'>\n";
|
||||
if (permission_exists('conference_control_add')) {
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','link'=>'conference_control_edit.php']);
|
||||
echo button::create(['type'=>'button','label'=>$text['button-add'],'icon'=>$settings->get('theme', 'button_icon_add'),'id'=>'btn_add','link'=>'conference_control_edit.php'.($query_string ? '?'.$query_string : '')]);
|
||||
}
|
||||
if (permission_exists('conference_control_add') && $conference_controls) {
|
||||
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');"]);
|
||||
@@ -141,12 +158,17 @@
|
||||
if (permission_exists('conference_control_delete') && $conference_controls) {
|
||||
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";
|
||||
echo "<input type='text' class='txt list-search' name='search' id='search' value=\"".escape($search)."\" placeholder=\"".$text['label-search']."\" onkeydown=''>";
|
||||
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=''>";
|
||||
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-reset'],'icon'=>$settings->get('theme', 'button_icon_reset'),'type'=>'button','id'=>'btn_reset','link'=>'conference_controls.php','style'=>($search == '' ? 'display: none;' : null)]);
|
||||
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";
|
||||
@@ -168,7 +190,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";
|
||||
@@ -178,8 +199,8 @@
|
||||
echo " <input type='checkbox' id='checkbox_all' name='checkbox_all' onclick='list_all_toggle(); checkbox_on_change(this);' ".(!empty($conference_controls) ?: "style='visibility: hidden;'").">\n";
|
||||
echo " </th>\n";
|
||||
}
|
||||
echo th_order_by('control_name', $text['label-control_name'], $order_by, $order);
|
||||
echo th_order_by('control_enabled', $text['label-control_enabled'], $order_by, $order, null, "class='center shrink'");
|
||||
echo th_order_by('control_name', $text['label-control_name'], $order_by, $order, null, null, $query_string);
|
||||
echo th_order_by('control_enabled', $text['label-control_enabled'], $order_by, $order, null, "class='center shrink'", $query_string);
|
||||
echo " <th class='hide-sm-dn'>".$text['label-control_description']."</th>\n";
|
||||
if (permission_exists('conference_control_edit') && $list_row_edit_button) {
|
||||
echo " <td class='action-button'> </td>\n";
|
||||
@@ -190,7 +211,7 @@
|
||||
$x = 0;
|
||||
foreach ($conference_controls as $row) {
|
||||
if (permission_exists('conference_control_edit')) {
|
||||
$list_row_url = "conference_control_edit.php?id=".urlencode($row['conference_control_uuid']);
|
||||
$list_row_url = "conference_control_edit.php?id=".urlencode($row['conference_control_uuid']).($query_string ? '&'.$query_string : '');
|
||||
}
|
||||
echo "<tr class='list-row' href='".$list_row_url."'>\n";
|
||||
if (permission_exists('conference_control_add') || permission_exists('conference_control_edit') || permission_exists('conference_control_delete')) {
|
||||
|
||||
Reference in New Issue
Block a user