// decode encodeURIComponent params CUtil::JSPostUnescape(); $needle = isset($_REQUEST['NEEDLE']) ? $_REQUEST['NEEDLE'] : ''; } $items = array(); $imageless = array(); if (!CCrmOwnerType::IsDefined($ownerTypeID) || $ownerID <= 0) { if ($enableSearch && $needle !== '') { $results = CCrmActivity::FindContactCommunications($needle, $commType !== 'PERSON' ? $commType : '', 10); if ($commType !== '') { //If communication type defined add companies communications $results = array_merge($results, CCrmActivity::FindCompanyCommunications($needle, $commType !== 'PERSON' ? $commType : '', 10)); } $results = array_merge($results, CCrmActivity::FindLeadCommunications($needle, $commType !== 'PERSON' ? $commType : '', 10)); } else { $results = CCrmActivity::GetRecentlyUsedCommunications($commType !== 'PERSON' ? $commType : ''); foreach ($results as &$result) { CCrmActivity::PrepareCommunicationInfo($result); } unset($result); } foreach ($results as &$result) { $entityID = intval($result['ENTITY_ID']); $entityTypeID = intval($result['ENTITY_TYPE_ID']); $entityTypeName = CCrmOwnerType::ResolveName($entityTypeID); if (!CCrmAuthorizationHelper::CheckReadPermission($entityTypeName, $entityID, $userPerms)) { continue; } $item = array('OWNER_ID' => $entityID, 'OWNER_TYPE_ID' => $entityTypeID, 'OWNER_TYPE_NAME' => $entityTypeName, 'TITLE' => $result['TITLE'], 'DESCRIPTION' => $result['DESCRIPTION'], 'IMAGE_URL' => '', 'COMMUNICATIONS' => array()); if ($result['TYPE'] !== '' && $result['VALUE'] !== '') { $item['COMMUNICATIONS'][] = array('TYPE' => $result['TYPE'], 'VALUE' => $result['VALUE']);