mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 21:49:15 +01:00
MDL-71182 calendar: add logic for category events in get_context
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.
This commit is contained in:
parent
1fcd850859
commit
beff5c6685
@ -114,12 +114,15 @@ class events_related_objects_cache {
|
|||||||
public function get_context(event_interface $event) {
|
public function get_context(event_interface $event) {
|
||||||
global $USER;
|
global $USER;
|
||||||
|
|
||||||
|
$categoryid = $event->get_category() ? $event->get_category()->get('id') : null;
|
||||||
$courseid = $event->get_course() ? $event->get_course()->get('id') : null;
|
$courseid = $event->get_course() ? $event->get_course()->get('id') : null;
|
||||||
$groupid = $event->get_group() ? $event->get_group()->get('id') : null;
|
$groupid = $event->get_group() ? $event->get_group()->get('id') : null;
|
||||||
$userid = $event->get_user() ? $event->get_user()->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;
|
$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'));
|
return \context_course::instance($event->get_course()->get('id'));
|
||||||
} else if (!empty($groupid)) {
|
} else if (!empty($groupid)) {
|
||||||
$group = $this->get_group($event);
|
$group = $this->get_group($event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user