MDL-51415 webservice: Check course access using can_access_course()

This function check both user enrolled and course:view capabilities
This commit is contained in:
Juan Leyva
2015-09-28 16:55:32 +02:00
parent ee64a43e1f
commit 550445a364
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -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');
}
}
+1 -1
View File
@@ -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');
}