Skip to content

Commit

Permalink
Merge branch 'MDL-66768-master' of git://github.com/rezaies/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
snake committed Oct 14, 2019
2 parents 7f518ce + bf2e1be commit e7ac8db
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 18 deletions.
19 changes: 18 additions & 1 deletion mod/forum/report/summary/classes/summary_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ public function col_select($data) {
* @return string User's full name.
*/
public function col_fullname($data): string {
global $OUTPUT;
if ($this->is_downloading()) {
return fullname($data);
}

global $OUTPUT;
return $OUTPUT->user_picture($data, array('size' => 35, 'courseid' => $this->cm->course, 'includefullname' => true));
}

Expand Down Expand Up @@ -384,6 +387,7 @@ protected function define_table_configs(): void {
$this->collapsible(false);
$this->sortable(true, 'firstname', SORT_ASC);
$this->pageable(true);
$this->is_downloadable(true);
$this->no_sorting('select');
$this->set_attribute('id', 'forumreport_summary_table');
}
Expand Down Expand Up @@ -646,4 +650,17 @@ protected function is_filtered_by_groups(array $groups): bool {

return (count($groups) < $groupsavailablecount);
}

/**
* Download the summary report in the selected format.
*
* @param string $format The format to download the report.
*/
public function download($format) {
$filename = 'summary_report_' . userdate(time(), get_string('backupnameformat', 'langconfig'),
99, false);

$this->is_downloading($format, $filename);
$this->out($this->perpage, false);
}
}
41 changes: 24 additions & 17 deletions mod/forum/report/summary/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
$filters['forums'] = [$forumid];
$filters['groups'] = optional_param_array('filtergroups', [], PARAM_INT);

$download = optional_param('download', '', PARAM_ALPHA);

$cm = null;
$modinfo = get_fast_modinfo($courseid);

Expand Down Expand Up @@ -73,27 +75,32 @@
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add(get_string('nodetitle', "forumreport_summary"));

echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('summarytitle', 'forumreport_summary', $forumname), 2, 'p-b-2');

if (!empty($filters['groups'])) {
\core\notification::info(get_string('viewsdisclaimer', 'forumreport_summary'));
}

// Render the report filters form.
$renderer = $PAGE->get_renderer('forumreport_summary');
echo $renderer->render_filters_form($cm, $url, $filters);

// Prepare and display the report.
$bulkoperations = !empty($CFG->messaging) && has_capability('moodle/course:bulkmessaging', $context);
$bulkoperations = !$download && !empty($CFG->messaging) && has_capability('moodle/course:bulkmessaging', $context);

$table = new \forumreport_summary\summary_table($courseid, $filters, $bulkoperations);
$table->baseurl = $url;

echo $renderer->render_summary_table($table, $perpage);
if ($download) {
$table->download($download);
} else {
echo $OUTPUT->header();
echo $OUTPUT->heading(get_string('summarytitle', 'forumreport_summary', $forumname), 2, 'p-b-2');

if ($bulkoperations) {
echo $renderer->render_bulk_action_menu();
}
if (!empty($filters['groups'])) {
\core\notification::info(get_string('viewsdisclaimer', 'forumreport_summary'));
}

// Render the report filters form.
$renderer = $PAGE->get_renderer('forumreport_summary');

echo $renderer->render_filters_form($cm, $url, $filters);
$table->show_download_buttons_at(array(TABLE_P_BOTTOM));
echo $renderer->render_summary_table($table, $perpage);

echo $OUTPUT->footer();
if ($bulkoperations) {
echo $renderer->render_bulk_action_menu();
}

echo $OUTPUT->footer();
}

0 comments on commit e7ac8db

Please sign in to comment.