From 550445a364709ec7df74d1d016410e611d4e7bbf Mon Sep 17 00:00:00 2001 From: Juan Leyva Date: Tue, 22 Sep 2015 15:29:49 +0200 Subject: [PATCH] MDL-51415 webservice: Check course access using can_access_course() This function check both user enrolled and course:view capabilities --- notes/externallib.php | 2 +- user/externallib.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/notes/externallib.php b/notes/externallib.php index fab1f22f20b..8f23cae410f 100644 --- a/notes/externallib.php +++ b/notes/externallib.php @@ -690,7 +690,7 @@ class core_notes_external extends external_api { throw new moodle_exception('invaliduserid'); } - if ($course->id != SITEID and !is_enrolled($context, $user, '', true)) { + if ($course->id != SITEID and !can_access_course($course, $user, '', true)) { throw new moodle_exception('notenrolledprofile'); } } diff --git a/user/externallib.php b/user/externallib.php index def4e0d1300..f03b9b858a9 100644 --- a/user/externallib.php +++ b/user/externallib.php @@ -1394,7 +1394,7 @@ class core_user_external extends external_api { profile_view($user, $usercontext); } else { // Case like user/view.php. - if (!$currentuser and !is_enrolled($coursecontext, $user->id)) { + if (!$currentuser and !can_access_course($course, $user, '', true)) { throw new moodle_exception('notenrolledprofile'); }