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/chat/message.php +45 -3 1.8.6 → 1.8.16 View file →
@@ -2,9 +2,9 @@
2 2 /**
3 3 * @package VikBooking
4 4 * @subpackage core
5 5 * @author E4J s.r.l.
6 - * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved.
6 + * @copyright Copyright (C) 2026 E4J s.r.l. All Rights Reserved.
7 7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 8 * @link https://vikwp.com
9 9 */
10 10
@@ -75,8 +75,16 @@
75 75 */
76 76 protected $createdby;
77 77
78 78 /**
79 + * The ID of the external resource this message is linked to.
80 + *
81 + * @var string
82 + * @since 1.8.8
83 + */
84 + protected $ref_id = null;
85 +
86 + /**
79 87 * Whether the message has been read by the user.
80 88 *
81 89 * @var bool
82 90 */
@@ -286,15 +294,20 @@
286 294 */
287 295 public function setCreationDate($date)
288 296 {
289 297 try {
290 - if (is_string($date)) {
298 + if (!$date instanceof DateTime) {
291 299 // make sure the provided date is correct
292 - $date = JFactory::getDate($date);
300 + $date = JFactory::getDate($date ?: 'now');
293 301 }
294 302
295 303 // convert date object into a string
296 304 $date = $date->toSql();
305 +
306 + // make sure the specified date is not in the future
307 + if ($date > JFactory::getDate()->toSql()) {
308 + throw new UnexpectedValueException('Cannot accept a date in the future.', 400);
309 + }
297 310 } catch (Exception $error) {
298 311 // malformed date
299 312 $date = null;
300 313 }
@@ -318,8 +331,36 @@
318 331 return $this->createdby;
319 332 }
320 333
321 334 /**
335 + * Returns the ID of the external resource this message is linked to.
336 + *
337 + * @return string|null
338 + *
339 + * @since 1.8.8
340 + */
341 + public function getReferenceID()
342 + {
343 + return $this->ref_id;
344 + }
345 +
346 + /**
347 + * Sets the ID of the external resource this message is linked to.
348 + *
349 + * @param string|null $refId
350 + *
351 + * @return self
352 + *
353 + * @since 1.8.8
354 + */
355 + public function setReferenceID(?string $refId)
356 + {
357 + $this->ref_id = $refId;
358 +
359 + return $this;
360 + }
361 +
362 + /**
322 363 * Checks whether the message has been read by the current user.
323 364 *
324 365 * @return bool
325 366 */
@@ -346,7 +387,8 @@
346 387 'attachments' => $this->getAttachments(),
347 388 'createdon' => $this->getCreationDate(),
348 389 'createdby' => $this->getAuthor(),
349 390 'read' => $this->isRead(),
391 + 'ref_id' => $this->ref_id,
350 392 ];
351 393 }
352 394 }