Skip to content

Commit

Permalink
Timetable: removed the display of declined events from Google Calenda…
Browse files Browse the repository at this point in the history
…r on the timetable
  • Loading branch information
SKuipers committed Feb 18, 2025
1 parent bfdf0b8 commit 87b746f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ v29.0.00
Planner: added an attendance indicator to the Today's Lessons list for teachers
System Admin: adjusted action access for Column Rows import
System Admin: added new imports for Columns and Tie Days to Dates in timetable
Timetable: removed the display of declined events from Google Calendar on the timetable
Timetable Admin: added an Edit Timetable by Class button to Course Enrolment by Class
User Admin: improved the image uploader in Manage Users, detect invalid images

Expand Down
22 changes: 18 additions & 4 deletions modules/Timetable/moduleFunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,17 @@ function getCalendarEvents($connection2, $guid, $xml, $startDayStamp, $endDaySta
{
global $container, $session;

$settingGateway = $container->get(SettingGateway::class);
$ssoMicrosoft = $settingGateway->getSettingByScope('System Admin', 'ssoMicrosoft');
$ssoMicrosoft = json_decode($ssoMicrosoft, true);
$calendarEventsCache = 'calendarCache-'.date('W', $startDayStamp).'-'.substr($xml, 0, 24);

$calendarRefresh = $_REQUEST['ttCalendarRefresh'] ?? false;

if ($session->has($calendarEventsCache) && (empty($calendarRefresh) || $calendarRefresh == 'false')) {
return $session->get($calendarEventsCache);
}

$settingGateway = $container->get(SettingGateway::class);
$ssoMicrosoft = $settingGateway->getSettingByScope('System Admin', 'ssoMicrosoft');
$ssoMicrosoft = json_decode($ssoMicrosoft, true);

if (!empty($ssoMicrosoft) && $ssoMicrosoft['enabled'] == 'Y' && $session->has('microsoftAPIAccessToken')) {
$eventsSchool = [];

Expand Down Expand Up @@ -282,6 +282,20 @@ function getCalendarEvents($connection2, $guid, $xml, $startDayStamp, $endDaySta
} else {
$count = 0;
foreach ($calendarListEntry as $entry) {
$hideEvent = false;

// Prevent displaying events that this user has declined
$email = $session->get('email');
$attendees = $entry['attendees'] ?? [];
foreach ($attendees as $attendee) {
if (!empty($attendee['email']) && $attendee['email'] != $email) continue;
if (!empty($attendee['responseStatus']) && strtolower($attendee['responseStatus']) == 'declined') {
$hideEvent = true;
}
}

if ($hideEvent) continue;

$multiDay = false;
if (substr($entry['start']['dateTime'], 0, 10) != substr($entry['end']['dateTime'], 0, 10)) {
$multiDay = true;
Expand Down

0 comments on commit 87b746f

Please sign in to comment.