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 / review.php

review.php in VikBooking Hotel Booking Engine & PMS trunk, at admin/helpers/src/notification/data/review.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) 2022 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 guest review.
16 *
17 * @since 1.15.0 (J) - 1.5.0 (WP)
18 */
19 final class VBONotificationDataReview extends VBONotificationAdapter
20 {
21 /**
22 * The type of the scheduled notification.
23 *
24 * @var string
25 */
26 protected $_notification_type = 'review';
27
28 /**
29 * Public method to be called after setting the review
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 booking id is set
39 $booking_id = $this->get('_idorder');
40 if (empty($booking_id)) {
41 $booking_id = $this->get('idorder');
42 }
43 if (empty($booking_id)) {
44 // useless to proceed if no reservation 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 "review"
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.
88 */
89 protected function generateBuildUrl()
90 {
91 return null;
92 }
93 }
94