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
← All changes | admin/helpers/src/dooraccess/factory.php +81 -2 1.8.7 → 1.8.16 View file →
@@ -27,11 +27,11 @@
27 27
28 28 /**
29 29 * List of door access integration objects loaded.
30 30 *
31 - * @var VBODooraccessFactory
31 + * @var VBODooraccessIntegrationAware[]
32 32 */
33 - protected $integrations = [];
33 + protected array $integrations = [];
34 34
35 35 /**
36 36 * Class constructor is protected.
37 37 *
@@ -626,8 +626,67 @@
626 626 return $tagsCount;
627 627 }
628 628
629 629 /**
630 + * Tells whether the given booking should have gone through passcode generation.
631 + * The method will NOT check if device passcodes were already generated. Useful
632 + * to match bookings generated before configuring a DAC integration provider.
633 + *
634 + * @param VBOBookingRegistry $registry The booking registry.
635 + *
636 + * @return bool
637 + *
638 + * @since 1.18.16 (J) - 1.8.16 (WP)
639 + */
640 + public function shouldBookingHavePasscodes(VBOBookingRegistry $registry)
641 + {
642 + if (!$registry->isConfirmed()) {
643 + // only confirmed bookings can get passcodes
644 + return false;
645 + }
646 +
647 + // get the unique list of booked listing ids and subunits
648 + $bookedListingSubunits = $registry->getBookedListingSubunits();
649 +
650 + // check if the booking has pre-check-in values
651 + $hasPreCheckIn = $registry->hasPreCheckedIn();
652 +
653 + // scan the eligible integrations for generating passcodes at the time of booking or pre-checkin
654 + foreach ($this->loadGeneratingIntegrations(['booking', 'precheckin']) as $record) {
655 + // get the integration provider
656 + $integration = $this->getIntegrationProvider($record['provider_alias']);
657 + if (!$integration) {
658 + // unknown integration provider
659 + continue;
660 + }
661 +
662 + // inject profile record within the integration provider
663 + $integration->setProfileRecord($record);
664 +
665 + // iterate all provider integration devices
666 + foreach ($integration->getDevices() as $device) {
667 + // get the listing-subunit pairs compatible with the current device
668 + $deviceListingUnits = $device->intersectListingUnits($bookedListingSubunits);
669 +
670 + if (!$deviceListingUnits) {
671 + // ignore device
672 + continue;
673 + }
674 +
675 + if (($record['gentype'] ?? '') === 'precheckin' && !$hasPreCheckIn) {
676 + // this device will get a passcode generated once pre-check-in will be completed
677 + continue;
678 + }
679 +
680 + // device matching booked listing should have had a passcode generated
681 + return true;
682 + }
683 + }
684 +
685 + return false;
686 + }
687 +
688 + /**
630 689 * Attempts to return a list of associative arrays that include the active passcode string
631 690 * value and the device information based on what was generated for a specific booking.
632 691 *
633 692 * @param VBOBookingRegistry $registry The booking registry.
@@ -1129,8 +1188,11 @@
1129 1188 'idorder' => $registry->getID(),
1130 1189 'avatar' => preg_match('/^http/', (string) $integration->getIcon()) ? $integration->getIcon() : null,
1131 1190 ],
1132 1191 ]);
1192 +
1193 + // update booking registration status to "checked-in"
1194 + (new VBOModelReservation)->updateRegistration(1, $registry->getID());
1133 1195 }
1134 1196 } catch (Exception $e) {
1135 1197 // do nothing
1136 1198 }
@@ -1830,6 +1892,23 @@
1830 1892 } catch (Throwable $e) {
1831 1893 // do nothing but skip the current integration
1832 1894 }
1833 1895 }
1896 +
1897 + /**
1898 + * Sort the integrations by name and by offline status.
1899 + *
1900 + * @since 1.18.15 (J) - 1.8.15 (WP)
1901 + */
1902 + usort($this->integrations, function($a, $b) {
1903 + if (($a->isOffline ?? null) && !($b->isOffline ?? null)) {
1904 + return 1;
1905 + }
1906 +
1907 + if (($b->isOffline ?? null) && !($a->isOffline ?? null)) {
1908 + return -1;
1909 + }
1910 +
1911 + return strcasecmp($a->getShortName(), $b->getShortName());
1912 + });
1834 1913 }
1835 1914 }