本文整理汇总了PHP中CIBlockSection::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CIBlockSection::add方法的具体用法?PHP CIBlockSection::add怎么用?PHP CIBlockSection::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CIBlockSection
的用法示例。
在下文中一共展示了CIBlockSection::add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRootSectionIdForUser
public static function getRootSectionIdForUser($iblockId, $userId)
{
global $USER_FIELD_MANAGER;
global $UF_USE_BP;
$result = CIBlockWebdavSocnet::getSectionId($iblockId, 'user', $userId);
if (($result = intval($result)) > 0) {
return $result;
}
$fields = array('IBLOCK_ID' => $iblockId, 'ACTIVE' => 'Y', 'SOCNET_GROUP_ID' => false, 'IBLOCK_SECTION_ID' => 0, 'UF_USE_BP' => 'N', 'UF_USE_EXT_SERVICES' => CWebDavIblock::resolveDefaultUseExtServices());
$user = CUser::getById($userId)->fetch();
if (empty($user)) {
return false;
}
$fields['NAME'] = trim($user['LAST_NAME'] . ' ' . $user['FIRST_NAME']);
$fields['NAME'] = trim(!empty($fields["NAME"]) ? $fields['NAME'] : $user['LOGIN']);
$fields['CREATED_BY'] = $user['ID'];
$fields['MODIFIED_BY'] = $user['ID'];
if (CIBlock::GetArrayByID($iblockId, "RIGHTS_MODE") === "E") {
$tasks = CWebDavIblock::GetTasks();
$fields['RIGHTS'] = array('n0' => array('GROUP_CODE' => 'U' . $userId, 'TASK_ID' => $tasks['X']));
}
$UF_USE_BP = $fields['UF_USE_BP'];
$USER_FIELD_MANAGER->editFormAddFields('IBLOCK_' . $iblockId . '_SECTION', $fields);
$section = new CIBlockSection();
$sectionId = $section->add($fields);
if (!$sectionId) {
return false;
}
WDClearComponentCache(array('webdav.element.edit', 'webdav.element.hist', 'webdav.element.upload', 'webdav.element.view', 'webdav.menu', 'webdav.section.edit', 'webdav.section.list'));
return $sectionId;
}
示例2: createSymLinkSection
/**
* User by user
* array(
* 'IBLOCK_ID' => 16,
* 'IBLOCK_SECTION_ID' => 162,
* );
* array(
* 'NAME' => 'link on folder',
* 'IBLOCK_ID' => 15,
* 'ID' => 3574,
* 'CREATED_BY' => 1,
* 'CAN_FORWARD' => 1,
* 'INVITE_USER_ID' => 480,
* );
*
* @param array $sectionTargetData
* @param array $sectionLinkData
* @param string $typeLibrary - user, group, shared
* @return bool|int
*/
public 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 = 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 = \Bitrix\Webdav\FolderInviteTable::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'];
\Bitrix\Webdav\FolderInviteTable::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'];
\Bitrix\Webdav\FolderInviteTable::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;
}