• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/lib/integration/ui/entityselector/userprovider.php
  • Класс: BitrixSocialnetworkIntegrationUIEntitySelectorUserProvider
  • Вызов: UserProvider::fillDialog
public function fillDialog(Dialog $dialog): void
{
	if (!$this->shouldFillDialog())
	{
		return;
	}

	// Preload first 50 users ('doSearch' method has to have the same filter).
	$preloadedUsers = $this->getPreloadedUsersCollection();

	if ($preloadedUsers->count() < self::MAX_USERS_IN_RECENT_TAB)
	{
		// Turn off the user search
		$entity = $dialog->getEntity(static::ENTITY_ID);
		if ($entity)
		{
			$entity->setDynamicSearch(false);
		}
	}

	$recentUsers = new EO_User_Collection();

	// Recent Items
	$recentItems = $dialog->getRecentItems()->getEntityItems(static::ENTITY_ID);
	$recentIds = array_map('intval', array_keys($recentItems));
	$this->fillRecentUsers($recentUsers, $recentIds, $preloadedUsers);

	// Global Recent Items
	if ($recentUsers->count() < self::MAX_USERS_IN_RECENT_TAB)
	{
		$recentGlobalItems = $dialog->getGlobalRecentItems()->getEntityItems(static::ENTITY_ID);
		$recentGlobalIds = [];

		if (!empty($recentGlobalItems))
		{
			$recentGlobalIds = array_map('intval', array_keys($recentGlobalItems));
			$recentGlobalIds = array_values(array_diff($recentGlobalIds, $recentUsers->getIdList()));
			$recentGlobalIds = array_slice($recentGlobalIds, 0, self::MAX_USERS_IN_RECENT_TAB - $recentUsers->count());
		}

		$this->fillRecentUsers($recentUsers, $recentGlobalIds, $preloadedUsers);
	}

	// The rest of preloaded users
	foreach ($preloadedUsers as $preloadedUser)
	{
		$recentUsers->add($preloadedUser);
	}

	$dialog->addRecentItems($this->makeUserItems($recentUsers));

	// Footer
	if (Loader::includeModule('intranet'))
	{
		$inviteEmployeeLink = null;
		$employeeInvitationAvailable = Invitation::canCurrentUserInvite();
		$intranetUsersOnly = $this->options['intranetUsersOnly'] ?? false;
		$extranetInvitationAvailable = (
			ModuleManager::isModuleInstalled('extranet')
			&& Option::get('extranet', 'extranet_site')
			&& !$intranetUsersOnly
		);

		if (
			$this->options['inviteEmployeeLink']
			&& (
				$employeeInvitationAvailable
				|| $extranetInvitationAvailable
			)
			&& self::isIntranetUser()
		)
		{
			$inviteEmployeeLink = UrlManager::getInstance()->create('getSliderContent', [
				'c' => 'bitrix:intranet.invitation',
				'mode' => Router::COMPONENT_MODE_AJAX,
				'analyticsLabel[source]' => 'userProvider',
			]);
		}

		$inviteGuestLink = null;
		if ($this->options['inviteGuestLink'] && ModuleManager::isModuleInstalled('mail') && self::isIntranetUser())
		{
			$inviteGuestLink = UrlManager::getInstance()->create('getSliderContent', [
				'c' => 'bitrix:intranet.invitation.guest',
				'mode' => Router::COMPONENT_MODE_AJAX,
			]);
		}

		if ($inviteEmployeeLink || $inviteGuestLink)
		{
			$footerOptions = [];
			if ($dialog->getFooter() === 'BX.SocialNetwork.EntitySelector.Footer')
			{
				// Footer could be set from ProjectProvider
				$footerOptions = $dialog->getFooterOptions() ?? [];
			}

			$footerOptions['inviteEmployeeLink'] = $inviteEmployeeLink;
			$footerOptions['inviteGuestLink'] = $inviteGuestLink;
			if ($inviteEmployeeLink)
			{
				$footerOptions['inviteEmployeeScope'] = ($employeeInvitationAvailable ? 'I' : '').($extranetInvitationAvailable ? 'E' : '');
			}

			$dialog->setFooter('BX.SocialNetwork.EntitySelector.Footer', $footerOptions);
		}
	}
}