MDL-66297 forumreport_summary: add export links to the report
This commit is contained in:
committed by
Michael Hawkins
parent
84ed2320dd
commit
1743d4a3e9
@@ -102,9 +102,10 @@ class summary_table extends table_sql {
|
||||
* @param bool $allowbulkoperations Is the user allowed to perform bulk operations?
|
||||
* @param bool $canseeprivatereplies Whether the user can see all private replies or not.
|
||||
* @param int $perpage The number of rows to display per page.
|
||||
* @param bool $canexport Is the user allowed to export records?
|
||||
*/
|
||||
public function __construct(int $courseid, array $filters, bool $allowbulkoperations,
|
||||
bool $canseeprivatereplies, int $perpage) {
|
||||
bool $canseeprivatereplies, int $perpage, bool $canexport) {
|
||||
global $USER, $OUTPUT;
|
||||
|
||||
$forumid = $filters['forums'][0];
|
||||
@@ -156,6 +157,10 @@ class summary_table extends table_sql {
|
||||
$columnheaders['earliestpost'] = get_string('earliestpost', 'forumreport_summary');
|
||||
$columnheaders['latestpost'] = get_string('latestpost', 'forumreport_summary');
|
||||
|
||||
if ($canexport) {
|
||||
$columnheaders['export'] = '';
|
||||
}
|
||||
|
||||
$this->define_columns(array_keys($columnheaders));
|
||||
$this->define_headers(array_values($columnheaders));
|
||||
|
||||
@@ -277,6 +282,23 @@ class summary_table extends table_sql {
|
||||
return empty($data->latestpost) ? '-' : userdate($data->latestpost, "", \core_date::get_user_timezone($USER));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the export column.
|
||||
*
|
||||
* @param \stdClass $data The row data.
|
||||
* @return string The link to export content belonging to the row.
|
||||
*/
|
||||
public function col_export(\stdClass $data): string {
|
||||
global $OUTPUT;
|
||||
|
||||
$params = [
|
||||
'id' => $this->cm->instance, // Forum id.
|
||||
'userids[]' => $data->userid // User id.
|
||||
];
|
||||
|
||||
return $OUTPUT->action_link(new \moodle_url('/mod/forum/export.php', $params), get_string('export', 'mod_forum'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Override the default implementation to set a decent heading level.
|
||||
*
|
||||
|
||||
@@ -80,8 +80,10 @@ $PAGE->navbar->add(get_string('nodetitle', "forumreport_summary"));
|
||||
// Prepare and display the report.
|
||||
$allowbulkoperations = !$download && !empty($CFG->messaging) && has_capability('moodle/course:bulkmessaging', $context);
|
||||
$canseeprivatereplies = has_capability('mod/forum:readprivatereplies', $context);
|
||||
$canexport = has_capability('mod/forum:exportforum', $context);
|
||||
|
||||
$table = new \forumreport_summary\summary_table($courseid, $filters, $allowbulkoperations, $canseeprivatereplies, $perpage);
|
||||
$table = new \forumreport_summary\summary_table($courseid, $filters, $allowbulkoperations,
|
||||
$canseeprivatereplies, $perpage, $canexport);
|
||||
$table->baseurl = $url;
|
||||
|
||||
if ($download) {
|
||||
|
||||
Reference in New Issue
Block a user