MDL-60899 block_lp: no permissions - empty block
authorDamyon Wiese <damyon@moodle.com>
Tue, 28 Nov 2017 05:37:35 +0000 (13:37 +0800)
committerDamyon Wiese <damyon@moodle.com>
Tue, 28 Nov 2017 05:37:35 +0000 (13:37 +0800)
Show an empty block if the current user does not have the capability to see any plans.

blocks/lp/classes/output/summary.php

index e5cee22..995f6d4 100644 (file)
@@ -35,6 +35,7 @@ use core_competency\url;
 use renderable;
 use renderer_base;
 use templatable;
+use required_capability_exception;
 
 /**
  * Summary renderable class.
@@ -68,7 +69,11 @@ class summary implements renderable, templatable {
         $this->user = $user;
 
         // Get the plans.
-        $this->plans = api::list_user_plans($this->user->id);
+        try {
+            $this->plans = api::list_user_plans($this->user->id);
+        } catch (required_capability_exception $e) {
+            $this->plans = [];
+        }
 
         // Get the competencies to review.
         $this->compstoreview = api::list_user_competencies_to_review(0, 3);