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/Http/Controllers/SchedulesController.php +20 -3 2.2.5 → 2.5.0 View file →
@@ -240,10 +240,19 @@
240 240 if (!in_array($value, ['scheduled', 'completed', 'cancelled', 'rejected', 'no_show'])) {
241 241 return $this->sendError(['message' => __('Invalid status', 'fluent-booking')]);
242 242 }
243 243
244 + if (in_array($booking->status, ['cancelled', 'rejected'])) {
245 + return $this->sendError(['message' => __('A cancelled or rejected booking can not be changed', 'fluent-booking')]);
246 + }
247 +
244 248 if ($value == 'scheduled' && $booking->payment_method && $booking->payment_order) {
245 249 $order = $booking->payment_order;
250 +
251 + if (in_array($order->status, ['refunded', 'partially-refunded'])) {
252 + return $this->sendError(['message' => __('A refunded payment can not be marked as paid', 'fluent-booking')]);
253 + }
254 +
246 255 $order->total_paid = $order->total_amount;
247 256 $order->completed_at = gmdate('Y-m-d H:i:s'); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
248 257 $order->status = 'paid';
249 258 $order->save();
@@ -258,18 +267,24 @@
258 267 do_action('fluent_booking/log_booking_activity', $this->getConfirmLog($booking->id));
259 268 }
260 269
261 270 if ($value == 'cancelled') {
262 - $cancelReason = sanitize_text_field($data['cancel_reason']);
271 + $cancelReason = sanitize_text_field(Arr::get($data, 'cancel_reason', ''));
263 272 $booking->cancelMeeting($cancelReason, 'host', get_current_user_id());
264 273 }
265 274
266 275 if ($value == 'rejected') {
267 - $rejectReason = sanitize_text_field($data['reject_reason']);
276 + $rejectReason = sanitize_text_field(Arr::get($data, 'reject_reason', ''));
268 277 $booking->rejectMeeting($rejectReason, get_current_user_id());
269 278 }
270 279
271 280 if (in_array($value, ['cancelled', 'rejected'])) {
281 + // cancelMeeting() and rejectMeeting() refuse some statuses without changing the booking.
282 + if ($booking->status != $value) {
283 + /* translators: %s: Booking status */
284 + return $this->sendError(['message' => sprintf(__('This booking can not be %s', 'fluent-booking'), $value)]);
285 + }
286 +
272 287 if ($booking->payment_method && Arr::get($data, 'refund_payment') == 'yes') {
273 288 do_action('fluent_booking/refund_payment_' . $booking->payment_method, $booking, $booking->calendar_event);
274 289 }
275 290 return [
@@ -437,8 +452,9 @@
437 452 {
438 453 $this->resolveOwnedBookingOrFail($bookingId);
439 454
440 455 $activities = BookingActivity::where('booking_id', $bookingId)
456 + ->where('type', '!=', BookingActivity::TYPE_NOTE)
441 457 ->orderBy('id', 'DESC')
442 458 ->get();
443 459
444 460 return [
@@ -450,11 +466,12 @@
450 466 {
451 467 $booking = $this->resolveOwnedBookingOrFail($bookingId);
452 468
453 469 $activities = BookingActivity::where('booking_id', $booking->id)
470 + ->where('type', '!=', BookingActivity::TYPE_NOTE)
454 471 ->orderBy('id', 'DESC')
455 472 ->get();
456 -
473 +
457 474 $activities->each(function ($activity) {
458 475 $activity->description = wp_unslash($activity->description);
459 476 });
460 477