Skip to content

Commit

Permalink
Merge pull request #214 from Tsheke/CONFIG_CSV_DELIMITER
Browse files Browse the repository at this point in the history
csv delimiter settings
  • Loading branch information
jleyva authored Oct 3, 2024
2 parents 0ad1baa + f7a86ae commit 8a41734
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
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

0 comments on commit 8a41734

Please sign in to comment.