PluginProbe
VikBooking Hotel Booking Engine & PMS / 1.6.4
VikBooking Hotel Booking Engine & PMS v1.6.4
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
vikbooking / admin / helpers / src / notification / display / message.php

message.php in VikBooking Hotel Booking Engine & PMS 1.6.4, at admin/helpers/src/notification/display/message.php

114 lines 3.3 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 * Browser notification displayer handler for a new guest message.
16 *
17 * @since 1.15.0 (J) - 1.5.0 (WP)
18 */
19 final class VBONotificationDisplayMessage extends JObject implements VBONotificationDisplayer
20 {
21 /**
22 * Proxy for immediately getting the object and bind data.
23 *
24 * @param array|object $data the notification payload data to bind.
25 */
26 public static function getInstance($data = null)
27 {
28 return new static($data);
29 }
30
31 /**
32 * Composes an object with the necessary properties to display
33 * the notification in the browser.
34 *
35 * @return null|object the notification display data payload.
36 */
37 public function getData()
38 {
39 $booking_id = (int)$this->get('idorder', 0);
40 if (empty($booking_id)) {
41 return null;
42 }
43
44 // customer picture
45 $customer_pic = $this->get('pic', '');
46
47 // channel logo
48 $channel_logo = $this->get('channel_logo', '');
49
50 // the notification icon
51 $notif_icon = '';
52 if (!empty($customer_pic)) {
53 $notif_icon = strpos($customer_pic, 'http') === 0 ? $customer_pic : VBO_SITE_URI . 'resources/uploads/' . $customer_pic;
54 } elseif (!empty($channel_logo)) {
55 $notif_icon = $channel_logo;
56 } else {
57 $notif_icon = $this->getIconUrl();
58 }
59
60 // compose notification title
61 $conv_subject = $this->get('subject', '');
62 $guest_name = $this->get('first_name', '') . ' ' . $this->get('last_name', '');
63 $notif_title = $guest_name . (!empty($conv_subject) ? (' - ' . $conv_subject) : '');
64
65 // compose the notification data to display
66 $notif_data = new stdClass;
67 $notif_data->title = $notif_title;
68 $notif_data->message = $this->get('content', '');
69 $notif_data->icon = $notif_icon;
70 $notif_data->onclick = 'VBOCore.handleDisplayWidgetNotification';
71 $notif_data->gotourl = 'index.php?option=com_vikbooking&task=editorder&cid[]=' . $booking_id;
72 if (VBOPlatformDetection::isWordPress()) {
73 $notif_data->gotourl = str_replace('index.php', 'admin.php', $notif_data->gotourl);
74 }
75
76 // set additional properties to the notification payload related to the guest message
77 $notif_data->widget_id = 'guest_messages';
78 $notif_data->channel = $this->get('channel', null);
79 $notif_data->id_order = $booking_id;
80 $notif_data->id_customer = $this->get('id_customer', null);
81 $notif_data->id_message = $this->get('id_message', null);
82 $notif_data->id_thread = $this->get('id_thread', null);
83
84 return $notif_data;
85 }
86
87 /**
88 * Returns the URL to the default icon for the history
89 * browser notifications. Custom logos are preferred.
90 *
91 * @return string|null
92 */
93 private function getIconUrl()
94 {
95 $config = VBOFactory::getConfig();
96
97 // back-end custom logo
98 $use_logo = $config->get('backlogo');
99 if (empty($use_logo) || !strcasecmp($use_logo, 'vikbooking.png')) {
100 // fallback to company (site) logo
101 $use_logo = $config->get('sitelogo');
102 }
103
104 if (!empty($use_logo) && strcasecmp($use_logo, 'vikbooking.png')) {
105 // uploaded logo found
106 $use_logo = VBO_ADMIN_URI . 'resources/' . $use_logo;
107 } else {
108 $use_logo = null;
109 }
110
111 return $use_logo;
112 }
113 }
114