From fb36d8dd2ca8b37e155ca84cc3da2cf435d16c89 Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 10 Mar 2017 12:05:38 +0800 Subject: [PATCH] MDL-58048 mod: New callback implementation * Callback function implementation of _core_calendar_event_action_shows_item_count for: - mod_assign - mod_forum Part of MDL-55611 epic. --- mod/assign/lib.php | 17 +++++++++++++++++ mod/forum/lib.php | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/mod/assign/lib.php b/mod/assign/lib.php index 57ac40853fd..c789465e031 100644 --- a/mod/assign/lib.php +++ b/mod/assign/lib.php @@ -1772,3 +1772,20 @@ function mod_assign_core_calendar_provide_event_action(\core_calendar\event $eve $actionable ); } + +/** + * Callback function that determines whether an action event should be showing its item count + * based on the event type and the item count. + * + * @param \core_calendar\event $event The calendar event. + * @param int $itemcount The item count associated with the action event. + * @return bool + */ +function mod_assign_core_calendar_event_action_shows_item_count(\core_calendar\event $event, $itemcount = 0) { + // List of event types where the action event's item count should be shown. + $eventtypesshowingitemcount = [ + ASSIGN_EVENT_TYPE_GRADINGDUE + ]; + // For mod_assign, item count should be shown if the event type is 'gradingdue' and there is one or more item count. + return in_array($event->eventtype, $eventtypesshowingitemcount) && $itemcount > 0; +} diff --git a/mod/forum/lib.php b/mod/forum/lib.php index e26deede178..be1a17d179f 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -8116,3 +8116,16 @@ function mod_forum_get_fontawesome_icon_map() { 'mod_forum:t/unsubscribed' => 'fa-envelope-open-o', ]; } + +/** + * Callback function that determines whether an action event should be showing its item count + * based on the event type and the item count. + * + * @param \core_calendar\event $event The calendar event. + * @param int $itemcount The item count associated with the action event. + * @return bool + */ +function mod_forum_core_calendar_event_action_shows_item_count(\core_calendar\event $event, $itemcount = 0) { + // Always show item count for forums if item count is greater than 0. + return $itemcount > 0; +} \ No newline at end of file