PluginProbe
VikBooking Hotel Booking Engine & PMS / trunk
VikBooking Hotel Booking Engine & PMS vtrunk
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 1.7.3 All 36 releases
vikbooking / admin / helpers / src / notification / data / operatormessage.php

operatormessage.php in VikBooking Hotel Booking Engine & PMS trunk, at admin/helpers/src/notification/data/operatormessage.php

94 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package VikBooking
4 * @subpackage core
5 * @author Alessio Gaggii - E4J s.r.l.
6 * @copyright Copyright (C) 2025 E4J s.r.l. All Rights Reserved.
7 * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
8 * @link https://vikwp.com
9 */
10
11 // No direct access
12 defined('ABSPATH') or die('No script kiddies please!');
13
14 /**
15 * Builds a browser notification data object for a new operator message.
16 *
17 * @since 1.18.0 (J) - 1.8.0 (WP)
18 */
19 final class VBONotificationDataOperatormessage extends VBONotificationAdapter
20 {
21 /**
22 * The type of the scheduled notification.
23 *
24 * @var string
25 */
26 protected $_notification_type = 'operatormessage';
27
28 /**
29 * Public method to be called after setting the operator message
30 * record data properties as "reserved" (starting with "_").
31 * Needed to set "public" properties for the notification
32 * data object to serve as display data for instant dispatch.
33 *
34 * @return bool True if display data were built.
35 */
36 public function buildDisplayData()
37 {
38 // make sure the sender id is set
39 $id_sender = $this->get('_id_sender');
40 if (empty($id_sender)) {
41 $id_sender = $this->get('id_sender');
42 }
43 if (empty($id_sender)) {
44 // useless to proceed if no sender ID set
45 return false;
46 }
47
48 // access any kind of object-property set
49 $props = $this->getProperties($public = false);
50
51 // convert "reserved" keys into "public" ones
52 foreach ($props as $prop => $val) {
53 if ('_' == substr($prop, 0, 1)) {
54 $props[substr($prop, 1)] = $val;
55 unset($props[$prop]);
56 }
57 }
58
59 // get the notification displayer for "operatormessage"
60 $displayer = VBONotificationBuilder::getInstance($props)->getDisplayer($this->_notification_type);
61 if (!$displayer) {
62 return false;
63 }
64
65 // build notification display data
66 try {
67 $display_data = $displayer->getData();
68 if (!$display_data) {
69 throw new Exception('Error building the notification display data', 500);
70 }
71 } catch (Exception $e) {
72 return false;
73 }
74
75 // set display data "public" properties
76 foreach ($display_data as $prop_name => $prop_val) {
77 $this->set($prop_name, $prop_val);
78 }
79
80 return true;
81 }
82
83 /**
84 * This kind of notification will be returned inclusive of
85 * display data for dispatching. It won't need to be built.
86 *
87 * @return null Always null for never building this notification data.
88 */
89 protected function generateBuildUrl()
90 {
91 return null;
92 }
93 }
94