PluginProbe
Fluent Support – Helpdesk & Customer Support Ticket System / 2.4.5
Fluent Support – Helpdesk & Customer Support Ticket System v2.4.5
2.4.5 2.4.0 2.3.2 2.3.1 2.3.0 2.2.1 2.2.0 trunk 1.10.0 1.10.1 1.10.2 1.10.3 1.10.4 1.10.5 1.4.0 1.4.1 1.4.2 1.4.5 1.4.6 1.4.7 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 All 69 releases
← All changes | app/Services/Integrations/FluentBooking/BookingLinkManager.php +14 -43 2.2.1 → 2.4.5 View file →
@@ -10,9 +10,9 @@
10 10
11 11 class BookingLinkManager
12 12 {
13 13 /**
14 - * Persists a booking link record as serialised ticket meta.
14 + * Store a booking link record as ticket meta.
15 15 *
16 16 * @param Ticket $ticket
17 17 * @param array $metadata
18 18 * @return void
@@ -27,9 +27,9 @@
27 27 ]);
28 28 }
29 29
30 30 /**
31 - * Extracts a link token and event details from a URL and stores them as ticket meta, skipping duplicates.
31 + * Store the link token and event from a booking URL, skipping tokens already stored.
32 32 *
33 33 * @param Ticket $ticket
34 34 * @param object $person
35 35 * @param string $bookingUrl
@@ -64,10 +64,8 @@
64 64 ]);
65 65 }
66 66
67 67 /**
68 - * Returns true when this link token is already recorded in the ticket's booking link meta.
69 - *
70 68 * @param Ticket $ticket
71 69 * @param string $linkToken
72 70 * @return bool
73 71 */
@@ -79,9 +77,9 @@
79 77 ->exists();
80 78 }
81 79
82 80 /**
83 - * Returns all deserialised booking link records stored in this ticket's meta, most recent first.
81 + * The ticket's 5 most recent booking link records.
84 82 *
85 83 * @param Ticket $ticket
86 84 * @return array
87 85 */
@@ -100,12 +98,10 @@
100 98 ->toArray();
101 99 }
102 100
103 101 /**
104 - * Returns a DB-ready datetime one day before the oldest stored link's creation date.
102 + * One day before the oldest link's created_at, used to bound the booking query.
105 103 *
106 - * Used to bound the booking query when scoping by generated links.
107 - *
108 104 * @param array $generatedLinks
109 105 * @return string
110 106 */
111 107 public function getEarliestLinkDate($generatedLinks)
@@ -126,9 +122,9 @@
126 122 return gmdate('Y-m-d H:i:s', strtotime(min($dates)) - DAY_IN_SECONDS);
127 123 }
128 124
129 125 /**
130 - * Extracts all tokenised booking URLs (containing fs_booking_link_token) from HTML content.
126 + * Booking URLs carrying fs_booking_link_token found in the content.
131 127 *
132 128 * @param string $content
133 129 * @return array
134 130 */
@@ -143,10 +139,8 @@
143 139 return array_values(array_unique(array_map('esc_url_raw', $matches[0])));
144 140 }
145 141
146 142 /**
147 - * Returns the fs_booking_link_token query param value from a URL.
148 - *
149 143 * @param string $url
150 144 * @return string
151 145 */
152 146 public function getLinkTokenFromUrl($url)
@@ -154,12 +148,10 @@
154 148 return sanitize_key(Arr::get($this->parseUrlQueryArgs($url), 'fs_booking_link_token'));
155 149 }
156 150
157 151 /**
158 - * Resolves a CalendarSlot from a booking URL.
152 + * Resolve the event from the host/event query args, or from the last two path segments.
159 153 *
160 - * Tries host/event query params first; falls back to extracting calendar and event slugs from the URL path.
161 - *
162 154 * @param string $bookingUrl
163 155 * @return \FluentBooking\App\Models\CalendarSlot|null
164 156 */
165 157 public function getEventFromUrl($bookingUrl)
@@ -191,13 +183,10 @@
191 183 ->first();
192 184 }
193 185
194 186 /**
195 - * Resolves which ticket a new booking belongs to.
187 + * Find the ticket a booking belongs to, by fs_ticket_id first, then by link token.
196 188 *
197 - * Tries matching via the fs_ticket_id query param first, then falls back to
198 - * fs_booking_link_token stored in ticket meta.
199 - *
200 189 * @param object $booking
201 190 * @param array $bookingData
202 191 * @return Ticket|null
203 192 */
@@ -227,12 +216,10 @@
227 216 return null;
228 217 }
229 218
230 219 /**
231 - * Returns true when an internal_info conversation entry already exists for this booking.
220 + * Whether the booking already has a timeline note on the ticket.
232 221 *
233 - * Prevents duplicate timeline notes from being created.
234 - *
235 222 * @param object $booking
236 223 * @return bool
237 224 */
238 225 public function hasTimelineNote($booking)
@@ -242,12 +229,10 @@
242 229 ->exists();
243 230 }
244 231
245 232 /**
246 - * Maps a Booking model to a sanitised array for frontend display.
233 + * Sanitised booking data for the frontend.
247 234 *
248 - * Includes local time conversion and join-URL extraction.
249 - *
250 235 * @param object $booking
251 236 * @return array
252 237 */
253 238 public function formatBooking($booking)
@@ -278,12 +263,8 @@
278 263 ];
279 264 }
280 265
281 266 /**
282 - * Returns a pre-scoped Meta query for ticket booking_link records.
283 - *
284 - * Shared by lookup, existence-check, and fetch operations.
285 - *
286 267 * @return \FluentSupport\Framework\Database\Orm\Builder
287 268 */
288 269 private function metaQuery()
289 270 {
@@ -291,10 +272,8 @@
291 272 ->where('key', 'fluent_booking_link');
292 273 }
293 274
294 275 /**
295 - * Parses the query string of a URL into an associative array.
296 - *
297 276 * @param string $url
298 277 * @return array
299 278 */
300 279 private function parseUrlQueryArgs($url)
@@ -310,12 +289,10 @@
310 289 return is_array($queryArgs) ? $queryArgs : [];
311 290 }
312 291
313 292 /**
314 - * Returns query args from the booking's source URL.
293 + * Query args of the booking's source URL, preferring $bookingData['source_url'].
315 294 *
316 - * Prefers $bookingData['source_url'] over the booking model's own field.
317 - *
318 295 * @param object $booking
319 296 * @param array $bookingData
320 297 * @return array
321 298 */
@@ -326,10 +303,8 @@
326 303 return $sourceUrl ? $this->parseUrlQueryArgs($sourceUrl) : [];
327 304 }
328 305
329 306 /**
330 - * Returns true when the booking's email case-insensitively matches the ticket customer's email.
331 - *
332 307 * @param object $booking
333 308 * @param Ticket $ticket
334 309 * @return bool
335 310 */
@@ -340,9 +315,9 @@
340 315 && strtolower(sanitize_email($ticket->customer->email)) === strtolower(sanitize_email($booking->email));
341 316 }
342 317
343 318 /**
344 - * Returns true when the email matches and the ticket has a stored booking link for this event.
319 + * Email matches and the ticket has a stored link for this event.
345 320 *
346 321 * @param object $booking
347 322 * @param Ticket $ticket
348 323 * @return bool
@@ -353,10 +328,8 @@
353 328 && $this->ticketHasGeneratedEventLink($ticket, (int) $booking->event_id);
354 329 }
355 330
356 331 /**
357 - * Returns true when any stored booking link for this ticket targets the given event ID.
358 - *
359 332 * @param Ticket $ticket
360 333 * @param int $eventId
361 334 * @return bool
362 335 */
@@ -371,9 +344,9 @@
371 344 return false;
372 345 }
373 346
374 347 /**
375 - * Searches stored link-token meta across all tickets and returns the first whose email and event ID match the booking.
348 + * First ticket holding this link token whose customer email and event match the booking.
376 349 *
377 350 * @param object $booking
378 351 * @param string $linkToken
379 352 * @return Ticket|null
@@ -409,10 +382,8 @@
409 382 return null;
410 383 }
411 384
412 385 /**
413 - * Returns true when the booking email matches the ticket customer and the stored link targets the same event.
414 - *
415 386 * @param object $booking
416 387 * @param Ticket $ticket
417 388 * @param array $link
418 389 * @return bool
@@ -423,9 +394,9 @@
423 394 && (int) Arr::get($link, 'event_type_id') === (int) $booking->event_id;
424 395 }
425 396
426 397 /**
427 - * Returns the display timezone for a booking, preferring the calendar author timezone.
398 + * Calendar author's timezone, then the host's, then the site's.
428 399 *
429 400 * @param object $booking
430 401 * @return string
431 402 */
@@ -442,9 +413,9 @@
442 413 return wp_timezone_string();
443 414 }
444 415
445 416 /**
446 - * Converts a UTC booking time string to the given timezone.
417 + * Convert a UTC time to $timezone.
447 418 *
448 419 * @param string $time
449 420 * @param string $timezone
450 421 * @return string