• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/componenthelper.php
  • Класс: BitrixSocialnetworkComponentHelper
  • Вызов: ComponentHelper::getEmailUserIdList
static function getEmailUserIdList()
{
	global $CACHE_MANAGER;

	$result = array();

	if (
		!ModuleManager::isModuleInstalled('mail')
		|| !ModuleManager::isModuleInstalled('intranet')
	)
	{
		return $result;
	}

	$ttl = (defined("BX_COMP_MANAGED_CACHE") ? 2592000 : 600);
	$cacheId = 'sonet_email_userid';
	$cache = new CPHPCache;
	$cacheDir = '/bitrix/sonet/user_email';

	if($cache->initCache($ttl, $cacheId, $cacheDir))
	{
		$tmpVal = $cache->getVars();
		$result = $tmpVal['EMAIL_USER_ID'];
		unset($tmpVal);
	}
	else
	{
		if (defined("BX_COMP_MANAGED_CACHE"))
		{
			$CACHE_MANAGER->startTagCache($cacheDir);
		}

		$res = BitrixMainUserTable::getList(array(
			'order' => array(),
			'filter' => array(
				'=EXTERNAL_AUTH_ID' => 'email'
			),
			'select' => array('ID')
		));

		while($user = $res->fetch())
		{
			$result[] = $user["ID"];
		}

		if (defined("BX_COMP_MANAGED_CACHE"))
		{
			$CACHE_MANAGER->registerTag('USER_CARD');
			$CACHE_MANAGER->endTagCache();
		}

		if($cache->startDataCache())
		{
			$cache->endDataCache(array(
				'EMAIL_USER_ID' => $result
			));
		}
	}

	return $result;
}