示例#1
0
 /**
  * @param Entity\Event $event
  * @return Entity\EventResult
  * @throws \Bitrix\Main\ArgumentException
  */
 public static function onDelete(Entity\Event $event)
 {
     $result = new Entity\EventResult();
     $data = $event->getParameters();
     $arId = array();
     if (array_key_exists('ID', $data['primary'])) {
         $arId[] = $data['primary']['ID'];
     } else {
         $arFilter = array();
         foreach ($data['primary'] as $primKey => $primVal) {
             $arFilter[$primKey] = $primVal;
         }
         $tableDataList = static::getList(array('select' => array('ID'), 'filter' => $arFilter));
         while ($tableData = $tableDataList->fetch()) {
             $arId[] = $tableData['ID'];
         }
     }
     foreach ($arId as $primaryId) {
         $primary = array('POSTING_ID' => $primaryId);
         PostingReadTable::delete($primary);
         PostingClickTable::delete($primary);
         PostingUnsubTable::delete($primary);
         PostingRecipientTable::delete($primary);
     }
     return $result;
 }
示例#2
0
 /**
  * @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));
         }
     }
 }
示例#3
0
 public static function onGetAttributeTypes()
 {
     return array('sender_chain_source' => array('MODULE' => 'sender', 'GROUP' => 'source', 'NAME' => Loc::getMessage('sender_conversion_chain_source'), 'SORT' => 5100, 'SPLIT_BY' => 'sender_chain_source', 'BG_COLOR' => '#cf4343', 'GET_VALUES' => function (array $list) {
         $itemList = array();
         $filter = array();
         if ($list) {
             $filter['=POSTING.MAILING_CHAIN.ID'] = $list;
         }
         $itemDb = PostingClickTable::getList(array('select' => array('MAILING_CHAIN_ID' => 'POSTING.MAILING_CHAIN.ID', 'MAILING_CHAIN_SUBJECT' => 'POSTING.MAILING_CHAIN.SUBJECT'), 'filter' => $filter, 'group' => array('MAILING_CHAIN_ID', 'MAILING_CHAIN_SUBJECT')));
         while ($item = $itemDb->fetch()) {
             if (strlen($item['MAILING_CHAIN_SUBJECT']) <= 0) {
                 continue;
             }
             $itemList[$item['MAILING_CHAIN_ID']] = array('NAME' => $item['MAILING_CHAIN_SUBJECT']);
         }
         return $itemList;
     }));
 }
示例#4
0
 /**
  * @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();
             }
         }
     }
 }
示例#5
0
        }
    }
    // get statistic by last posting
    if (!empty($arPosting)) {
        $statResult['all'] = $arPosting['STATUS'] != \Bitrix\Sender\PostingTable::STATUS_ABORT ? $arPosting['COUNT_SEND_ALL'] : 0;
        $statResult['delivered'] = $arPosting['COUNT_SEND_SUCCESS'];
        $statResult['not_send'] = $arPosting['COUNT_SEND_NONE'];
        $statResult['error'] = $arPosting['COUNT_SEND_ERROR'];
        $statResult['read'] = $arPosting['COUNT_READ'];
        $statResult['click'] = $arPosting['COUNT_CLICK'];
        $statResult['unsub'] = $arPosting['COUNT_UNSUB'];
        $statResult['all_print'] = $statResult['all'];
    }
    // get url clicking statistic
    if (!empty($arPosting)) {
        $statClickDb = \Bitrix\Sender\PostingClickTable::getList(array('select' => array('URL', 'CNT'), 'filter' => array('POSTING_ID' => $arPosting['ID']), 'runtime' => array(new \Bitrix\Main\Entity\ExpressionField('CNT', 'COUNT(%s)', 'ID')), 'group' => array('URL'), 'order' => array('CNT' => 'DESC'), 'limit' => 15));
        while ($statClick = $statClickDb->fetch()) {
            $statClickList[] = $statClick;
        }
    }
}
$strError = "";
if (empty($arPosting)) {
    $strError = GetMessage("sender_stat_error_no_data");
}
$lAdmin->BeginCustomContent();
if (!empty($strError)) {
    CAdminMessage::ShowMessage($strError);
} else {
    if (intval($statResult['all']) <= 0) {
        $statResult['all'] = 1;
示例#6
0
 public static function updateRecipientReadCounters($type)
 {
     $params = array('select' => array('RECIPIENT_ID'), 'runtime' => array(new \Bitrix\Main\Entity\ReferenceField('UPDATE_RECIPIENT', 'Bitrix\\Sender\\PostingRecipientTable', array('=this.RECIPIENT_ID' => 'ref.ID'))), 'filter' => array('!UPDATE_RECIPIENT.ID' => null, '=UPDATE_RECIPIENT.IS_' . $type => 'N'), 'group' => array('RECIPIENT_ID'));
     $dataDb = null;
     switch ($type) {
         case 'READ':
             $dataDb = \Bitrix\Sender\PostingReadTable::getList($params);
             break;
         case 'CLICK':
             $dataDb = \Bitrix\Sender\PostingClickTable::getList($params);
             break;
         case 'UNSUB':
             $dataDb = \Bitrix\Sender\PostingUnsubTable::getList($params);
             break;
     }
     if (!$dataDb) {
         return false;
     }
     while ($item = $dataDb->fetch()) {
         if (self::isTimeUp()) {
             return true;
         }
         \Bitrix\Sender\PostingRecipientTable::update(array('ID' => $item['RECIPIENT_ID']), array('IS_' . $type => 'Y'));
     }
     return false;
 }
示例#7
0
 /**
  * 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();
             }
         }
     }
 }