• Модуль: imbot
  • Путь к файлу: ~/bitrix/modules/imbot/lib/bot/support24.php
  • Класс: BitrixImBotBotSupport24
  • Вызов: Support24::onAfterLicenseChange
static function onAfterLicenseChange()
{
	if (!MainLoader::includeModule('im'))
	{
		return false;
	}

	if (!MainLoader::includeModule('bitrix24'))
	{
		return false;
	}

	if (!self::getBotId())
	{
		return false;
	}

	self::addAgent([
		'agent' => 'refreshAgent(false)',/** @see Support24::refreshAgent */
		'class' => __CLASS__,
		'delay' => 15,
		'interval' => 100,
	]);

	/*
	$previousDemoState = Option::get('imbot', self::OPTION_BOT_DEMO_ACTIVE, false);

	$previousSupportLevel = Option::get('imbot', self::OPTION_BOT_SUPPORT_LEVEL, self::SUPPORT_LEVEL_FREE);
	$currentSupportLevel = self::getSupportLevel();

	$isPreviousSupportLevelPartner = $previousSupportLevel === self::SUPPORT_LEVEL_PARTNER;

	$previousLicence = CBitrix24::getLicenseType(CBitrix24::LICENSE_TYPE_PREVIOUS);
	$currentLicence = CBitrix24::getLicenseType(CBitrix24::LICENSE_TYPE_CURRENT);

	$previousRegion = CBitrix24::getPortalZone(CBitrix24::LICENSE_TYPE_PREVIOUS);
	$currentRegion = CBitrix24::getPortalZone(CBitrix24::LICENSE_TYPE_CURRENT);

	$currentDemoState = CBitrix24::isDemoLicense();
	Option::set('imbot', self::OPTION_BOT_DEMO_ACTIVE, $currentDemoState);

	$isSupportLevelChanged = $previousSupportLevel != $currentSupportLevel;
	$isDemoLevelChanged = $previousDemoState != $currentDemoState;
	$isRegionChanged = $previousRegion != $currentRegion;

	if (!$isSupportLevelChanged && !$isDemoLevelChanged && !$isRegionChanged)
	{
		return true;
	}

	if ($isSupportLevelChanged)
	{
		Option::set('imbot', self::OPTION_BOT_SUPPORT_LEVEL, $currentSupportLevel);
	}

	if (self::getSupportLevel() == self::SUPPORT_LEVEL_PAID)
	{
		$previousCode = Option::get('imbot', self::OPTION_BOT_FREE_CODE, '');
		$currentCode = Option::get('imbot', self::OPTION_BOT_PAID_CODE, '');
	}
	else
	{
		$previousCode = Option::get('imbot', self::OPTION_BOT_PAID_CODE, '');
		$currentCode = Option::get('imbot', self::OPTION_BOT_FREE_CODE, '');
	}

	if ($isPreviousSupportLevelPartner)
	{
		$previousCode = Option::get("bitrix24", "partner_ol", "");
	}

	if ($isSupportLevelChanged)
	{
		(new DialogSession)->clearSessions(['BOT_ID' => self::getBotId()]);

		self::deleteScheduledAction(self::SCHEDULE_DELETE_ALL);
	}

	if ($currentDemoState)
	{
		Option::set('imbot', self::OPTION_BOT_FREE_START_DATE, time());
	}

	self::updateBotProperties();

	self::sendNotifyAboutChangeLevel([
		'BUSINESS_USERS' => self::getBusinessUsers(),
		'IS_SUPPORT_LEVEL_CHANGE' => $isSupportLevelChanged,
		'IS_DEMO_LEVEL_CHANGE' => $isDemoLevelChanged,
		'IS_SUPPORT_CODE_CHANGE' => $isRegionChanged,
	]);

	$http = self::instanceHttpClient();
	$http->query(
		'clientChangeLicence',
		[
			'BOT_ID' => self::getBotId(),
			'PREVIOUS_LICENCE_TYPE' => $previousLicence,
			'PREVIOUS_LICENCE_NAME' => CBitrix24::getLicenseName($previousLicence),
			'CURRENT_LICENCE_TYPE' => $currentLicence,
			'CURRENT_LICENCE_NAME' => CBitrix24::getLicenseName($currentLicence),
			'PREVIOUS_BOT_CODE' => $previousCode,
			'CURRENT_BOT_CODE' => $currentCode,
			'MESSAGE' => self::getMessage('SUPPORT_INFO_CHANGE_CODE', $previousSupportLevel),
		],
		false
	);
	*/

	return true;
}