/** * @param $recipientId * @param $url * @throws \Bitrix\Main\ArgumentException */ public static function click($recipientId, $url) { $postingContactPrimary = array('ID' => $recipientId); $arPostingEmail = PostingRecipientTable::getRowById($postingContactPrimary); if ($arPostingEmail && $arPostingEmail['ID']) { $arPostingRead = PostingReadTable::getRowById(array('POSTING_ID' => $arPostingEmail['POSTING_ID'], 'RECIPIENT_ID' => $arPostingEmail['ID'])); if ($arPostingRead === null) { static::read($recipientId); } $postingDb = PostingTable::getList(array('select' => array('ID'), 'filter' => array('ID' => $arPostingEmail['POSTING_ID'], 'MAILING.TRACK_CLICK' => 'Y'))); if ($postingDb->fetch()) { PostingClickTable::add(array('POSTING_ID' => $arPostingEmail['POSTING_ID'], 'RECIPIENT_ID' => $arPostingEmail['ID'], 'URL' => $url)); } } }
/** * @param $recipientId * @param $url * @throws \Bitrix\Main\ArgumentException */ public static function click($recipientId, $url) { $postingContactPrimary = array('ID' => $recipientId); $recipient = PostingRecipientTable::getRowById($postingContactPrimary); if ($recipient && $recipient['ID']) { $read = PostingReadTable::getRowById(array('POSTING_ID' => $recipient['POSTING_ID'], 'RECIPIENT_ID' => $recipient['ID'])); if ($read === null) { static::read($recipientId); } $postingDb = PostingTable::getList(array('select' => array('ID'), 'filter' => array('ID' => $recipient['POSTING_ID']))); if ($postingDb->fetch()) { $fixedUrl = str_replace(array('&bx_sender_conversion_id=' . $recipient['ID'], '?bx_sender_conversion_id=' . $recipient['ID']), array('', ''), $url); $addClickDb = PostingClickTable::add(array('POSTING_ID' => $recipient['POSTING_ID'], 'RECIPIENT_ID' => $recipient['ID'], 'URL' => $fixedUrl)); if ($addClickDb->isSuccess()) { // send event $eventData = array('URL' => $url, 'URL_FIXED' => $fixedUrl, 'CLICK_ID' => $addClickDb->getId(), 'RECIPIENT' => $recipient); $event = new Event('sender', 'OnAfterRecipientClick', array($eventData)); $event->send(); } } } }
/** * Do click actions * * @param $recipientId * @param $url * @return void * @throws \Bitrix\Main\ArgumentException */ public static function click($recipientId, $url) { $postingContactPrimary = array('ID' => $recipientId); $recipient = PostingRecipientTable::getRowById($postingContactPrimary); if ($recipient && $recipient['ID']) { $read = PostingReadTable::getRowById(array('POSTING_ID' => $recipient['POSTING_ID'], 'RECIPIENT_ID' => $recipient['ID'])); if ($read === null) { static::read($recipientId); } $postingDb = PostingTable::getList(array('select' => array('ID'), 'filter' => array('ID' => $recipient['POSTING_ID']))); if ($postingDb->fetch()) { $uri = new \Bitrix\Main\Web\Uri($url); $fixedUrl = $uri->deleteParams(array('bx_sender_conversion_id'))->getLocator(); $addClickDb = PostingClickTable::add(array('POSTING_ID' => $recipient['POSTING_ID'], 'RECIPIENT_ID' => $recipient['ID'], 'URL' => $fixedUrl)); if ($addClickDb->isSuccess()) { // send event $eventData = array('URL' => $url, 'URL_FIXED' => $fixedUrl, 'CLICK_ID' => $addClickDb->getId(), 'RECIPIENT' => $recipient); $event = new Event('sender', 'OnAfterRecipientClick', array($eventData)); $event->send(); } } } }