MDL-66213 report_loglive: Do not look up course 0
authorAndrew Nicols <andrew@nicols.co.uk>
Tue, 14 Jan 2020 05:53:39 +0000 (13:53 +0800)
committerSara Arjona <sara@moodle.com>
Tue, 14 Jan 2020 12:20:02 +0000 (13:20 +0100)
report/loglive/classes/renderable.php

index d122d07..8c12ee9 100644 (file)
@@ -174,6 +174,10 @@ class report_loglive_renderable implements renderable {
         $filter = new \stdClass();
         if (!empty($this->course)) {
             $filter->courseid = $this->course->id;
         $filter = new \stdClass();
         if (!empty($this->course)) {
             $filter->courseid = $this->course->id;
+            $context = context_course::instance($filter->courseid);
+            if (!has_capability('moodle/site:viewanonymousevents', $context)) {
+                $filter->anonymous = 0;
+            }
         } else {
             $filter->courseid = 0;
         }
         } else {
             $filter->courseid = 0;
         }
@@ -181,11 +185,6 @@ class report_loglive_renderable implements renderable {
         $filter->date = $this->date;
         $filter->orderby = $this->order;
 
         $filter->date = $this->date;
         $filter->orderby = $this->order;
 
-        $context = context_course::instance($filter->courseid);
-        if (!has_capability('moodle/site:viewanonymousevents', $context)) {
-            $filter->anonymous = 0;
-        }
-
         return $filter;
     }
 
         return $filter;
     }