diff --git a/application/Calendar/CalendarModel.php b/application/Calendar/CalendarModel.php index f7e8b87bc..69d998b58 100644 --- a/application/Calendar/CalendarModel.php +++ b/application/Calendar/CalendarModel.php @@ -126,6 +126,7 @@ class CalendarModel $dbcal = self::dbKalender(); $termstring = trim($r->term); $calendars = $r->calendars; + $visibleCalendarTypes = $r->visibleCalendarTypes; $termExplode = explode(" ", $termstring); $where = ""; @@ -133,7 +134,13 @@ class CalendarModel $where .= " AND (name LIKE '%" . $term . "%' OR location LIKE '%" . $term . "%') "; } $where .= " AND calendar_id IN (" . implode(",", $calendars) . ")"; + if ($visibleCalendarTypes) { + $where .= " AND event_type IN (" . implode(",", $visibleCalendarTypes) . ")"; + } + if ($r->visibleCancellation === "0") { + $where .= " AND ((canceld = '0' AND `cal_events`.name NOT LIKE 'Abgesagt:%' AND `cal_events`.name NOT LIKE 'Absage%' AND `cal_events`.name NOT LIKE 'Canceled%') OR event_type = '1')"; + } $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"); @@ -208,12 +215,11 @@ class CalendarModel $where .= " AND event_type IN (" . implode(",", $visibleCalendarTypes) . ")"; } if ($r->visibleCancellation === "0") { - $where .= " AND canceld = '0' "; + $where .= " AND ((canceld = '0' AND `cal_events`.name NOT LIKE 'Abgesagt:%' AND `cal_events`.name NOT LIKE 'Absage%' AND `cal_events`.name NOT LIKE 'Canceled%') OR event_type = '1')"; } $sql = "SELECT `cal_events`.id,`cal_events`.categories, uuid, calendar_id, `cal_events`.user_id, start_time, end_time, timezone, all_day_event, `cal_events`.name,`cal_calendars`.name calendar_name, description, location, repeat_end_time, reminder, ctime,cname, mtime,mname, muser_id, busy, status, resource_event_id, private, rrule, `cal_events`.background, `cal_events`.files_folder_id, read_only, category_id, exception_for_event_id, recurrence_id, is_organizer,event_type,busy,recurrence,rrule_events,canceld FROM cal_events INNER JOIN `cal_calendars` ON (`cal_calendars`.`id`=`cal_events`.`calendar_id`) WHERE 1=1 $where ORDER BY start_time DESC"; - $res = $dbcal->query($sql); if ($dbcal->num_rows($res)) { diff --git a/public/js/pages/Calendar/View.js b/public/js/pages/Calendar/View.js index e580e6cd2..4bd7bdcec 100644 --- a/public/js/pages/Calendar/View.js +++ b/public/js/pages/Calendar/View.js @@ -2093,17 +2093,31 @@ $(document).ready(function () { url: requestEventSearchURL, data: function (params) { let checkbox = $(".calendar-check"); + let calendarFilter = $('.btn-light-search'); let visibleCalendars = []; + let visibleCalendarTypes = []; + let visibleCancellation = 0; visibleCalendars.push(0); checkbox.each(function () { if ($(this).prop('checked')) { visibleCalendars.push($(this).data('calendar_id')); } }); + calendarFilter.each(function () { + if (!$(this).hasClass('top-search-filter')) { + visibleCalendarTypes.push($(this).data('ctype')); + if ($(this).data('eventcancelled')) { + visibleCancellation = 1; + } + + } + }); return { q: params.term, // Der Suchbegriff term: params.term, // Der Suchbegriff calendars: visibleCalendars, // Die dynamische letiable, die du hinzufügen möchtest + visibleCalendarTypes: visibleCalendarTypes, + visibleCancellation: visibleCancellation, cal_id: $('#calendar-id').data('calendarid') }; },