MDL-53589 badges: fix capability check
authorTim Hunt <T.J.Hunt@open.ac.uk>
Tue, 22 Mar 2016 17:22:18 +0000 (17:22 +0000)
committerAndrew Nicols <andrew@nicols.co.uk>
Fri, 6 May 2016 01:27:24 +0000 (09:27 +0800)
badges/lib.php

index 6e1be22..4c2a0ff 100644 (file)
@@ -45,13 +45,7 @@ function core_badges_myprofile_navigation(\core_user\output\myprofile\tree $tree
     // Add category. This node should appear after 'contact' so that administration block appears towards the end. Refer MDL-49928.
     $category = new core_user\output\myprofile\category('badges', get_string('badges', 'badges'), 'contact');
     $tree->add_category($category);
-
-    // Determine context.
-    if (isloggedin()) {
-        $context = context_user::instance($USER->id);
-    } else {
-        $context = context_system::instance();
-    }
+    $context = context_user::instance($user->id);
     $courseid = empty($course) ? 0 : $course->id;
 
     if ($USER->id == $user->id || has_capability('moodle/badges:viewotherbadges', $context)) {
@@ -78,4 +72,4 @@ function core_badges_myprofile_navigation(\core_user\output\myprofile\tree $tree
             }
         }
     }
-}
\ No newline at end of file
+}