Subscription::getList

  1. Bitrix24 API (v. 23.675.0)
  2. sender
  3. Subscription
  4. getList
  • Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/subscription.php
  • Класс: Bitrix\Sender\Subscription
  • Вызов: Subscription::getList
static function getList($data)
{
	$resultMailingList = array();

	$mailing = MailingTable::getRowById(array('ID' => $data['MAILING_ID']));
	if(isset($data['TEST']) && $data['TEST'] == 'Y')
	{
		$resultMailingList[] = array(
			'ID' => $mailing['ID'],
			'NAME' => $mailing['NAME'],
			'DESC' => $mailing['DESCRIPTION'],
			'SELECTED' => true,
		);

		return $resultMailingList;
	}

	$mailingUnsub = array();
	$unSubDb = MailingSubscriptionTable::getUnSubscriptionList(array(
		'select' => array('MAILING_ID'),
		'filter' => array(
			'=CONTACT.EMAIL' => trim(mb_strtolower($data['EMAIL'])),
			'=MAILING.SITE_ID' => $mailing['SITE_ID']
		)
	));
	while($unSub = $unSubDb->fetch())
		$mailingUnsub[] = $unSub['MAILING_ID'];

	$mailingList = array();
	// all receives mailings
	$receiveMailingDb = PostingRecipientTable::getList(array(
		'select' => array('MAILING_ID' => 'POSTING.MAILING.ID'),
		'filter' => array(
			'=EMAIL' => trim(mb_strtolower($data['EMAIL'])),
			'=POSTING.MAILING.ACTIVE' => 'Y',
			'=POSTING.MAILING.SITE_ID' => $mailing['SITE_ID']
		),
		'group' => array('MAILING_ID')
	));
	while ($receiveMailing = $receiveMailingDb->fetch())
	{
		$mailingList[] = $receiveMailing['MAILING_ID'];
	}

	// all subscribed mailings
	$subscribedMailingDb = MailingSubscriptionTable::getSubscriptionList(array(
		'select' => array('MAILING_ID'),
		'filter' => array(
			'=CONTACT.EMAIL' => trim(mb_strtolower($data['EMAIL'])),
			'=MAILING.ACTIVE' => 'Y',
			'=MAILING.SITE_ID' => $mailing['SITE_ID']
		)
	));
	while ($subscribedMailing = $subscribedMailingDb->fetch())
	{
		$mailingList[] = $subscribedMailing['MAILING_ID'];
	}

	$mailingList = array_unique($mailingList);
	foreach($mailingList as $mailingId)
	{
		if(!in_array($mailingId, $mailingUnsub))
		{
			$mailingDesc = MailingTable::getRowById($mailingId);
			if($mailingDesc)
			{
				$resultMailingList[] = array(
					'ID' => $mailingDesc['ID'],
					'NAME' => $mailingDesc['NAME'],
					'DESC' => $mailingDesc['DESCRIPTION'],
					'SELECTED' => in_array($mailingDesc['ID'], array($data['MAILING_ID'])),
				);
			}
		}
	}

	return $resultMailingList;
}

Добавить комментарий