public static function filterFiles(array $fileIDs, $storageTypeID, $userID = 0) { if (!is_integer($storageTypeID)) { $storageTypeID = (int) $storageTypeID; } $result = array(); if ($storageTypeID === StorageType::WebDav) { foreach ($fileIDs as $fileID) { if (\CCrmWebDavHelper::CheckElementReadPermission($fileID, $userID)) { $result[] = $fileID; } } } elseif ($storageTypeID === StorageType::Disk) { foreach ($fileIDs as $fielID) { if (DiskManager::checkFileReadPermission($fielID, $userID)) { $result[] = $fielID; } } } elseif ($storageTypeID === StorageType::File) { $result = $fileIDs; } return $result; }
$componentSettings['ENABLE_TAX'] = $productRowSettings['ENABLE_TAX'] ? 'Y' : 'N'; } } ob_start(); $APPLICATION->IncludeComponent('bitrix:crm.product_row.list', '', $componentSettings, false, array('HIDE_ICONS' => 'Y', 'ACTIVE_COMPONENT' => 'Y')); $sProductsHtml .= ob_get_contents(); ob_end_clean(); unset($componentSettings); $arResult['FIELDS']['tab_1'][] = array('id' => 'PRODUCT_ROWS', 'name' => GetMessage('CRM_QUOTE_FIELD_PRODUCT_ROWS'), 'colspan' => true, 'type' => 'vertical_container', 'value' => $sProductsHtml); $arResult['FIELDS']['tab_1'][] = array('id' => 'section_additional', 'name' => GetMessage('CRM_SECTION_ADDITIONAL'), 'type' => 'section'); $arResult['FIELDS']['tab_1'][] = array('id' => 'COMMENTS', 'name' => GetMessage('CRM_QUOTE_FIELD_COMMENTS'), 'params' => array(), 'type' => 'lhe', 'componentParams' => array('inputName' => 'COMMENTS', 'inputId' => 'COMMENTS', 'height' => '180', 'content' => isset($arResult['ELEMENT']['~COMMENTS']) ? $arResult['ELEMENT']['~COMMENTS'] : '', 'bUseFileDialogs' => false, 'bFloatingToolbar' => false, 'bArisingToolbar' => false, 'bResizable' => true, 'bSaveOnBlur' => true, 'toolbarConfig' => array('Bold', 'Italic', 'Underline', 'Strike', 'BackColor', 'ForeColor', 'CreateLink', 'DeleteLink', 'InsertOrderedList', 'InsertUnorderedList', 'Outdent', 'Indent'))); $icnt = count($arResult['FIELDS']['tab_1']); $CCrmUserType->AddFields($arResult['FIELDS']['tab_1'], $arResult['ELEMENT']['ID'], $arResult['FORM_ID'], $bVarsFromForm, false, false, array('FILE_URL_TEMPLATE' => "/bitrix/components/bitrix/crm.quote.show/show_file.php?ownerId=#owner_id#&fieldName=#field_name#&fileId=#file_id#")); if (count($arResult['FIELDS']['tab_1']) == $icnt) { unset($arResult['FIELDS']['tab_1'][$icnt - 1]); } if ($bCopy) { $arParams['ELEMENT_ID'] = 0; $arFields['ID'] = 0; $arResult['ELEMENT']['ID'] = 0; } if (!$arResult['ENABLE_WEBDAV']) { $arResult['WEBDAV_SELECT_URL'] = $arResult['WEBDAV_UPLOAD_URL'] = $arResult['WEBDAV_SHOW_URL'] = ''; } else { $webDavPaths = CCrmWebDavHelper::GetPaths(); $arResult['WEBDAV_SELECT_URL'] = isset($webDavPaths['PATH_TO_FILES']) ? $webDavPaths['PATH_TO_FILES'] : ''; $arResult['WEBDAV_UPLOAD_URL'] = isset($webDavPaths['ELEMENT_UPLOAD_URL']) ? $webDavPaths['ELEMENT_UPLOAD_URL'] : ''; $arResult['WEBDAV_SHOW_URL'] = isset($webDavPaths['ELEMENT_SHOW_INLINE_URL']) ? $webDavPaths['ELEMENT_SHOW_INLINE_URL'] : ''; } $this->IncludeComponentTemplate(); include_once $_SERVER['DOCUMENT_ROOT'] . '/bitrix/components/bitrix/crm.quote/include/nav.php';
protected function tryExternalizeWebDavElementField(&$fields, $fieldName, $multiple = false) { if (!isset($fields[$fieldName])) { return false; } if (!$multiple) { $elementID = intval($fields[$fieldName]); $info = CCrmWebDavHelper::GetElementInfo($elementID, false); if (empty($info)) { unset($fields[$fieldName]); return false; } else { $fields[$fieldName] = array('id' => $elementID, 'url' => isset($info['SHOW_URL']) ? $info['SHOW_URL'] : ''); return true; } } $result = array(); $elementsID = $fields[$fieldName]; if (is_array($elementsID)) { foreach ($elementsID as $elementID) { $elementID = intval($elementID); $info = CCrmWebDavHelper::GetElementInfo($elementID, false); if (empty($info)) { continue; } $result[] = array('id' => $elementID, 'url' => isset($info['SHOW_URL']) ? $info['SHOW_URL'] : ''); } } if (!empty($result)) { $fields[$fieldName] =& $result; unset($result); return true; } unset($fields[$fieldName]); return false; }
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) { $infos = array(); foreach ($storageElementIDs as $elementID) { $infos[] = \CCrmWebDavHelper::GetElementInfo($elementID, $storageTypeID); } $arFields['WEBDAV_ELEMENTS'] =& $infos; unset($infos); } elseif ($storageTypeID === StorageType::Disk) { $infos = array(); foreach ($storageElementIDs as $elementID) { $infos[] = Bitrix\Crm\Integration\DiskManager::getFileInfo($elementID, false, array('OWNER_TYPE_ID' => CCrmOwnerType::Activity, 'OWNER_ID' => $arFields['ID'])); } $arFields['DISK_FILES'] =& $infos; unset($infos); } }
private static function PrepareUrl($template, &$arElement) { if (!(IsModuleInstalled('iblock') && CModule::IncludeModule('iblock'))) { return ''; } $template = strval($template); if ($template === '' || !is_array($arElement)) { return ''; } $elementID = isset($arElement['ID']) ? intval($arElement['ID']) : 0; $elementName = isset($arElement['NAME']) ? $arElement['NAME'] : ''; $authorID = isset($arElement['CREATED_BY']) ? intval($arElement['CREATED_BY']) : 0; $navChainKey = $arElement['IBLOCK_ID'] . '_' . $arElement['IBLOCK_SECTION_ID']; if (is_array(self::$IBLOCK_SECTION_NAV_CHAINS) && isset(self::$IBLOCK_SECTION_NAV_CHAINS[$navChainKey])) { $arSection = self::$IBLOCK_SECTION_NAV_CHAINS[$navChainKey]; } else { if (self::$IBLOCK_SECTION_NAV_CHAINS === null) { self::$IBLOCK_SECTION_NAV_CHAINS = array(); } $dbNav = CIBlockSection::GetNavChain($arElement['IBLOCK_ID'], $arElement['IBLOCK_SECTION_ID']); $arSection = self::$IBLOCK_SECTION_NAV_CHAINS[$navChainKey] = is_object($dbNav) ? $dbNav->Fetch() : null; } $socnetGroupID = is_array($arSection) && isset($arSection['SOCNET_GROUP_ID']) ? intval($arSection['SOCNET_GROUP_ID']) : 0; $url = $template; $url = str_replace(array('#ELEMENT_ID#', '#element_id#', '#ID#', '#id#'), $elementID, $url); $url = str_replace(array('#ELEMENT_NAME#', '#element_name#', '#NAME#', '#name#'), $elementName, $url); $url = str_replace(array('#SOCNET_USER_ID#', '#socnet_user_id#', '#USER_ID#', '#user_id#'), $authorID, $url); $url = str_replace(array('#SOCNET_GROUP_ID#', '#socnet_group_id#', '#GROUP_ID#', '#group_id#'), $socnetGroupID, $url); $url = str_replace(array('#SOCNET_OBJECT#', '#socnet_object#'), $socnetGroupID > 0 ? 'group' : 'user', $url); $url = str_replace(array('#SOCNET_OBJECT_ID#', '#socnet_object_id#'), $socnetGroupID > 0 ? $socnetGroupID : $authorID, $url); return str_replace(array("///", "//"), "/", $url); }