From 89cfa1e6b2b9b085e1960eb96c1180d42b9d7fe9 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 22 Mar 2017 09:34:01 +0800 Subject: [PATCH] MDL-58363 mod_data: Remove calendar is_visible Part of MDL-55611 epic. --- mod/data/lib.php | 12 ----------- mod/data/tests/lib_test.php | 42 ------------------------------------- 2 files changed, 54 deletions(-) diff --git a/mod/data/lib.php b/mod/data/lib.php index bd758fffbc6..098092fa072 100644 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -4216,18 +4216,6 @@ function data_check_updates_since(cm_info $cm, $from, $filter = array()) { return $updates; } -/** - * Is the event visible? - * - * @param \core_calendar\event $event - * @return bool Returns true if the event is visible to the current user, false otherwise. - */ -function mod_data_core_calendar_is_event_visible(\core_calendar\event $event) { - $cm = get_fast_modinfo($event->courseid)->instances['data'][$event->instance]; - $context = context_module::instance($cm->id); - - return has_capability('mod/data:view', $context); -} /** * Handles creating actions for events. * diff --git a/mod/data/tests/lib_test.php b/mod/data/tests/lib_test.php index b852116a83d..18348261a67 100644 --- a/mod/data/tests/lib_test.php +++ b/mod/data/tests/lib_test.php @@ -995,48 +995,6 @@ class mod_data_lib_testcase extends advanced_testcase { $this->assertEquals([$datarecor1did, $datarecor2did], $updates->entries->itemids, '', 0, 10, true); } - public function test_data_core_calendar_is_event_visible() { - $this->resetAfterTest(); - - $this->setAdminUser(); - - // Create a course. - $course = $this->getDataGenerator()->create_course(); - - // Create a database activity. - $data = $this->getDataGenerator()->create_module('data', array('course' => $course->id)); - - // Create a calendar event. - $event = $this->create_action_event($course->id, $data->id, DATA_EVENT_TYPE_OPEN); - - // Check that we can see the event. - $this->assertTrue(mod_data_core_calendar_is_event_visible($event)); - } - - public function test_data_core_calendar_is_event_visible_as_non_user() { - global $CFG; - - $this->resetAfterTest(); - - $this->setAdminUser(); - - // Create a course. - $course = $this->getDataGenerator()->create_course(); - - // Create a database activity. - $data = $this->getDataGenerator()->create_module('data', array('course' => $course->id)); - - // Create a calendar event. - $event = $this->create_action_event($course->id, $data->id, DATA_EVENT_TYPE_OPEN); - - // Log out the user and set force login to true. - \core\session\manager::init_empty_session(); - $CFG->forcelogin = true; - - // Check that we can't see the event. - $this->assertFalse(mod_data_core_calendar_is_event_visible($event)); - } - public function test_data_core_calendar_provide_event_action_open() { $this->resetAfterTest();