/** * @return string */ public function getFileInfo() { $fileInfo = null; if ($this->encoding === 'B' || $this->encoding === 'BASE64') { $type = $this->type !== '' ? strtolower($this->type) : 'jpg'; if ($type === '' || !in_array($type, explode(',', \CFile::GetImageExtensions()), true)) { $type = 'jpg'; } $filePath = \CTempFile::GetFileName(uniqid('vcard_img') . '.' . $type); CheckDirPath($filePath); //Removing of line folding $encodedData = preg_replace("/\\\\n/i", "\n", $this->value); if (file_put_contents($filePath, base64_decode($encodedData)) !== false) { $fileInfo = \CFile::MakeFileArray($filePath, "image/{$type}"); } } elseif ($this->valueType === 'URI' && \CCrmUrlUtil::HasScheme($this->value) && \CCrmUrlUtil::IsSecureUrl($this->value)) { $fileInfo = \CFile::MakeFileArray($this->value); } return is_array($fileInfo) && strlen(\CFile::CheckImageFile($fileInfo)) === 0 ? $fileInfo : null; }
} if (!function_exists('__CrmEventGetPhones')) { function __CrmEventGetPhones($entityID, $elementID) { $result = array(); $arFields = CCrmFieldMulti::GetEntityFields($entityID, $elementID, 'PHONE', true, false); foreach ($arFields as $arField) { $result[] = array('TITLE' => $arField['ENTITY_NAME'], 'NUMBER' => $arField['VALUE']); } return $result; } } CUtil::InitJSCore(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $eventPage = isset($_POST['EVENT_PAGE']) ? $_POST['EVENT_PAGE'] : ''; if ($eventPage === '' || !CCrmUrlUtil::IsSecureUrl($eventPage)) { $eventPage = $GLOBALS['APPLICATION']->GetCurPage(); } $formID = isset($_POST['FORM_ID']) ? $_POST['FORM_ID'] : ''; if ($formID === '') { $formID = 'CRM_' . trim($_POST['ENTITY_TYPE']) . '_' . trim($_POST['FORM_TYPE']) . '_V12'; } $arResult['EVENT_PAGE'] = CHTTP::urlAddParams($eventPage, array($formID . '_active_tab' => !empty($_POST['TAB_ID']) ? $_POST['TAB_ID'] : 'tab_event')); if (check_bitrix_sessid()) { $entityTypeID = isset($_POST['ENTITY_TYPE']) ? trim($_POST['ENTITY_TYPE']) : ''; $entityID = isset($_POST['ENTITY_ID']) ? intval($_POST['ENTITY_ID']) : 0; $eventID = isset($_POST['EVENT_ID']) ? trim($_POST['EVENT_ID']) : ''; $eventDesc = isset($_POST['EVENT_DESC']) ? trim($_POST['EVENT_DESC']) : ''; $eventDate = isset($_POST['EVENT_DATE']) ? trim($_POST['EVENT_DATE']) : ''; $postFiles = isset($_FILES['ATTACH']) ? $_FILES['ATTACH'] : array(); $attachedFiles = array();
if (is_array($arCommunication["ENTITY_SETTINGS"]) && isset($arCommunication["ENTITY_SETTINGS"]["COMPANY_TITLE"])) { $arTmp["COMPANY"] = $arCommunication["ENTITY_SETTINGS"]["COMPANY_TITLE"]; } $arResult["CLIENTS_FOR_JS"][] = $arTmp; } } $arResult["STORAGE_ELEMENTS"] = array(); $arResult["RECORDS"] = array(); if ($arActivity["TYPE_ID"] == CCrmActivityType::Call && !empty($arActivity["STORAGE_ELEMENT_IDS"])) { $arStorageElementID = unserialize($arActivity["STORAGE_ELEMENT_IDS"]); if (is_array($arStorageElementID) && !empty($arStorageElementID)) { $arMediaExtensions = array("flv", "mp3", "mp4", "vp6", "aac"); foreach ($arStorageElementID as $elementID) { $info = Bitrix\Crm\Integration\StorageManager::getFileInfo($elementID, $arActivity["STORAGE_TYPE_ID"], false); if (is_array($info) && in_array(GetFileExtension(strtolower($info["NAME"])), $arMediaExtensions)) { //Hacks for flv player $recordUrl = CCrmUrlUtil::ToAbsoluteUrl($info["VIEW_URL"]); if (substr($recordUrl, -1) !== "/") { $recordUrl .= "/"; } $recordUrl .= !empty($info["NAME"]) ? $info["NAME"] : "dummy.flv"; $arResult["RECORDS"][] = array("URL" => $recordUrl, "NAME" => $info["NAME"]); } $arResult["STORAGE_ELEMENTS"][] = $info; } } } } } $this->IncludeComponentTemplate(); return array("CACHED_CSS_PATH" => $this->getTemplate()->GetFolder() . "/style.css", "CACHED_JS_PATH" => $this->getTemplate()->GetFolder() . "/script.js");
$emailOwnerTypeName = CCrmOwnerType::ContactName; $emailOwnerID = $contactID; if ($dealID > 0) { $emailOwnerTypeName = CCrmOwnerType::DealName; $emailOwnerID = $dealID; } $arFields['CONTACT_EMAIL_EDIT_URL'] = CCrmUrlUtil::AddUrlParams(CComponentEngine::makePathFromTemplate($arParams['ACTIVITY_EDIT_URL_TEMPLATE'], array('owner_type' => $emailOwnerTypeName, 'owner_id' => $emailOwnerID, 'type_id' => CCrmActivityType::Email)), array('comm[]' => strtolower(CCrmOwnerType::ContactName) . '_' . $contactID)); } if ($companyID <= 0) { $arResult['COMPANY_CALLTO'] = $arFields['COMPANY_SHOW_URL'] = $arFields['COMPANY_EMAIL_EDIT_URL'] = ''; } else { $arResult['COMPANY_CALLTO'] = CCrmMobileHelper::PrepareCalltoParams(array('COMMUNICATION_LIST_URL_TEMPLATE' => $arParams['COMMUNICATION_LIST_URL_TEMPLATE'], 'ENTITY_TYPE_ID' => CCrmOwnerType::Company, 'ENTITY_ID' => $companyID, 'FM' => $arFields['COMPANY_FM'])); $arFields['COMPANY_SHOW_URL'] = CComponentEngine::makePathFromTemplate($arParams['COMPANY_SHOW_URL_TEMPLATE'], array('company_id' => $companyID)); $emailOwnerTypeName = CCrmOwnerType::ContactName; $emailOwnerID = $contactID; if ($dealID > 0) { $emailOwnerTypeName = CCrmOwnerType::DealName; $emailOwnerID = $dealID; } $arFields['COMPANY_EMAIL_EDIT_URL'] = CCrmUrlUtil::AddUrlParams(CComponentEngine::makePathFromTemplate($arParams['ACTIVITY_EDIT_URL_TEMPLATE'], array('owner_type' => $emailOwnerTypeName, 'owner_id' => $emailOwnerID, 'type_id' => CCrmActivityType::Email)), array('comm[]' => strtolower(CCrmOwnerType::CompanyName) . '_' . $companyID)); } /*$arFields['PRODUCT_ROWS_QUANTITY'] = CAllCrmProductRow::GetRowQuantity( CCrmOwnerTypeAbbr::ResolveByTypeID(CCrmOwnerType::Invoice), $entityID );*/ $arFields['PRODUCT_ROWS_URL'] = CComponentEngine::makePathFromTemplate($arParams['PRODUCT_ROW_LIST_URL_TEMPLATE'], array('entity_type_id' => CCrmOwnerType::Invoice, 'entity_id' => $entityID)); $arFields['EVENT_LIST_URL'] = CComponentEngine::makePathFromTemplate($arParams['EVENT_LIST_URL_TEMPLATE'], array('entity_type_id' => CCrmOwnerType::Invoice, 'entity_id' => $entityID)); $arResult['INVOICE_STATUS_SELECTOR_URL'] = CComponentEngine::makePathFromTemplate($arParams['INVOICE_STATUS_SELECTOR_URL_TEMPLATE'], array('context_id' => '')); $arResult['ENTITY'] =& $arFields; unset($arFields); $this->IncludeComponentTemplate();
if (!isset($_POST['COMPANY_ID']) && isset($_POST['COMPANY_NAME'])) { if (CCrmCompany::CheckCreatePermission()) { $arFields = array('TITLE' => trim($_POST['COMPANY_NAME']), 'CONTACT_ID' => array($ID)); $CCrmCompany = new CCrmCompany(); $companyId = $CCrmCompany->Add($arFields); $CCrmContact->UpdateCompanyId($ID, $companyId); } } if (isset($_POST['apply'])) { if (CCrmContact::CheckUpdatePermission($ID)) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_EDIT'], array('contact_id' => $ID))); } } elseif (isset($_POST['saveAndAdd'])) { $redirectUrl = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_EDIT'], array('contact_id' => 0)); if ($companyID > 0) { $redirectUrl = CCrmUrlUtil::AddUrlParams($redirectUrl, array('company_id' => $companyID)); } LocalRedirect($redirectUrl); } elseif (isset($_POST['saveAndView'])) { if (CCrmContact::CheckReadPermission($ID)) { LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_SHOW'], array('contact_id' => $ID))); } } //save LocalRedirect(isset($_REQUEST['backurl']) && $_REQUEST['backurl'] !== '' ? $_REQUEST['backurl'] : CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_LIST'], array())); } } } else { if (isset($_GET['delete']) && check_bitrix_sessid()) { if ($isEditMode) { $arResult['ERROR_MESSAGE'] = '';
public static function CreateLogMessage(&$fields, $options = array()) { if (!CModule::IncludeModule('socialnetwork')) { return false; } global $APPLICATION, $DB; if (!is_array($options)) { $options = array(); } $entityTypeID = isset($fields['ENTITY_TYPE_ID']) ? intval($fields['ENTITY_TYPE_ID']) : CCrmOwnerType::Undefined; if (!CCrmOwnerType::IsDefined($entityTypeID)) { $fields['ERROR'] = GetMessage('CRM_LF_MSG_ENTITY_TYPE_NOT_FOUND'); return false; } $entityType = CCrmOwnerType::ResolveName($entityTypeID); $entityID = isset($fields['ENTITY_ID']) ? intval($fields['ENTITY_ID']) : 0; if ($entityID < 0) { $fields['ERROR'] = GetMessage('CRM_LF_MSG_ENTITY_TYPE_NOT_FOUND'); return false; } $message = isset($fields['MESSAGE']) && is_string($fields['MESSAGE']) ? $fields['MESSAGE'] : ''; if ($message === '') { $fields['ERROR'] = GetMessage('CRM_LF_MSG_EMPTY'); return false; } $title = isset($fields['TITLE']) && is_string($fields['TITLE']) ? $fields['TITLE'] : ''; if ($title === '') { $title = self::UntitledMessageStub; } $userID = isset($fields['USER_ID']) ? intval($fields['USER_ID']) : 0; if ($userID <= 0) { $userID = CCrmSecurityHelper::GetCurrentUserID(); } $bbCodeParser = new CTextParser(); $bbCodeParser->allow["HTML"] = "Y"; $eventText = $bbCodeParser->convert4mail($message); $CCrmEvent = new CCrmEvent(); $eventID = $CCrmEvent->Add(array('ENTITY_TYPE' => $entityType, 'ENTITY_ID' => $entityID, 'EVENT_ID' => 'INFO', 'EVENT_TYPE' => 0, 'EVENT_TEXT_1' => $eventText, 'DATE_CREATE' => ConvertTimeStamp(time() + CTimeZone::GetOffset(), 'FULL', SITE_ID), 'FILES' => array())); if (is_string($eventID)) { //MS SQL RETURNS STRING INSTEAD INT $eventID = intval($eventID); } if (!(is_int($eventID) && $eventID > 0)) { $fields['ERROR'] = 'Could not create event'; return false; } $liveFeedEntityType = CCrmLiveFeedEntity::GetByEntityTypeID($entityTypeID); $eventID = CCrmLiveFeedEvent::GetEventID($liveFeedEntityType, CCrmLiveFeedEvent::Message); $eventFields = array('EVENT_ID' => $eventID, '=LOG_DATE' => $DB->CurrentTimeFunction(), 'TITLE' => $title, 'MESSAGE' => $message, 'TEXT_MESSAGE' => '', 'MODULE_ID' => 'crm_shared', 'CALLBACK_FUNC' => false, 'ENABLE_COMMENTS' => 'Y', 'PARAMS' => '', 'USER_ID' => $userID, 'ENTITY_TYPE' => $liveFeedEntityType, 'ENTITY_ID' => $entityID, 'SOURCE_ID' => $eventID, 'URL' => CCrmUrlUtil::AddUrlParams(CCrmOwnerType::GetShowUrl($entityTypeID, $entityID), array())); if (isset($fields['WEB_DAV_FILES']) && is_array($fields['WEB_DAV_FILES'])) { $eventFields = array_merge($eventFields, $fields['WEB_DAV_FILES']); } $sendMessage = isset($options['SEND_MESSAGE']) && is_bool($options['SEND_MESSAGE']) ? $options['SEND_MESSAGE'] : false; $logEventID = CSocNetLog::Add($eventFields, $sendMessage); if (is_int($logEventID) && $logEventID > 0) { $arSocnetRights = $fields["RIGHTS"]; if (!empty($arSocnetRights)) { $socnetPermsAdd = array(); foreach ($arSocnetRights as $perm_tmp) { if (preg_match('/^SG(\\d+)$/', $perm_tmp, $matches)) { if (!in_array("SG" . $matches[1] . "_" . SONET_ROLES_USER, $arSocnetRights)) { $socnetPermsAdd[] = "SG" . $matches[1] . "_" . SONET_ROLES_USER; } if (!in_array("SG" . $matches[1] . "_" . SONET_ROLES_MODERATOR, $arSocnetRights)) { $socnetPermsAdd[] = "SG" . $matches[1] . "_" . SONET_ROLES_MODERATOR; } if (!in_array("SG" . $matches[1] . "_" . SONET_ROLES_OWNER, $arSocnetRights)) { $socnetPermsAdd[] = "SG" . $matches[1] . "_" . SONET_ROLES_OWNER; } } } if (count($socnetPermsAdd) > 0) { $arSocnetRights = array_merge($arSocnetRights, $socnetPermsAdd); } CSocNetLogRights::DeleteByLogID($logEventID); CSocNetLogRights::Add($logEventID, $arSocnetRights); if (array_key_exists("UF_SONET_LOG_DOC", $eventFields) && is_array($eventFields["UF_SONET_LOG_DOC"]) && count($eventFields["UF_SONET_LOG_DOC"]) > 0) { if (!in_array("U" . $userID, $arSocnetRights)) { $arSocnetRights[] = "U" . $userID; } CSocNetLogTools::SetUFRights($eventFields["UF_SONET_LOG_DOC"], $arSocnetRights); } } $arUpdateFields = array("RATING_TYPE_ID" => "LOG_ENTRY", "RATING_ENTITY_ID" => $logEventID); CSocNetLog::Update($logEventID, $arUpdateFields); self::RegisterOwnershipRelations($logEventID, $eventID, $fields); $eventFields["LOG_ID"] = $logEventID; CCrmLiveFeed::CounterIncrement($eventFields); return $logEventID; } $ex = $APPLICATION->GetException(); $fields['ERROR'] = $ex->GetString(); return false; }
public static function TryResolveFile($var, &$file, $options = array()) { if (!is_array($options)) { $options = array(); } $result = null; if (is_array($var)) { if (isset($options['ENABLE_UPLOAD']) && $options['ENABLE_UPLOAD'] && self::IsUploadedFile($var)) { $result = $var; } } elseif (is_numeric($var)) { if (isset($options['ENABLE_ID']) && $options['ENABLE_ID']) { $result = CFile::MakeFileArray($var); } } elseif (is_string($var)) { $path = CCrmUrlUtil::ToAbsoluteUrl($var); //Parent directories and not secure URLs are not allowed. if ($path !== '' && !CHTTP::isPathTraversalUri($path) && CCrmUrlUtil::IsSecureUrl($path)) { $result = CFile::MakeFileArray($path); } } if (is_array($result)) { $result['MODULE_ID'] = 'crm'; $file = $result; return true; } return false; }
$dbResUser = CUser::GetByID($responsibleID); $arRes['RESPONSIBLE'] = $dbResUser->Fetch(); $arRes['RESPONSIBLE_FULL_NAME'] = is_array($arRes['RESPONSIBLE']) ? CUser::FormatName(CSite::GetNameFormat(false), $arRes['RESPONSIBLE'], true, false) : ''; } else { $arRes['RESPONSIBLE'] = false; $arRes['RESPONSIBLE_FULL_NAME'] = ''; $arRes['PATH_TO_RESPONSIBLE'] = ''; } $arRes['FILES'] = array(); CCrmActivity::PrepareStorageElementIDs($arRes); $arFileID = $arRes['STORAGE_ELEMENT_IDS']; if (is_array($arFileID)) { $fileCount = count($arFileID); for ($i = 0; $i < $fileCount; $i++) { if (is_array($arData = CFile::GetFileArray($arFileID[$i]))) { $arRes['FILES'][] = array('fileID' => $arData['ID'], 'fileName' => $arData['FILE_NAME'], 'fileURL' => CCrmUrlUtil::UrnEncode($arData['SRC']), 'fileSize' => $arData['FILE_SIZE']); } } } $arRes['SETTINGS'] = isset($arRes['~SETTINGS']) ? unserialize($arRes['~SETTINGS']) : array(); $arRes['COMMUNICATIONS'] = CCrmActivity::GetCommunications($arRes['~ID']); $commData = array(); if (is_array($arRes['COMMUNICATIONS'])) { foreach ($arRes['COMMUNICATIONS'] as &$arComm) { CCrmActivity::PrepareCommunicationInfo($arComm); $commData[] = array('id' => $arComm['ID'], 'type' => $arComm['TYPE'], 'value' => $arComm['VALUE'], 'entityId' => $arComm['ENTITY_ID'], 'entityType' => CCrmOwnerType::ResolveName($arComm['ENTITY_TYPE_ID']), 'entityTitle' => $arComm['TITLE']); } unset($arComm); } $item = array('ID' => $arRes['~ID'], 'typeID' => $arRes['~TYPE_ID'], 'subject' => strval($arRes['~SUBJECT']), 'description' => strval($arRes['~DESCRIPTION']), 'direction' => intval($arRes['~DIRECTION']), 'location' => strval($arRes['~LOCATION']), 'start' => isset($arRes['~START_TIME']) ? ConvertTimeStamp(MakeTimeStamp($arRes['~START_TIME']), 'FULL', SITE_ID) : '', 'end' => isset($arRes['~START_TIME']) ? ConvertTimeStamp(MakeTimeStamp($arRes['~END_TIME']), 'FULL', SITE_ID) : '', 'deadline' => isset($arRes['~DEADLINE']) ? ConvertTimeStamp(MakeTimeStamp($arRes['~DEADLINE']), 'FULL', SITE_ID) : '', 'completed' => strval($arRes['~COMPLETED']) == 'Y', 'notifyType' => intval($arRes['~NOTIFY_TYPE']), 'notifyValue' => intval($arRes['~NOTIFY_VALUE']), 'priority' => intval($arRes['~PRIORITY']), 'responsibleName' => isset($arRes['RESPONSIBLE_FULL_NAME'][0]) ? $arRes['RESPONSIBLE_FULL_NAME'] : GetMessage('CRM_UNDEFINED_VALUE'), 'files' => $arRes['FILES'], 'associatedEntityID' => isset($arRes['~ASSOCIATED_ENTITY_ID']) ? intval($arRes['~ASSOCIATED_ENTITY_ID']) : 0, 'communications' => $commData); $arItems[] = $item;
public static function GetDataForPopup($callId, $phone, $userId = 0) { if (strlen($phone) <= 0 || !CModule::IncludeModule('crm')) { return false; } if ($userId > 0) { $findParams = array('USER_ID' => $userId); } else { $findParams = array('ENABLE_EXTENDED_MODE' => false); } $crm = CCrmSipHelper::findByPhoneNumber((string) $phone, $findParams); if ($crm) { $dealStatuses = CCrmViewHelper::GetDealStageInfos(); $entity = ''; $entityData = array(); $entities = array(); $arResult = array('FOUND' => 'Y', 'CONTACT' => array(), 'COMPANY' => array(), 'ACTIVITIES' => array(), 'DEALS' => array(), 'RESPONSIBILITY' => array()); if (isset($crm['CONTACT'])) { $entity = 'CONTACT'; $entityData = $crm[$entity][0]; $arResult['CONTACT'] = array('NAME' => $entityData['FORMATTED_NAME'], 'POST' => $entityData['POST'], 'PHOTO' => ''); if (intval($entityData['PHOTO']) > 0) { $arPhoto = CFile::ResizeImageGet($entityData['PHOTO'], array('width' => 37, 'height' => 37), BX_RESIZE_IMAGE_EXACT, false, false, true); $arResult['CONTACT']['PHOTO'] = $arPhoto['src']; } $arResult['COMPANY'] = $entityData['COMPANY_TITLE']; $arResult['CONTACT_DATA'] = array('ID' => $entityData['ID']); } else { if (isset($crm['LEAD'])) { $entity = 'LEAD'; $entityData = $crm[$entity][0]; $arResult['CONTACT'] = array('ID' => 0, 'NAME' => !empty($entityData['FORMATTED_NAME']) ? $entityData['FORMATTED_NAME'] : $entityData['TITLE'], 'POST' => $entityData['POST'], 'PHOTO' => ''); $arResult['COMPANY'] = $entityData['COMPANY_TITLE']; $arResult['LEAD_DATA'] = array('ID' => $entityData['ID'], 'ASSIGNED_BY_ID' => $entityData['ASSIGNED_BY_ID']); } else { if (isset($crm['COMPANY'])) { $entity = 'COMPANY'; $entityData = $crm[$entity][0]; $arResult['COMPANY'] = $entityData['TITLE']; $arResult['COMPANY_DATA'] = array('ID' => $entityData['ID']); } } } if ($entityData['ASSIGNED_BY_ID'] > 0) { $ar = Bitrix\Main\UserTable::getById($entityData['ASSIGNED_BY_ID']); if ($user = $ar->fetch()) { $arPhoto = CFile::ResizeImageGet($user['PERSONAL_PHOTO'], array('width' => 37, 'height' => 37), BX_RESIZE_IMAGE_EXACT, false, false, true); $arResult['RESPONSIBILITY'] = array('ID' => $user['ID'], 'NAME' => CUser::FormatName(CSite::GetNameFormat(false), $user, true, false), 'PHOTO' => $arPhoto ? $arPhoto['src'] : '', 'POST' => $user['WORK_POSITION']); } } if (isset($entityData['SHOW_URL'])) { $arResult['SHOW_URL'] = $entityData['SHOW_URL']; } if (isset($entityData['ACTIVITY_LIST_URL'])) { $arResult['ACTIVITY_URL'] = $entityData['ACTIVITY_LIST_URL']; } if (isset($entityData['INVOICE_LIST_URL'])) { $arResult['INVOICE_URL'] = $entityData['INVOICE_LIST_URL']; } if (isset($entityData['DEAL_LIST_URL'])) { $arResult['DEAL_URL'] = $entityData['DEAL_LIST_URL']; } $activityId = CCrmActivity::GetIDByOrigin('VI_' . $callId); if ($activityId) { $arResult['CURRENT_CALL_URL'] = CCrmOwnerType::GetEditUrl(CCrmOwnerType::Activity, $activityId); if ($arResult['CURRENT_CALL_URL'] !== '') { $arResult['CURRENT_CALL_URL'] = CCrmUrlUtil::AddUrlParams($arResult['CURRENT_CALL_URL'], array("disable_storage_edit" => 'Y')); } } if (isset($crm['CONTACT']) && isset($crm['COMPANY'])) { $entities = array('CONTACT', 'COMPANY', 'LEAD'); } else { if (isset($crm['CONTACT']) && isset($crm['LEAD']) && !isset($crm['COMPANY'])) { $entities = array('CONTACT', 'LEAD'); } else { if (isset($crm['LEAD']) && isset($crm['COMPANY']) && !isset($crm['CONTACT'])) { $entities = array('LEAD', 'COMPANY'); } else { $entities = array($entity); } } } foreach ($entities as $entity) { if (isset($crm[$entity][0]['ACTIVITIES'])) { foreach ($crm[$entity][0]['ACTIVITIES'] as $activity) { if ($activity['ID'] == $activityId) { continue; } $overdue = 'N'; if (strlen($activity['DEADLINE']) > 0 && MakeTimeStamp($activity['DEADLINE']) < time()) { $overdue = 'Y'; } $arResult['ACTIVITIES'][$activity['ID']] = array('TITLE' => $activity['SUBJECT'], 'DATE' => strlen($activity['DEADLINE']) > 0 ? $activity['DEADLINE'] : $activity['END_TIME'], 'OVERDUE' => $overdue, 'URL' => $activity['SHOW_URL']); } if (!empty($arResult['ACTIVITIES'])) { $arResult['ACTIVITIES'] = array_values($arResult['ACTIVITIES']); } } if (isset($crm[$entity][0]['DEALS'])) { foreach ($crm[$entity][0]['DEALS'] as $deal) { $opportunity = CCrmCurrency::MoneyToString($deal['OPPORTUNITY'], $deal['CURRENCY_ID']); if (strpos('&', $opportunity)) { $opportunity = CCrmCurrency::MoneyToString($deal['OPPORTUNITY'], $deal['CURRENCY_ID'], '#') . ' ' . $deal['CURRENCY_ID']; } $opportunity = str_replace('.00', '', $opportunity); $arResult['DEALS'][$deal['ID']] = array('ID' => $deal['ID'], 'TITLE' => $deal['TITLE'], 'STAGE' => $dealStatuses[$deal['STAGE_ID']]['NAME'], 'STAGE_COLOR' => $dealStatuses[$deal['STAGE_ID']]['COLOR'] ? $dealStatuses[$deal['STAGE_ID']]['COLOR'] : "#5fa0ce", 'OPPORTUNITY' => $opportunity, 'URL' => $deal['SHOW_URL']); } if (!empty($arResult['DEALS'])) { $arResult['DEALS'] = array_values($arResult['DEALS']); } } } } else { $arResult = array('FOUND' => 'N'); $userPermissions = CCrmPerms::GetUserPermissions($userId); if (CCrmLead::CheckCreatePermission($userPermissions)) { $arResult['LEAD_URL'] = CCrmOwnerType::GetEditUrl(CCrmOwnerType::Lead, 0); if ($arResult['LEAD_URL'] !== '') { $arResult['LEAD_URL'] = CCrmUrlUtil::AddUrlParams($arResult['LEAD_URL'], array("phone" => (string) $phone, 'origin_id' => 'VI_' . $callId)); } } if (CCrmContact::CheckCreatePermission($userPermissions)) { $arResult['CONTACT_URL'] = CCrmOwnerType::GetEditUrl(CCrmOwnerType::Contact, 0); if ($arResult['CONTACT_URL'] !== '') { $arResult['CONTACT_URL'] = CCrmUrlUtil::AddUrlParams($arResult['CONTACT_URL'], array("phone" => (string) $phone, 'origin_id' => 'VI_' . $callId)); } } } return $arResult; }
return; } $arFields['FM'] = array(); $dbMultiFields = CCrmFieldMulti::GetList(array('ID' => 'asc'), array('ENTITY_ID' => 'COMPANY', 'ELEMENT_ID' => $entityID)); if ($dbMultiFields) { while ($arMultiField = $dbMultiFields->Fetch()) { $arFields['FM'][$arMultiField['TYPE_ID']][$arMultiField['ID']] = array('VALUE' => $arMultiField['VALUE'], 'VALUE_TYPE' => $arMultiField['VALUE_TYPE']); } } CCrmMobileHelper::PrepareCompanyItem($arFields, $arParams, array('COMPANY_TYPE' => $arResult['COMPANY_TYPE'], 'INDUSTRY' => $arResult['INDUSTRY'], 'EMPLOYEES_LIST' => $arResult['EMPLOYEES'])); } $arResult['ENTITY'] = $arFields; $sid = bitrix_sessid(); $serviceURLTemplate = $arParams["SERVICE_URL_TEMPLATE"] ? $arParams["SERVICE_URL_TEMPLATE"] : '#SITE_DIR#bitrix/components/bitrix/mobile.crm.company.edit/ajax.php?site_id=#SITE#&sessid=#SID#'; $arResult['SERVICE_URL'] = CComponentEngine::makePathFromTemplate($serviceURLTemplate, array('SID' => $sid)); $arResult['UPLOAD_URL'] = CCrmUrlUtil::ToAbsoluteUrl(CComponentEngine::makePathFromTemplate('#SITE_DIR#mobile/crm/company/file.php?id=#ID#&sessid=#SID#', array('SID' => $sid, 'ID' => $entityID))); // CONTEXT_ID --> $contextID = isset($arParams['CONTEXT_ID']) ? $arParams['CONTEXT_ID'] : ''; if ($contextID === '' && isset($_REQUEST['context_id'])) { $contextID = $_REQUEST['context_id']; } if ($contextID === '') { $contextID = "{$uid}_{$entityID}"; } $arResult['CONTEXT_ID'] = $arParams['CONTEXT_ID'] = $contextID; //<-- CONTEXT_ID // ENABLE_CONTACT --> if (isset($arParams['ENABLE_CONTACT'])) { $arResult['ENABLE_CONTACT'] = (bool) $arParams['ENABLE_CONTACT']; } else { $arResult['ENABLE_CONTACT'] = !isset($_REQUEST['enable_contact']) || $_REQUEST['enable_contact'] !== 'N';
public static function findByPhoneNumber($number, $params = array()) { if (!is_string($number)) { throw new \Bitrix\Main\ArgumentTypeException('number', 'string'); } if ($number === '') { throw new \Bitrix\Main\ArgumentException('Is empty', 'number'); } if (!is_array($params)) { $params = array(); } $userID = isset($params['USER_ID']) ? intval($params['USER_ID']) : 0; if ($userID <= 0) { $userID = CCrmPerms::GetCurrentUserID(); } $isAdmin = CCrmPerms::IsAdmin($userID); $userPermissions = CCrmPerms::GetUserPermissions($userID); $enableExtendedMode = isset($params['ENABLE_EXTENDED_MODE']) ? (bool) $params['ENABLE_EXTENDED_MODE'] : true; $contactFormID = isset($params['CONTACT_FORM_ID']) ? intval($params['CONTACT_FORM_ID']) : ''; if ($contactFormID === '') { $contactFormID = CCrmContact::DEFAULT_FORM_ID; } $dups = array(); $criterion = new \Bitrix\Crm\Integrity\DuplicateCommunicationCriterion('PHONE', $number); $entityTypes = array(CCrmOwnerType::Contact, CCrmOwnerType::Company, CCrmOwnerType::Lead); foreach ($entityTypes as $entityType) { $duplicate = $criterion->find($entityType, 1); if ($duplicate !== null) { $dups[] = $duplicate; } } $entityByType = array(); foreach ($dups as &$dup) { /** @var \Bitrix\Crm\Integrity\Duplicate $dup */ $entities = $dup->getEntities(); if (!(is_array($entities) && !empty($entities))) { continue; } //Each entity type limited by 50 items foreach ($entities as &$entity) { /** @var \Bitrix\Crm\Integrity\DuplicateEntity $entity */ $entityTypeID = $entity->getEntityTypeID(); $entityID = $entity->getEntityID(); $fields = null; if ($entityTypeID === CCrmOwnerType::Contact) { $dbEntity = CCrmContact::GetListEx(array(), array('=ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'PHOTO', 'POST', 'COMPANY_ID', 'COMPANY_TITLE', 'ASSIGNED_BY_ID')); $entityFields = is_object($dbEntity) ? $dbEntity->Fetch() : null; if (is_array($entityFields)) { $formattedName = CCrmContact::PrepareFormattedName(array('HONORIFIC' => isset($entityFields['HONORIFIC']) ? $entityFields['HONORIFIC'] : '', 'NAME' => isset($entityFields['NAME']) ? $entityFields['NAME'] : '', 'SECOND_NAME' => isset($entityFields['SECOND_NAME']) ? $entityFields['SECOND_NAME'] : '', 'LAST_NAME' => isset($entityFields['LAST_NAME']) ? $entityFields['LAST_NAME'] : '')); $fields = array('ID' => intval($entityFields['ID']), 'FORMATTED_NAME' => $formattedName, 'PHOTO' => isset($entityFields['PHOTO']) ? intval($entityFields['PHOTO']) : 0, 'COMPANY_ID' => isset($entityFields['COMPANY_ID']) ? intval($entityFields['COMPANY_ID']) : 0, 'COMPANY_TITLE' => isset($entityFields['COMPANY_TITLE']) ? $entityFields['COMPANY_TITLE'] : '', 'POST' => isset($entityFields['POST']) ? $entityFields['POST'] : '', 'ASSIGNED_BY_ID' => isset($entityFields['ASSIGNED_BY_ID']) ? intval($entityFields['ASSIGNED_BY_ID']) : 0, 'CAN_READ' => CCrmContact::CheckReadPermission($entityID, $userPermissions)); if ($fields['CAN_READ'] && $enableExtendedMode) { $deals = array(); $dbDeal = CCrmDeal::GetListEx(array('BEGINDATE' => 'ASC'), array('=CONTACT_ID' => $entityID, 'CLOSED' => 'N', 'CHECK_PERMISSIONS' => $isAdmin ? 'N' : 'Y'), false, array('nTopCount' => 2), array('ID', 'TITLE', 'STAGE_ID'), array('PERMS' => $userPermissions)); if (is_object($dbDeal)) { while ($dealFields = $dbDeal->Fetch()) { $dealID = intval($dealFields['ID']); //$dealFields['CAN_READ'] = CCrmDeal::CheckReadPermission($dealID, $userPermissions); $dealFields['SHOW_URL'] = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Deal, $dealID); $deals[] = $dealFields; } } $fields['DEALS'] =& $deals; unset($deals); } } } elseif ($entityTypeID === CCrmOwnerType::Company) { $dbEntity = CCrmCompany::GetListEx(array(), array('=ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'TITLE', 'LOGO', 'ASSIGNED_BY_ID')); $entityFields = is_object($dbEntity) ? $dbEntity->Fetch() : null; if (is_array($entityFields)) { $fields = array('ID' => intval($entityFields['ID']), 'TITLE' => isset($entityFields['TITLE']) ? $entityFields['TITLE'] : '', 'LOGO' => isset($entityFields['LOGO']) ? intval($entityFields['LOGO']) : 0, 'ASSIGNED_BY_ID' => isset($entityFields['ASSIGNED_BY_ID']) ? intval($entityFields['ASSIGNED_BY_ID']) : 0, 'CAN_READ' => CCrmCompany::CheckReadPermission($entityID, $userPermissions)); if ($fields['CAN_READ'] && $enableExtendedMode) { $deals = array(); $dbDeal = CCrmDeal::GetListEx(array('BEGINDATE' => 'ASC'), array('=COMPANY_ID' => $entityID, 'CLOSED' => 'N', 'CHECK_PERMISSIONS' => $isAdmin ? 'N' : 'Y'), false, array('nTopCount' => 2), array('ID', 'TITLE', 'STAGE_ID'), array('PERMS' => $userPermissions)); if (is_object($dbDeal)) { while ($dealFields = $dbDeal->Fetch()) { $dealID = intval($dealFields['ID']); //$dealFields['CAN_READ'] = CCrmDeal::CheckReadPermission($dealID, $userPermissions); $dealFields['SHOW_URL'] = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Deal, $dealID); $deals[] = $dealFields; } } $fields['DEALS'] =& $deals; unset($deals); } } } elseif ($entityTypeID === CCrmOwnerType::Lead) { $dbEntity = CCrmLead::GetListEx(array(), array('=ID' => $entityID, 'CHECK_PERMISSIONS' => 'N'), false, false, array('ID', 'TITLE', 'HONORIFIC', 'NAME', 'SECOND_NAME', 'LAST_NAME', 'POST', 'COMPANY_TITLE', 'ASSIGNED_BY_ID')); $entityFields = is_object($dbEntity) ? $dbEntity->Fetch() : null; if (is_array($entityFields)) { $formattedName = ''; if (!empty($entityFields['NAME']) || !empty($entityFields['SECOND_NAME']) || !empty($entityFields['LAST_NAME'])) { $formattedName = CCrmLead::PrepareFormattedName(array('HONORIFIC' => isset($entityFields['HONORIFIC']) ? $entityFields['HONORIFIC'] : '', 'NAME' => isset($entityFields['NAME']) ? $entityFields['NAME'] : '', 'SECOND_NAME' => isset($entityFields['SECOND_NAME']) ? $entityFields['SECOND_NAME'] : '', 'LAST_NAME' => isset($entityFields['LAST_NAME']) ? $entityFields['LAST_NAME'] : '')); } $fields = array('ID' => intval($entityFields['ID']), 'TITLE' => isset($entityFields['TITLE']) ? $entityFields['TITLE'] : '', 'FORMATTED_NAME' => $formattedName, 'COMPANY_TITLE' => isset($entityFields['COMPANY_TITLE']) ? $entityFields['COMPANY_TITLE'] : '', 'POST' => isset($entityFields['POST']) ? $entityFields['POST'] : '', 'ASSIGNED_BY_ID' => isset($entityFields['ASSIGNED_BY_ID']) ? intval($entityFields['ASSIGNED_BY_ID']) : 0, 'CAN_READ' => CCrmLead::CheckReadPermission($entityID, $userPermissions)); } } if (!is_array($fields)) { continue; } if ($fields['CAN_READ'] && $enableExtendedMode) { $showUrl = $fields['SHOW_URL'] = CCrmOwnerType::GetShowUrl($entityTypeID, $entityID); if ($showUrl !== '') { $fields['ACTIVITY_LIST_URL'] = CCrmUrlUtil::AddUrlParams($showUrl, array("{$contactFormID}_active_tab" => 'tab_activity')); $fields['INVOICE_LIST_URL'] = CCrmUrlUtil::AddUrlParams($showUrl, array("{$contactFormID}_active_tab" => 'tab_invoice')); if ($entityTypeID === CCrmOwnerType::Contact || $entityTypeID === CCrmOwnerType::Company) { $fields['DEAL_LIST_URL'] = CCrmUrlUtil::AddUrlParams($showUrl, array("{$contactFormID}_active_tab" => 'tab_deal')); } } $activities = array(); $dbActivity = CCrmActivity::GetList(array('DEADLINE' => 'ASC'), array('COMPLETED' => 'N', 'BINDINGS' => array(array('OWNER_TYPE_ID' => $entityTypeID, 'OWNER_ID' => $entityID)), 'CHECK_PERMISSIONS' => $isAdmin ? 'N' : 'Y'), false, array('nTopCount' => 4), array('ID', 'SUBJECT', 'START_TIME', 'END_TIME', 'DEADLINE'), array('PERMS' => $userPermissions)); if (is_object($dbActivity)) { while ($activityFields = $dbActivity->Fetch()) { $activityFields['SHOW_URL'] = CCrmOwnerType::GetShowUrl(CCrmOwnerType::Activity, $activityFields['ID']); $activities[] =& $activityFields; unset($activityFields); } } $fields['ACTIVITIES'] =& $activities; unset($activities); } $entityTypeName = CCrmOwnerType::ResolveName($entityTypeID); if (!isset($entityByType[$entityTypeName])) { $entityByType[$entityTypeName] = array($fields); } elseif (!in_array($entityID, $entityByType[$entityTypeName], true)) { $entityByType[$entityTypeName][] = $fields; } } } unset($dup); return $entityByType; }
} else { if ($arProps[$currentKey]['PROPERTY_TYPE'] === 'L' && $arProps[$currentKey]['USER_TYPE'] === '') { $propValueHash = md5($data); if (!isset($arPropertyListCache[$propID])) { $arPropertyListCache[$propID] = array(); $propEnumRes = CIBlockPropertyEnum::GetList(array('SORT' => 'ASC', 'VALUE' => 'ASC'), array('IBLOCK_ID' => $catalogID, 'PROPERTY_ID' => $propID)); while ($propEnumValue = $propEnumRes->Fetch()) { $arPropertyListCache[$propID][md5($propEnumValue['VALUE'])] = $propEnumValue['ID']; } } if (isset($arPropertyListCache[$propID][$propValueHash])) { $prop = array('VALUE' => $arPropertyListCache[$propID][$propValueHash]); } } else { if ($arProps[$currentKey]['PROPERTY_TYPE'] === 'F' && $arProps[$currentKey]['USER_TYPE'] === '') { if (CCrmUrlUtil::HasScheme($data) && CCrmUrlUtil::IsSecureUrl($data)) { $data = CFile::MakeFileArray($data); $file = new CFile(); if (is_array($data) && strlen($file->CheckFile($data)) === 0) { $prop = array('VALUE' => array_merge($data, array('MODULE_ID' => 'crm'))); } unset($file); } } else { if ($arProps[$currentKey]['PROPERTY_TYPE'] === 'S' && $arProps[$currentKey]['USER_TYPE'] === 'HTML') { if (strtoupper(substr($data, 0, 6)) !== '[TEXT]') { if ($sanitizer === null || !$sanitizer instanceof CBXSanitizer) { $sanitizer = new CBXSanitizer(); $sanitizer->ApplyDoubleEncode(false); $sanitizer->SetLevel(CBXSanitizer::SECURE_LEVEL_LOW); }
private static function SynchronizeLiveFeedEvent($invoiceID, $params) { $invoiceID = intval($invoiceID); if ($invoiceID <= 0) { return; } if (!is_array($params)) { $params = array(); } $processParents = isset($params['PROCESS_PARENTS']) ? (bool) $params['PROCESS_PARENTS'] : false; $parents = isset($params['PARENTS']) && is_array($params['PARENTS']) ? $params['PARENTS'] : array(); $hasParents = !empty($parents); if ($processParents) { CCrmSonetRelation::UnRegisterRelationsByEntity(CCrmOwnerType::Invoice, $invoiceID, array('QUICK' => $hasParents)); } $userID = CCrmSecurityHelper::GetCurrentUserID(); $startResponsibleID = isset($params['START_RESPONSIBLE_ID']) ? intval($params['START_RESPONSIBLE_ID']) : 0; $finalResponsibleID = isset($params['FINAL_RESPONSIBLE_ID']) ? intval($params['FINAL_RESPONSIBLE_ID']) : 0; $enableMessages = ($startResponsibleID > 0 || $finalResponsibleID > 0) && IsModuleInstalled('im') && CModule::IncludeModule('im'); $topic = isset($params['TOPIC']) ? $params['TOPIC'] : $invoiceID; $slEntities = CCrmLiveFeed::GetLogEvents(array(), array('ENTITY_TYPE_ID' => CCrmOwnerType::Invoice, 'ENTITY_ID' => $invoiceID), array('ID', 'EVENT_ID')); foreach ($slEntities as &$slEntity) { $slID = intval($slEntity['ID']); $slEventType = $slEntity['EVENT_ID']; if (isset($params['REFRESH_DATE']) ? (bool) $params['REFRESH_DATE'] : false) { //Update LOG_UPDATE for force event to rise in global feed //Update LOG_DATE for force event to rise in entity feed global $DB; CCrmLiveFeed::UpdateLogEvent($slID, array('=LOG_UPDATE' => $DB->CurrentTimeFunction(), '=LOG_DATE' => $DB->CurrentTimeFunction())); } else { //HACK: FAKE UPDATE FOR INVALIDATE CACHE CCrmLiveFeed::UpdateLogEvent($slID, array('ENTITY_TYPE_ID' => CCrmOwnerType::Invoice, 'ENTITY_ID' => $invoiceID)); } if ($processParents && $hasParents) { CCrmSonetRelation::RegisterRelationBundle($slID, $slEventType, CCrmOwnerType::Invoice, $invoiceID, $parents, array('TYPE_ID' => CCrmSonetRelationType::Ownership)); } if ($enableMessages) { $messageFields = array('MESSAGE_TYPE' => IM_MESSAGE_SYSTEM, 'FROM_USER_ID' => $userID, 'NOTIFY_TYPE' => IM_NOTIFY_FROM, 'NOTIFY_MODULE' => 'crm', 'LOG_ID' => $slID, 'NOTIFY_EVENT' => 'invoice_responsible_changed', 'NOTIFY_TAG' => "CRM|INVOICE|{$invoiceID}"); $eventUrl = CCrmLiveFeed::GetShowUrl($slID); if ($startResponsibleID > 0 && $startResponsibleID !== $userID) { $messageFields['TO_USER_ID'] = $startResponsibleID; $messageFields['NOTIFY_MESSAGE'] = GetMessage('CRM_INVOICE_NOT_RESPONSIBLE_IM_NOTIFY', array('#title#' => '<a href="' . htmlspecialcharsbx($eventUrl) . '">' . htmlspecialcharsbx($topic) . '</a>')); $messageFields['NOTIFY_MESSAGE_OUT'] = GetMessage('CRM_INVOICE_NOT_RESPONSIBLE_IM_NOTIFY', array('#title#' => htmlspecialcharsbx($topic))) . " (" . CCrmUrlUtil::ToAbsoluteUrl($eventUrl) . ")"; CIMNotify::Add($messageFields); } if ($finalResponsibleID > 0 && $finalResponsibleID !== $userID) { $messageFields['TO_USER_ID'] = $finalResponsibleID; $messageFields['NOTIFY_MESSAGE'] = GetMessage('CRM_INVOICE_RESPONSIBLE_IM_NOTIFY', array('#title#' => '<a href="' . htmlspecialcharsbx($eventUrl) . '">' . htmlspecialcharsbx($topic) . '</a>')); $messageFields['NOTIFY_MESSAGE_OUT'] = GetMessage('CRM_INVOICE_RESPONSIBLE_IM_NOTIFY', array('#title#' => htmlspecialcharsbx($topic))) . " (" . CCrmUrlUtil::ToAbsoluteUrl($eventUrl) . ")"; CIMNotify::Add($messageFields); } } } unset($slEntity); }
} if ($arParams['TYPE'] === 'list') { if ($bAdd) { $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_CONTACT_ADD'), 'TITLE' => GetMessage('CRM_CONTACT_ADD_TITLE'), 'LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_EDIT'], array('contact_id' => 0)), 'HIGHLIGHT' => true); } if ($bImport) { $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_CONTACT_IMPORT_VCARD'), 'TITLE' => GetMessage('CRM_CONTACT_IMPORT_VCARD_TITLE'), 'LINK' => CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_IMPORTVCARD'], array()), 'ICON' => 'btn-import'); $importUrl = CComponentEngine::MakePathFromTemplate($arParams['PATH_TO_CONTACT_IMPORT'], array()); $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_CONTACT_IMPORT_GMAIL'), 'TITLE' => GetMessage('CRM_CONTACT_IMPORT_GMAIL_TITLE'), 'LINK' => CCrmUrlUtil::AddUrlParams($importUrl, array('origin' => 'gmail')), 'ICON' => 'btn-import'); $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_CONTACT_IMPORT_OUTLOOK'), 'TITLE' => GetMessage('CRM_CONTACT_IMPORT_OUTLOOK_TITLE'), 'LINK' => CCrmUrlUtil::AddUrlParams($importUrl, array('origin' => 'outlook')), 'ICON' => 'btn-import'); if (LANGUAGE_ID === 'ru' || LANGUAGE_ID === 'ua') { $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_CONTACT_IMPORT_YANDEX'), 'TITLE' => GetMessage('CRM_CONTACT_IMPORT_YANDEX_TITLE'), 'LINK' => CCrmUrlUtil::AddUrlParams($importUrl, array('origin' => 'yandex')), 'ICON' => 'btn-import'); } $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_CONTACT_IMPORT_YAHOO'), 'TITLE' => GetMessage('CRM_CONTACT_IMPORT_YAHOO_TITLE'), 'LINK' => CCrmUrlUtil::AddUrlParams($importUrl, array('origin' => 'yahoo')), 'ICON' => 'btn-import'); if (LANGUAGE_ID === 'ru' || LANGUAGE_ID === 'ua') { $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_CONTACT_IMPORT_MAILRU'), 'TITLE' => GetMessage('CRM_CONTACT_IMPORT_MAILRU_TITLE'), 'LINK' => CCrmUrlUtil::AddUrlParams($importUrl, array('origin' => 'mailru')), 'ICON' => 'btn-import'); } /* * LIVEMAIL is temporary disabled due to implementation error * $arResult['BUTTONS'][] = array( * 'TEXT' => GetMessage('CRM_CONTACT_IMPORT_LIVEMAIL'), * 'TITLE' => GetMessage('CRM_CONTACT_IMPORT_LIVEMAIL_TITLE'), * 'LINK' => CCrmUrlUtil::AddUrlParams($importUrl, array('origin' => 'livemail')), * 'ICON' => 'btn-import' );*/ $arResult['BUTTONS'][] = array('TEXT' => GetMessage('CRM_CONTACT_IMPORT_CUSTOM'), 'TITLE' => GetMessage('CRM_CONTACT_IMPORT_CUSTOM_TITLE'), 'LINK' => $importUrl, 'ICON' => 'btn-import', 'MENU' => array(array('TITLE' => 'X', 'TEXT' => 'X', 'ONCLICK' => 'alert();'))); } if ($bExport) { if ($bImport) { $arResult['BUTTONS'][] = array('SEPARATOR' => true); }
public static function PrepareStorageElementInfo(&$arFields) { $storageTypeID = isset($arFields['STORAGE_TYPE_ID']) ? (int) $arFields['STORAGE_TYPE_ID'] : StorageType::Undefined; if (!StorageType::IsDefined($storageTypeID)) { $storageTypeID = self::GetDefaultStorageTypeID(); } $storageElementIDs = isset($arFields['STORAGE_ELEMENT_IDS']) && is_array($arFields['STORAGE_ELEMENT_IDS']) ? $arFields['STORAGE_ELEMENT_IDS'] : array(); if ($storageTypeID === StorageType::File) { $arFields['FILES'] = array(); foreach ($storageElementIDs as $fileID) { $arData = CFile::GetFileArray($fileID); if (is_array($arData)) { $arFields['FILES'][] = array('fileID' => $arData['ID'], 'fileName' => $arData['FILE_NAME'], 'fileURL' => CCrmUrlUtil::UrnEncode($arData['SRC']), 'fileSize' => $arData['FILE_SIZE']); } } } elseif ($storageTypeID === StorageType::WebDav || $storageTypeID === StorageType::Disk) { $infos = array(); foreach ($storageElementIDs as $elementID) { $infos[] = StorageManager::getFileInfo($elementID, $storageTypeID); } $arFields[$storageTypeID === StorageType::Disk ? 'DISK_FILES' : 'WEBDAV_ELEMENTS'] =& $infos; unset($infos); } }
if (!empty($arResult["RECORDS"]) && is_array($arResult["RECORDS"])) { ?> <div class="crm-feed-deal-description"> <div class="crm-feed-deal-descr-title"><?php echo GetMessage("C_T_CRM_LFA_RECORDS"); ?> :</div> <div class="crm-feed-deal-descr-text"><?php $cnt = 0; foreach ($arResult["RECORDS"] as $key => $arRecord) { ?> <div style="padding-top: <?php echo !$cnt ? "0" : "10"; ?> px;"><?php $APPLICATION->IncludeComponent("bitrix:player", "", array("PLAYER_TYPE" => "flv", "CHECK_FILE" => $arParams["ACTIVITY"]["STORAGE_TYPE_ID"] == CCrmActivityStorageType::WebDav ? "N" : "Y", "USE_PLAYLIST" => "N", "PATH" => CCrmUrlUtil::ToAbsoluteUrl($arRecord["URL"]), "WIDTH" => 398, "HEIGHT" => 24, "PREVIEW" => false, "LOGO" => false, "FULLSCREEN" => "N", "SKIN_PATH" => "/bitrix/components/bitrix/player/mediaplayer/skins", "SKIN" => "", "CONTROLBAR" => "bottom", "WMODE" => "transparent", "WMODE_WMV" => "windowless", "HIDE_MENU" => "N", "SHOW_CONTROLS" => "Y", "SHOW_STOP" => "N", "SHOW_DIGITS" => "Y", "CONTROLS_BGCOLOR" => "FFFFFF", "CONTROLS_COLOR" => "000000", "CONTROLS_OVER_COLOR" => "000000", "SCREEN_COLOR" => "000000", "AUTOSTART" => "N", "REPEAT" => "N", "VOLUME" => "90", "DISPLAY_CLICK" => "play", "MUTE" => "N", "HIGH_QUALITY" => "N", "ADVANCED_MODE_SETTINGS" => "Y", "BUFFER_LENGTH" => "10", "DOWNLOAD_LINK" => false, "DOWNLOAD_LINK_TARGET" => "_self", "ALLOW_SWF" => "N", "ADDITIONAL_PARAMS" => array('LOGO' => false, 'NUM' => false, 'HEIGHT_CORRECT' => false), "PLAYER_ID" => "bitrix_crm_activity_" . $arParams["ACTIVITY"]["ID"] . "_" . $key), false, array("HIDE_ICONS" => "Y")); ?> </div><?php $cnt++; } ?> </div> </div><?php } if (!empty($arResult["DESCRIPTION"])) { ?> <div class="crm-feed-deal-description"> <div class="crm-feed-deal-descr-title"><?php echo GetMessage("C_T_CRM_LFA_DESCRIPTION"); ?> :</div>
public function Add($data) { if (($r = self::CheckAuth()) !== false) { return $r; } $arFieldsInfo = CCrmContact::GetFields(); $arFields = array(); $arEl = $data->elementsByName('Field'); foreach ($arEl as $el) { $children = $el->children(); $sFieldName = $el->getAttribute('id'); // Fix for issue #40193 if (!isset($arFieldsInfo[$sFieldName])) { continue; } if (!is_null($children)) { $arFields[$sFieldName] = array(); foreach ($children as $child) { $arFields[$sFieldName][] = $child->content; } } else { $arFields[$sFieldName] = $el->content; } } CCrmFieldMulti::PrepareFields($arFields); if (isset($arFields['PHOTO'])) { $arFile = null; if (CCrmUrlUtil::HasScheme($arFields['PHOTO']) && CCrmUrlUtil::IsSecureUrl($arFields['PHOTO'])) { $arFile = CFile::MakeFileArray($arFields['PHOTO']); if (is_array($arFile)) { $arFile += array('MODULE_ID' => 'crm'); } } if (is_array($arFile)) { $arFields['PHOTO'] = $arFile; } else { unset($arFields['PHOTO']); } } $arUserFields = $GLOBALS['USER_FIELD_MANAGER']->GetUserFields(CCrmContact::$sUFEntityID); foreach ($arUserFields as $FIELD_NAME => $arUserField) { if ($arUserField['USER_TYPE']['BASE_TYPE'] == 'file') { if (!isset($arFields[$FIELD_NAME])) { continue; } if (is_array($arFields[$FIELD_NAME])) { $arFiles = array(); foreach ($arFields[$FIELD_NAME] as $sFilePath) { if (!(CCrmUrlUtil::HasScheme($sFilePath) && CCrmUrlUtil::IsSecureUrl($sFilePath))) { continue; } $arFile = CFile::MakeFileArray($sFilePath); if (is_array($arFile)) { $arFile += array('MODULE_ID' => 'crm'); $arFiles[] = $arFile; } } $arFields[$FIELD_NAME] = $arFiles; } else { $arFile = null; $sFilePath = $arFields[$FIELD_NAME]; if (CCrmUrlUtil::HasScheme($sFilePath) && CCrmUrlUtil::IsSecureUrl($sFilePath)) { $arFile = CFile::MakeFileArray($sFilePath); if (is_array($arFile)) { $arFile += array('MODULE_ID' => 'crm'); } } if (is_array($arFile)) { $arFields[$FIELD_NAME] = $arFile; } else { unset($arFields[$FIELD_NAME]); } } } } $CCrmContact = new CCrmContact(); return $CCrmContact->Add($arFields) ? 'ok' : new CSoapFault('CCrmLead::Add', htmlspecialcharsbx(strip_tags(nl2br($arFields['RESULT_MESSAGE'])))); }
public static function getFileInfo($fileID, $checkPermissions = true, $options = null) { if (!Loader::includeModule('disk')) { return null; } $fileID = (int) $fileID; if ($fileID <= 0) { return null; } /** @var File $file */ $file = File::loadById($fileID); if (!$file) { return null; } if (!is_array($options)) { $options = array(); } $ownerID = isset($options['OWNER_ID']) ? $options['OWNER_ID'] : 0; $ownerTypeID = isset($options['OWNER_TYPE_ID']) ? $options['OWNER_TYPE_ID'] : \CCrmOwnerType::Undefined; $canRead = true; $viewUrl = ''; if ($ownerID > 0 && \CCrmOwnerType::isDefined($ownerTypeID)) { $viewUrlParams = array('fileId' => $fileID, 'ownerTypeId' => $ownerTypeID, 'ownerId' => $ownerID); if (isset($options['VIEW_PARAMS']) && is_array($options['VIEW_PARAMS'])) { $viewUrlParams = array_merge($viewUrlParams, $options['VIEW_PARAMS']); } $viewUrl = \CHTTP::urlAddParams('/bitrix/tools/crm_show_file.php', $viewUrlParams); if (isset($options['USE_ABSOLUTE_PATH']) && $options['USE_ABSOLUTE_PATH']) { $viewUrl = \CCrmUrlUtil::ToAbsoluteUrl($viewUrl); } } elseif ($checkPermissions) { $canRead = $file->canRead($file->getStorage()->getSecurityContext(\CCrmSecurityHelper::getCurrentUserID())); if ($canRead) { $viewUrl = Driver::getInstance()->getUrlManager()->getUrlForDownloadFile($file); } } return array('ID' => $fileID, 'NAME' => $file->getName(), 'SIZE' => \CFile::FormatSize($file->getSize()), 'CAN_READ' => $canRead, 'VIEW_URL' => $viewUrl); }
public static function Notify(&$arFields, $schemeTypeID, $tag = '') { if (!is_array($arFields)) { return false; } $responsibleID = $arFields['RESPONSIBLE_ID'] ? intval($arFields['RESPONSIBLE_ID']) : 0; if ($responsibleID <= 0) { return false; } if ($schemeTypeID === CCrmNotifierSchemeType::IncomingEmail) { $showUrl = CCrmOwnerType::GetShowUrl($arFields['OWNER_TYPE_ID'] ? intval($arFields['OWNER_TYPE_ID']) : 0, $arFields['OWNER_ID'] ? intval($arFields['OWNER_ID']) : 0); if ($showUrl === '') { return false; } $subject = isset($arFields['SUBJECT']) ? $arFields['SUBJECT'] : ''; $addresserHtml = ''; $communications = isset($arFields['COMMUNICATIONS']) ? $arFields['COMMUNICATIONS'] : array(); if (!empty($communications)) { $comm = $communications[0]; $caption = ''; if (isset($comm['ENTITY_TYPE_ID']) && isset($comm['ENTITY_ID'])) { $caption = CCrmOwnerType::GetCaption($comm['ENTITY_TYPE_ID'], $comm['ENTITY_ID']); } if ($caption === '') { $caption = $comm['VALUE']; } $addresserShowUrl = CCrmOwnerType::GetShowUrl($comm['ENTITY_TYPE_ID'], $comm['ENTITY_ID']); $addresserHtml = $addresserShowUrl !== '' ? '<a target="_blank" href="' . htmlspecialcharsbx($addresserShowUrl) . '">' . htmlspecialcharsbx($caption) . '</a>' : htmlspecialcharsbx($caption); } if ($addresserHtml === '') { $messageTemplate = GetMessage('CRM_ACTIVITY_NOTIFY_MESSAGE_INCOMING_EMAIL'); return CCrmNotifier::Notify($responsibleID, str_replace('#VIEW_URL#', htmlspecialcharsbx($showUrl), $messageTemplate), str_replace('#VIEW_URL#', htmlspecialcharsbx(CCrmUrlUtil::ToAbsoluteUrl($showUrl)), $messageTemplate), $schemeTypeID, $tag); } $messageTemplate = GetMessage('CRM_ACTIVITY_NOTIFY_MESSAGE_INCOMING_EMAIL_EXT'); return CCrmNotifier::Notify($responsibleID, str_replace(array('#VIEW_URL#', '#SUBJECT#', '#ADDRESSER#'), array(htmlspecialcharsbx($showUrl), htmlspecialcharsbx($subject), $addresserHtml), $messageTemplate), str_replace(array('#VIEW_URL#', '#SUBJECT#', '#ADDRESSER#'), array(htmlspecialcharsbx(CCrmUrlUtil::ToAbsoluteUrl($showUrl)), htmlspecialcharsbx($subject), $addresserHtml), $messageTemplate), $schemeTypeID, $tag); } return false; }
public static function TryResolveFile(&$path, &$file, $arOptions = array()) { $result = null; if (is_numeric($path)) { if (is_array($arOptions) && isset($arOptions['ENABLE_ID']) && $arOptions['ENABLE_ID']) { $result = CFile::MakeFileArray($path); } } elseif (is_string($path)) { $absPath = CCrmUrlUtil::ToAbsoluteUrl($path); //Parent directories and not secure URLs are not allowed. if ($absPath !== '' && preg_match('/[\\/,\\\\]\\.\\.[\\/,\\\\]/', $absPath) !== 1 && CCrmUrlUtil::IsSecureUrl($absPath)) { $result = CFile::MakeFileArray($absPath); } } if (is_array($result)) { $result['MODULE_ID'] = 'crm'; $file = $result; return true; } return false; }