diff --git a/classes/table/csp_report.php b/classes/table/csp_report.php index 5f5c2f2..97f0a7a 100644 --- a/classes/table/csp_report.php +++ b/classes/table/csp_report.php @@ -131,7 +131,11 @@ private function format_uri($uri, $label = '', $size = 40) { } $label = str_replace($CFG->wwwroot, '', $label); $label = ltrim($label, '/'); - $label = shorten_text($label, $size, true); + + // Only shorten text when not exporting. + if(!$this->is_downloading()) { + $label = shorten_text($label, $size, true); + } $label = s($label); return \html_writer::link($uri, $label); @@ -287,6 +291,11 @@ protected function col_courses($record) { * @return string HTML link. */ protected function col_action($record) { + // Output no action if exporting. + if($this->is_downloading()) { + return ''; + } + global $OUTPUT; // Find whether we are drilling down. diff --git a/csp_report.php b/csp_report.php index 009ebd7..05aa56c 100644 --- a/csp_report.php +++ b/csp_report.php @@ -33,6 +33,7 @@ $removedirective = optional_param('removedirective', false, PARAM_TEXT); $removedomain = optional_param('removedomain', false, PARAM_TEXT); $removerecordwithid = optional_param('removerecordwithid', false, PARAM_TEXT); +$download = optional_param('download', '', PARAM_ALPHA); admin_externalpage_setup('local_csp_report', '', null, '', array('pagelayout' => 'report')); @@ -58,6 +59,14 @@ redirect($PAGE->url); } +$PAGE->set_url('/local/csp/csp_report.php', [ + 'blockeddomain' => $viewblockeddomain, + 'blockeddirective' => $viewdirective ?? '', + 'removedirective' => $removedirective, + 'removedomain' => $removedomain, + 'removerecordwithid' => $removerecordwithid, +]); + $resetallcspstatistics = optional_param('resetallcspstatistics', 0, PARAM_INT); if ($resetallcspstatistics == 1 && confirm_sesskey()) { $DB->delete_records('local_csp'); @@ -69,18 +78,10 @@ $PAGE->set_heading($title); $PAGE->set_pagelayout('admin'); -global $OUTPUT, $DB; - -echo $OUTPUT->header(); -echo $OUTPUT->heading($title); +$table = new \local_csp\table\csp_report('cspreportstable'); +$table->is_downloading($download, 'csp_report', 'csp_report'); -$action = new \confirm_action(get_string('areyousuretodeleteallrecords', 'local_csp')); -$urlresetallcspstatistics = new moodle_url($PAGE->url, array( - 'resetallcspstatistics' => 1, - 'sesskey' => sesskey(), -)); -echo $OUTPUT->single_button($urlresetallcspstatistics, - get_string('resetallcspstatistics', 'local_csp'), 'post', array('actions' => array($action))); +global $OUTPUT, $DB; $blockeduri = get_string('blockeduri', 'local_csp'); $blockeddomain = get_string('blockeddomain', 'local_csp'); @@ -93,7 +94,6 @@ $timeupdated = get_string('timeupdated', 'local_csp'); $action = get_string('action', 'local_csp'); -$table = new \local_csp\table\csp_report('cspreportstable'); $table->define_baseurl($PAGE->url); $table->sortable(true, 'failcounter', SORT_DESC); $table->set_attribute('class', 'generaltable generalbox table-sm'); @@ -159,8 +159,21 @@ $where = '1 = 1'; $params = array(); } -$table->set_sql($fields, $from, $where, $params); +if(!$table->is_downloading()) { + echo $OUTPUT->header(); + echo $OUTPUT->heading($title); + + $action = new \confirm_action(get_string('areyousuretodeleteallrecords', 'local_csp')); + $urlresetallcspstatistics = new moodle_url($PAGE->url, array( + 'resetallcspstatistics' => 1, + 'sesskey' => sesskey(), + )); + echo $OUTPUT->single_button($urlresetallcspstatistics, + get_string('resetallcspstatistics', 'local_csp'), 'post', array('actions' => array($action))); +} + +$table->set_sql($fields, $from, $where, $params); $table->out(30, true); echo $OUTPUT->footer();