Skip to content

Commit

Permalink
MDL-66076 forumreport_summary: Minor cleanup of report code
Browse files Browse the repository at this point in the history
Removed some unnecessary code and added the current page to breadcrumbs
  • Loading branch information
rezaies authored and junpataleta committed Oct 11, 2019
1 parent 0942e58 commit 14f9216
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 30 deletions.
22 changes: 1 addition & 21 deletions mod/forum/report/summary/classes/summary_table.php
Expand Up @@ -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;

Expand All @@ -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
*/
Expand Down Expand Up @@ -106,8 +94,6 @@ public function __construct(int $courseid, array $filters, bool $bulkoperations)
$this->userid = $USER->id;
}

$this->courseid = intval($courseid);

$columnheaders = [];

if ($bulkoperations) {
Expand Down Expand Up @@ -459,7 +445,7 @@ protected function define_base_sql(): void {

$this->sql->params = [
'component' => 'mod_forum',
'courseid' => $this->courseid,
'courseid' => $this->cm->course,
];

// Handle if a user is limited to viewing their own summary.
Expand Down Expand Up @@ -504,12 +490,6 @@ public function set_sql($fields, $from, $where, array $params = []) {
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();

Expand Down
15 changes: 6 additions & 9 deletions mod/forum/report/summary/index.php
Expand Up @@ -40,18 +40,14 @@
$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);

Expand All @@ -75,6 +71,7 @@
$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');
Expand Down

0 comments on commit 14f9216

Please sign in to comment.