1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
user.php
См. документацию.
1<?php
2
9namespace Bitrix\Socialnetwork\Helper;
10
11use Bitrix\Main\ModuleManager;
12use Bitrix\Main\UserTable;
13
14class User
15{
16 protected static string $userTableClass = UserTable::class;
17
18 public static function getCurrentUserId(): int
19 {
20 global $USER;
21
22 return (int)$USER?->getId();
23 }
24
25 public static function getUserListNameFormatted(array $userIdList = [], $params = []): array
26 {
27 static $cache = [];
28
29 $nameFormat = ($params['nameFormat'] ?? \CSite::getNameFormat());
30
31 $result = [];
32
33 $userIdList = array_map(static function ($userId) {
34 return (int)$userId;
35 }, $userIdList);
36
37 $userIdList = array_filter($userIdList, static function ($userId) {
38 return $userId > 0;
39 });
40
41 $userIdList = array_unique($userIdList);
42
43 if (empty($userIdList))
44 {
45 return $result;
46 }
47
48 if (!isset($cache[$nameFormat]))
49 {
50 $cache[$nameFormat] = [];
51 }
52
53 $result = array_filter($cache[$nameFormat], function($cacheItem, $userId) use ($userIdList) {
54 return in_array($userId, $userIdList);
55 }, ARRAY_FILTER_USE_BOTH);
56
57 $userIdListToGet = array_diff($userIdList, array_keys($cache[$nameFormat]));
58 if (!empty($userIdListToGet))
59 {
60 $res = self::$userTableClass::getList([
61 'filter' => [
62 '@ID' => $userIdListToGet,
63 ],
64 'select' => [
65 'ID',
66 'LOGIN',
67 'EMAIL',
68 'NAME',
69 'SECOND_NAME',
70 'LAST_NAME',
71 ],
72 ]);
73
74 $useLogin = ModuleManager::isModuleInstalled('intranet');
75
76 while ($userFields = $res->fetch())
77 {
78 $value = \CUser::FormatName($nameFormat, $userFields, $useLogin, false);
79 $result[(int)$userFields['ID']] = $value;
80 $cache[$nameFormat][(int)$userFields['ID']] = $value;
81 }
82 }
83
84 return $result;
85 }
86}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static getUserListNameFormatted(array $userIdList=[], $params=[])
Определения user.php:25
static getCurrentUserId()
Определения user.php:18
static string $userTableClass
Определения user.php:16
$nameFormat
Определения discount_coupon_list.php:278
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
global $USER
Определения csv_new_run.php:40
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799