• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/chat/chat.php
  • Класс: BitrixLandingChatChat
  • Вызов: Chat::update
static function update($id, $fields = [])
{
	$chatRow = self::getRow($id);

	if (!$chatRow)
	{
		$result = new BitrixMainResult;
		$result->addErrors([
			new BitrixMainError(
				Loc::getMessage('LANDING_CHAT_ERROR_CHAT_UPDATE'),
				'ERROR_CHAT_UPDATE'
			)
		]);
		return $result;
	}

	$result = parent::update($id, $fields);

	// update IM chat
	if ($result->isSuccess())
	{
		$chat = new CIMChat(0);
		// title
		if (
			isset($fields['TITLE']) &&
			$chatRow['TITLE'] != $fields['TITLE']
		)
		{
			$chat->rename(
				$chatRow['CHAT_ID'],
				$fields['TITLE'],
				false
			);
		}
		// avatar
		if (
			isset($fields['AVATAR']) &&
			$chatRow['AVATAR'] != $fields['AVATAR']
		)
		{
			$fields['AVATAR'] = self::getAvatarId($fields['AVATAR']);
			if ($fields['AVATAR'])
			{
				File::deletePhysical(
					$chatRow['AVATAR']
				);
				$chat->setAvatarId(
					$chatRow['CHAT_ID'],
					$fields['AVATAR']
				);
			}
		}
	}

	return $result;
}