Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
consentresponsemail.php
1<?php
2
4
13
15{
16 const CODE = iBase::CODE_MAIL;
17 private $fields;
18
27 public function loadData($data): iConsentResponse
28 {
29 if (is_string($data))
30 {
31 $this->fields = Consent::decodeTag($data);
32 } elseif (is_array($data))
33 {
34 $this->fields = $data;
35 } else
36 {
37 throw new ArgumentException("");
38 }
39 return $this;
40 }
41
42 protected function isContactUpdated($apply)
43 {
44 $typeId = Recipient\Type::detect($this->fields['CODE']);
45 $code = Recipient\Normalizer::normalize($this->fields['CODE'], $typeId);
46
47 $contact = ContactTable::getRow([
48 'select' => ['CODE', 'CONSENT_STATUS'],
49 'filter' => [
50 '=ID' => $this->getContactId(),
51 '=TYPE_ID' => $typeId,
52 '=CODE' => $code,
53 ]
54 ]);
56
57 return (
58 isset($contact) &&
59 $contact['CODE'] === $this->fields['CODE'] &&
60 $contact['CONSENT_STATUS'] !== $currentStatus
61 );
62 }
63
64 protected function getContactId()
65 {
66 return $this->fields['CONTACT'];
67 }
68
69 protected function getConsentId()
70 {
71 return $this->fields['CONSENT'];
72 }
73
74 protected function getPostingId()
75 {
76 return $this->fields['POSTING'];
77 }
78}