Skip to content

Commit

Permalink
MDL-71182 calendar: add logic for category events in get_context
Browse files Browse the repository at this point in the history
This commit adds the missing logic for category events in
get_context() method. Without this fix, users will get errors
if they have category events with userid set to 0.
  • Loading branch information
lameze committed Mar 24, 2021
1 parent 1fcd850 commit beff5c6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion calendar/classes/external/events_related_objects_cache.php
Expand Up @@ -114,12 +114,15 @@ public function get_course(event_interface $event) {
public function get_context(event_interface $event) {
global $USER;

$categoryid = $event->get_category() ? $event->get_category()->get('id') : null;
$courseid = $event->get_course() ? $event->get_course()->get('id') : null;
$groupid = $event->get_group() ? $event->get_group()->get('id') : null;
$userid = $event->get_user() ? $event->get_user()->get('id') : null;
$moduleid = $event->get_course_module() ? $event->get_course_module()->get('id') : null;

if (!empty($courseid)) {
if (!empty($categoryid)) {
return \context_coursecat::instance($categoryid);
} else if (!empty($courseid)) {
return \context_course::instance($event->get_course()->get('id'));
} else if (!empty($groupid)) {
$group = $this->get_group($event);
Expand Down

0 comments on commit beff5c6

Please sign in to comment.