Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1365,3 +1365,34 @@ function zoom_cm_info_dynamic(cm_info $cm) {
function zoom_apply_filter_on_meeting_name($name, $options) {
return substr(format_string($name, true, $options + ['escape' => false]), 0, 200);
}

/**
* Checks whether a given calendar event should be visible to the user.
*
* @param calendar_event $event The calendar event object.
* @param ?int $userid User ID.
* @return bool True if visible, false otherwise.
*/
function mod_zoom_core_calendar_is_event_visible(calendar_event $event, $userid = null) {
global $USER;

// Only check our events.
if (empty($event->instance) || $event->modulename !== 'zoom') {
return false;
}

try {
$modinfo = get_fast_modinfo($event->courseid, $userid ?? $USER->id);
$cm = $modinfo->instances['zoom'][$event->instance] ?? null;

if (empty($cm)) {
return false;
}

// Return the user's visibility for the module.
return $cm->uservisible;
} catch (\moodle_exception $e) {
// Hide the event if the activity module does not exist.
return false;
}
}