mirror of
https://github.com/moodle/moodle.git
synced 2025-08-08 10:26:40 +02:00
MDL-62960 calendar: Visuall indicator for valid course event drop zones
This commit is contained in:
parent
86eff20271
commit
8baf412ef7
1 changed files with 41 additions and 0 deletions
|
@ -176,6 +176,9 @@ class calendar_event_exporter extends event_exporter_base {
|
|||
|
||||
if ($event->get_course_module()) {
|
||||
$values = array_merge($values, $this->get_module_timestamp_limits($event));
|
||||
} else if ($hascourse && $course->id != SITEID && empty($event->get_group())) {
|
||||
// This is a course event.
|
||||
$values = array_merge($values, $this->get_course_timestamp_limits($event));
|
||||
}
|
||||
|
||||
return $values;
|
||||
|
@ -210,6 +213,44 @@ class calendar_event_exporter extends event_exporter_base {
|
|||
return $this->event->get_type();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the set of minimum and maximum date timestamp values
|
||||
* for the given event.
|
||||
*
|
||||
* @param event_interface $event
|
||||
* @return array
|
||||
*/
|
||||
protected function get_course_timestamp_limits($event) {
|
||||
$values = [];
|
||||
$mapper = container::get_event_mapper();
|
||||
$starttime = $event->get_times()->get_start_time();
|
||||
|
||||
list($min, $max) = component_callback(
|
||||
'core_course',
|
||||
'core_calendar_get_valid_event_timestart_range',
|
||||
[$mapper->from_event_to_legacy_event($event), $event->get_course()->get_proxied_instance()],
|
||||
[false, false]
|
||||
);
|
||||
|
||||
// The callback will return false for either of the
|
||||
// min or max cutoffs to indicate that there are no
|
||||
// valid timestart values. In which case the event is
|
||||
// not draggable.
|
||||
if ($min === false || $max === false) {
|
||||
return ['draggable' => false];
|
||||
}
|
||||
|
||||
if ($min) {
|
||||
$values = array_merge($values, $this->get_timestamp_min_limit($starttime, $min));
|
||||
}
|
||||
|
||||
if ($max) {
|
||||
$values = array_merge($values, $this->get_timestamp_max_limit($starttime, $max));
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the set of minimum and maximum date timestamp values
|
||||
* for the given event.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue