• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/search/searchmap.php
  • Класс: Bitrix\Crm\Search\SearchMap
  • Вызов: SearchMap::addPhone
public function addPhone($phone)
{
	$originalPhone = DuplicateCommunicationCriterion::sanitizePhone($phone);
	if($originalPhone === '')
	{
		return;
	}

	//Fix for issue #111401. Store original phone for providing opportunity to search by not normalized phone.
	$this->data[$originalPhone] = true;

	$phone = DuplicateCommunicationCriterion::normalizePhone($phone);
	if($phone === '')
	{
		return;
	}

	$length = mb_strlen($phone);
	if($length >= 10 && mb_substr($phone, 0, 1) === '7')
	{
		$altPhone = '8'.mb_substr($phone, 1);
		if(!isset($this->data[$altPhone]))
		{
			$this->data[$altPhone] = true;
		}
	}

	//Right bound. We will stop when 3 digits are left.
	$bound = $length - 2;
	if($bound > 0)
	{
		for($i = 0; $i < $bound; $i++)
		{
			$fragment = mb_substr($phone, $i);
			if(!isset($this->data[$fragment]))
			{
				$this->data[$fragment] = true;
			}
		}
	}
}