...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/integration/im/chat.php
- Класс: Bitrix\Crm\Integration\Im\Chat
- Вызов: Chat::onAddChatUser
static function onAddChatUser(array $eventArgs) { $observersRestriction = Crm\Restriction\RestrictionManager::getObserversRestriction(); if (!$observersRestriction->hasPermission()) { return; } $chatID = isset($eventArgs['CHAT_ID']) ? (int)$eventArgs['CHAT_ID'] : 0; if($chatID <= 0) { return; } $userIDs = isset($eventArgs['NEW_USERS']) && is_array($eventArgs['NEW_USERS']) ? $eventArgs['NEW_USERS'] : []; Main\Type\Collection::normalizeArrayValuesByInt($userIDs); if(empty($userIDs)) { return; } $chatData = Im\Model\ChatTable::getList( [ 'select' => [ 'ID', 'ENTITY_TYPE', 'ENTITY_ID' ], 'filter' => [ '=ID' => $chatID ] ] )->fetch(); if(!is_array($chatData)) { return; } if(!(isset($chatData['ENTITY_TYPE']) && $chatData['ENTITY_TYPE'] === self::CHAT_ENTITY_TYPE)) { return; } $entityInfo = Crm\Integration\Im\Chat::resolveEntityInfo( isset($chatData['ENTITY_ID']) ? $chatData['ENTITY_ID'] : '' ); if(!is_array($entityInfo)) { return; } if($entityInfo['ENTITY_TYPE_ID'] === \CCrmOwnerType::Deal) { \CCrmDeal::AddObserverIDs($entityInfo['ENTITY_ID'], $userIDs); } elseif($entityInfo['ENTITY_TYPE_ID'] === \CCrmOwnerType::Lead) { \CCrmLead::AddObserverIDs($entityInfo['ENTITY_ID'], $userIDs); } else { $factory = Container::getInstance()->getFactory((int)$entityInfo['ENTITY_TYPE_ID']); if ($factory && $factory->isObserversEnabled()) { $item = $factory->getItem((int)$entityInfo['ENTITY_ID']); if ($item) { $currentObservers = $item->getObservers(); $currentAndNewObservers = array_merge($currentObservers, $userIDs); $item->setObservers($currentAndNewObservers); $factory->getUpdateOperation($item) ->disableCheckAccess() ->launch() ; } } } }