* @param \moodle_url|string $linkhref link to event referer
* @param boolean $showcourselink whether links to courses should be shown
* @return string|null $content html block content
+ * @deprecated since 3.4
*/
public static function get_upcoming_content($events, $linkhref = null, $showcourselink = false) {
+ debugging(
+ 'get_upcoming_content() is deprecated. ' +
+ 'Please see block_calendar_upcoming::get_content() for the correct API usage.',
+ DEBUG_DEVELOPER
+ );
+
$content = '';
$lines = count($events);
--- /dev/null
+=== 3.4 ===
+
+* block_calendar_upcoming::get_upcoming_content has been deprecated. Please
+ update your code to use the new APIs. You can see an example of how these
+ may be used in block_calendar_upcoming::get_content().
return $calendartype->get_starting_weekday();
}
-/**
- * Gets the calendar upcoming event.
- *
- * @param array $courses array of courses
- * @param array|int|bool $groups array of groups, group id or boolean for all/no group events
- * @param array|int|bool $users array of users, user id or boolean for all/no user events
- * @param int $daysinfuture number of days in the future we 'll look
- * @param int $maxevents maximum number of events
- * @param int $fromtime start time
- * @return array $output array of upcoming events
- */
-function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents, $fromtime=0) {
- global $COURSE;
-
- $display = new \stdClass;
- $display->range = $daysinfuture; // How many days in the future we 'll look.
- $display->maxevents = $maxevents;
-
- $output = array();
-
- $processed = 0;
- $now = time(); // We 'll need this later.
- $usermidnighttoday = usergetmidnight($now);
-
- if ($fromtime) {
- $display->tstart = $fromtime;
- } else {
- $display->tstart = $usermidnighttoday;
- }
-
- // This works correctly with respect to the user's DST, but it is accurate
- // only because $fromtime is always the exact midnight of some day!
- $display->tend = usergetmidnight($display->tstart + DAYSECS * $display->range + 3 * HOURSECS) - 1;
-
- // Get the events matching our criteria.
- $events = calendar_get_legacy_events($display->tstart, $display->tend, $users, $groups, $courses);
-
- // This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
- // possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
- // will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
- // arguments to this function.
- $hrefparams = array();
- if (!empty($courses)) {
- $courses = array_diff($courses, array(SITEID));
- if (count($courses) == 1) {
- $hrefparams['course'] = reset($courses);
- }
- }
-
- if ($events !== false) {
- foreach ($events as $event) {
- if (!empty($event->modulename)) {
- $instances = get_fast_modinfo($event->courseid)->get_instances_of($event->modulename);
- if (empty($instances[$event->instance]->uservisible)) {
- continue;
- }
- }
-
- if ($processed >= $display->maxevents) {
- break;
- }
-
- $event->time = calendar_format_event_time($event, $now, $hrefparams);
- $output[] = $event;
- $processed++;
- }
- }
-
- return $output;
-}
-
/**
* Get a HTML link to a course.
*
information provided here is intended especially for developers.
=== 3.4 ===
-* calendar_get_mini has been deprecated. Please update to use the new
- exporters and renderers.
+* calendar_get_mini, and calendar_get_upcoming have been deprecated. Please update to use the new exporters and renderers.
* added core_calendar_get_valid_event_timestart_range and core_calendar_event_timestart_updated callbacks for module events
when the update_event_start_day function is used in the local api.
function calendar_get_block_upcoming($events, $linkhref = null, $showcourselink = false) {
global $CFG;
- debugging(__FUNCTION__ . '() is deprecated, please use block_calendar_upcoming::get_upcoming_content() instead.',
- DEBUG_DEVELOPER);
+ debugging(
+ __FUNCTION__ . '() has been deprecated. ' +
+ 'Please see block_calendar_upcoming::get_content() for the correct API usage.',
+ DEBUG_DEVELOPER
+ );
require_once($CFG->dirroot . '/blocks/moodleblock.class.php');
require_once($CFG->dirroot . '/blocks/calendar_upcoming/block_calendar_upcoming.php');
list($data, $template) = calendar_get_view($calendar, 'mini');
return $renderer->render_from_template($template, $data);
}
+
+/**
+ * Gets the calendar upcoming event.
+ *
+ * @param array $courses array of courses
+ * @param array|int|bool $groups array of groups, group id or boolean for all/no group events
+ * @param array|int|bool $users array of users, user id or boolean for all/no user events
+ * @param int $daysinfuture number of days in the future we 'll look
+ * @param int $maxevents maximum number of events
+ * @param int $fromtime start time
+ * @return array $output array of upcoming events
+ * @deprecated since Moodle 3.4. MDL-59333
+ */
+function calendar_get_upcoming($courses, $groups, $users, $daysinfuture, $maxevents, $fromtime=0) {
+ debugging(
+ 'calendar_get_upcoming() has been deprecated. ' +
+ 'Please see block_calendar_upcoming::get_content() for the correct API usage.',
+ DEBUG_DEVELOPER
+ );
+
+ global $COURSE;
+
+ $display = new \stdClass;
+ $display->range = $daysinfuture; // How many days in the future we 'll look.
+ $display->maxevents = $maxevents;
+
+ $output = array();
+
+ $processed = 0;
+ $now = time(); // We 'll need this later.
+ $usermidnighttoday = usergetmidnight($now);
+
+ if ($fromtime) {
+ $display->tstart = $fromtime;
+ } else {
+ $display->tstart = $usermidnighttoday;
+ }
+
+ // This works correctly with respect to the user's DST, but it is accurate
+ // only because $fromtime is always the exact midnight of some day!
+ $display->tend = usergetmidnight($display->tstart + DAYSECS * $display->range + 3 * HOURSECS) - 1;
+
+ // Get the events matching our criteria.
+ $events = calendar_get_legacy_events($display->tstart, $display->tend, $users, $groups, $courses);
+
+ // This is either a genius idea or an idiot idea: in order to not complicate things, we use this rule: if, after
+ // possibly removing SITEID from $courses, there is only one course left, then clicking on a day in the month
+ // will also set the $SESSION->cal_courses_shown variable to that one course. Otherwise, we 'd need to add extra
+ // arguments to this function.
+ $hrefparams = array();
+ if (!empty($courses)) {
+ $courses = array_diff($courses, array(SITEID));
+ if (count($courses) == 1) {
+ $hrefparams['course'] = reset($courses);
+ }
+ }
+
+ if ($events !== false) {
+ foreach ($events as $event) {
+ if (!empty($event->modulename)) {
+ $instances = get_fast_modinfo($event->courseid)->get_instances_of($event->modulename);
+ if (empty($instances[$event->instance]->uservisible)) {
+ continue;
+ }
+ }
+
+ if ($processed >= $display->maxevents) {
+ break;
+ }
+
+ $event->time = calendar_format_event_time($event, $now, $hrefparams);
+ $output[] = $event;
+ $processed++;
+ }
+ }
+
+ return $output;
+}