Skip to content

Commit

Permalink
Merge pull request #83 from openequella/feature/web-service-returns-n…
Browse files Browse the repository at this point in the history
…o-courses

bugfix: ensure web services return correct courses
  • Loading branch information
PenghaiZhang authored Aug 18, 2021
2 parents 8c5c874 + 416afe2 commit 96b5064
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
10 changes: 2 additions & 8 deletions externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,8 @@ public static function list_courses_for_user($username, $modifiable, $archived)
}

if ($modifiable) {
$contextrecord = new stdclass();
$contextrecord->id = $course->contextid;
$contextrecord->contextlevel = CONTEXT_COURSE;
$contextrecord->instanceid = $course->id;
$contextrecord->path = $course->path;
$contextrecord->depth = $course->depth;
$coursecontext = eq_context_course::get_from_record($contextrecord);
if (!has_capability(self::WRITE_PERMISSION, $coursecontext, $userobj)) {
$ctx = context_course::instance($course->id);
if (!has_capability(self::WRITE_PERMISSION, $ctx, $userobj)) {
continue;
}
}
Expand Down
11 changes: 0 additions & 11 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -749,14 +749,3 @@ public function process() {
}
}
}

class eq_context_course extends context_course {
public static function get_from_record($record) {
if ($context = context::cache_get(CONTEXT_COURSE, $record->id)) {
return $context;
}
$context = new context_course($record);
context::cache_add($context);
return $context;
}
}

0 comments on commit 96b5064

Please sign in to comment.