Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

csv delimiter settings #214

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion export/csv/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ function export_report($report) {
}
}

$csvexport = new csv_export_writer();
$csvdelimiter = get_config('block_configurable_reports', 'csvdelimiter');
$csvexport = new csv_export_writer("$csvdelimiter");
$csvexport->set_filename($filename);

foreach ($matrix as $ri => $col) {
Expand Down
4 changes: 4 additions & 0 deletions lang/en/block_configurable_reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,8 +568,12 @@

$string['checksql_execution'] = 'Block Configurable Reports SQL execution';
$string['checksql_execution_ok'] = 'SQL execution is disabled.';

$string['checksql_execution_warning'] = 'It is recommended to disable SQL execution to avoid execution of arbitrary SQL code in
your server.';
$string['checksql_execution_details'] = 'By allowing SQL code execution there is a potential security issue with users adding
arbitrary code. SQL code execution should be disable to only allow SQL queries for reading/retreaving data. SQL execution can
be disabled in your config.php file by setting $CFG->block_configurable_reports_enable_sql_execution to 0';
$string['csvdelimiter'] = 'CSV delimiter';
$string['csvdelimiterinfo'] = 'CSV delimiter: "colon" for ":", "comma" for ",", semicolon for ";", "tab" for "\t" and "cfg" for character configured in "CFG->CSV_DELIMITER" of the config.php file.';

7 changes: 7 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@
)
);


$settings->add(new admin_setting_configtext('block_configurable_reports/allowedsqlusers', get_string('allowedsqlusers', 'block_configurable_reports'),
get_string('allowedsqlusersinfo', 'block_configurable_reports'), '', PARAM_TEXT));
// csv delimiters used in get_delimiter() of moodle lib/csvlib.class.php
$csvdelimiteroptions= array('cfg'=>'cfg','colon'=>'colon','comma'=>'comma','semicolon'=>'semicolon','tab'=>'tab');
$settings->add(new admin_setting_configselect('block_configurable_reports/csvdelimiter', get_string('csvdelimiter', 'block_configurable_reports'),
get_string('csvdelimiterinfo', 'block_configurable_reports'), 'cfg', $csvdelimiteroptions));
$settings->add(
new admin_setting_configtext(
'block_configurable_reports/allowedsqlusers', get_string('allowedsqlusers', 'block_configurable_reports'),
Expand Down
Loading