public static function createDownloadedFolder($iblockId, $sectionId, $userId) { $droppedMetaData = CWebDavIblock::getDroppedMetaData(); $name = self::getNameDownloadedFolder(); if (isset($droppedMetaData['alias'])) { $name = $droppedMetaData['alias']; } return self::createFolder($name, null, $iblockId, $sectionId, $userId); }
function _isDropped($iblockID, $sectionID) { if (!CModule::IncludeModule('iblock')) { return false; } $droppedName = CWebDavIblock::getDroppedMetaData(); $droppedName = isset($droppedName['name']) ? $droppedName['name'] : '.Dropped'; //set to default ".Dropped". It's unbelievable, but... $dropped = false; $dbChain = CIBlockSection::GetNavChain($iblockID, $sectionID); if ($dbChain) { if ($arChain = $dbChain->Fetch()) { if ($arChain["NAME"] == $droppedName) { $dropped = true; } else { if ($arChain = $dbChain->Fetch()) { if ($arChain["NAME"] == $droppedName) { $dropped = true; } } } } } return $dropped; }
function WDUFUserFieldEdit(&$arParams, &$arResult) { global $APPLICATION; static $userIblockID = false; static $groupIblockID = false; static $iblockOptionTypes = array("group_files", "shared_files", "user_files"); static $iblockOptions = array(); static $arIBlock = array(); static $DROPPED = null; $arResult['ELEMENTS'] = array(); $arResult['JSON'] = array(); if (!CModule::IncludeModule('webdav')) { return false; } if ($DROPPED === null) { $DROPPED = CWebDavIblock::getDroppedMetaData(); $DROPPED = $DROPPED['name']; } $arResult['controlName'] = $arParams['arUserField']['FIELD_NAME']; $arValue = $arParams['arUserField']['VALUE']; if (is_array($arValue) && sizeof($arValue) > 0) { if (empty($iblockOptions)) { foreach ($iblockOptionTypes as $type) { $arOpt = CWebDavIblock::LibOptions($type, false, SITE_ID); if (is_set($arOpt, 'id') && intval($arOpt['id']) > 0) { $iblockOptions[$type] = $arOpt['id']; } } } foreach ($arValue as $elementID) { $elementID = intval($elementID); if ($elementID <= 0) { continue; } $title = ''; $dropped = false; $dbElement = CIBlockElement::GetList(array(), array('ID' => $elementID), false, false, array('ID', 'NAME', 'IBLOCK_ID', 'IBLOCK_SECTION_ID', 'SOCNET_GROUP_ID', 'CREATED_BY')); if ($dbElement && ($arElement = $dbElement->Fetch())) { $arSectionTree = WDUGetNavChainSections($arElement['IBLOCK_ID'], $arElement['IBLOCK_SECTION_ID'], false); $dropped = false; if (sizeof($arSectionTree) > 0 && $arSectionTree[0]['NAME'] == $DROPPED) { $title = GetMessage('WD_LOCAL_COPY_ONLY'); $dropped = true; } else { $type = array_search($arElement['IBLOCK_ID'], $iblockOptions); if ($type == 'group_files') { if (sizeof($arSectionTree) > 0) { $title = $arSectionTree[0]['NAME']; } } elseif ($type == 'user_files') { if (sizeof($arSectionTree) > 1 && $arSectionTree[1]['NAME'] == $DROPPED) { $title = GetMessage('WD_LOCAL_COPY_ONLY'); $dropped = true; } elseif (sizeof($arSectionTree) > 0) { $title = GetMessage('WD_MY_LIBRARY'); /*$l = sizeof($arSectionTree); for($i = 1; $i < $l; $i++) { $title .= " / " . $arSectionTree[$i]['NAME']; }*/ } } else { if (!isset($arIBlock[$arElement['IBLOCK_ID']])) { $dbIB = CIBlock::GetList(array(), array('ID' => $arElement['IBLOCK_ID'])); if ($dbIB && ($arIB = $dbIB->Fetch())) { $arIBlock[$arElement['IBLOCK_ID']] = $arIB; } } if (isset($arIBlock[$arElement['IBLOCK_ID']])) { $title = $arIBlock[$arElement['IBLOCK_ID']]['NAME']; } } } $arElement['FILE_SIZE'] = ''; $dbSize = CIBlockElement::GetProperty($arElement['IBLOCK_ID'], $arElement['ID'], array(), array('CODE' => 'WEBDAV_SIZE')); if ($dbSize && ($arSize = $dbSize->Fetch())) { $arElement['FILE_SIZE'] = CFile::FormatSize(intval($arSize['VALUE']), 0); } $arElement['FILE'] = array(); $dbSize = CIBlockElement::GetProperty($arElement['IBLOCK_ID'], $arElement['ID'], array(), array('CODE' => 'FILE')); if ($dbSize && ($arSize = $dbSize->Fetch())) { $arElement['FILE'] = CFile::GetFileArray($arSize['VALUE']); } $arSection =& $arSectionTree[0]; $detailPath = CWebDavIblock::LibOptions('lib_paths', true, $arElement['IBLOCK_ID']); $arPaths = WDUFGetPathOptions($detailPath, $arElement['IBLOCK_ID'], $arSection, $arElement); $arElement["URL_VIEW"] = $arPaths["path"]; $arElement["URL_EDIT"] = $arPaths["edit"]; $arElement["URL_DELETE_DROPPED"] = $arPaths["delete_dropped"]; $arElement["URL_GET"] = $arPaths["history_get"]; $arElement['DROPPED'] = $dropped; $arElement['TITLE'] = $title; $arResult['ELEMENTS'][] = $arElement; } } } // need to load Options for ajax dialogs $extDir = WDUFGetExtranetDir(); if ($extDir !== '') { $groupIBlockID = CWebDavIblock::LibOptions('group_files', false, SITE_ID); if (!($groupIBlockID && isset($groupIBlockID['id']) && intval($groupIBlockID['id']) > 0)) { $arGroups = CIBlockWebdavSocnet::GetUserGroups(0, false); if (sizeof($arGroups) > 0) { $arGroup = array_pop($arGroups); $groupFilesUrl = str_replace(array("///", "//"), "/", "/" . $extDir . '/workgroups/group/' . $arGroup['GROUP_ID'] . '/files/'); $arResult['JSON'][] = $groupFilesUrl; } } } else { $sharedLibID = CWebDavIblock::LibOptions('shared_files', false, SITE_ID); if (!($sharedLibID && isset($sharedLibID['id']) && intval($sharedLibID['id']) > 0 && isset($sharedLibID['base_url']) && strlen($sharedLibID['base_url']) > 0)) { if (!(CModule::IncludeModule('extranet') && strlen(CExtranet::GetExtranetSiteID()) > 0 && SITE_ID == CExtranet::GetExtranetSiteID())) { $arResult['JSON'][] = '/docs/'; $arResult['JSON'][] = '/docs/shared/'; } } $userIBlockID = CWebDavIblock::LibOptions('user_files', false, SITE_ID); if (!($userIBlockID && isset($userIBlockID['id']) && intval($userIBlockID['id']) > 0)) { $arResult['JSON'][] = '/company/personal/user/' . $GLOBALS['USER']->GetID() . '/files/lib/'; } $groupIBlockID = CWebDavIblock::LibOptions('group_files', false, SITE_ID); if (!($groupIBlockID && isset($groupIBlockID['id']) && intval($groupIBlockID['id']) > 0)) { $arGroups = CIBlockWebdavSocnet::GetUserGroups(0, false); if (sizeof($arGroups) > 0) { $arGroup = array_pop($arGroups); $arResult['JSON'][] = '/workgroups/group/' . $arGroup['GROUP_ID'] . '/files/'; } } } }
public function getDownloadedSectionId($iblockId, $parentSectionId, array $additionalData = array()) { $metaData = CWebDavIblock::getDroppedMetaData(); $sectionId = CWebDavIblock::findMetaSection($metaData['name'], $iblockId, $parentSectionId); if (!$sectionId) { $sectionId = CWebDavIblock::createMetaSection($metaData['name'], $iblockId, $parentSectionId, $additionalData); } return $sectionId; }
while (ob_end_clean()) { true; } /** @var CWebDavIblock $ob */ $ob = $arParams['OBJECT']; if (!empty($arResult["ERROR_MESSAGE"])) { ShowError($arResult["ERROR_MESSAGE"]); } if (!empty($arResult["NOTIFY_MESSAGE"])) { ShowNote($arResult["NOTIFY_MESSAGE"]); } if (empty($arResult['ERROR_MESSAGE'])) { $title = ''; $dropped = $createdFile = false; if ($ob->_isInMeta($arResult["ELEMENT"]["ID"], "DROPPED")) { $savedMetaData = CWebDavIblock::getDroppedMetaData(); $title = GetMessage('WD_MY_LIBRARY'); $title .= ' / ' . $savedMetaData['alias']; $dropped = true; } elseif (isset($ob->attributes['user_id']) && $ob->attributes['user_id'] == $GLOBALS['USER']->GetID()) { $title = GetMessage('WD_MY_LIBRARY'); if (CIBlockWebdavSocnet::isCreatedDocFolder($ob->IBLOCK_ID, $arResult['ELEMENT']['IBLOCK_SECTION_ID'], $GLOBALS['USER']->GetID())) { $createdFile = true; $title .= ' / ' . CIBlockWebdavSocnet::getNameCreatedDocFolder(); } } elseif (isset($ob->attributes['group_id'])) { $title = $ob->arRootSection['NAME']; if ($title == GetMessage("SONET_GROUP_PREFIX")) { $arGroup = CSocNetGroup::GetByID($ob->attributes['group_id']); $title = GetMessage("SONET_GROUP_PREFIX") . $arGroup['NAME']; }