Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
fixed bug where user couldnt access self enrolled course
Browse files Browse the repository at this point in the history
  • Loading branch information
mkocagoel committed Dec 7, 2022
1 parent 04aefb8 commit 0f20485
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lbplanner/classes/helpers/course_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ public static function get_lbplanner_course($courseid, $userid) : stdClass {
*/
public static function check_access($courseid, $userid) : bool {
global $DB;
$enrolmentid = $DB->get_field(self::ENROL_TABLE, 'id', array('courseid' => $courseid));
if ($DB->record_exists(self::USER_ENROL_TABLE, array('enrolid' => $enrolmentid, 'userid' => $userid))) {
return true;
$enrolmentids = $DB->get_records(self::ENROL_TABLE, array('courseid' => $courseid), '', 'id');
foreach ($enrolmentids as $enrolmentid) {
if ($DB->record_exists(self::USER_ENROL_TABLE, array('enrolid' => $enrolmentid, 'userid' => $userid))) {
return true;
}
}
return false;
}
Expand Down

0 comments on commit 0f20485

Please sign in to comment.