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 +22 -8 2.2.0 → 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
@@ -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;
@@ -279,9 +281,9 @@
279 281
280 282 return $preparedEventData;
281 283 }
282 284
283 - protected static function prepareEventMetas($eventMetasData)
285 + protected static function prepareEventMetas($eventMetasData, $event = null)
284 286 {
285 287 $preparedEventMetas = [];
286 288
287 289 foreach ($eventMetasData as $eventMeta) {
@@ -290,16 +292,28 @@
290 292 }
291 293
292 294 $value = $eventMeta['value'];
293 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 +
294 303 if ($eventMeta['key'] == 'email_notification') {
295 304 $value = self::updateNotificationImageUrl($value);
296 305 }
297 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 +
298 312 $preparedEventMetas[] = [
299 313 'key' => sanitize_text_field($eventMeta['key']),
300 314 'value' => is_array($value) ? self::sanitize_mapped_data($value) : sanitize_text_field($value),
301 - 'object_type' => sanitize_text_field($eventMeta['object_type'])
315 + 'object_type' => $objectType
302 316 ];
303 317 }
304 318
305 319 return $preparedEventMetas;
@@ -375,9 +389,9 @@
375 389 ->latest()
376 390 ->get();
377 391
378 392 $formattedCalendars = [];
379 - foreach ($calendars as $index => $calendar) {
393 + foreach ($calendars as $calendar) {
380 394 $slots = Arr::get($calendar, 'slots');
381 395 if (!empty($slots)) {
382 396 $options = [];
383 397 foreach ($slots as $slot) {
@@ -386,9 +400,9 @@
386 400 'value' => Arr::get($slot, 'id')
387 401 ];
388 402 }
389 403 if (!empty($options)) {
390 - $formattedCalendars[$index] = [
404 + $formattedCalendars[] = [
391 405 'label' => Arr::get($calendar, 'title'),
392 406 'options' => $options
393 407 ];
394 408 }
@@ -424,9 +438,9 @@
424 438
425 439 $calendars = $calendarsQuery->latest()->get();
426 440
427 441 $formattedCalendars = [];
428 - foreach ($calendars as $index => $calendar) {
442 + foreach ($calendars as $calendar) {
429 443 $slots = Arr::get($calendar, 'slots');
430 444 if (!empty($slots)) {
431 445 $options = [];
432 446 foreach ($slots as $slot) {
@@ -435,9 +449,9 @@
435 449 'title' => Arr::get($slot, 'title')
436 450 ];
437 451 }
438 452 if (!empty($options)) {
439 - $formattedCalendars[$index] = [
453 + $formattedCalendars[] = [
440 454 'id' => Arr::get($calendar, 'id'),
441 455 'title' => Arr::get($calendar, 'title'),
442 456 'options' => $options
443 457 ];