MDL-53996 block_lp: Check user login before fetching block contents
authorJun Pataleta <jun@moodle.com>
Mon, 2 May 2016 01:34:17 +0000 (09:34 +0800)
committerJun Pataleta <jun@moodle.com>
Mon, 2 May 2016 01:40:06 +0000 (09:40 +0800)
blocks/lp/block_lp.php

index 60a9aea..53fede6 100644 (file)
@@ -66,14 +66,17 @@ class block_lp extends block_base {
             return $this->content;
         }
 
-        $summary = new \block_lp\output\summary();
-        if (!$summary->has_content()) {
-            return $this->content;
-        }
+        // Block needs a valid, non-guest user to be logged-in in order to display the user's learning plans.
+        if (isloggedin() && !isguestuser()) {
+            $summary = new \block_lp\output\summary();
+            if (!$summary->has_content()) {
+                return $this->content;
+            }
 
-        $renderer = $this->page->get_renderer('block_lp');
-        $this->content->text = $renderer->render($summary);
-        $this->content->footer = '';
+            $renderer = $this->page->get_renderer('block_lp');
+            $this->content->text = $renderer->render($summary);
+            $this->content->footer = '';
+        }
 
         return $this->content;
     }