• Модуль: sale
  • Путь к файлу: ~/bitrix/modules/sale/lib/discountcouponsmanagerbase.php
  • Класс: BitrixSaleDiscountCouponsManagerBase
  • Вызов: DiscountCouponsManagerBase::migrateStorage
static function migrateStorage($oldUser)
{
	if (self::$useMode != self::MODE_MANAGER && self::$useMode != self::MODE_ORDER || self::$userId === null)
	{
		return;
	}

	$oldUser = (int)$oldUser;
	if ($oldUser < 0)
	{
		return;
	}

	$session = self::getSession();
	if (!$session)
	{
		return;
	}

	if (empty($session[self::STORAGE_MANAGER_COUPONS]))
	{
		$session[self::STORAGE_MANAGER_COUPONS] = [];
	}

	if (empty($session[self::STORAGE_MANAGER_COUPONS][self::$userId]) || !is_array($session[self::STORAGE_MANAGER_COUPONS][self::$userId]))
	{
		$session[self::STORAGE_MANAGER_COUPONS][self::$userId] = [];
	}

	if (!empty($session[self::STORAGE_MANAGER_COUPONS][$oldUser]))
	{
		if (is_array($session[self::STORAGE_MANAGER_COUPONS][$oldUser]))
		{
			$session[self::STORAGE_MANAGER_COUPONS][self::$userId] = $session[self::STORAGE_MANAGER_COUPONS][$oldUser];
		}
		unset($session[self::STORAGE_MANAGER_COUPONS][$oldUser]);
	}
}