PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.5.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.5.0
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
← All changes | app/Services/CalendarService.php +65 -13 1.7.1 → 2.5.0 View file →
@@ -92,9 +92,9 @@
92 92
93 93 foreach ($createdEvents as $index => $event) {
94 94 $eventMetasData = Arr::get($createEventMetasData, $index, []);
95 95
96 - $eventMetasData = self::prepareEventMetas($eventMetasData);
96 + $eventMetasData = self::prepareEventMetas($eventMetasData, $event);
97 97
98 98 $event->event_metas()->createMany($eventMetasData);
99 99 }
100 100
@@ -146,9 +146,9 @@
146 146 $firstCalendar = Calendar::where('user_id', $preparedData['user_id'])->where('type', 'simple')->first();
147 147
148 148 if ($isHostCalendar && $firstCalendar) {
149 149 if ($isFileInput) {
150 - return new \WP_Error('calendar_exists', esc_html__('The user already have a calendar. Please delete it first to create a new one', 'fluent-booking'));
150 + return new \WP_Error('calendar_exists', esc_html__('The user already has a calendar. Please delete it first to create a new one', 'fluent-booking'));
151 151 }
152 152 return $firstCalendar;
153 153 }
154 154
@@ -168,9 +168,11 @@
168 168
169 169 $preparedCalendarMetas[] = [
170 170 'key' => sanitize_text_field($calendarMeta['key']),
171 171 'value' => is_array($value) ? self::sanitize_mapped_data($value) : sanitize_text_field($value),
172 - 'object_type' => sanitize_text_field($calendarMeta['object_type'])
172 + // Bound to the imported calendar; never let the payload pick the type
173 + // (e.g. a user_meta / _access_permissions row).
174 + 'object_type' => 'Calendar'
173 175 ];
174 176 }
175 177
176 178 return $preparedCalendarMetas;
@@ -208,10 +210,10 @@
208 210 }
209 211
210 212 $preparedEventData['settings'] = [
211 213 'schedule_type' => sanitize_text_field(Arr::get($eventSettings, 'schedule_type')),
212 - 'weekly_schedules' => SanitizeService::weeklySchedules(Arr::get($eventSettings, 'weekly_schedules', []), $calendar->author_timezone, 'UTC'),
213 - 'date_overrides' => SanitizeService::slotDateOverrides(Arr::get($eventSettings, 'date_overrides', []), $calendar->author_timezone, 'UTC'),
214 + 'weekly_schedules' => SanitizeService::weeklySchedules(Arr::get($eventSettings, 'weekly_schedules', []), $calendar->author_timezone, 'UTC', true),
215 + 'date_overrides' => SanitizeService::slotDateOverrides(Arr::get($eventSettings, 'date_overrides', []), $calendar->author_timezone, 'UTC', null, true),
214 216 'range_type' => sanitize_text_field(Arr::get($eventSettings, 'range_type')),
215 217 'range_days' => (int)(Arr::get($eventSettings, 'range_days', 60)) ?: 60,
216 218 'range_date_between' => SanitizeService::rangeDateBetween(Arr::get($eventSettings, 'range_date_between', ['', ''])),
217 219 'schedule_conditions' => SanitizeService::scheduleConditions(Arr::get($eventSettings, 'schedule_conditions', [])),
@@ -236,14 +238,52 @@
236 238 'lock_timezone' => [
237 239 'enabled' => Arr::isTrue($eventSettings, 'lock_timezone.enabled'),
238 240 'timezone' => sanitize_text_field(Arr::get($eventSettings, 'lock_timezone.timezone'))
239 241 ],
242 + 'booking_title' => sanitize_text_field(Arr::get($eventSettings, 'booking_title')),
243 + 'submit_button_text' => sanitize_text_field(Arr::get($eventSettings, 'submit_button_text')),
244 + 'custom_redirect' => [
245 + 'enabled' => Arr::isTrue($eventSettings, 'custom_redirect.enabled'),
246 + 'redirect_url' => sanitize_url(Arr::get($eventSettings, 'custom_redirect.redirect_url')),
247 + 'is_query_string' => Arr::get($eventSettings, 'custom_redirect.is_query_string') == 'yes' ? 'yes' : 'no',
248 + 'query_string' => sanitize_text_field(Arr::get($eventSettings, 'custom_redirect.query_string')),
249 + ],
250 + 'requires_confirmation' => [
251 + 'enabled' => Arr::isTrue($eventSettings, 'requires_confirmation.enabled'),
252 + 'type' => sanitize_text_field(Arr::get($eventSettings, 'requires_confirmation.type')),
253 + 'condition' => [
254 + 'unit' => sanitize_text_field(Arr::get($eventSettings, 'requires_confirmation.condition.unit')),
255 + 'value' => intval(Arr::get($eventSettings, 'requires_confirmation.condition.value'))
256 + ]
257 + ],
258 + 'multiple_booking' => [
259 + 'enabled' => Arr::isTrue($eventSettings, 'multiple_booking.enabled'),
260 + 'limit' => intval(Arr::get($eventSettings, 'multiple_booking.limit'))
261 + ],
262 + 'can_not_cancel' => [
263 + 'enabled' => Arr::isTrue($eventSettings, 'can_not_cancel.enabled'),
264 + 'type' => sanitize_text_field(Arr::get($eventSettings, 'can_not_cancel.type')),
265 + 'message' => sanitize_text_field(Arr::get($eventSettings, 'can_not_cancel.message')),
266 + 'condition' => [
267 + 'unit' => sanitize_text_field(Arr::get($eventSettings, 'can_not_cancel.condition.unit')),
268 + 'value' => intval(Arr::get($eventSettings, 'can_not_cancel.condition.value'))
269 + ]
270 + ],
271 + 'can_not_reschedule' => [
272 + 'enabled' => Arr::isTrue($eventSettings, 'can_not_reschedule.enabled'),
273 + 'type' => sanitize_text_field(Arr::get($eventSettings, 'can_not_reschedule.type')),
274 + 'message' => sanitize_text_field(Arr::get($eventSettings, 'can_not_reschedule.message')),
275 + 'condition' => [
276 + 'unit' => sanitize_text_field(Arr::get($eventSettings, 'can_not_reschedule.condition.unit')),
277 + 'value' => intval(Arr::get($eventSettings, 'can_not_reschedule.condition.value'))
278 + ]
279 + ]
240 280 ];
241 281
242 282 return $preparedEventData;
243 283 }
244 284
245 - protected static function prepareEventMetas($eventMetasData)
285 + protected static function prepareEventMetas($eventMetasData, $event = null)
246 286 {
247 287 $preparedEventMetas = [];
248 288
249 289 foreach ($eventMetasData as $eventMeta) {
@@ -252,16 +292,28 @@
252 292 }
253 293
254 294 $value = $eventMeta['value'];
255 295
296 + // Only the two types an event actually stores; anything else in the
297 + // payload (e.g. user_meta / _access_permissions) is dropped.
298 + $objectType = sanitize_text_field(Arr::get($eventMeta, 'object_type'));
299 + if (!in_array($objectType, ['calendar_event', 'integration'], true)) {
300 + continue;
301 + }
302 +
256 303 if ($eventMeta['key'] == 'email_notification') {
257 304 $value = self::updateNotificationImageUrl($value);
258 305 }
259 306
307 + // Rendered on the public form via {@html}; sanitize as the admin path does.
308 + if ($eventMeta['key'] == 'booking_fields' && is_array($value)) {
309 + $value = BookingFieldService::sanitizeBookingFields($value, $event);
310 + }
311 +
260 312 $preparedEventMetas[] = [
261 313 'key' => sanitize_text_field($eventMeta['key']),
262 314 'value' => is_array($value) ? self::sanitize_mapped_data($value) : sanitize_text_field($value),
263 - 'object_type' => sanitize_text_field($eventMeta['object_type'])
315 + 'object_type' => $objectType
264 316 ];
265 317 }
266 318
267 319 return $preparedEventMetas;
@@ -337,9 +389,9 @@
337 389 ->latest()
338 390 ->get();
339 391
340 392 $formattedCalendars = [];
341 - foreach ($calendars as $index => $calendar) {
393 + foreach ($calendars as $calendar) {
342 394 $slots = Arr::get($calendar, 'slots');
343 395 if (!empty($slots)) {
344 396 $options = [];
345 397 foreach ($slots as $slot) {
@@ -348,9 +400,9 @@
348 400 'value' => Arr::get($slot, 'id')
349 401 ];
350 402 }
351 403 if (!empty($options)) {
352 - $formattedCalendars[$index] = [
404 + $formattedCalendars[] = [
353 405 'label' => Arr::get($calendar, 'title'),
354 406 'options' => $options
355 407 ];
356 408 }
@@ -386,9 +438,9 @@
386 438
387 439 $calendars = $calendarsQuery->latest()->get();
388 440
389 441 $formattedCalendars = [];
390 - foreach ($calendars as $index => $calendar) {
442 + foreach ($calendars as $calendar) {
391 443 $slots = Arr::get($calendar, 'slots');
392 444 if (!empty($slots)) {
393 445 $options = [];
394 446 foreach ($slots as $slot) {
@@ -397,9 +449,9 @@
397 449 'title' => Arr::get($slot, 'title')
398 450 ];
399 451 }
400 452 if (!empty($options)) {
401 - $formattedCalendars[$index] = [
453 + $formattedCalendars[] = [
402 454 'id' => Arr::get($calendar, 'id'),
403 455 'title' => Arr::get($calendar, 'title'),
404 456 'options' => $options
405 457 ];
@@ -459,14 +511,14 @@
459 511
460 512 foreach ($calendarEvents as $event) {
461 513 if ($weeklySchedule = Arr::get($event->settings, 'weekly_schedules', [])) {
462 514 $originalSchedule = SanitizeService::weeklySchedules($weeklySchedule, 'UTC', $oldTimezone);
463 - $weeklySchedule = SanitizeService::weeklySchedules($originalSchedule, $updatedTimezone, 'UTC');
515 + $weeklySchedule = SanitizeService::weeklySchedules($originalSchedule, $updatedTimezone, 'UTC', true);
464 516 }
465 517
466 518 if ($dateOverride = Arr::get($event->settings, 'date_overrides', [])) {
467 519 $originalOverride = SanitizeService::slotDateOverrides($dateOverride, 'UTC', $oldTimezone);
468 - $dateOverride = SanitizeService::slotDateOverrides($originalOverride, $updatedTimezone, 'UTC');
520 + $dateOverride = SanitizeService::slotDateOverrides($originalOverride, $updatedTimezone, 'UTC', null, true);
469 521 }
470 522
471 523 $event->settings = [
472 524 'weekly_schedules' => $weeklySchedule,