mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
MDL-58363 mod_chat: Remove calendar is_visible
Part of MDL-55611 epic.
This commit is contained in:
parent
0c9dc98b44
commit
73be2a8821
@ -1407,19 +1407,6 @@ function chat_view($chat, $course, $cm, $context) {
|
||||
$completion->set_module_viewed($cm);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_chat_core_calendar_is_event_visible(\core_calendar\event $event) {
|
||||
$cm = get_fast_modinfo($event->courseid)->instances['chat'][$event->instance];
|
||||
$context = context_module::instance($cm->id);
|
||||
|
||||
return has_capability('mod/chat:view', $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles creating actions for events.
|
||||
*
|
||||
|
@ -39,23 +39,7 @@ class mod_chat_lib_testcase extends advanced_testcase {
|
||||
$this->resetAfterTest();
|
||||
}
|
||||
|
||||
public function test_chat_core_calendar_is_event_visible_chattime_event_as_admin() {
|
||||
$this->setAdminUser();
|
||||
|
||||
// Create a course.
|
||||
$course = $this->getDataGenerator()->create_course();
|
||||
|
||||
// Create a chat.
|
||||
$chat = $this->getDataGenerator()->create_module('chat', array('course' => $course->id));
|
||||
|
||||
// Create a calendar event.
|
||||
$event = $this->create_action_event($course->id, $chat->id, CHAT_EVENT_TYPE_CHATTIME);
|
||||
|
||||
// Check that we can see the event.
|
||||
$this->assertTrue(mod_chat_core_calendar_is_event_visible($event));
|
||||
}
|
||||
|
||||
public function test_chat_core_calendar_is_event_visible_chattime_event_as_non_user() {
|
||||
public function test_chat_core_calendar_provide_event_action_chattime_event_as_non_user() {
|
||||
global $CFG;
|
||||
|
||||
$this->setAdminUser();
|
||||
@ -69,12 +53,18 @@ class mod_chat_lib_testcase extends advanced_testcase {
|
||||
// Create a calendar event.
|
||||
$event = $this->create_action_event($course->id, $chat->id, CHAT_EVENT_TYPE_CHATTIME);
|
||||
|
||||
// Create an action factory.
|
||||
$factory = new \core_calendar\action_factory();
|
||||
|
||||
// Log out the user and set force login to true.
|
||||
\core\session\manager::init_empty_session();
|
||||
$CFG->forcelogin = true;
|
||||
|
||||
// Decorate action event.
|
||||
$actionevent = mod_chat_core_calendar_provide_event_action($event, $factory);
|
||||
|
||||
// Check that we can't see the event.
|
||||
$this->assertFalse(mod_chat_core_calendar_is_event_visible($event));
|
||||
$this->assertNull($actionevent);
|
||||
}
|
||||
|
||||
public function test_chat_core_calendar_provide_event_action_chattime_event() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user