Skip to content

Commit

Permalink
MDL-58424 core_calendar: moved logic from api.php to lib.php
Browse files Browse the repository at this point in the history
Also moved related PHPUnit tests.

Part of MDL-55611 epic.
  • Loading branch information
mdjnelson authored and danpoltawski committed Apr 4, 2017
1 parent 10515e1 commit 23a29de
Show file tree
Hide file tree
Showing 23 changed files with 2,111 additions and 2,601 deletions.
10 changes: 5 additions & 5 deletions blocks/calendar_month/block_calendar_month.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,25 @@ public function get_content() {
if ($issite) {
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
// the list of courses it will be grabbing events from.
$filtercourse = \core_calendar\api::get_default_courses();
$filtercourse = calendar_get_default_courses();
} else {
// Forcibly filter events to include only those from the particular course we are in.
$filtercourse = array($courseid => $this->page->course);
}

list($courses, $group, $user) = \core_calendar\api::set_filters($filtercourse);
list($courses, $group, $user) = calendar_set_filters($filtercourse);
if ($issite) {
// For the front page.
$this->content->text .= \core_calendar\api::get_mini_calendar($courses, $group, $user, false, false,
$this->content->text .= calendar_get_mini($courses, $group, $user, false, false,
'frontpage', $courseid, $time);
// No filters for now.
} else {
// For any other course.
$this->content->text .= \core_calendar\api::get_mini_calendar($courses, $group, $user, false, false,
$this->content->text .= calendar_get_mini($courses, $group, $user, false, false,
'course', $courseid, $time);
$this->content->text .= '<h3 class="eventskey">'.get_string('eventskey', 'calendar').'</h3>';
$this->content->text .= '<div class="filters calendar_filters">' .
\core_calendar\api::get_filter_controls($this->page->url) . '</div>';
calendar_filter_controls($this->page->url) . '</div>';
}

return $this->content;
Expand Down
10 changes: 5 additions & 5 deletions blocks/calendar_upcoming/block_calendar_upcoming.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ public function get_content() {
if ($courseshown == SITEID) {
// Being displayed at site level. This will cause the filter to fall back to auto-detecting
// the list of courses it will be grabbing events from.
$filtercourse = \core_calendar\api::get_default_courses();
$filtercourse = calendar_get_default_courses();
} else {
// Forcibly filter events to include only those from the particular course we are in.
$filtercourse = array($courseshown => $this->page->course);
}
}

list($courses, $group, $user) = \core_calendar\api::set_filters($filtercourse);
list($courses, $group, $user) = calendar_set_filters($filtercourse);

$defaultlookahead = CALENDAR_DEFAULT_UPCOMING_LOOKAHEAD;
if (isset($CFG->calendar_lookahead)) {
Expand All @@ -85,7 +85,7 @@ public function get_content() {
$defaultmaxevents = intval($CFG->calendar_maxevents);
}
$maxevents = get_user_preferences('calendar_maxevents', $defaultmaxevents);
$events = \core_calendar\api::get_upcoming($courses, $group, $user, $lookahead, $maxevents);
$events = calendar_get_upcoming($courses, $group, $user, $lookahead, $maxevents);

if (!empty($this->instance)) {
$link = 'view.php?view=day&amp;course='.$courseshown.'&amp;';
Expand Down Expand Up @@ -120,14 +120,14 @@ public static function get_upcoming_content($events, $linkhref = null, $showcour
if (!isset($events[$i]->time)) {
continue;
}
$events[$i] = \core_calendar\api::add_event_metadata($events[$i]);
$events[$i] = calendar_add_event_metadata($events[$i]);
$content .= '<div class="event"><span class="icon c0">' . $events[$i]->icon . '</span>';
if (!empty($events[$i]->referer)) {
// That's an activity event, so let's provide the hyperlink.
$content .= $events[$i]->referer;
} else {
if (!empty($linkhref)) {
$href = \core_calendar\api::get_link_href(new \moodle_url(CALENDAR_URL . $linkhref), 0, 0, 0,
$href = calendar_get_link_href(new \moodle_url(CALENDAR_URL . $linkhref), 0, 0, 0,
$events[$i]->timestart);
$href->set_anchor('event_' . $events[$i]->id);
$content .= \html_writer::link($href, $events[$i]->name);
Expand Down
Loading

0 comments on commit 23a29de

Please sign in to comment.