• Модуль: sender
  • Путь к файлу: ~/bitrix/modules/sender/lib/trigger/manager.php
  • Класс: BitrixSenderTriggerManager
  • Вызов: Manager::actualizeHandler
static function actualizeHandler(array $params, $activate = null)
{
	$moduleId = $params['MODULE_ID'];
	$eventType = $params['EVENT_TYPE'];
	$calledBeforeChange = $params['CALLED_BEFORE_CHANGE'];

	if($params['IS_CLOSED_TRIGGER'])
	{

		return;
	}

	if($activate === null)
	{
		// if actualizing will be called before deleting record (or updating record with clearing field),
		// query will select this record.
		// In this reason, it should be considered - check if more 1 or 0 selected rows.
		if($calledBeforeChange)
			$minRowsCount = 1;
		else
			$minRowsCount = 0;

		$existsDb = MailingTriggerTable::getList(array(
			'select' => array('MAILING_CHAIN_ID'),
			'filter' => array(
				'=EVENT' => $moduleId.'/'.$eventType,
				'=MAILING_CHAIN.IS_TRIGGER' => 'Y',
				'=MAILING_CHAIN.MAILING.ACTIVE' => 'Y',
				//'=STATUS' => array(MailingChainTable::STATUS_WAIT, MailingChainTable::STATUS_SEND)
			),
			'group' => array('MAILING_CHAIN_ID'),
			'limit' => 2
		));
		$rowsCount = 0;
		while($existsDb->fetch()) $rowsCount++;

		if($rowsCount > $minRowsCount)
		{
			$activate = true;
		}
		else
		{
			$activate = false;
		}
	}

	if($activate)
	{
		EventManager::getInstance()->registerEventHandler(
			$moduleId, $eventType, 'sender', __CLASS__, 'handleEvent'
		);
	}
	else
	{
		EventManager::getInstance()->unRegisterEventHandler(
			$moduleId, $eventType, 'sender', __CLASS__, 'handleEvent'
		);
	}
}