MDL-58048 mod: New callback implementation

* Callback function implementation of
<modname>_core_calendar_event_action_shows_item_count for:
 - mod_assign
 - mod_forum

Part of MDL-55611 epic.
This commit is contained in:
Jun Pataleta
2017-03-10 12:05:38 +08:00
committed by Damyon Wiese
parent fe75ef33ee
commit fb36d8dd2c
2 changed files with 30 additions and 0 deletions
+17
View File
@@ -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;
}
+13
View File
@@ -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;
}