MDL-66076 forumreport_summary: Minor cleanup of report code

Removed some unnecessary code and added the current page to breadcrumbs
This commit is contained in:
Shamim Rezaie 2019-09-28 00:20:42 +10:00 committed by Jun Pataleta
parent 0942e58c91
commit 14f92164f1
2 changed files with 7 additions and 30 deletions

View File

@ -53,12 +53,6 @@ class summary_table extends table_sql {
/** @var int The number of rows to be displayed per page. */
protected $perpage = 25;
/** @var int The course ID being reported on. */
protected $courseid;
/** @var int The forum ID being reported on. */
protected $forumid;
/** @var \stdClass The course module object of the forum being reported on. */
protected $cm;
@ -68,12 +62,6 @@ class summary_table extends table_sql {
*/
protected $userid;
/**
* @var bool Whether the table should be overridden to show the 'nothing to display' message.
* False unless checks confirm there will be nothing to display.
*/
protected $nothingtodisplay = false;
/**
* @var \core\log\sql_reader|null
*/
@ -106,8 +94,6 @@ class summary_table extends table_sql {
$this->userid = $USER->id;
}
$this->courseid = intval($courseid);
$columnheaders = [];
if ($bulkoperations) {
@ -459,7 +445,7 @@ class summary_table extends table_sql {
$this->sql->params = [
'component' => 'mod_forum',
'courseid' => $this->courseid,
'courseid' => $this->cm->course,
];
// Handle if a user is limited to viewing their own summary.
@ -504,12 +490,6 @@ class summary_table extends table_sql {
public function out($pagesize, $useinitialsbar, $downloadhelpbutton = ''): void {
global $DB;
// If there is nothing to display, print the relevant string and return, no further action is required.
if ($this->nothingtodisplay) {
$this->print_nothing_to_display();
return;
}
if (!$this->columns) {
$sql = $this->get_full_sql();

View File

@ -40,18 +40,14 @@ $filters['groups'] = optional_param_array('filtergroups', [], PARAM_INT);
$cm = null;
$modinfo = get_fast_modinfo($courseid);
if ($forumid > 0) {
if (!isset($modinfo->instances['forum'][$forumid])) {
throw new \moodle_exception("A valid forum ID is required to generate a summary report.");
}
$foruminfo = $modinfo->instances['forum'][$forumid];
$forumname = $foruminfo->name;
$cm = $foruminfo->get_course_module_record();
} else {
if (!isset($modinfo->instances['forum'][$forumid])) {
throw new \moodle_exception("A valid forum ID is required to generate a summary report.");
}
$foruminfo = $modinfo->instances['forum'][$forumid];
$forumname = $foruminfo->name;
$cm = $foruminfo->get_course_module_record();
require_login($courseid, false, $cm);
$context = \context_module::instance($cm->id);
@ -75,6 +71,7 @@ $PAGE->set_url($url);
$PAGE->set_pagelayout('report');
$PAGE->set_title($forumname);
$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');