• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/item/workgroup.php
  • Класс: BitrixSocialnetworkItemWorkgroup
  • Вызов: Workgroup::onAfterIBlockSectionUpdate
static function onAfterIBlockSectionUpdate($section)
{
	if(
		!isset($section['ID'], $section['IBLOCK_ID'])
		|| (int)$section['ID'] <= 0
		|| (int)$section['IBLOCK_ID'] <= 0
		|| (int)$section['IBLOCK_ID'] !== (int)Option::get('intranet', 'iblock_structure', 0)
	)
	{
		return true;
	}

	$oldGroupsIdToCheckList = self::$groupsIdToCheckList;
	$newGroupsIdToCheckList = [];

	if (
		isset($section['ACTIVE'])
		&& $section['ACTIVE'] === 'N'
	)
	{
		self::disconnectSection($section['ID']);
	}
	else
	{
		$res = CIBlockSection::getNavChain($section['IBLOCK_ID'], $section['ID'], array('ID'));
		while ($rootSection = $res->fetch())
		{
			if ((int)$rootSection['ID'] !== (int)$section['ID'])
			{
				$rootSectionIdList[] = $rootSection['ID'];
			}
		}

		if (!empty($rootSectionIdList))
		{
			$newGroupsIdToCheckList = UserToGroup::getConnectedGroups($rootSectionIdList);
		}
	}

	if (!empty($oldGroupsIdToCheckList))
	{
		$oldGroupsIdToCheckList = array_unique($oldGroupsIdToCheckList);
		foreach($oldGroupsIdToCheckList as $groupId)
		{
			$groupItem = self::getById($groupId, false);
			$groupItem->syncDeptConnection(true);
		}
	}

	if (!empty($newGroupsIdToCheckList))
	{
		$newGroupsIdToCheckList = array_unique($newGroupsIdToCheckList);
		foreach($newGroupsIdToCheckList as $groupId)
		{
			$groupItem = self::getById($groupId, false);
			$groupItem->syncDeptConnection();
		}
	}

	return true;
}