CCrmSearch::OnSearchReindex

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CCrmSearch
  4. OnSearchReindex
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_search.php
  • Класс: \CCrmSearch
  • Вызов: CCrmSearch::OnSearchReindex
static function OnSearchReindex($NS = array(), $oCallback = null, $callback_method = '')
{
	$arFilter = array();
	$ENTITY_TYPE = 'LEAD';
	if (isset($NS['ID']) && $NS['ID'] <> '' && preg_match('/^[A-Z]+\.\d+$/'.BX_UTF_PCRE_MODIFIER, $NS['ID']))
	{
		$arTemp = explode('.', $NS['ID']);
		$ENTITY_TYPE = $arTemp[0];
		//Start processing from next entity
		$arFilter['>ID'] = intval($arTemp[1]);
	}

	self::$oCallback = $oCallback;
	self::$callback_method = $callback_method;
	self::$bReIndex = true;

	$arAllResult = array();
	if ($ENTITY_TYPE == 'LEAD')
	{
		$arResult = self::UpdateSearch($arFilter, 'LEAD');
		if(is_array($arResult))
		{
			//Save leads and go to contacts
			$arAllResult = array_merge($arAllResult, $arResult);
			$ENTITY_TYPE = 'CONTACT';
			if(!empty($arFilter))
			{
				$arFilter = array();
			}
		}
		else
		{
			//Termination of process
			self::$bReIndex = false;
			self::$oCallback = null;
			self::$callback_method = '';

			return $arResult;
		}
	}

	if ($ENTITY_TYPE == 'CONTACT')
	{
		$arResult = self::UpdateSearch($arFilter, 'CONTACT');
		if (is_array($arResult))
		{
			//Save contacts and go to companies
			$arAllResult = array_merge($arAllResult, $arResult);
			$ENTITY_TYPE = 'COMPANY';
			if(!empty($arFilter))
			{
				$arFilter = array();
			}
		}
		else
		{
			//Termination of process
			self::$bReIndex = false;
			self::$oCallback = null;
			self::$callback_method = '';

			return $arResult;
		}
	}

	if ($ENTITY_TYPE == 'COMPANY')
	{
		$arResult = self::UpdateSearch($arFilter, 'COMPANY');
		if (is_array($arResult))
		{
			//Save companies and go to deals
			$arAllResult = array_merge($arAllResult, $arResult);
			$ENTITY_TYPE = 'DEAL';
			if(!empty($arFilter))
			{
				$arFilter = array();
			}
		}
		else
		{
			//Termination of process
			self::$bReIndex = false;
			self::$oCallback = null;
			self::$callback_method = '';

			return $arResult;
		}
	}

	if ($ENTITY_TYPE == 'DEAL')
	{
		$arResult = self::UpdateSearch($arFilter, 'DEAL');
		if (is_array($arResult))
		{
			//Save deals and go to invoices
			$arAllResult = array_merge($arAllResult, $arResult);
			$ENTITY_TYPE = 'INVOICE';
			if(!empty($arFilter))
			{
				$arFilter = array();
			}
		}
		else
		{
			self::$bReIndex = false;
			self::$oCallback = null;
			self::$callback_method = '';

			return $arResult;
		}
	}

	if ($ENTITY_TYPE == 'INVOICE')
	{
		$arResult = self::UpdateSearch($arFilter, 'INVOICE');
		if (is_array($arResult))
		{
			//Save deals and go to quotes
			$arAllResult = array_merge($arAllResult, $arResult);
			$ENTITY_TYPE = 'QUOTE';
			if(!empty($arFilter))
			{
				$arFilter = array();
			}
		}
		else
		{
			self::$bReIndex = false;
			self::$oCallback = null;
			self::$callback_method = '';

			return $arResult;
		}
	}

	if ($ENTITY_TYPE == 'QUOTE')
	{
		$arResult = self::UpdateSearch($arFilter, 'QUOTE');
		if (is_array($arResult))
		{
			$arAllResult = array_merge($arAllResult, $arResult);
		}
		else
		{
			self::$bReIndex = false;
			self::$oCallback = null;
			self::$callback_method = '';

			return $arResult;
		}
	}

	self::$bReIndex = false;
	self::$oCallback = null;
	self::$callback_method = '';

	if($oCallback)
	{
		return false;
	}

	return $arAllResult;
}

Добавить комментарий