• Модуль: voximplant
  • Путь к файлу: ~/bitrix/modules/voximplant/classes/general/vi_phone.php
  • Класс: CVoxImplantPhone
  • Вызов: CVoxImplantPhone::DeletePhoneConfig
static function DeletePhoneConfig($configId)
{
	$configId = intval($configId);
	$result = VIConfigTable::getList(Array(
		'select'=>Array('ID', 'SEARCH_ID'),
		'filter'=>Array(
			'=ID' => $configId
		)
	));
	$config = $result->fetch();
	if (!$config)
		return false;

	VIConfigTable::delete($configId);

	$needChangePortalNumber = false;
	if ($config['SEARCH_ID'] == CVoxImplantConfig::GetPortalNumber())
	{
		$needChangePortalNumber = true;
	}

	$firstPhoneNumber = '';
	$result = VIConfigTable::getList(Array(
		'select'=>Array('ID', 'SEARCH_ID'),
	));
	while ($row = $result->fetch())
	{
		if (!$firstPhoneNumber)
		{
			$firstPhoneNumber = $row['SEARCH_ID'];
			break;
		}
	}

	if (!$firstPhoneNumber)
	{
		CVoxImplantConfig::SetModeStatus(CVoxImplantConfig::MODE_RENT, false);
	}

	if ($needChangePortalNumber)
	{
		if ($firstPhoneNumber)
		{
			CVoxImplantConfig::SetPortalNumber($firstPhoneNumber);
		}
		else
		{
			CVoxImplantConfig::SetPortalNumber(CVoxImplantConfig::LINK_BASE_NUMBER);
		}
	}

	return true;
}