- Модуль: sender
- Путь к файлу: ~/bitrix/modules/sender/lib/consent/abstractconsentresponse.php
- Класс: Bitrix\Sender\Consent\AbstractConsentResponse
- Вызов: AbstractConsentResponse::getConsentId
function getConsentId(); /** * @return mixed */ protected abstract function getPostingId(); /** * @param $apply * @return mixed */ protected abstract function isContactUpdated($apply); /** * @param $apply * @return bool * @throws \Bitrix\Main\ArgumentException * @throws \Bitrix\Main\ObjectPropertyException * @throws \Bitrix\Main\SystemException */ protected function updateContact($apply) { $result = false; if ($this->isContactUpdated($apply)) { $contactId = $this->getContactId(); $type = ($apply? ContactTable::CONSENT_STATUS_ACCEPT : ContactTable::CONSENT_STATUS_DENY); $isUnsub = ($apply? 'N':'Y'); $result = ContactTable::update($contactId,[ 'CONSENT_STATUS' => $type, 'IS_UNSUB' => $isUnsub, 'DATE_UPDATE' => new DateTime() ])->isSuccess(); $recipients = RecipientTable::getList([ 'select' => ['ID','STATUS'], 'filter' => [ '=CONTACT_ID' => $contactId, '@STATUS' => [RecipientTable::SEND_RESULT_NONE, RecipientTable::SEND_RESULT_WAIT_ACCEPT] ] ])->fetchAll(); if(!empty($recipients)) { SqlBatch::update(RecipientTable::getTableName(),array_map( function($recipient) use ($isUnsub) { $changeStatus = $recipient['STATUS'] === RecipientTable::SEND_RESULT_WAIT_ACCEPT; return [ 'ID' => $recipient['ID'], 'STATUS' => ($changeStatus? RecipientTable::SEND_RESULT_NONE: $recipient['STATUS']), 'IS_UNSUB' => $isUnsub ]; }, $recipients )); } } return $result; }