Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
user.php
1<?php
3
4use Bitrix\Main\EO_User;
5
6class User
7{
8 public static function formatName(EO_User $user, array $options = []): string
9 {
10 return \CUser::formatName(
11 !empty($options['nameTemplate'])
12 ? $options['nameTemplate']
13 : \CSite::getNameFormat(false),
14 [
15 'NAME' => $user->getName(),
16 'LAST_NAME' => $user->getLastName(),
17 'SECOND_NAME' => $user->getSecondName(),
18 'LOGIN' => $user['LOGIN'],
19 'EMAIL' => $user['EMAIL'],
20 'TITLE' => $user['TITLE'],
21 ],
22 true,
23 false
24 );
25 }
26
27 public static function makeAvatar(EO_User $user): ?string
28 {
29 if (empty($user->getPersonalPhoto()))
30 {
31 return null;
32 }
33
34 $avatar = \CFile::resizeImageGet(
35 $user->getPersonalPhoto(),
36 ['width' => 100, 'height' => 100],
37 BX_RESIZE_IMAGE_EXACT,
38 false
39 );
40
41 return !empty($avatar['src']) ? $avatar['src'] : null;
42 }
43
44 public static function getCurrentUserId(): int
45 {
46 return is_object($GLOBALS['USER']) ? (int)$GLOBALS['USER']->getId() : 0;
47 }
48}
static formatName(EO_User $user, array $options=[])
Definition user.php:8
$GLOBALS['____1444769544']
Definition license.php:1