Proper treatment of partner codes in booking urls for resellers
This commit is contained in:
@@ -110,11 +110,10 @@ class ResellerService implements SingletonInterface
|
||||
$data[$row['dateStart']] = $date;
|
||||
}
|
||||
|
||||
$date->bookingurl = BookingUrlUtility::generateUrl(
|
||||
$date->bookingurl = BookingUrlUtility::generateResellerUrl(
|
||||
$row['dateBusProId'],
|
||||
$row['hotelBusProId'],
|
||||
$row['dateEnd'],
|
||||
'base',
|
||||
$paCode
|
||||
);
|
||||
|
||||
|
||||
@@ -44,7 +44,56 @@ class BookingUrlUtility
|
||||
* @param string $paCode
|
||||
* @return string
|
||||
*/
|
||||
public static function generateUrl($bookingId, $hotelId, $dateEnd, $template = 'base', $paCode = null)
|
||||
public static function generateUrl($bookingId, $hotelId, $dateEnd, $template = 'base')
|
||||
{
|
||||
$query = static::buildQuery($bookingId, $hotelId, $dateEnd, $template);
|
||||
|
||||
$cookie = $_COOKIE[static::COOKIE_NAME];
|
||||
if (strpos($cookie, '?') !== false) {
|
||||
$items = GeneralUtility::trimExplode('?', $cookie);
|
||||
$cookie = $items[0];
|
||||
}
|
||||
$bpnCookie = $_COOKIE[static::COOKIE_NAME_BPN];
|
||||
|
||||
if (!empty($bpnCookie)) {
|
||||
$query['agenturcode'] = $bpnCookie;
|
||||
} elseif (!empty($cookie)) {
|
||||
if (preg_match('/^P[a-zA-Z0-9]*/', $cookie)) {
|
||||
$query['agenturcode'] = $cookie;
|
||||
} else {
|
||||
$query['crminfo'] = $cookie;
|
||||
}
|
||||
}
|
||||
|
||||
return static::buildUrl($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $bookingId
|
||||
* @param string $hotelId
|
||||
* @param string $dateEnd
|
||||
* @param string $paCode
|
||||
* @return string
|
||||
*/
|
||||
public static function generateResellerUrl($bookingId, $hotelId, $dateEnd, $paCode = null)
|
||||
{
|
||||
$query = static::buildQuery($bookingId, $hotelId, $dateEnd);
|
||||
|
||||
if (!empty($paCode)) {
|
||||
$query['agenturcode'] = $paCode;
|
||||
}
|
||||
|
||||
return static::buildUrl($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $bookingId
|
||||
* @param string $hotelId
|
||||
* @param string $dateEnd
|
||||
* @param string $template
|
||||
* @return array
|
||||
*/
|
||||
protected static function buildQuery($bookingId, $hotelId, $dateEnd, $template = 'base')
|
||||
{
|
||||
$query = [
|
||||
'id' => $bookingId,
|
||||
@@ -59,28 +108,15 @@ class BookingUrlUtility
|
||||
$query['templatezusatz'] = '_' . $template;
|
||||
}
|
||||
|
||||
if ($paCode !== null) {
|
||||
$query['agenturcode'] = $paCode;
|
||||
} else {
|
||||
$cookie = $_COOKIE[static::COOKIE_NAME];
|
||||
if (strpos($cookie, '?') !== false) {
|
||||
$items = GeneralUtility::trimExplode('?', $cookie);
|
||||
$cookie = $items[0];
|
||||
}
|
||||
$bpnCookie = $_COOKIE[static::COOKIE_NAME_BPN];
|
||||
|
||||
if (!empty($bpnCookie)) {
|
||||
$query['agenturcode'] = $bpnCookie;
|
||||
} elseif (!empty($cookie)) {
|
||||
if (preg_match('/^P[a-zA-Z0-9]*/', $cookie)) {
|
||||
$query['agenturcode'] = $cookie;
|
||||
} else {
|
||||
$query['crminfo'] = $cookie;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return static::URL_BASE . '?' . http_build_query($query, '', '&');
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $query
|
||||
* @return string
|
||||
*/
|
||||
protected static function buildUrl(array $query)
|
||||
{
|
||||
return static::URL_BASE . '?' . http_build_query($query, '', '&');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user