...Человеческий поиск в разработке...
- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_search.php
- Класс: \CCrmSearch
- Вызов: CCrmSearch::_buildEntityCard
static function _buildEntityCard($arEntity, $sTitle, $ENTITY_TYPE, $arOptions = null) { static $arEntityGroup = array(); static $arStatuses = array(); static $arSite = array(); $sBody = $arEntity[$sTitle]."\n"; $arField2status = array( 'STATUS_ID' => 'STATUS', 'SOURCE_ID' => 'SOURCE', 'CURRENCY_ID' => 'CURRENCY', 'PRODUCT_ID' => 'PRODUCT', 'TYPE_ID' => 'CONTACT_TYPE', 'STAGE_ID' => 'DEAL_STAGE', 'EVENT_ID' => 'EVENT_TYPE', 'COMPANY_TYPE' => 'COMPANY_TYPE', 'EMPLOYEES' => 'EMPLOYEES', 'INDUSTRY' => 'INDUSTRY' ); foreach ($arEntity as $_k => $_v) { if ($_k == $sTitle || mb_strpos($_k, '_BY_') !== false || mb_strpos($_k, 'DATE_') === 0 || mb_strpos($_k, 'UF_') === 0) continue ; if($ENTITY_TYPE === 'CONTACT' && ($_k === 'NAME' || $_k === 'SECOND_NAME' || $_k === 'LAST_NAME')) { //Already added as title continue; } if (is_array($_v)) continue ; if($_k === 'COMMENTS') { $_v = CSearch::KillTags($_v); } $_v = trim($_v); if (isset($arField2status[$_k])) { if (!isset($arStatuses[$_k])) $arStatuses[$_k] = CCrmStatus::GetStatusList($arField2status[$_k]); $_v = $arStatuses[$_k][$_v] ?? null; } if (!empty($_v) && !is_numeric($_v) && $_v != 'N' && $_v != 'Y') $sBody .= (self::$arMess[$ENTITY_TYPE]['CRM_FIELD_'.$_k] ?? null).": $_v\n"; } if($ENTITY_TYPE === 'CONTACT' || $ENTITY_TYPE === 'COMPANY' || $ENTITY_TYPE === 'LEAD') { $multiFields = is_array($arOptions) && isset($arOptions['FM']) ? $arOptions['FM'] : null; if(is_array($multiFields)) { foreach($multiFields as $typeID => $multiFieldItems) { if($typeID === 'PHONE') { $sBody .= GetMessage('CRM_PHONES').': '.implode(', ', $multiFieldItems)."\n"; } elseif($typeID === 'EMAIL') { $sBody .= GetMessage('CRM_EMAILS').': '.implode(', ', $multiFieldItems)."\n"; } } } } $sDetailURL = CComponentEngine::MakePathFromTemplate(COption::GetOptionString('crm', 'path_to_'.mb_strtolower($ENTITY_TYPE).'_show'), array( mb_strtolower($ENTITY_TYPE).'_id' => $arEntity['ID'] ) ); $_arAttr = \Bitrix\Crm\Security\EntityAuthorization::getPermissionAttributes( CCrmOwnerType::ResolveID($ENTITY_TYPE), array($arEntity['ID']) ); if (empty($arSite)) { $rsSite = CSite::GetList(); while ($_arSite = $rsSite->Fetch()) $arSite[] = $_arSite['ID']; } $sattr_d = ''; $sattr_s = ''; $sattr_u = ''; $sattr_o = ''; $arAttr = array(); if (!isset($_arAttr[$arEntity['ID']])) $_arAttr[$arEntity['ID']] = array(); $permEntity = $ENTITY_TYPE; if($ENTITY_TYPE === 'DEAL') { $permEntity = \Bitrix\Crm\Category\DealCategory::convertToPermissionEntityType( $arEntity['CATEGORY_ID'] ); } $arAttr[] = $permEntity; // for perm X foreach ($_arAttr[$arEntity['ID']] as $_s) { if (preg_match('/^U/', $_s)) { $sattr_u = $_s; } elseif (preg_match('/^D/', $_s)) { $sattr_d = $_s; } elseif (preg_match('/^S/', $_s)) { $sattr_s = $_s; } elseif (preg_match('/^O/', $_s)) { $sattr_o = $_s; } $arAttr[] = "{$permEntity}_{$_s}"; } if (!empty($sattr_s)) { $arAttr[] = "{$permEntity}_{$sattr_s}"; // for perm X in status if (!empty($sattr_u)) { $arAttr[] = "{$permEntity}_{$sattr_u}_{$sattr_s}"; } if (!empty($sattr_d)) { $arAttr[] = "{$permEntity}_{$sattr_d}_{$sattr_s}"; } if (!empty($sattr_o)) { $arAttr[] = "{$permEntity}_{$sattr_o}_{$sattr_s}"; } } $arSitePath = array(); foreach ($arSite as $sSite) $arSitePath[$sSite] = $sDetailURL; $arResult = Array( 'LAST_MODIFIED' => $arEntity['DATE_MODIFY'], 'DATE_FROM' => $arEntity['DATE_CREATE'], 'TITLE' => GetMessage('CRM_'.$ENTITY_TYPE).': '.$arEntity[$sTitle], 'PARAM1' => $ENTITY_TYPE, 'PARAM2' => $arEntity['ID'], 'SITE_ID' => $arSitePath, 'PERMISSIONS' => $arAttr, 'BODY' => $sBody, 'TAGS' => 'crm,'.mb_strtolower($ENTITY_TYPE).','.GetMessage('CRM_'.$ENTITY_TYPE) ); if (self::$bReIndex) $arResult['ID'] = $ENTITY_TYPE.'.'.$arEntity['ID']; return $arResult; }