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
vikbooking / libraries / lite / vcm / helper.php

helper.php in VikBooking Hotel Booking Engine & PMS 1.8.16, at libraries/lite/vcm/helper.php

204 lines 4.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 - Libraries
4 * @subpackage lite
5 * @author 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 * Helper implementor used to apply the restrictions of the LITE version.
16 *
17 * @since 1.8
18 */
19 class VikChannelManagerLiteHelper
20 {
21 /**
22 * The platform application instance.
23 *
24 * @var JApplication
25 */
26 private $app;
27
28 /**
29 * The platform database instance.
30 *
31 * @var JDatabase
32 */
33 private $db;
34
35 /**
36 * Class constructor.
37 */
38 public function __construct()
39 {
40 $this->app = JFactory::getApplication();
41 $this->db = JFactory::getDbo();
42 }
43
44 /**
45 * Intercepts any calls to the channel manager.
46 *
47 * @return void
48 */
49 public function hijackChannelManager()
50 {
51 if (!$this->app->isAdmin())
52 {
53 return;
54 }
55
56 $input = $this->app->input;
57
58 // get current component
59 $option = preg_replace("/^com_/i", '', (string) $input->get('page', $input->get('option')));
60
61 if ($option === 'vikchannelmanager')
62 {
63 // route to VikBooking controller
64 $this->app->redirect('index.php?option=com_vikbooking&view=vikchannelmanager');
65 $this->app->close();
66 }
67 }
68
69 /**
70 * Helper method used to display an advertsing banner while trying
71 * to reach a page available only with VCM installed.
72 *
73 * @return void
74 */
75 public function displayViewBanners()
76 {
77 if (!$this->app->isAdmin())
78 {
79 return;
80 }
81
82 $input = $this->app->input;
83
84 // get current view
85 $view = $input->get('view', $input->get('task'));
86
87 // define list of pages not supported without VikChannelManager
88 $lookup = [
89 'taskmanager' => 'taskmanager',
90 'vikchannelmanager' => 'vikchannelmanager',
91 ];
92
93 // check whether a banner should be displayed
94 if (!isset($lookup[$view]))
95 {
96 return;
97 }
98
99 // use a missing view to display blank contents
100 $input->set('view', 'liteview');
101 $input->set('task', '');
102 $input->set('hide_menu', true);
103
104 // display menu before unsetting the view
105 VikBookingHelper::printHeader($lookup[$view]);
106
107 // display adv banner
108 echo JLayoutHelper::render('html.license.adv.' . $view);
109
110 if (VikBooking::showFooter())
111 {
112 VikBookingHelper::printFooter();
113 }
114 }
115
116 /**
117 * Helper method used to display an advertsing banner while trying
118 * to render a widget available only with VCM installed.
119 *
120 * @return void
121 */
122 public function displayWidgetBanners()
123 {
124 if (!$this->app->isAdmin())
125 {
126 return;
127 }
128
129 $input = $this->app->input;
130
131 // make sure we are rendering an admin widget
132 if ($input->get('task') !== 'exec_admin_widget' || $input->get('call') !== 'render')
133 {
134 return;
135 }
136
137 $widget = $input->get('widget_id');
138
139 // define list of widgets not supported without VikChannelManager
140 $lookup = [
141 'aitools' => 'ai',
142 'guest_messages' => 'guestmessages',
143 'guest_reviews' => 'guestreviews',
144 'latest_from_guests' => 'guestnews',
145 'operators_chat' => 'operatorschat',
146 ];
147
148 // check whether a banner should be displayed
149 if (!isset($lookup[$widget]))
150 {
151 return;
152 }
153
154 // output the JSON encoded response and exit
155 VBOHttpDocument::getInstance()->json([
156 'render' => JLayoutHelper::render('html.license.adv.' . $lookup[$widget])
157 ]);
158 }
159
160 /**
161 * Prevents certain widgets from being added to the multitask panel.
162 *
163 * @return void
164 */
165 public function hijackWidgetMultitask()
166 {
167 if (!$this->app->isAdmin())
168 {
169 return;
170 }
171
172 $input = $this->app->input;
173
174 // make sure we are updating a widget an admin widget
175 if ($input->get('task') !== 'exec_multitask_widgets' || $input->get('call') !== 'updateMultitaskingMap')
176 {
177 return;
178 }
179
180 $args = $input->get('call_args', [], 'array');
181 $widgets = (array) (!empty($args[1]) ? $args[1] : []);
182
183 // define list of widgets not supported without VikChannelManager
184 $lookup = [
185 'aitools',
186 'guest_messages',
187 'guest_reviews',
188 'latest_from_guests',
189 'operators_chat',
190 ];
191
192 // remove all the widgets that should not be saved within the multitask panel
193 $filtered = array_filter($widgets, function($widget) use ($lookup) {
194 return !in_array($widget, $lookup);
195 });
196
197 // in case something has changed, update the filtered widgets array into the request
198 if (count($widgets) !== count($filtered)) {
199 $args[1] = array_values($filtered);
200 $input->set('call_args', $args);
201 }
202 }
203 }
204