...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/mysql/crm_activity.php
- Класс: \CCrmActivity
- Вызов: CCrmActivity::DoSaveCommunications
static function DoSaveCommunications($ID, &$arComms, $arFields = array(), $registerEvents = true, $checkPerms = true) { global $DB; $ID = intval($ID); if($ID <= 0 || !is_array($arComms)) { self::RegisterError(array('text' => 'Invalid arguments are supplied.')); return false; } if(!is_array($arPresentComms = self::GetCommunications($ID))) { self::RegisterError(array('text' => self::GetLastErrorMessage())); return false; } $ar2Delete = array(); $ar2Add = array(); foreach($arComms as $arComm) { $commID = isset($arComm['ID']) ? intval($arComm['ID']) : 0; if($commID <= 0) { $ar2Add[] = $arComm; continue; } } foreach($arPresentComms as $arPresentComm) { $presentCommID = intval($arPresentComm['ID']); $found = false; foreach($arComms as $arComm) { $commID = isset($arComm['ID']) ? intval($arComm['ID']) : 0; if($commID === $presentCommID) { $found = true; break; } } if(!$found) { $ar2Delete[] = $arPresentComm; } } if($ID > 0) { self::DeleteCommunications($ID); } if($registerEvents) { foreach($ar2Delete as $arComm) { self::RegisterCommunicationEvent( $ID, $arFields, $arComm, 'REMOVE', $checkPerms ); } } if(count($arComms) == 0) { return true; } $bulkColumns = ''; $bulkValues = array(); foreach($arComms as &$arComm) { if(isset($arComm['ID'])) { unset($arComm['ID']); } $arComm['TYPE'] = (string)($arComm['TYPE'] ?? ''); $arComm['VALUE'] = (string)($arComm['VALUE'] ?? ''); $data = $DB->PrepareInsert(self::COMMUNICATION_TABLE_NAME, $arComm); if($bulkColumns == '') { $bulkColumns = $data[0]; } $bulkValues[] = $data[1]; } unset($arComm); if(count($bulkValues) == 0) { self::RegisterError(array('text' => 'There are no values for insert.')); return false; } $query = ''; foreach($bulkValues as &$value) { if($query !== '') { $query .= ','; } $query .= "($value)"; } if($query == '') { self::RegisterError(array('text' => 'Could not build query.')); return false; } $DB->Query( 'INSERT INTO '.self::COMMUNICATION_TABLE_NAME.'('.$bulkColumns.') VALUES'.$query, false, 'File: '.__FILE__.'
Line: '.__LINE__ ); if($registerEvents) { foreach($ar2Add as $arComm) { self::RegisterCommunicationEvent( $ID, $arFields, $arComm, 'ADD', $checkPerms ); } } return true; }