Fix CDR last_query session variable (#7880)

* Fix CDR last_query session variable

- Use http_build_query function to build the query string.
- foreach removes empty parameters to store less in the session

* Update xml_cdr.php

* Update xml_cdr_details.php
This commit is contained in:
Alex
2026-04-16 22:57:26 +00:00
committed by GitHub
parent ea6a02d5f0
commit df389effdf
3 changed files with 55 additions and 51 deletions
+1 -5
View File
@@ -710,10 +710,6 @@
echo "</form>";
}
//mod paging parameters for inclusion in column sort heading links
$param = substr($param, 1); //remove leading '&'
$param = substr($param, 0, strrpos($param, '&order_by=')); //remove trailing order by
//column overflow setting
echo "<style>\n";
if ($settings->get('cdr', 'column_overflow', 'hidden') == 'scroll') {
@@ -1145,7 +1141,7 @@
echo "</form>\n";
//store last search/sort query parameters in session
$_SESSION['xml_cdr']['last_query'] = $_SERVER["QUERY_STRING"];
$_SESSION['xml_cdr']['last_query'] = $query_string;
//show the footer
require_once "resources/footer.php";
+2 -2
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):
@@ -465,7 +465,7 @@
echo "<tr>\n";
echo "<td width='30%' align='left' valign='top' nowrap='nowrap'><b>".$text['title2']."</b><br><br></td>\n";
echo "<td width='70%' align='right' valign='top'>\n";
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'link'=>'xml_cdr.php'.(!empty($_SESSION['xml_cdr']['last_query']) ? '?'.urlencode($_SESSION['xml_cdr']['last_query']) : null)]);
echo button::create(['type'=>'button','label'=>$text['button-back'],'icon'=>$settings->get('theme', 'button_icon_back'),'link'=>'xml_cdr.php'.(!empty($_SESSION['xml_cdr']['last_query']) ? '?'.$_SESSION['xml_cdr']['last_query'] : null)]);
if (permission_exists('xml_cdr_call_log') && $call_log_enabled && isset($log_content) && !empty($log_content)) {
echo button::create(['type'=>'button','label'=>$text['button-call_log'],'icon'=>$settings->get('theme', 'button_icon_search'),'style'=>'margin-left: 15px;','link'=>'xml_cdr_log.php?id='.$uuid]);
}
+52 -44
View File
@@ -204,65 +204,73 @@
}
//set the param variable which is used with paging
$param = "&cdr_id=".urlencode($cdr_id ?? '');
$param .= "&missed=".urlencode($missed ?? '');
$param .= "&direction=".urlencode($direction ?? '');
$param .= "&caller_id_name=".urlencode($caller_id_name ?? '');
$param .= "&caller_id_number=".urlencode($caller_id_number ?? '');
$param .= "&caller_destination=".urlencode($caller_destination ?? '');
$param['cdr_id'] = $cdr_id ?? '';
$param['missed'] = $missed ?? '';
$param['direction'] = $direction ?? '';
$param['caller_id_name'] = $caller_id_name ?? '';
$param['caller_id_number'] = $caller_id_number ?? '';
$param['caller_destination'] = $caller_destination ?? '';
foreach ($extension_uuids as $key => $value) {
if (is_uuid($value)) {
$param .= "&extension_uuids[]=".urlencode($value);
$param['extension_uuids[]'] = $value;
}
}
$param .= "&destination_number=".urlencode($destination_number ?? '');
$param .= "&context=".urlencode($context ?? '');
$param .= "&start_stamp_begin=".urlencode($start_stamp_begin ?? '');
$param .= "&start_stamp_end=".urlencode($start_stamp_end ?? '');
$param .= "&answer_stamp_begin=".urlencode($answer_stamp_begin ?? '');
$param .= "&answer_stamp_end=".urlencode($answer_stamp_end ?? '');
$param .= "&end_stamp_begin=".urlencode($end_stamp_begin ?? '');
$param .= "&end_stamp_end=".urlencode($end_stamp_end ?? '');
$param .= "&start_epoch=".urlencode($start_epoch ?? '');
$param .= "&stop_epoch=".urlencode($stop_epoch ?? '');
$param .= "&duration_min=".urlencode($duration_min ?? '');
$param .= "&duration_max=".urlencode($duration_max ?? '');
$param .= "&billsec=".urlencode($billsec ?? '');
$param .= "&hangup_cause=".urlencode($hangup_cause ?? '');
$param .= "&status=".urlencode($status ?? '');
$param .= "&xml_cdr_uuid=".urlencode($xml_cdr_uuid ?? '');
$param .= "&bleg_uuid=".urlencode($bleg_uuid ?? '');
$param .= "&accountcode=".urlencode($accountcode ?? '');
$param .= "&read_codec=".urlencode($read_codec ?? '');
$param .= "&write_codec=".urlencode($write_codec ?? '');
$param .= "&remote_media_ip=".urlencode($remote_media_ip ?? '');
$param .= "&network_addr=".urlencode($network_addr ?? '');
$param .= "&bridge_uuid=".urlencode($bridge_uuid ?? '');
$param .= "&mos_comparison=".urlencode($mos_comparison ?? '');
$param .= "&mos_score=".urlencode($mos_score ?? '');
$param .= "&wait_min=".urlencode($wait_min ?? '');
$param .= "&wait_max=".urlencode($wait_max ?? '');
$param .= "&tta_min=".urlencode($tta_min ?? '');
$param .= "&tta_max=".urlencode($tta_max ?? '');
$param .= "&recording=".urlencode($recording ?? '');
$param .= "&cc_side=".urlencode($cc_side ?? '');
$param .= "&call_center_queue_uuid=".urlencode($call_center_queue_uuid ?? '');
$param['destination_number'] = $destination_number ?? '';
$param['context'] = $context ?? '';
$param['start_stamp_begin'] = $start_stamp_begin ?? '';
$param['start_stamp_end'] = $start_stamp_end ?? '';
$param['answer_stamp_begin'] = $answer_stamp_begin ?? '';
$param['answer_stamp_end'] = $answer_stamp_end ?? '';
$param['end_stamp_begin'] = $end_stamp_begin ?? '';
$param['end_stamp_end'] = $end_stamp_end ?? '';
$param['start_epoch'] = $start_epoch ?? '';
$param['stop_epoch'] = $stop_epoch ?? '';
$param['duration_min'] = $duration_min ?? '';
$param['duration_max'] = $duration_max ?? '';
$param['billsec'] = $billsec ?? '';
$param['hangup_cause'] = $hangup_cause ?? '';
$param['status'] = $status ?? '';
$param['xml_cdr_uuid'] = $xml_cdr_uuid ?? '';
$param['bleg_uuid'] = $bleg_uuid ?? '';
$param['accountcode'] = $accountcode ?? '';
$param['read_codec'] = $read_codec ?? '';
$param['write_codec'] = $write_codec ?? '';
$param['remote_media_ip'] = $remote_media_ip ?? '';
$param['network_addr'] = $network_addr ?? '';
$param['bridge_uuid'] = $bridge_uuid ?? '';
$param['mos_comparison'] = $mos_comparison ?? '';
$param['mos_score'] = $mos_score ?? '';
$param['wait_min'] = $wait_min ?? '';
$param['wait_max'] = $wait_max ?? '';
$param['tta_min'] = $tta_min ?? '';
$param['tta_max'] = $tta_max ?? '';
$param['recording'] = $recording ?? '';
$param['cc_side'] = $cc_side ?? '';
$param['call_center_queue_uuid'] = $call_center_queue_uuid ?? '';
if (isset($_SESSION['cdr']['field']) && is_array($_SESSION['cdr']['field'])) {
foreach ($_SESSION['cdr']['field'] as $field) {
$array = explode(",", $field);
$field_name = end($array);
if (isset($$field_name)) {
$param .= "&".$field_name."=".urlencode($$field_name);
$param[$field_name] = $$field_name;
}
}
}
if ($_GET['show'] == 'all' && $permission['xml_cdr_all']) {
$param .= "&show=all";
$param['show'] = 'all';
}
if (!empty($order_by)) {
$param .= "&order_by=".urlencode($order_by)."&order=".urlencode($order);
$param['order_by'] = $order_by;
$param['order'] = $order;
}
// Remove empty parameters
foreach ($param as $key => $value) {
if (empty($value)) {
unset($param[$key]);
}
}
$query_string = http_build_query($param);
//create the sql query to get the xml cdr records
if (empty($order_by)) { $order_by = "start_stamp"; }
@@ -682,8 +690,8 @@
//return the paging
if (empty($_REQUEST['export_format'])) {
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $param, $rows_per_page, true, $result_count); //top
list($paging_controls, $rows_per_page) = paging($num_rows, $param, $rows_per_page, false, $result_count); //bottom
list($paging_controls_mini, $rows_per_page) = paging($num_rows, $query_string, $rows_per_page, true, $result_count); //top
list($paging_controls, $rows_per_page) = paging($num_rows, $query_string, $rows_per_page, false, $result_count); //bottom
}
?>