PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.8.16
VikBooking Hotel Booking Engine & PMS v1.8.16
1.8.16 1.8.15 1.8.14 1.8.13 1.8.12 1.8.11 1.8.10 1.8.9 1.8.6 1.8.7 1.8.8 trunk 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 All 37 releases
← All changes | admin/helpers/src/notification/scheduler.php +63 -0 1.7.2 → 1.8.16 View file →
@@ -300,8 +300,71 @@
300 300 return $data_objects;
301 301 }
302 302
303 303 /**
304 + * Builds a notification display data object for a recent operator
305 + * chat message for an administrator. This kind of notification will
306 + * be actually dispatched immediately with no scheduling, and so
307 + * so it won't provide a build-URL, it will provide display data.
308 + *
309 + * @param object $message Operator chat message record object to parse.
310 + *
311 + * @return ?object
312 + *
313 + * @since 1.18.0 (J) - 1.8.0 (WP)
314 + */
315 + public function getOperatorsChatDataObject($message)
316 + {
317 + if (!$message instanceof VBOChatMessage) {
318 + return null;
319 + }
320 +
321 + // get a new notification data object
322 + $notification = VBONotificationDataOperatormessage::getInstance();
323 +
324 + // inject all record properties as "reserved" properties
325 + foreach ($message->jsonSerialize() as $prop => $val) {
326 + // properties starting with an underscore are "reserved"
327 + $notification->set("_{$prop}", $val);
328 + }
329 +
330 + // the notification will be dispatched immediately
331 + $notification->setDateTime('now');
332 +
333 + // let the notification build the display data
334 + $notification->buildDisplayData();
335 +
336 + // return the notification data-object
337 + return $notification->toDataObject();
338 + }
339 +
340 + /**
341 + * Given a list of recent operators chat messages for the administrators,
342 + * builds a list of notification data objects of type (operator) "message".
343 + * Such notifications will be immediately dispatched, and they will contain
344 + * the necessary data for display without being built through a callback.
345 + *
346 + * @param array $messages List of recent operators chat message objects for the admin.
347 + *
348 + * @return array List of browser notification display data objects.
349 + *
350 + * @since 1.18.0 (J) - 1.8.0 (WP)
351 + */
352 + public function buildOperatorsChatDataObjects(array $messages)
353 + {
354 + // container of notification display data objects
355 + $data_objects = [];
356 +
357 + foreach ($messages as $message) {
358 + if ($data_object = $this->getOperatorsChatDataObject($message)) {
359 + $data_objects[] = $data_object;
360 + }
361 + }
362 +
363 + return $data_objects;
364 + }
365 +
366 + /**
304 367 * Enqueues a list of notification objects for the overdue reminders.
305 368 * This should be called upon a regular page loading, not during AJAX
306 369 * requests, as it attachs a script declaration to the document.
307 370 *