- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/userconsent/agreementlink.php
- Класс: BitrixMainUserConsentAgreementLink
- Вызов: AgreementLink::getAgreementFromUriParameters
static function getAgreementFromUriParameters(array $parameters = array())
{
self::clearErrors();
$data =$parameters['data'];
$sec = $parameters['sec'];
if (!$data || !$sec)
{
self::$errors[] = new Error('Parameters not found', 1);
return null;
}
$data = base64_decode($data);
$sec = base64_decode($sec);
if (!$data || !$sec)
{
self::$errors[] = new Error('Can not decode parameters', 2);
return null;
}
try
{
$signer = new Signer();
if (!$signer->validate($data, $sec, self::SIGN_SALT))
{
self::$errors[] = new Error('Parameters signature is not valid', 3);
return null;
}
}
catch (Exception $exception)
{
self::$errors[] = new Error('Parameters signature error: ' . $exception->getMessage(), 7);
return null;
}
try
{
$data = Json::decode($data);
}
catch (Exception $exception)
{
$data = null;
}
if (!$data || !isset($data['id']) || !isset($data['replace']))
{
self::$errors[] = new Error('Decode data parameters failed', 6);
return null;
}
$agreement = new Agreement($data['id'], $data['replace']);
if (!$agreement->isExist())
{
self::$errors[] = new Error('Agreement is not exist', 4);
return null;
}
if (!$agreement->isActive())
{
self::$errors[] = new Error('Agreement is not active', 5);
return null;
}
return $agreement;
}