Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/socialnetwork/lib/helper/ |
Upload File : |
<?php /** * Bitrix Framework * @package bitrix * @subpackage socialnetwork * @copyright 2001-2021 Bitrix */ namespace Bitrix\Socialnetwork\Helper; use Bitrix\Main\ModuleManager; use Bitrix\Main\UserTable; class User { protected static string $userTableClass = UserTable::class; public static function getCurrentUserId(): int { global $USER; return (int)$USER?->getId(); } public static function getUserListNameFormatted(array $userIdList = [], $params = []): array { static $cache = []; $nameFormat = ($params['nameFormat'] ?? \CSite::getNameFormat()); $result = []; $userIdList = array_map(static function ($userId) { return (int)$userId; }, $userIdList); $userIdList = array_filter($userIdList, static function ($userId) { return $userId > 0; }); $userIdList = array_unique($userIdList); if (empty($userIdList)) { return $result; } if (!isset($cache[$nameFormat])) { $cache[$nameFormat] = []; } $result = array_filter($cache[$nameFormat], function($cacheItem, $userId) use ($userIdList) { return in_array($userId, $userIdList); }, ARRAY_FILTER_USE_BOTH); $userIdListToGet = array_diff($userIdList, array_keys($cache[$nameFormat])); if (!empty($userIdListToGet)) { $res = self::$userTableClass::getList([ 'filter' => [ '@ID' => $userIdListToGet, ], 'select' => [ 'ID', 'LOGIN', 'EMAIL', 'NAME', 'SECOND_NAME', 'LAST_NAME', ], ]); $useLogin = ModuleManager::isModuleInstalled('intranet'); while ($userFields = $res->fetch()) { $value = \CUser::FormatName($nameFormat, $userFields, $useLogin, false); $result[(int)$userFields['ID']] = $value; $cache[$nameFormat][(int)$userFields['ID']] = $value; } } return $result; } }