PluginProbe ʕ •ᴥ•ʔ
VikAppointments Services Booking Calendar / 1.2.21
VikAppointments Services Booking Calendar v1.2.21
1.2.21 1.2.20 trunk 1.2.17 1.2.18 1.2.19
vikappointments / site / layouts / blocks / login.php
vikappointments / site / layouts / blocks Last commit date
calendar 2 days ago login 2 days ago payment 2 days ago alert.php 2 days ago carttotals.php 2 days ago checkout.php 2 days ago couponform.php 2 days ago index.html 2 days ago login.php 2 days ago options.php 2 days ago paymentmethods.php 2 days ago quickcontact.php 2 days ago reviews.php 2 days ago timeline.php 2 days ago waitlist.php 2 days ago
login.php
545 lines
1 <?php
2 /**
3 * @package VikAppointments
4 * @subpackage core
5 * @author E4J s.r.l.
6 * @copyright Copyright (C) 2021 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 $canRegister = isset($displayData['register']) ? $displayData['register'] : false;
15 $returnUrl = isset($displayData['return']) ? $displayData['return'] : '';
16 $remember = isset($displayData['remember']) ? $displayData['remember'] : false;
17 $useCaptcha = isset($displayData['captcha']) ? $displayData['captcha'] : null;
18 $gdpr = isset($displayData['gdpr']) ? $displayData['gdpr'] : null;
19 $footerLinks = isset($displayData['footer']) ? $displayData['footer'] : true;
20 $active = isset($displayData['active']) ? $displayData['active'] : 'login';
21 $formId = isset($displayData['form']) ? ltrim($displayData['form'], '#') : null;
22
23 $vik = VAPApplication::getInstance();
24
25 if (is_null($useCaptcha))
26 {
27 // check if 'captcha' is configured
28 $useCaptcha = (bool) $vik->getUserCaptcha();
29 }
30
31 $app = JFactory::getApplication();
32 $input = $app->input;
33
34 if (($tab = $input->get('tab')))
35 {
36 // overwrite pre-selected tab with the one set in request
37 $active = $tab;
38 }
39
40 if ((!$canRegister && $active == 'registration') || !in_array($active, array('login', 'registration')))
41 {
42 // restore active tab to "login" as the registration is disabled
43 $active = 'login';
44 }
45
46 if (is_null($gdpr))
47 {
48 $config = VAPFactory::getConfig();
49
50 // gdpr setting not provided, get it from the global configuration
51 $gdpr = $config->getBool('gdpr', false);
52 $policy = $config->get('policylink');
53 }
54
55 if ($footerLinks)
56 {
57 // load com_users site language to display footer messages
58 JFactory::getLanguage()->load('com_users', JPATH_SITE, JFactory::getLanguage()->getTag(), true);
59 }
60
61 if ($canRegister)
62 {
63 $dispatcher = VAPFactory::getEventDispatcher();
64
65 $forms = array();
66
67 foreach (array('top', 'name', 'username', 'email', 'password', 'captcha', 'policy', 'bottom') as $location)
68 {
69 /**
70 * Trigger event to let the plugins add custom HTML contents within the user registration form.
71 *
72 * @param string $location The HTML will be always placed after the specified location.
73 *
74 * @return string The HTML to display.
75 *
76 * @since 1.7
77 */
78 $html = array_filter($dispatcher->trigger('onDisplayUserRegistrationForm', array($location)));
79
80 // display all returned blocks, separated by a new line
81 $forms[$location] = implode("\n", $html);
82 }
83
84 // evaluate the task that will be used to register the account
85 if ($input->get('view') != 'emplogin')
86 {
87 $controller = 'userprofile';
88 }
89 else
90 {
91 $controller = 'emplogin';
92 }
93
94 /**
95 * In case of failed registration, the user details are stored
96 * within the user state. We can fetch them to auto-populate
97 * the registration form.
98 *
99 * @since 1.7
100 */
101 $data = $app->getUserState('vap.cms.user.register', array());
102 // immediately unset the specified user data to avoid displaying
103 // them again in case the user decides to leave the page
104 $app->setUserState('vap.cms.user.register', null);
105 ?>
106
107 <!-- REGISTRATION -->
108
109 <script>
110
111 var vapUserRegistrationValidator;
112
113 jQuery(function($) {
114 // in case of a specified form, register only the fields contained within the registration wrapper
115 const formSelector = '<?php echo $formId ? '#' . $formId . ' .vapregform' : '#vapregform'; ?>';
116
117 // create validator once the document is ready, because certain themes
118 // might load the resources after the body
119 vapUserRegistrationValidator = new VikFormValidator(formSelector, 'vapinvalid');
120
121 // register callback to make sure both the password fields are equals
122 vapUserRegistrationValidator.addCallback((form) => {
123 const pwd1 = $('#register-password');
124 const pwd2 = $('#register-confpassword');
125
126 if (!pwd1.val() || (pwd1.val() !== pwd2.val())) {
127 // the specified password are not matching
128 form.setInvalid($(pwd1).add(pwd2));
129 return false;
130 }
131
132 // the specified password are equals
133 form.unsetInvalid($(pwd1).add(pwd2));
134 return true;
135 });
136
137 <?php
138 if ($gdpr)
139 {
140 // in case of GDPR enabled, validate the disclaimer checkbox
141 ?>
142 vapUserRegistrationValidator.addCallback((form) => {
143 const field = $('#gdpr-register');
144
145 if (!field.is(':checked')) {
146 // not checked
147 form.setInvalid(field);
148 return false;
149 }
150
151 // checked
152 form.unsetInvalid(field);
153 return true;
154 });
155 <?php
156 }
157
158 if ($useCaptcha)
159 {
160 // make sure the captcha has been validated
161 ?>
162 vapUserRegistrationValidator.addCallback((form) => {
163 // get recaptcha elements
164 var captcha = $(form.form).find('.g-recaptcha').first();
165 var iframe = captcha.find('iframe').first();
166
167 // get widget ID
168 var widget_id = captcha.data('recaptcha-widget-id');
169
170 // check if recaptcha instance exists
171 // and whether the recaptcha was completed
172 if (typeof grecaptcha !== 'undefined'
173 && widget_id !== undefined
174 && !grecaptcha.getResponse(widget_id)) {
175 // captcha not completed
176 iframe.addClass(form.clazz);
177 return false;
178 }
179
180 // captcha completed
181 iframe.removeClass(form.clazz);
182 return true;
183 });
184 <?php
185 }
186 ?>
187
188 /**
189 * Overwrite getLabel method to properly access the label by using
190 * our custom layout.
191 *
192 * @param mixed input The input element.
193 *
194 * @param mixed The label of the input.
195 */
196 vapUserRegistrationValidator.getLabel = function(input) {
197 // get all labels at the same level of the input (see checkbox)
198 const siblings = $(input).siblings('label');
199
200 if (siblings.length) {
201 // label found, use it
202 return siblings.first();
203 }
204
205 // otherwise fallback to label placed on a different block
206 return $(input).closest('.vaploginfield').find('.vaploginsplabel label');
207 }
208
209 $(formSelector).find('button[name="registerbutton"]').on('click', function(event) {
210 if (!vapUserRegistrationValidator.validate()) {
211 event.preventDefault();
212 event.stopPropagation();
213 return false;
214 }
215
216 // find parent form
217 const formElement = $(this).closest('form');
218
219 <?php
220 if ($formId)
221 {
222 ?>
223 // check if we have an option field within our form
224 let optionField = $(formElement).find('input[name="option"]');
225
226 if (!optionField.length) {
227 // nope, create it and append it at the end of the form
228 optionField = $('<input type="hidden" name="option" value="" />');
229 $(formElement).append(optionField);
230 }
231
232 // register the correct option value
233 optionField.val('com_vikappointments');
234
235 // check if we have a task field within our form
236 let taskField = $(formElement).find('input[name="task"]');
237
238 if (!taskField.length) {
239 // nope, create it and append it at the end of the form
240 taskField = $('<input type="hidden" name="task" value="" />');
241 $(formElement).append(taskField);
242 }
243
244 // register the correct task value
245 taskField.val('<?php echo $controller; ?>.register');
246
247 // check if we have a return field within our form
248 let returnField = $(formElement).find('input[name="return"]');
249
250 if (!returnField.length) {
251 // nope, create it and append it at the end of the form
252 returnField = $('<input type="hidden" name="return" value="" />');
253 $(formElement).append(returnField);
254 }
255
256 // register the correct return value
257 returnField.val('<?php echo base64_encode($returnUrl); ?>');
258 <?php
259 }
260 ?>
261
262 return true;
263 });
264 });
265
266 function vapLoginValueChanged() {
267 if (jQuery('input[name=loginradio]:checked').val() == 1) {
268 jQuery('.vapregisterblock').css('display', 'none');
269 jQuery('.vaploginblock').fadeIn();
270 } else {
271 jQuery('.vaploginblock').css('display', 'none');
272 jQuery('.vapregisterblock').fadeIn();
273 }
274 }
275
276 </script>
277
278 <div class="vaploginradiobox" id="vaploginradiobox">
279 <span class="vaploginradiosp">
280 <label for="logradio1"><?php echo JText::translate('VAPLOGINRADIOCHOOSE1'); ?></label>
281 <input type="radio" id="logradio1" name="loginradio" value="1" onChange="vapLoginValueChanged();" <?php echo $active == 'login' ? 'checked="checked"' : ''; ?> />
282 </span>
283
284 <span class="vaploginradiosp">
285 <label for="logradio2"><?php echo JText::translate('VAPLOGINRADIOCHOOSE2'); ?></label>
286 <input type="radio" id="logradio2" name="loginradio" value="2" onChange="vapLoginValueChanged();" <?php echo $active != 'login' ? 'checked="checked"' : ''; ?> />
287 </span>
288 </div>
289
290 <div class="vapregisterblock" style="<?php echo $active != 'login' ? '' : 'display: none;'; ?>">
291 <?php
292 if ($formId)
293 {
294 // the registration is already contained within a parent form
295 ?>
296 <div class="vapregform">
297 <?php
298 }
299 else
300 {
301 // wrap the registration fields within a form
302 ?>
303 <form action="<?php echo JRoute::rewrite('index.php?option=com_vikappointments'); ?>" method="post" name="vapregform" id="vapregform">
304 <?php
305 }
306 ?>
307
308 <h3><?php echo JText::translate('VAPREGISTRATIONTITLE'); ?></h3>
309
310 <div class="vaploginfieldsdiv">
311
312 <!-- Define role to detect the supported hook -->
313 <!-- {"rule":"customizer","event":"onDisplayUserRegistrationForm","type":"sitepage","key":"top"} -->
314
315 <?php
316 // display custom HTML at the beginning of the form
317 echo $forms['top'];
318 ?>
319
320 <!-- FIRST NAME -->
321
322 <div class="vaploginfield">
323 <span class="vaploginsplabel" id="vapfname">
324 <label for="register-fname" id="register-fname-label"><?php echo JText::translate('VAPREGNAME'); ?><sup>*</sup></label>
325 </span>
326 <span class="vaploginspinput">
327 <input id="register-fname" type="text" name="fname" value="<?php echo $this->escape(!empty($data['firstname']) ? $data['firstname'] : ''); ?>" size="30" class="vapinput required" aria-labelledby="register-fname-label" />
328 </span>
329 </div>
330
331 <!-- LAST NAME -->
332
333 <div class="vaploginfield">
334 <span class="vaploginsplabel" id="vaplname">
335 <label for="register-lname" id="register-lname-label"><?php echo JText::translate('VAPREGLNAME'); ?><sup>*</sup></label>
336 </span>
337 <span class="vaploginspinput">
338 <input id="register-lname" type="text" name="lname" value="<?php echo $this->escape(!empty($data['lastname']) ? $data['lastname'] : ''); ?>" size="30" class="vapinput required" aria-labelledby="register-lname-label" />
339 </span>
340 </div>
341
342 <!-- Define role to detect the supported hook -->
343 <!-- {"rule":"customizer","event":"onDisplayUserRegistrationForm","type":"sitepage","key":"name"} -->
344
345 <?php
346 // display custom HTML after the first name and last name fields
347 echo $forms['name'];
348 ?>
349
350 <!-- USERNAME -->
351
352 <div class="vaploginfield">
353 <span class="vaploginsplabel" id="vapusername">
354 <label for="register-username" id="register-username-label"><?php echo JText::translate('VAPREGUNAME'); ?><sup>*</sup></label>
355 </span>
356 <span class="vaploginspinput">
357 <input id="register-username" type="text" name="reg_username" value="<?php echo $this->escape(!empty($data['username']) ? $data['username'] : ''); ?>" size="30" class="vapinput required" aria-labelledby="register-username-label" />
358 </span>
359 </div>
360
361 <!-- Define role to detect the supported hook -->
362 <!-- {"rule":"customizer","event":"onDisplayUserRegistrationForm","type":"sitepage","key":"username"} -->
363
364 <?php
365 // display custom HTML after the username field
366 echo $forms['username'];
367 ?>
368
369 <!-- E-MAIL -->
370
371 <div class="vaploginfield">
372 <span class="vaploginsplabel" id="vapemail">
373 <label for="register-email" id="register-email-label"><?php echo JText::translate('VAPREGEMAIL'); ?><sup>*</sup></label>
374 </span>
375 <span class="vaploginspinput">
376 <input id="register-email" type="email" name="email" value="<?php echo $this->escape(!empty($data['email']) ? $data['email'] : ''); ?>" size="30" class="vapinput required" aria-labelledby="register-email-label" />
377 </span>
378 </div>
379
380 <!-- Define role to detect the supported hook -->
381 <!-- {"rule":"customizer","event":"onDisplayUserRegistrationForm","type":"sitepage","key":"email"} -->
382
383 <?php
384 // display custom HTML after the username field
385 echo $forms['email'];
386 ?>
387
388 <!-- PASSWORD -->
389
390 <div class="vaploginfield">
391 <span class="vaploginsplabel" id="vappassword">
392 <label for="register-password" id="register-password-label"><?php echo JText::translate('VAPREGPWD'); ?><sup>*</sup></label>
393 </span>
394 <span class="vaploginspinput">
395 <input id="register-password" type="password" name="reg_password" value="" size="30" class="vapinput required" aria-labelledby="register-password-label" />
396 </span>
397 </div>
398
399 <!-- CONFIRM PASSWORD -->
400
401 <div class="vaploginfield">
402 <span class="vaploginsplabel" id="vapconfpassword">
403 <label for="register-confpassword" id="register-confpassword-label"><?php echo JText::translate('VAPREGCONFIRMPWD'); ?><sup>*</sup></label>
404 </span>
405 <span class="vaploginspinput">
406 <input id="register-confpassword" type="password" name="confpassword" value="" size="30" class="vapinput required" aria-labelledby="register-confpassword-label" />
407 </span>
408 </div>
409
410 <!-- Define role to detect the supported hook -->
411 <!-- {"rule":"customizer","event":"onDisplayUserRegistrationForm","type":"sitepage","key":"password"} -->
412
413 <?php
414 // display custom HTML after the password fields
415 echo $forms['password'];
416 ?>
417
418 <?php
419 if ($gdpr)
420 {
421 // load fancybox to support login GDPR popup
422 JHtml::fetch('vaphtml.assets.fancybox');
423 ?>
424 <div class="vaploginfield field-gdpr">
425 <!-- <span class="vaploginsplabel" class="">&nbsp;</span> -->
426 <span class="vaploginspinput">
427 <input type="checkbox" class="required" id="gdpr-register" value="1" />
428 <label for="gdpr-register" style="display: inline;">
429 <?php
430 if ($policy)
431 {
432 // label with link to read the privacy policy
433 echo JText::sprintf(
434 'GDPR_POLICY_AUTH_LINK',
435 'javascript: void(0);',
436 'vapOpenPopup(\'' . $policy . '\');'
437 );
438 }
439 else
440 {
441 // label without link
442 echo JText::translate('GDPR_POLICY_AUTH_NO_LINK');
443 }
444 ?>
445 </label>
446 </span>
447 </div>
448 <?php
449 }
450 ?>
451
452 <!-- Define role to detect the supported hook -->
453 <!-- {"rule":"customizer","event":"onDisplayUserRegistrationForm","type":"sitepage","key":"policy"} -->
454
455 <?php
456 // display custom HTML after the privacy field
457 echo $forms['policy'];
458 ?>
459
460 <?php
461 if ($useCaptcha)
462 {
463 ?>
464 <div class="vaploginfield field-captcha">
465 <?php echo $vik->captcha('display', ['captcha' => $vik->getUserCaptcha(), 'name' => 'user']); ?>
466 </div>
467 <?php
468 }
469 ?>
470
471 <!-- Define role to detect the supported hook -->
472 <!-- {"rule":"customizer","event":"onDisplayUserRegistrationForm","type":"sitepage","key":"captcha"} -->
473
474 <?php
475 // display custom HTML after the reCAPTCHA field
476 echo $forms['captcha'];
477 ?>
478
479 <div class="vaploginfield field-button">
480 <span class="vaploginsplabel" class="">&nbsp;</span>
481 <span class="vaploginspinput">
482 <button type="submit" class="vap-btn blue" name="registerbutton">
483 <?php echo JText::translate('VAPREGSIGNUPBTN'); ?>
484 </button>
485 </span>
486 </div>
487
488 <!-- Define role to detect the supported hook -->
489 <!-- {"rule":"customizer","event":"onDisplayUserRegistrationForm","type":"sitepage","key":"bottom"} -->
490
491 <?php
492 // display custom HTML at the end of the form
493 echo $forms['bottom'];
494 ?>
495
496 </div>
497
498 <?php echo JHtml::fetch('form.token'); ?>
499
500 <?php
501 if ($formId)
502 {
503 ?></div><?php
504 }
505 else
506 {
507 ?>
508 <input type="hidden" name="option" value="com_vikappointments" />
509 <input type="hidden" name="task" value="<?php echo $controller; ?>.register" />
510 <input type="hidden" name="return" value="<?php echo base64_encode($returnUrl); ?>" />
511 </form>
512 <?php
513 }
514 ?>
515
516 </div>
517
518 <?php
519 }
520 ?>
521
522 <!-- LOGIN -->
523
524 <div class="vaploginblock" style="<?php echo $active == 'login' ? '' : 'display: none;'; ?>">
525 <?php
526 /**
527 * The login form is displayed from the layout below:
528 * /components/com_vikappointments/layouts/blocks/login/[PLATFORM_NAME].php
529 * which depends on the current platform ("joomla" or "wordpress").
530 *
531 * If you need to change something from this layout, just create
532 * an override of this layout by following the instructions below:
533 * - open the back-end of your Joomla
534 * - visit the Extensions > Templates > Templates page
535 * - edit the active template
536 * - access the "Create Overrides" tab
537 * - select Layouts > com_vikappointments > blocks
538 * - start editing the login/[platform].php file on your template to create your own layout
539 *
540 * @since 1.6.3
541 */
542 echo $this->sublayout(VersionListener::getPlatform(), $displayData);
543 ?>
544 </div>
545