• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/helper/workgroup.php
  • Класс: BitrixSocialnetworkHelperWorkgroup
  • Вызов: Workgroup::deleteRelation
static function deleteRelation(array $fields = []): bool
{
	global $APPLICATION;

	$relationId = (int)($fields['relationId'] ?? 0);

	if ($relationId <= 0)
	{
		throw new ArgumentException(Loc::getMessage('SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_RELATION_ID'));
	}

	try
	{
		$relation = static::getRelation([
			'=ID' => $relationId,
		]);
	}
	catch (Exception $e)
	{
		throw new Exception($e->getMessage(), $e->getCode());
	}

	if (!CSocNetUserToGroup::delete($relation->getId()))
	{
		if ($ex = $APPLICATION->getException())
		{
			$errorMessage = $ex->getString();
		}
		else
		{
			$errorMessage = Loc::getMessage('SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
		}

		throw new Exception($errorMessage, 100);
	}

	return true;
}