Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
user.php
1<?php
3
8
9class User extends Controller
10{
11 public function getDefaultPreFilters(): array
12 {
13 return [
14 new Authentication(),
16 ];
17 }
18
24 public static function getUserNameByIdAction(int $userId): string
25 {
26 $res = UserTable::getList([
27 'select' => [
28 'NAME',
29 'LAST_NAME'
30 ],
31 'filter' => [
32 'ID' => $userId
33 ]
34 ]);
35 $row = $res->fetch();
36 $result = new PublicActionResult();
37 $result->setResult([
38 'NAME' => \CUser::formatName(
39 \CSite::getNameFormat(false),
40 $row, true, false
41 )
42 ]);
43 return $result->getResult()['NAME'];
44 }
45
51 public static function getUsersInfoAction(array $setUserId): array
52 {
53 $res = UserTable::getList([
54 'select' => [
55 'NAME',
56 'LAST_NAME',
57 'PERSONAL_PHOTO',
58 ],
59 'filter' => [
60 'ID' => $setUserId
61 ]
62 ]);
63 $setName = [];
64 $personalPhoto = [];
65
66 while ($row = $res->fetch())
67 {
68 $name = new PublicActionResult();
69 $name->setResult([
70 'NAME' => \CUser::formatName(
71 \CSite::getNameFormat(false),
72 $row, true, false
73 )
74 ]);
75 $setName[] = $name->getResult()['NAME'];
76 if ($row['PERSONAL_PHOTO'])
77 {
78 $personalPhoto[] = $row['PERSONAL_PHOTO'];
79 }
80 else
81 {
82 $personalPhoto[] = null;
83 }
84 }
85
86 $data = [];
87 $data['name'] = $setName;
88 $data['personalPhoto'] = $personalPhoto;
89
90 return $data;
91 }
92}
static getUserNameByIdAction(int $userId)
Definition user.php:24
static getUsersInfoAction(array $setUserId)
Definition user.php:51