• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/finderdest.php
  • Класс: BitrixMainFinderDestTable
  • Вызов: FinderDestTable::migrateData
static function migrateData()
{
	$res = CUserOptions::getList(
		[],
		[
			"CATEGORY" => "socialnetwork",
			"NAME" => "log_destination"
		]
	);

	while ($option = $res->fetch())
	{
		if (!empty($option["VALUE"]))
		{
			$optionValue = unserialize($option["VALUE"], ['allowed_classes' => false]);

			if (is_array($optionValue))
			{
				foreach ($optionValue as $key => $val)
				{
					if (in_array(
						$key,
						["users", "sonetgroups", "department", "companies", "contacts", "leads", "deals"]
					))
					{
						$codes = CUtil::jsObjectToPhp($val);
						if (is_array($codes))
						{
							BitrixMainFinderDestTable::merge(
								[
									"USER_ID" => $option["USER_ID"],
									"CONTEXT" => "blog_post",
									"CODE" => array_keys($codes)
								]
							);
						}
					}
				}
			}
		}
	}

	$res = CUserOptions::getList(
		[],
		[
			"CATEGORY" => "crm",
			"NAME" => "log_destination"
		]
	);

	while ($option = $res->fetch())
	{
		if (!empty($option["VALUE"]))
		{
			$optionValue = unserialize($option["VALUE"], ['allowed_classes' => false]);

			if (is_array($optionValue))
			{
				foreach ($optionValue as $key => $val)
				{
					$codes = explode(',', $val);
					if (is_array($codes))
					{
						BitrixMainFinderDestTable::merge(
							[
								"USER_ID" => $option["USER_ID"],
								"CONTEXT" => "crm_post",
								"CODE" => $codes
							]
						);
					}
				}
			}
		}
	}
}