1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
consent.php
См. документацию.
1<?php
2
3namespace Bitrix\Sender\Consent;
4
5use Bitrix\Main\Web\Json;
6use Bitrix\Sender\ContactTable;
7use Bitrix\Sender\Transport;
8use Bitrix\Main\ArgumentNullException;
9use Bitrix\Main\Security\Sign\TimeSigner;
10
15final class Consent
16{
17 private const SALT = "SENDER_CONSENT_SALT";
18
25 private static function getTransport(?string $code): Transport\Adapter
26 {
27 static $transports = [];
28 if(!isset($transports[$code]))
29 {
30 $transports[$code] = Transport\Adapter::create($code);
31 }
32 return $transports[$code];
33 }
34
48 public static function isUnsub(string $status, ?int $requests, ?string $code): bool
49 {
50 return Consent::getTransport($code)->isConsentAvailable() &&
51 (
55 );
56 }
57
68 public static function checkIfConsentRequestLimitExceeded(int $requests, string $code): bool
69 {
70 return $requests > Consent::getTransport($code)->getConsentMaxRequests();
71 }
72
81 public static function encodeTag(array $fields): string
82 {
83 if(isset($fields))
84 {
85 $signer = new TimeSigner();
86 $tagString = Json::encode($fields);
87 return $signer->sign($tagString,"+ 4 weeks", Consent::SALT);
88 }
89
90 throw new ArgumentNullException("fields");
91 }
92
100 public static function decodeTag(string $tag)
101 {
102 $signer = new TimeSigner();
103 $tag = $signer->unsign($tag,static::SALT);
104 return Json::decode($tag);
105 }
106}
const CONSENT_STATUS_DENY
Определения contact.php:46
const CONSENT_STATUS_ACCEPT
Определения contact.php:47
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195
$status
Определения session.php:10
$fields
Определения yandex_run.php:501