From 1a02aaba9d6b9c8541915b24742574c6af887cae Mon Sep 17 00:00:00 2001 From: Michael Milette Date: Tue, 14 Nov 2023 00:58:42 -0500 Subject: [PATCH 1/3] Fix-236: Creation of dynamic properties not supported in PHP 8.2. --- report.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/report.class.php b/report.class.php index 5b0323f7..1e2a2fd9 100755 --- a/report.class.php +++ b/report.class.php @@ -36,6 +36,8 @@ class report_base { public $endtime = 0; public $sql = ''; public $filterform = null; + public $config; + public $currentcourseid; public function reports_base($report) { global $DB, $CFG, $USER, $remotedb; @@ -793,5 +795,3 @@ public function utf8_strrev($str) { return join('', array_reverse($ar[0])); } } - - From 35006b233163b667061b09d4c6e23400e4c44478 Mon Sep 17 00:00:00 2001 From: Michael Milette Date: Sat, 3 Dec 2022 13:05:55 -0500 Subject: [PATCH 2/3] No longer gets string from report_customsql plugin This fixes an issue where block_configurable_report would report an "Invalid get_string() identifier: 'nosemicolon'" when saving an SQL query. This is only visible when debug is set to Developer mode and only happens if the report_customsql plugin is not also installed. --- components/customsql/form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/customsql/form.php b/components/customsql/form.php index 349ceefd..8ca44159 100644 --- a/components/customsql/form.php +++ b/components/customsql/form.php @@ -102,7 +102,7 @@ public function validation_high_security($data, $files) { } else if (strpos($sql, ';') !== false) { // Do not allow any semicolons. - $errors['querysql'] = get_string('nosemicolon', 'report_customsql'); + $errors['querysql'] = get_string('nosemicolon', 'block_configurable_reports'); } else if ($CFG->prefix != '' && preg_match('/\b' . $CFG->prefix . '\w+/i', $sql)) { // Make sure prefix is prefix_, not explicit. From aa80d6245f6fdbc98a0cb5ab156c2c0d456f4fe3 Mon Sep 17 00:00:00 2001 From: Michael Milette Date: Tue, 14 Nov 2023 01:54:39 -0500 Subject: [PATCH 3/3] Fix-201: Added filtering of report filename in case using {mlang}. --- editcomp.php | 6 +++--- export/csv/export.php | 2 +- export/json/export.php | 5 +++-- export/ods/export.php | 3 ++- export/xls/export.php | 3 ++- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/editcomp.php b/editcomp.php index 394ad9c8..736a15eb 100644 --- a/editcomp.php +++ b/editcomp.php @@ -132,9 +132,9 @@ $managereporturl = new \moodle_url('/blocks/configurable_reports/managereport.php', ['courseid' => $courseid]); $PAGE->navbar->add(get_string('managereports', 'block_configurable_reports'), $managereporturl); -$PAGE->navbar->add($report->name); - $title = format_string($report->name); +$PAGE->navbar->add($title); + $PAGE->set_title($title); $PAGE->set_heading($title); $PAGE->set_cacheable(true); @@ -221,4 +221,4 @@ echo ''; } -echo $OUTPUT->footer(); \ No newline at end of file +echo $OUTPUT->footer(); diff --git a/export/csv/export.php b/export/csv/export.php index 6ba406a1..7b58e905 100755 --- a/export/csv/export.php +++ b/export/csv/export.php @@ -28,7 +28,7 @@ function export_report($report) { $table = $report->table; $matrix = array(); - $filename = 'report'; + $filename = format_string($report->name) ?? 'report'; if (!empty($table->head)) { $countcols = count($table->head); diff --git a/export/json/export.php b/export/json/export.php index fcd0e944..1fa5c59d 100644 --- a/export/json/export.php +++ b/export/json/export.php @@ -24,7 +24,8 @@ */ function export_report($report){ $table = $report->table; - $filename = 'report_' . (time()) . '.json'; + $report_name = format_string($report->name) ?? 'report'; + $filename = $report_name.'_'.(time()).'.json'; $json = []; $headers = $table->head; foreach ($table->data as $data) { @@ -40,4 +41,4 @@ function export_report($report){ header('Content-type: application/json'); echo json_encode($json); exit; -} \ No newline at end of file +} diff --git a/export/ods/export.php b/export/ods/export.php index 9886cf58..09dc8a92 100755 --- a/export/ods/export.php +++ b/export/ods/export.php @@ -28,7 +28,8 @@ function export_report($report) { $table = $report->table; $matrix = array(); - $filename = 'report_'.(time()).'.ods'; + $report_name = format_string($report->name) ?? 'report'; + $filename = $report_name.'_'.(time()).'.ods'; if (!empty($table->head)) { $countcols = count($table->head); diff --git a/export/xls/export.php b/export/xls/export.php index f362d8b3..530b9c18 100755 --- a/export/xls/export.php +++ b/export/xls/export.php @@ -28,7 +28,8 @@ function export_report($report) { $table = $report->table; $matrix = array(); - $filename = 'report_'.(time()).'.xls'; + $report_name = format_string($report->name) ?? 'report'; + $filename = $report_name.'_'.(time()).'.xlsx'; if (!empty($table->head)) { $countcols = count($table->head);