...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_activity.php
- Класс: \CAllCrmActivity
- Вызов: CAllCrmActivity::DeleteUnbound
static function DeleteUnbound($arBindings = null) { $tableName = CCrmActivity::TABLE_NAME; $bindingTableName = CCrmActivity::BINDING_TABLE_NAME; global $DB; $dbRes = $DB->Query( "SELECT ID FROM {$tableName} WHERE ID NOT IN (SELECT ACTIVITY_ID FROM {$bindingTableName})", false, 'File: '.__FILE__.'
Line: '.__LINE__ ); $delOptions = array( 'SKIP_BINDINGS' => true, 'SKIP_USER_ACTIVITY_SYNC' => true, 'SKIP_STATISTICS' => true ); if(ActivitySettings::getValue(ActivitySettings::KEEP_UNBOUND_TASKS)) { $delOptions['SKIP_TASKS'] = true; } if(is_array($arBindings) && !empty($arBindings)) { $delOptions['ACTUAL_BINDINGS'] = $arBindings; } $processedIDs = array(); $responsibleIDs = array(); while($arRes = $dbRes->Fetch()) { $itemID = intval($arRes['ID']); $item = self::GetByID($itemID, false); if(!is_array($item)) { continue; } $processedIDs[] = $itemID; $responsibleID = isset($item['RESPONSIBLE_ID']) ? intval($item['RESPONSIBLE_ID']) : 0; if($responsibleID > 0 && !in_array($responsibleID, $responsibleIDs, true)) { $responsibleIDs[] = $responsibleID; } $delOptions['ACTUAL_ITEM'] = $item; self::Delete($itemID, false, false, $delOptions); } // Synchronize user activity --> if(is_array($arBindings) && !empty($arBindings)) { foreach($arBindings as &$arBinding) { foreach($responsibleIDs as $responsibleID) { self::SynchronizeUserActivity($arBinding['OWNER_TYPE_ID'], $arBinding['OWNER_ID'], $responsibleID); } self::SynchronizeUserActivity($arBinding['OWNER_TYPE_ID'], $arBinding['OWNER_ID'], 0); \Bitrix\Crm\Activity\CommunicationStatistics::rebuild( $arBinding['OWNER_TYPE_ID'], array($arBinding['OWNER_ID']) ); } unset($arBinding); } // <-- Synchronize user activity return $processedIDs; }