CAllCrmActivity::DeleteBindings

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmActivity
  4. DeleteBindings
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_activity.php
  • Класс: \CAllCrmActivity
  • Вызов: CAllCrmActivity::DeleteBindings
static function DeleteBindings($activityID, $registerBindingsChanges = true)
{
	$activityID = intval($activityID);
	if($activityID <= 0)
	{
		return false;
	}

	global $DB;

	if ($registerBindingsChanges)
	{
		\Bitrix\Crm\Activity\UncompletedActivity::synchronizeForActivity($activityID);
	}

	$affectedBindings =
		Crm\ActivityBindingTable::query()
			->setSelect(['OWNER_TYPE_ID', 'OWNER_ID'])
			->where('ACTIVITY_ID', $activityID)
			->fetchCollection()
	;
	$affectedBindingsArray = array_map(
		fn(Crm\EO_ActivityBinding $binding): array => $binding->collectValues(),
		$affectedBindings->getAll(),
	);

	$DB->Query(
		'DELETE FROM '.CCrmActivity::BINDING_TABLE_NAME.' WHERE ACTIVITY_ID = '.$activityID,
		false,
		'File: '.__FILE__.'
Line: '.__LINE__ ); if ($registerBindingsChanges) { \Bitrix\Crm\Counter\Monitor::getInstance()->onChangeActivityBindings( $activityID, $affectedBindingsArray, [] ); } Crm\Activity\Provider\ProviderManager::syncBadgesOnBindingsChange( $activityID, [], $affectedBindingsArray, ); $monitor = Crm\Service\Timeline\Monitor::getInstance(); foreach ($affectedBindings as $binding) { if (\CCrmOwnerType::IsDefined($binding->getOwnerTypeId()) && $binding->getOwnerId() > 0) { $monitor->onActivityRemoveIfSuitable(new Crm\ItemIdentifier($binding->getOwnerTypeId(), $binding->getOwnerId()), $activityID); } } return true; }

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