• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/rest.php
  • Класс: CSocNetLogRestService
  • Вызов: CSocNetLogRestService::deleteGroup
static function deleteGroup($arFields): bool
{
	$groupId = (int) ($arFields['GROUP_ID'] ?? null);

	if ($groupId <= 0)
	{
		throw new ArgumentException('Wrong group ID');
	}

	$filter = [
		'ID' => $groupId,
	];

	if (!self::isCurrentUserAdmin())
	{
		$filter['CHECK_PERMISSIONS'] = self::getCurrentUserId();
	}

	$res = CSocNetGroup::GetList([], $filter);
	$groupFields = $res->Fetch();
	if (!is_array($groupFields))
	{
		throw new ObjectNotFoundException('Socialnetwork group not found');
	}

	if (
		(int)$groupFields["OWNER_ID"] !== self::getCurrentUserId()
		&& !self::isCurrentUserAdmin()
	)
	{
		throw new AccessDeniedException('User has no permissions to delete group');
	}

	if (!CSocNetGroup::Delete($groupFields["ID"]))
	{
		throw new SystemException('Cannot delete group');
	}

	return true;
}