MDL-59393 calendar: use event context in update_event_start_day
authorRyan Wyllie <ryan@moodle.com>
Wed, 23 Aug 2017 01:32:51 +0000 (01:32 +0000)
committerRyan Wyllie <ryan@moodle.com>
Wed, 23 Aug 2017 01:32:51 +0000 (01:32 +0000)
calendar/externallib.php

index 94e74fd..ba62951 100644 (file)
@@ -947,9 +947,6 @@ class core_calendar_external extends external_api {
             'dayTimestamp' => $dayTimestamp,
         ]);
 
-        $context = \context_user::instance($USER->id);
-        self::validate_context($context);
-
         $vault = event_container::get_event_vault();
         $mapper = event_container::get_event_mapper();
         $event = $vault->get_event_by_id($eventId);
@@ -964,6 +961,8 @@ class core_calendar_external extends external_api {
             print_error('nopermissiontoupdatecalendar');
         }
 
+        self::validate_context($legacyevent->context);
+
         $newdate = usergetdate($dayTimestamp);
         $startdatestring = implode('-', [$newdate['year'], $newdate['mon'], $newdate['mday']]);
         $startdate = new DateTimeImmutable($startdatestring);