• Модуль: imbot
  • Путь к файлу: ~/bitrix/modules/imbot/lib/bot/partner24.php
  • Класс: BitrixImBotBotPartner24
  • Вызов: Partner24::onAfterSupportCodeChange
static function onAfterSupportCodeChange($currentCode = '', $previousCode = '')
{
	if (!MainLoader::includeModule('im'))
	{
		return false;
	}

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

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

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

	if (!$previousCode)
	{
		return false;
	}

	self::updateBotProperties();

	self::sendMessageForRecent(self::getMessage('CHANGE_CODE'));

	Option::delete(self::MODULE_ID, ['name' => "network_".$previousCode."_bot_id"]);
	Option::set(self::MODULE_ID, "network_".$currentCode."_bot_id", self::getBotId());

	self::sendRequestFinalizeSession([
		'MESSAGE' => self::getMessage('PARTNER_INFO_DEACTIVATE')
	]);

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

	return true;
}