Merge branch 'MDL-65211-master' of git://github.com/jleyva/moodle
[moodle.git] / enrol / externallib.php
index 5e555e0..593541e 100644 (file)
@@ -880,8 +880,7 @@ class core_enrol_external extends external_api {
         self::validate_context(context_system::instance());
 
         $course = $DB->get_record('course', array('id' => $params['courseid']), '*', MUST_EXIST);
-        $context = context_course::instance($course->id);
-        if (!$course->visible and !has_capability('moodle/course:viewhiddencourses', $context)) {
+        if (!core_course_category::can_view_course_info($course) && !can_access_course($course)) {
             throw new moodle_exception('coursehidden');
         }