CAllCrmActivity::DeleteBindingsByOwner

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

	$bindingTableName = CCrmActivity::BINDING_TABLE_NAME;
	global $DB;

	$dbRes = $DB->Query(
		"SELECT ACTIVITY_ID FROM {$bindingTableName} WHERE OWNER_ID = {$ownerID} AND OWNER_TYPE_ID = {$ownerTypeID}",
		false,
		'File: '.__FILE__.'
Line: '.__LINE__ ); $processedIDs = array(); if(is_object($dbRes)) { while($arRes = $dbRes->Fetch()) { $processedIDs[] = intval($arRes['ACTIVITY_ID']); Crm\Activity\UncompletedActivity::synchronizeForActivity((int)$arRes['ACTIVITY_ID'], [ [ 'OWNER_TYPE_ID' => $ownerTypeID, 'OWNER_ID' => $ownerID, ] ]); } } if(!empty($processedIDs)) { $DB->Query( "DELETE FROM {$bindingTableName} WHERE OWNER_ID = {$ownerID} AND OWNER_TYPE_ID = {$ownerTypeID}", false, 'File: '.__FILE__.'
Line: '.__LINE__ ); foreach ($processedIDs as $activityId) { \Bitrix\Crm\Counter\Monitor::getInstance()->onChangeActivitySingleBinding( $activityId, [ 'OWNER_TYPE_ID' => $ownerTypeID, 'OWNER_ID' => $ownerID, ], [] ); Crm\Activity\Provider\ProviderManager::syncBadgesOnBindingsChange( $activityId, [], [ ['OWNER_TYPE_ID' => $ownerTypeID, 'OWNER_ID' => $ownerID] ], ); } if (\CCrmOwnerType::IsDefined($ownerTypeID)) { Crm\Service\Timeline\Monitor::getInstance()->onActivityRemove(new Crm\ItemIdentifier($ownerTypeID, $ownerID)); } } return $processedIDs; }

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