1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
user.php
См. документацию.
1
<?php
8
9
namespace
Bitrix\Main\UI\AccessRights\Entity;
10
11
12
use Bitrix\Main\Access\AccessCode;
13
use Bitrix\Main\Loader;
14
use Bitrix\Main\UI\AccessRights\Avatar;
15
use Bitrix\Main\UserTable;
16
17
class
User
extends
EntityBase
18
{
19
private
const
SELECT_FIELDS = [
20
'ID'
,
21
'NAME'
,
22
'LAST_NAME'
,
23
'LOGIN'
,
24
'PERSONAL_PHOTO'
,
25
'UF_DEPARTMENT'
,
26
];
27
28
private
$isIntranetUser;
29
private
static
$modelsCache = [];
30
31
public
function
getType
(): string
32
{
33
return
AccessCode::TYPE_USER;
34
}
35
36
public
function
getName
(): string
37
{
38
if
($this->model)
39
{
40
$name
= trim($this->model->getName() .
' '
. $this->model->getLastName());
41
42
return
$name
?: $this->model->getLogin();
43
}
44
return
''
;
45
}
46
47
public
function
getUrl
(): string
48
{
49
if
($this->isExtranetUser())
50
{
51
$userPage = \COption::getOptionString(
"socialnetwork"
,
"user_page"
,
false
, \CExtranet::getExtranetSiteID());
52
if
(!$userPage)
53
{
54
$userPage =
'/extranet/contacts/personal/'
;
55
}
56
}
57
else
58
{
59
$userPage = \COption::getOptionString(
"socialnetwork"
,
"user_page"
,
false
,
SITE_ID
);
60
if
(!$userPage)
61
{
62
$userPage =
SITE_DIR
.
'company/personal/'
;
63
}
64
}
65
66
return
$userPage .
'user/'
. $this->
getId
() .
'/'
;
67
}
68
69
public
function
getAvatar
(
int
$width
= 58,
int
$height = 58): ?string
70
{
71
if
($this->model)
72
{
73
return
Avatar::getSrc
($this->model->getPersonalPhoto(),
$width
, $height);
74
}
75
return
''
;
76
}
77
78
protected
function
loadModel
()
79
{
80
if
(!$this->model)
81
{
82
if
(array_key_exists($this->
id
, self::$modelsCache))
83
{
84
$this->model = self::$modelsCache[
$this->id
];
85
}
86
else
87
{
88
$this->model =
UserTable::getList
([
89
'select'
=> self::SELECT_FIELDS,
90
'filter'
=> [
91
'=ID'
=> $this->
id
,
92
],
93
'limit'
=> 1,
94
])->fetchObject();
95
96
self::$modelsCache[
$this->id
] =
$this->model
;
97
}
98
}
99
}
100
101
private
function
isExtranetUser()
102
{
103
return
!$this->isIntranetUser() &&
Loader::includeModule
(
'extranet'
);
104
}
105
106
private
function
isIntranetUser()
107
{
108
if
(isset($this->isIntranetUser))
109
{
110
return
$this->isIntranetUser;
111
}
112
113
$this->isIntranetUser =
false
;
114
115
if
($this->model &&
Loader::includeModule
(
'intranet'
))
116
{
117
$this->isIntranetUser = !empty($this->model->getUfDepartment());
118
}
119
120
return
$this->isIntranetUser;
121
}
122
132
public
static
function
preLoadModels
(
array
$filter
): void
133
{
134
$rows
=
UserTable::getList
([
135
'select'
=> self::SELECT_FIELDS,
136
'filter'
=>
$filter
,
137
]);
138
while
($row =
$rows
->fetchObject())
139
{
140
self::$modelsCache[$row->getId()] = $row;
141
}
142
}
143
}
Bitrix\Main\Loader\includeModule
static includeModule($moduleName)
Определения
loader.php:67
Bitrix\Main\ORM\Data\DataManager\getList
static getList(array $parameters=array())
Определения
datamanager.php:431
Bitrix\Main\UI\AccessRights\Avatar\getSrc
static getSrc($avatarId, $width=58, $height=58)
Определения
avatar.php:15
Bitrix\Main\UI\AccessRights\Entity\EntityBase
Определения
entitybase.php:13
Bitrix\Main\UI\AccessRights\Entity\EntityBase\$model
$model
Определения
entitybase.php:15
Bitrix\Main\UI\AccessRights\Entity\EntityBase\getId
getId()
Определения
entitybase.php:23
Bitrix\Main\UI\AccessRights\Entity\EntityBase\$id
$id
Определения
entitybase.php:14
Bitrix\Main\UI\AccessRights\Entity\User
Определения
user.php:18
Bitrix\Main\UI\AccessRights\Entity\User\getName
getName()
Определения
user.php:36
Bitrix\Main\UI\AccessRights\Entity\User\loadModel
loadModel()
Определения
user.php:78
Bitrix\Main\UI\AccessRights\Entity\User\getAvatar
getAvatar(int $width=58, int $height=58)
Определения
user.php:69
Bitrix\Main\UI\AccessRights\Entity\User\getType
getType()
Определения
user.php:31
Bitrix\Main\UI\AccessRights\Entity\User\preLoadModels
static preLoadModels(array $filter)
Определения
user.php:132
Bitrix\Main\UI\AccessRights\Entity\User\getUrl
getUrl()
Определения
user.php:47
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$filter
$filter
Определения
iblock_catalog_list.php:54
SITE_DIR
const SITE_DIR(!defined('LANG'))
Определения
include.php:72
$name
$name
Определения
menu_edit.php:35
$width
$width
Определения
html.php:68
SITE_ID
const SITE_ID
Определения
sonet_set_content_view.php:12
$rows
$rows
Определения
options.php:264
bitrix
modules
main
lib
ui
accessrights
entity
user.php
Создано системой
1.14.0