PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / trunk
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution vtrunk
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 1.7.2 All 33 releases
fluent-booking / app / Services / CalendarEventService.php

CalendarEventService.php in Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution trunk, at app/Services/CalendarEventService.php

57 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentBooking\App\Services;
4
5 use FluentBooking\App\Models\Calendar;
6 use FluentBooking\Framework\Support\Arr;
7
8 class CalendarEventService
9 {
10 public static function processEvent($calendarEvent)
11 {
12 $calendarEvent->payment_html = $calendarEvent->getPaymentHtml();
13
14 $calendarEvent->public_url = $calendarEvent->getPublicUrl();
15
16 $calendarEvent->durations = $calendarEvent->getAvailableDurations();
17
18 $calendarEvent->description = $calendarEvent->getDescription();
19
20 $calendarEvent->locations = $calendarEvent->defaultLocationHtml();
21
22 do_action_ref_array('fluent_booking/processed_event', [&$calendarEvent]);
23
24 return $calendarEvent;
25 }
26
27 public static function processEvents(Calendar $calendar, $calendarEvents)
28 {
29 $eventOrder = $calendar->getMeta('event_order');
30
31 if (!empty($eventOrder)) {
32 $calendarEvents = $calendarEvents->sortBy(function($event) use ($eventOrder) {
33 return array_search($event->id, $eventOrder);
34 })->values();
35 }
36
37 foreach ($calendarEvents as $calendarEvent) {
38 $calendarEvent = self::processEvent($calendarEvent);
39 }
40
41 return $calendarEvents;
42 }
43
44 public static function isSharedCalendarEvent($calendarEvent)
45 {
46 $userId = get_current_user_id();
47
48 if ($calendarEvent->user_id == $userId) {
49 return true;
50 }
51
52 $teamMembers = Arr::get($calendarEvent, 'settings.team_members', []);
53
54 return in_array($userId, $teamMembers);
55 }
56 }
57