From 413b7303974c8d00148ec03904f3338cf63aaf3d Mon Sep 17 00:00:00 2001 From: Daniel Spitzer Date: Tue, 12 Nov 2024 11:12:07 +0100 Subject: [PATCH] =?UTF-8?q?Kalender=20Update:=20*=20resource=20wurde=20bei?= =?UTF-8?q?=20Teilnehmern=20entfernt=20*=20wenn=20es=20keinen=20Status=20f?= =?UTF-8?q?=C3=BCr=20die=20Terminteilnahme=20gibt=20wird=20der=20busy=20St?= =?UTF-8?q?atus=20hergenommen=20ohne=20Rahmeninformationen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/Calendar/CalendarModel.php | 46 ++++++++++++++++++++------ public/js/pages/Calendar/View.js | 8 +++-- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/application/Calendar/CalendarModel.php b/application/Calendar/CalendarModel.php index 0b8fcb4d9..2d5e46c27 100644 --- a/application/Calendar/CalendarModel.php +++ b/application/Calendar/CalendarModel.php @@ -43,6 +43,26 @@ class CalendarModel public static $specialCalendarColors = array(997 => '#bd0000', 998 => '#8000A3', 999 => '#08769b'); + + public static function replace_unicode_sequences($string) + { + $unicode_map = [ + '\u00f6' => 'ö', + '\u00fc' => 'ü', + '\u00e4' => 'ä', + '\u00df' => 'ß', + '\u00e9' => 'é', + '\u00e0' => 'à', + '\u00f3' => 'ó', + // Weitere Unicode-Zuordnungen können hier hinzugefügt werden + ]; + + foreach ($unicode_map as $unicode => $char) { + $string = str_replace($unicode, $char, $string); + } + return $string; + } + public static function dbKalender() { if (!TT_CALENDAR_ENABLE) { @@ -69,12 +89,12 @@ class CalendarModel foreach ($termExplode as $term) { $where .= " AND (name LIKE '%" . $term . "%' OR location LIKE '%" . $term . "%') "; } - $where .= " AND calendar_id IN (" . implode(",",$calendars) . ")"; + $where .= " AND calendar_id IN (" . implode(",", $calendars) . ")"; $res = $dbcal->select("cal_events", "id, uuid, calendar_id, user_id, start_time, end_time, timezone, all_day_event, name, description, location, repeat_end_time, reminder, ctime, mtime, muser_id, busy, status, resource_event_id, private, rrule, background, files_folder_id, read_only, category_id, exception_for_event_id, recurrence_id, is_organizer,event_type", "1=1 $where ORDER BY name"); - $rows=array(); + $rows = array(); while ($data = $dbcal->fetch_array($res)) { if ($data['location']) { $searchName = $data['name'] . " @" . $data['location']; @@ -310,20 +330,26 @@ class CalendarModel $attendees = json_decode($data['attendees'], true); $organizer = json_decode($data['organizer'], true); foreach ($attendees as $key => $value) { + if ($key == "required" || $key == "optional") { - foreach ($value as $attendeekey => $attendee) { -// echo $attendee['name']; - if ($attendee['email'] == $organizer['email']) { + foreach ($value as $attendeekey => $attendee) { + $attendee['name'] = self::replace_unicode_sequences($attendee['name']); + if ($attendee['email'] == $organizer['email']) { - } elseif ($Allcalendar[$attendee['name']] && $Allcalendar[$attendee['name']] == $data['calendar_id']) { + } elseif ($Allcalendar[$attendee['name']] && $Allcalendar[$attendee['name']] == $data['calendar_id']) { - } else if ($Allcalendar[$attendee['name']]) { - $AttendeeArray[] = $Allcalendar[$attendee['name']]; - } else { - $AttendeeArray[] = $attendee['email']; + } else if ($Allcalendar[$attendee['name']]) { + $AttendeeArray[] = $Allcalendar[$attendee['name']]; + } else { + $AttendeeArray[] = $attendee['email']; + } } } } + if (!$data['accepted'] && $data['busy'] == 1) { + $data['accepted']['ok']=1; + $data['accepted']=json_encode($data['accepted']); + } $rows = array( 'id' => array('id' => $data['id'], 'order' => $data['id']), diff --git a/public/js/pages/Calendar/View.js b/public/js/pages/Calendar/View.js index 73e444254..8273fc3f8 100644 --- a/public/js/pages/Calendar/View.js +++ b/public/js/pages/Calendar/View.js @@ -372,10 +372,12 @@ document.addEventListener('DOMContentLoaded', function () { let accepted = data.data.accepted.accepted; if (accepted) { const accept = JSON.parse(accepted); - const datetime = new Date(accept.time * 1000); - const germanDateTime = datetime.toLocaleString('de-DE'); + if (accept.time) { + const datetime = new Date(accept.time * 1000); + const germanDateTime = datetime.toLocaleString('de-DE'); + $('.accepted-status').prop('title', accept.user + ' (' + germanDateTime + ')'); + } $('.accepted-status').addClass('fa-circle-check'); - $('.accepted-status').prop('title', accept.user + ' (' + germanDateTime + ')'); $('.event-accepted').text('Akzeptiert'); } else { $('.accepted-status').addClass('fa-circle-info');