From 08f7a15bf1b32dc2a38a464eec064802ab6195ef Mon Sep 17 00:00:00 2001 From: Daniel Spitzer Date: Sun, 8 Dec 2024 19:00:06 +0100 Subject: [PATCH] Kalender Update: * Suche wurde angepasst --- application/Calendar/CalendarModel.php | 61 ++++++++++++++++++-------- public/js/pages/Calendar/View.js | 11 +++-- 2 files changed, 49 insertions(+), 23 deletions(-) diff --git a/application/Calendar/CalendarModel.php b/application/Calendar/CalendarModel.php index 2303b08d6..8b92c2e14 100644 --- a/application/Calendar/CalendarModel.php +++ b/application/Calendar/CalendarModel.php @@ -43,6 +43,23 @@ class CalendarModel public static $specialCalendarColors = array(997 => '#bd0000', 998 => '#8000A3', 999 => '#08769b'); + public static function convertToSummertime($timestamp) + { + // Create a DateTime object from the Unix timestamp + $date = new DateTime(); + $date->setTimestamp($timestamp); + + // Set the timezone to Europe/Berlin + $date->setTimezone(new DateTimeZone('Europe/Berlin')); + if ($date->format('I') == 1) { + $cest = 7200; + } else { + $cest = 3600; + } + $unixtimestamp = $date->getTimestamp() + $cest; + // Format the date and time + return date('Y-m-d H:i:s', $unixtimestamp); + } public static function replace_unicode_sequences($string) { @@ -96,16 +113,18 @@ class CalendarModel $rows = array(); while ($data = $dbcal->fetch_array($res)) { - if ($data['location']) { - $searchName = $data['name'] . " @" . $data['location']; - } else { - $searchName = $data['name']; + if ($data['private'] != 1 || $data['calendar_id'] == $r->cal_id) { + if ($data['location']) { + $searchName = $data['name'] . " @" . $data['location']; + } else { + $searchName = $data['name']; + } + $id = $data['id'] . ";" . date("Y-m-d", $data['start_time']); + $rows[] = array( + 'id' => $id, + 'text' => $searchName . " (" . date("Y-m-d", $data['start_time']) . ")" + ); } - $id = $data['id'] . ";" . date("Y-m-d", $data['start_time']); - $rows[] = array( - 'id' => $id, - 'text' => $searchName . " (" . date("Y-m-d", $data['start_time']) . ")" - ); } $json['incomplete_results'] = false; $json['total_count'] = count($rows); @@ -195,7 +214,11 @@ class CalendarModel if ($data['recurrence']) { $recurrence = json_decode($data['recurrence'], true); - $rrule_events= json_decode($data['rrule_events'], true); + $rrule_events = json_decode($data['rrule_events'], true); + foreach ($rrule_events as $key => $value) { + $rrule_events[$key]['start'] = self::convertToSummertime(strtotime($value['start'])); + $rrule_events[$key]['end'] = self::convertToSummertime(strtotime($value['end'])); + } if ($rrulefreq[$recurrence['pattern']['type']]) { unset ($byweekday); $freq = $rrulefreq[$recurrence['pattern']['type']]; @@ -237,19 +260,19 @@ class CalendarModel $txtcolor = "#000"; $colorCounter++; } - $location=$data['location']; - $eventtype=$data['event_type']; - $description=$data['description']; + $location = $data['location']; + $eventtype = $data['event_type']; + $description = $data['description']; if ($calenderRights[$data['calendar_id']]) { $rights = $calenderRights[$data['calendar_id']]; $CalendarUsers[$data['calendar_id']] = $data['calendar_name']; - if ($data['private']==1 && $calendar[0]->go_calendar_id != $data['calendar_id']) { + if ($data['private'] == 1 && $calendar[0]->go_calendar_id != $data['calendar_id']) { $name = "Privat"; $attachment = 0; $attachmentLinks = ""; - $location=""; - $eventtype="1"; - $description=""; + $location = ""; + $eventtype = "1"; + $description = ""; } $rows[] = array( 'id' => array('id' => $data['id']), @@ -552,7 +575,7 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda $busy = ($r->busy); $users = ($r->users); $attendees = ($r->attendees); - $privateflag=($r->privateflag); + $privateflag = ($r->privateflag); foreach ($users as $key => $value) { $user_id = $value; } @@ -750,7 +773,7 @@ WHERE `TimerecordingCategory`.`hourday`!='1' AND `TimerecordingCategory`.`hourda $users = ($r->users); $customer_info_reminder_check = 0; $attendees = ($r->attendees); - $privateflag=($r->privateflag); + $privateflag = ($r->privateflag); date_default_timezone_set('Europe/Berlin'); header('Content-Type: application/json'); foreach ($users as $key => $value) { diff --git a/public/js/pages/Calendar/View.js b/public/js/pages/Calendar/View.js index 9070d35ba..00a82f4f9 100644 --- a/public/js/pages/Calendar/View.js +++ b/public/js/pages/Calendar/View.js @@ -117,7 +117,7 @@ document.addEventListener('DOMContentLoaded', function () { } else { rights = false; } - if (value.privateflag.privateflag == '1' && mycalendar_id!=value.calendar_id.calendar_id) { + if (value.privateflag.privateflag == '1' && mycalendar_id != value.calendar_id.calendar_id) { rights = false; } @@ -843,7 +843,9 @@ if (typeof (EventSource) !== 'undefined') { } else { movable = false; } - if (event.privateflag == '1' && mycalendar_id!=event.calendar_id_check) { + console.log(mycalendar_id); + console.log(event.calendar_id_check.calendar_id); + if (event.privateflag == '1' && mycalendar_id != event.calendar_id_check.calendar_id) { rights = false; movable = false; @@ -1536,7 +1538,8 @@ $(document).ready(function () { return { q: params.term, // Der Suchbegriff term: params.term, // Der Suchbegriff - calendars: visibleCalendars // Die dynamische Variable, die du hinzufügen möchtest + calendars: visibleCalendars, // Die dynamische Variable, die du hinzufügen möchtest + cal_id: $('#calendar-id').data('calendarid') }; }, dataType: 'json', @@ -1918,7 +1921,7 @@ Xinon GMbH`; } else { movable = false; } - if (value.privateflag.privateflag == '1' && mycalendar_id!=value.calendar_id.calendar_id) { + if (value.privateflag.privateflag == '1' && mycalendar_id != value.calendar_id.calendar_id) { rights = false; movable = false;