MDL-64782 core_calendar: Privacy deletion fix

Deleting in course context should not delete from course modules
This commit is contained in:
Shamim Rezaie 2019-02-26 04:05:48 +11:00
parent 0c8cb62e8e
commit ac2bfc2c37
2 changed files with 14 additions and 4 deletions

View File

@ -532,8 +532,7 @@ class provider implements
AND ctx.contextlevel = :categorycontext)
OR (e.courseid = ctx.instanceid
AND (e.eventtype = 'course'
OR e.eventtype = 'group'
OR e.modulename != '0')
OR e.eventtype = 'group')
AND ctx.contextlevel = :coursecontext)
OR (e.userid = ctx.instanceid
AND e.eventtype = 'user'

View File

@ -365,12 +365,23 @@ class core_calendar_privacy_testcase extends provider_testcase {
// Delete all Calendar Events for all Users by Context for Course 2.
provider::delete_data_for_all_users_in_context($course2context);
// Verify all Calendar Events for Course 2 were deleted.
$events = $DB->get_records('event', array('courseid' => $course2->id));
// Verify all Calendar Events for Course 2 context were deleted.
$events = $DB->get_records('event', array('courseid' => $course2->id, 'modulename' => '0'));
$this->assertCount(0, $events);
// Verify all Calendar Subscriptions for Course 2 were deleted.
$subscriptions = $DB->get_records('event_subscriptions', array('courseid' => $course2->id));
$this->assertCount(0, $subscriptions);
// Verify all Calendar Events for the assignment exists still.
$events = $DB->get_records('event', array('modulename' => 'assign'));
$this->assertCount(2, $events);
// Delete all Calendar Events for all Users by Context for the assignment.
provider::delete_data_for_all_users_in_context($modulecontext);
// Verify all Calendar Events for the assignment context were deleted.
$events = $DB->get_records('event', array('modulename' => 'assign'));
$this->assertCount(0, $events);
}
/**