Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
UserService.php
1
<?php
2
3
namespace
Bitrix\Bizproc\Api\Service
;
4
5
use
Bitrix\Bizproc\Api\Response\UserService\GetCurrentUserResponse
;
6
use
Bitrix\Main\Engine\CurrentUser
;
7
use
Bitrix\Main\Loader
;
8
9
class
UserService
10
{
11
public
function
getCurrentUser
():
GetCurrentUserResponse
12
{
13
$currentUser =
CurrentUser::get
();
14
15
if
(!$this->
isAuthorised
((
int
)$currentUser->getId()))
16
{
17
return
GetCurrentUserResponse::createUnauthorizedError
();
18
}
19
20
return
GetCurrentUserResponse::createOk
([
'user'
=> $currentUser]);
21
}
22
23
public
function
isAuthorised
(
int
$userId): bool
24
{
25
return
$userId > 0;
26
}
27
28
public
function
isCurrentUserPortalAdmin
(): bool
29
{
30
$result = $this->
getCurrentUser
();
31
32
return
(
33
$result->isSuccess()
34
&& (
35
$result->getUser()?->isAdmin()
36
|| (
37
Loader::includeModule(
'bitrix24'
)
38
&& \CBitrix24::IsPortalAdmin($result->getUser()?->getId())
39
)
40
)
41
);
42
}
43
}
Bitrix\Bizproc\Api\Response\UserService\GetCurrentUserResponse
Definition
GetCurrentUserResponse.php:10
Bitrix\Bizproc\Api\Response\UserService\GetCurrentUserResponse\createUnauthorizedError
static createUnauthorizedError()
Definition
GetCurrentUserResponse.php:11
Bitrix\Bizproc\Api\Service\UserService
Definition
UserService.php:10
Bitrix\Bizproc\Api\Service\UserService\isCurrentUserPortalAdmin
isCurrentUserPortalAdmin()
Definition
UserService.php:28
Bitrix\Bizproc\Api\Service\UserService\isAuthorised
isAuthorised(int $userId)
Definition
UserService.php:23
Bitrix\Bizproc\Api\Service\UserService\getCurrentUser
getCurrentUser()
Definition
UserService.php:11
Bitrix\Bizproc\Result\createOk
static createOk(?array $data=null)
Definition
result.php:20
Bitrix\Main\Engine\CurrentUser
Definition
currentuser.php:8
Bitrix\Main\Engine\CurrentUser\get
static get()
Definition
currentuser.php:33
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Bizproc\Api\Service
Definition
TaskAccessService.php:3
modules
bizproc
lib
Api
Service
UserService.php
Создано системой
1.10.0