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/Hooks/Handlers/NotificationHandler.php +22 -2 2.2.0 → 2.5.0 View file →
@@ -3,8 +3,9 @@
3 3 namespace FluentBooking\App\Hooks\Handlers;
4 4
5 5 use FluentBooking\App\Models\Booking;
6 6 use FluentBooking\App\Services\EmailNotificationService;
7 +use FluentBooking\App\Services\NotificationGate;
7 8 use FluentBooking\Framework\Support\Arr;
8 9
9 10 class NotificationHandler
10 11 {
@@ -35,8 +36,11 @@
35 36 }
36 37
37 38 private function pushRemindersToQueue($booking, $reminderTimes, $emailTo)
38 39 {
40 + // A booking can be scheduled again (e.g. no_show back to scheduled); replace, don't stack.
41 + \as_unschedule_all_actions('fluent_booking/booking_schedule_reminder', [$booking->id, $emailTo], 'fluent-booking');
42 +
39 43 $this->clearGroupRemindersForHost($booking, $emailTo);
40 44
41 45 foreach ($reminderTimes as $time) {
42 46 $reminderTimestamp = $this->getReminderTime($time);
@@ -84,8 +88,12 @@
84 88 if (!is_null($booking->parent_id) && $booking->isRecurringBooking()) {
85 89 return;
86 90 }
87 91
92 + if (NotificationGate::isSuppressed('booking_scheduled', $booking)) {
93 + return;
94 + }
95 +
88 96 if (Arr::isTrue($notifications, 'booking_conf_attendee.enabled') || (Arr::isTrue($notifications, 'booking_conf_host.enabled'))) {
89 97 as_enqueue_async_action('fluent_booking/after_booking_scheduled_async', [
90 98 $booking->id,
91 99 $bookingEvent->id
@@ -94,8 +102,12 @@
94 102 }
95 103
96 104 public function pushBookingPendingToQueue($booking, $bookingEvent)
97 105 {
106 + if (NotificationGate::isSuppressed('booking_pending', $booking)) {
107 + return;
108 + }
109 +
98 110 if (!$bookingEvent->isConfirmationEnabled() || $bookingEvent->isMultiGuestEvent()) {
99 111 return;
100 112 }
101 113
@@ -118,8 +130,12 @@
118 130 }
119 131
120 132 public function emailToUpdatedEmail($booking, $calendarEvent)
121 133 {
134 + if (NotificationGate::isSuppressed('booking_email_changed', $booking)) {
135 + return;
136 + }
137 +
122 138 $notifications = $calendarEvent->getNotifications();
123 139
124 140 if (Arr::isTrue($notifications, 'booking_conf_attendee.enabled') || (Arr::isTrue($notifications, 'booking_conf_host.enabled'))) {
125 141 as_enqueue_async_action('fluent_booking/after_booking_scheduled_async', [
@@ -228,9 +244,9 @@
228 244 }
229 245
230 246 public function emailOnBookingCancelled(Booking $booking, $calendarEvent)
231 247 {
232 - if (!$calendarEvent) {
248 + if (!$calendarEvent || NotificationGate::isSuppressed('booking_cancelled', $booking)) {
233 249 return;
234 250 }
235 251
236 252 $notifications = $calendarEvent->getNotifications();
@@ -283,8 +299,12 @@
283 299 $reminderTimes = Arr::get($notifications, 'reminder_to_host.email.times', []);
284 300 $this->pushRemindersToQueue($booking, $reminderTimes, 'host');
285 301 }
286 302
303 + if (NotificationGate::isSuppressed('booking_rescheduled', $booking)) {
304 + return;
305 + }
306 +
287 307 $rescheduledBy = $booking->getMeta('rescheduled_by_type', 'host');
288 308
289 309 if ($rescheduledBy == 'host') {
290 310 if (Arr::isTrue($notifications, 'rescheduled_by_host.enabled')) {
@@ -306,9 +326,9 @@
306 326 }
307 327
308 328 public function emailOnBookingRejected(Booking $booking, $calendarEvent)
309 329 {
310 - if (!$calendarEvent) {
330 + if (!$calendarEvent || NotificationGate::isSuppressed('booking_rejected', $booking)) {
311 331 return;
312 332 }
313 333
314 334 $notifications = $calendarEvent->getNotifications();