| @@ -466,18 +466,21 @@ | ||
| 466 | 466 | /** |
| 467 | 467 | * Returns the booking or customer phone number, if any. |
| 468 | 468 | * Note that the + prefix may not be included. |
| 469 | 469 | * |
| 470 | + * @param ?string $forcedPhone Optional phone number to sanitize. | |
| 471 | + * | |
| 470 | 472 | * @return ?string |
| 471 | 473 | * |
| 472 | 474 | * @since 1.18.8 (J) - 1.8.8 (WP) |
| 475 | + * @since 1.18.16 (J) - 1.8.16 (WP) added argument $forcedPhone. | |
| 473 | 476 | */ |
| 474 | - public function getPhoneNumber() | |
| 477 | + public function getPhoneNumber(?string $forcedPhone = null) | |
| 475 | 478 | { |
| 476 | - // give higher priority to booking-level phone number | |
| 477 | - $phoneNumber = $this->getProperty('phone'); | |
| 479 | + // give higher priority to passed or booking-level phone number | |
| 480 | + $phoneNumber = $forcedPhone ?: $this->getProperty('phone'); | |
| 478 | 481 | |
| 479 | - if (!$phoneNumber) { | |
| 482 | + if (!$phoneNumber && $forcedPhone !== null) { | |
| 480 | 483 | // fetch booking customer details |
| 481 | 484 | $customer = $this->getCustomer(); |
| 482 | 485 | |
| 483 | 486 | // check customer-level phone number |
| @@ -498,8 +501,22 @@ | ||
| 498 | 501 | return $phoneNumber ?: null; |
| 499 | 502 | } |
| 500 | 503 | |
| 501 | 504 | /** |
| 505 | + * Returns the booking alias phone number (masked phone), if any. | |
| 506 | + * | |
| 507 | + * @return ?string | |
| 508 | + * | |
| 509 | + * @since 1.18.16 (J) - 1.8.16 (WP) | |
| 510 | + */ | |
| 511 | + public function getAliasPhoneNumber() | |
| 512 | + { | |
| 513 | + $phoneAlias = (string) $this->getProperty('phone_alias'); | |
| 514 | + | |
| 515 | + return $phoneAlias ? $this->getPhoneNumber($phoneAlias) : null; | |
| 516 | + } | |
| 517 | + | |
| 518 | + /** | |
| 502 | 519 | * Returns the booking or customer email address, if any. |
| 503 | 520 | * |
| 504 | 521 | * @return ?string |
| 505 | 522 | * |
| @@ -552,8 +569,24 @@ | ||
| 552 | 569 | return $this->previousBooking; |
| 553 | 570 | } |
| 554 | 571 | |
| 555 | 572 | /** |
| 573 | + * Sets the previous booking data. | |
| 574 | + * | |
| 575 | + * @param array $previous Previous booking assoc data. | |
| 576 | + * | |
| 577 | + * @return self | |
| 578 | + * | |
| 579 | + * @since 1.18.11 (J) - 1.8.11 (WP) | |
| 580 | + */ | |
| 581 | + public function setPrevious(array $previous) | |
| 582 | + { | |
| 583 | + $this->previousBooking = $previous; | |
| 584 | + | |
| 585 | + return $this; | |
| 586 | + } | |
| 587 | + | |
| 588 | + /** | |
| 556 | 589 | * Gets the current room index. |
| 557 | 590 | * |
| 558 | 591 | * @return int |
| 559 | 592 | */ |
| @@ -1229,6 +1262,58 @@ | ||
| 1229 | 1262 | $addresses[] = VCMOtaListing::getInstance()->getLocation($listingId)['address'] ?? null; |
| 1230 | 1263 | } |
| 1231 | 1264 | |
| 1232 | 1265 | return array_values(array_unique($addresses)); |
| 1266 | + } | |
| 1267 | + | |
| 1268 | + /** | |
| 1269 | + * Returns the booking routed URI, either in its regular or shorten forms. | |
| 1270 | + * | |
| 1271 | + * @return string | |
| 1272 | + * | |
| 1273 | + * @since 1.18.13 (J) - 1.8.13 (WP) | |
| 1274 | + */ | |
| 1275 | + public function getBookingLink(bool $shorten = false) | |
| 1276 | + { | |
| 1277 | + // construct booking link | |
| 1278 | + $useSid = !$this->getProperty('sid') && $this->getProperty('idorderota') ? $this->getProperty('idorderota') : $this->getProperty('sid'); | |
| 1279 | + $bestItemid = VikBooking::findProperItemIdType(['booking'], ($this->getProperty('lang') ?: null)); | |
| 1280 | + $langSuffix = $bestItemid && $this->getProperty('lang') ? '&lang=' . $this->getProperty('lang') : ''; | |
| 1281 | + | |
| 1282 | + $bookingLink = VikBooking::externalroute("index.php?option=com_vikbooking&view=booking&sid=" . $useSid . "&ts=" . $this->getProperty('ts') . $langSuffix, false, ($bestItemid ?: null)); | |
| 1283 | + | |
| 1284 | + if (!$shorten) { | |
| 1285 | + return $bookingLink; | |
| 1286 | + } | |
| 1287 | + | |
| 1288 | + // access the model for shortening URLs | |
| 1289 | + $model = VBOModelShortenurl::getInstance($onlyRouted = false)->setBooking($this->getData()); | |
| 1290 | + | |
| 1291 | + return $model->getShortUrl($bookingLink); | |
| 1292 | + } | |
| 1293 | + | |
| 1294 | + /** | |
| 1295 | + * Returns the booking pre-check-in routed URI, either in its regular or shorten forms. | |
| 1296 | + * | |
| 1297 | + * @return string | |
| 1298 | + * | |
| 1299 | + * @since 1.18.13 (J) - 1.8.13 (WP) | |
| 1300 | + */ | |
| 1301 | + public function getPrecheckinLink(bool $shorten = false) | |
| 1302 | + { | |
| 1303 | + // obtain booking link | |
| 1304 | + $useSid = !$this->getProperty('sid') && $this->getProperty('idorderota') ? $this->getProperty('idorderota') : $this->getProperty('sid'); | |
| 1305 | + $bestItemid = VikBooking::findProperItemIdType(['booking'], ($this->getProperty('lang') ?: null)); | |
| 1306 | + $langSuffix = $bestItemid && $this->getProperty('lang') ? '&lang=' . $this->getProperty('lang') : ''; | |
| 1307 | + | |
| 1308 | + $precheckinLink = VikBooking::externalroute("index.php?option=com_vikbooking&view=precheckin&sid=" . $useSid . "&ts=" . $this->getProperty('ts') . $langSuffix, false, ($bestItemid ?: null)); | |
| 1309 | + | |
| 1310 | + if (!$shorten) { | |
| 1311 | + return $precheckinLink; | |
| 1312 | + } | |
| 1313 | + | |
| 1314 | + // access the model for shortening URLs | |
| 1315 | + $model = VBOModelShortenurl::getInstance($onlyRouted = false)->setBooking($this->getData()); | |
| 1316 | + | |
| 1317 | + return $model->getShortUrl($precheckinLink); | |
| 1233 | 1318 | } |
| 1234 | 1319 | } |