Skip to content

Commit 3769a19

Browse files
committed
support user context
1 parent c653f6c commit 3769a19

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

classes/permission.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ public static function can_view_list(int $userid, ?\context $context = null): bo
235235
$context = \context_system::instance();
236236
}
237237
if ($context->contextlevel != CONTEXT_SYSTEM && $context->contextlevel != CONTEXT_COURSECAT
238-
&& $context->contextlevel != CONTEXT_COURSE) {
238+
&& $context->contextlevel != CONTEXT_COURSE && $context->contextlevel != CONTEXT_USER) {
239239
return false;
240240
}
241241
if (class_exists('\\tool_organisation\\organisation')) {

lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function tool_certificate_pluginfile($course, $cm, $context, $filearea, $args, $
112112
*/
113113
function tool_certificate_myprofile_navigation(core_user\output\myprofile\tree $tree, $user, $iscurrentuser, $course) {
114114
global $USER;
115-
if (permission::can_view_list($user->id)) {
115+
if (permission::can_view_list($user->id, \context_user::instance($user->id))) {
116116
if ($USER->id == $user->id) {
117117
$link = get_string('mycertificates', 'tool_certificate');
118118
} else {

my.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
// Check that we have a valid user.
3838
$user = \core_user::get_user($userid ?: $USER->id, '*', MUST_EXIST);
39-
if (!\tool_certificate\permission::can_view_list($user->id)) {
39+
if (!\tool_certificate\permission::can_view_list($user->id, \context_user::instance($user->id))) {
4040
throw new \required_capability_exception(context_system::instance(), 'tool/certificate:viewallcertificates',
4141
'nopermission', 'error');
4242
}

0 commit comments

Comments
 (0)