- Модуль: webdav
- Путь к файлу: ~/bitrix/modules/webdav/classes/symlinkhelper.php
- Класс: CWebDavSymlinkHelper
- Вызов: CWebDavSymlinkHelper::createSymLinkSection
static function createSymLinkSection(array $sectionTargetData, array $sectionLinkData, $typeLibrary = self::ENTITY_TYPE_USER)
{
if(
empty($sectionLinkData['IBLOCK_ID']) ||
empty($sectionLinkData['ID']) ||
empty($sectionLinkData['NAME']) ||
empty($sectionLinkData['CREATED_BY'])
)
{
return false;
}
if(empty($sectionTargetData['IBLOCK_ID']) || empty($sectionTargetData['IBLOCK_SECTION_ID']))
{
return false;
}
$typeLibrary = mb_strtolower($typeLibrary);
if($typeLibrary != self::ENTITY_TYPE_USER && $typeLibrary != self::ENTITY_TYPE_GROUP && $typeLibrary != self::ENTITY_TYPE_SHARED)
{
return false;
}
if(!CWebDavTools::isIntranetUser($sectionLinkData['INVITE_USER_ID']))
{
return false;
}
$sectionTargetData = array_intersect_key($sectionTargetData, array(
'IBLOCK_ID' => true,
'IBLOCK_SECTION_ID' => true,
));
$additionalData = array(
CWebDavIblock::UF_LINK_IBLOCK_ID => $sectionLinkData['IBLOCK_ID'],
CWebDavIblock::UF_LINK_SECTION_ID => $sectionLinkData['ID'],
CWebDavIblock::UF_LINK_ROOT_SECTION_ID => self::getRootSectionId($sectionLinkData['IBLOCK_ID'], $sectionLinkData['ID'], $typeLibrary),
CWebDavIblock::UF_LINK_CAN_FORWARD => $sectionLinkData['CAN_FORWARD'],
'CREATED_BY' => $sectionLinkData['CREATED_BY'],
'MODIFIED_BY' => $sectionLinkData['CREATED_BY'],
'NAME' => $sectionLinkData['NAME'],
);
$exists = BitrixWebdavFolderInviteTable::getRow(array('filter' => array(
'INVITE_USER_ID' => $sectionLinkData['INVITE_USER_ID'],
'IBLOCK_ID' => $sectionLinkData['IBLOCK_ID'],
'SECTION_ID' => $sectionLinkData['ID'],
), 'select' => array('ID', 'LINK_SECTION_ID', 'IS_DELETED', 'IS_APPROVED')));
//rewrite old self-deleted by user invite
if($exists && !$exists['IS_DELETED'] && $exists['IS_APPROVED'])
{
return $exists['LINK_SECTION_ID'];
}
$section = new CIBlockSection();
$sectionId = $section->add(array_merge(
$sectionTargetData,
$additionalData
));
if($typeLibrary == self::ENTITY_TYPE_GROUP)
{
$inviteUserId = $sectionLinkData['CREATED_BY'];
BitrixWebdavFolderInviteTable::addIfNonExists(array(
'INVITE_USER_ID' => $sectionLinkData['CREATED_BY'],
'USER_ID' => $sectionLinkData['CREATED_BY'],
'IBLOCK_ID' => $sectionLinkData['IBLOCK_ID'],
'SECTION_ID' => $sectionLinkData['ID'],
'LINK_SECTION_ID' => $sectionId,
'IS_APPROVED' => true,
'IS_DELETED' => false,
'CAN_FORWARD' => false,
));
}
elseif($typeLibrary == self::ENTITY_TYPE_USER)
{
if($sectionId)
{
$inviteUserId = $sectionLinkData['INVITE_USER_ID'];
BitrixWebdavFolderInviteTable::addIfNonExists(array(
'INVITE_USER_ID' => $sectionLinkData['INVITE_USER_ID'],
'USER_ID' => $sectionLinkData['CREATED_BY'],
'IBLOCK_ID' => $sectionLinkData['IBLOCK_ID'],
'SECTION_ID' => $sectionLinkData['ID'],
'LINK_SECTION_ID' => $sectionId,
'IS_APPROVED' => true,
'IS_DELETED' => false,
'CAN_FORWARD' => false,
'CAN_EDIT' => $sectionLinkData['CAN_EDIT'],
));
$rightsLetter = $sectionLinkData['CAN_EDIT']? 'W' : 'R';
CWebDavIblock::appendRightsOnSections(array($sectionLinkData), array(
$rightsLetter => 'U' . $sectionLinkData['INVITE_USER_ID'],
));
}
}
if($sectionId && $inviteUserId)
{
CWebDavDiskDispatcher::sendChangeStatus($inviteUserId, 'symlink');
}
return $sectionId;
}