• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/item/workgroup.php
  • Класс: BitrixSocialnetworkItemWorkgroup
  • Вызов: Workgroup::disconnectSection
static function disconnectSection($sectionId): void
{
	$groupList = array();
	$res = WorkgroupTable::getList(array(
		'filter' => array(
			'=UF_SG_DEPT' => $sectionId
		),
		'select' => array('ID', 'UF_SG_DEPT')
	));
	while($group = $res->fetch())
	{
		$groupList[] = $group;
	}

	foreach($groupList as $group)
	{
		$departmentListOld = array_map('intval',  $group['UF_SG_DEPT']);
		$departmentListNew = array_diff($departmentListOld, array($sectionId));

		CSocNetGroup::update($group['ID'], array(
			'UF_SG_DEPT' => $departmentListNew
		));

		$groupItem = self::getById($group['ID'], false);
		$groupItem->syncDeptConnection(true);
	}
}