TaskHandler::afterInsertTrigger

  1. Bitrix24 API (v. 23.675.0)
  2. tasks
  3. TaskHandler
  4. afterInsertTrigger
  • Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/replica/taskhandler.php
  • Класс: BitrixTasksReplicaTaskHandler
  • Вызов: TaskHandler::afterInsertTrigger
public function afterInsertTrigger(array $newRecord)
{
	global $CACHE_MANAGER;

	$newRecord['ACCOMPLICES'] = array();
	$newRecord['AUDITORS'] = array();
	$list = BitrixTasksInternalsTaskMemberTable::getList(array(
			"filter" => array(
			"=TASK_ID" => $newRecord["ID"],
		),
	));
	while ($item = $list->fetch())
	{
		if ($item['TYPE'] == 'A')
			$newRecord['ACCOMPLICES'][] = $item['USER_ID'];
		elseif ($item['TYPE'] == 'U')
			$newRecord['AUDITORS'][] = $item['USER_ID'];
	}

	CounterService::addEvent(
		EventDictionary::EVENT_AFTER_TASK_ADD,
		$newRecord
	);

	CTaskNotifications::sendAddMessage(
		array_merge($newRecord, array('CHANGED_BY' => $newRecord['CREATED_BY'])),
		array('SPAWNED_BY_AGENT' => true)
	);

	//CTaskSync::AddItem($arFields); // MS Exchange

	CTasks::Index($newRecord, $newRecord["TAGS"]);
	SearchIndex::setTaskSearchIndex($newRecord['ID'], $newRecord);

	$arParticipants = array_unique(array_merge(
		array($newRecord["CREATED_BY"], $newRecord["RESPONSIBLE_ID"]),
		$newRecord["ACCOMPLICES"],
		$newRecord["AUDITORS"]
	));

	foreach($arParticipants as $userId)
	{
		$CACHE_MANAGER->ClearByTag("tasks_user_".$userId);
	}

	// Emit pull event
	try
	{
		$eventGUID = sha1(uniqid('AUTOGUID', true));
		$arPullRecipients = array();

		foreach($arParticipants as $userId)
			$arPullRecipients[] = (int) $userId;

		$arPullData = array(
			'TASK_ID' => (int) $newRecord["ID"],
			'AFTER' => array(
				'GROUP_ID' => 0
			),
			'TS' => time(),
			'event_GUID' => $eventGUID
		);

		CTasks::EmitPullWithTagPrefix(
			$arPullRecipients,
			'TASKS_GENERAL_',
			'task_add',
			$arPullData
		);

		CTasks::EmitPullWithTag(
			$arPullRecipients,
			'TASKS_TASK_' . (int) $newRecord["ID"],
			'task_add',
			$arPullData
		);
	}
	catch (Exception $e)
	{
	}
}

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