Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
AccessService.php
1<?php
2
4
8
10{
12 {
13 return $this->checkIBlockPermission($iBlockId, IblockRight::READ);
14 }
15
17 {
18 $response = new CheckPermissionsResponse();
19
20 $checkPermissionsResponse = $this->checkIBlockTypePermission();
21 $response->fillFromResponse($checkPermissionsResponse);
22
23 if ($response->isSuccess() && $this->isAccessDeniedPermission($response->getPermission()))
24 {
25 $response->addError(self::getAccessDeniedError());
26 }
27
28 return $response;
29 }
30
31 public function canUserReadElement(int $elementId, int $sectionId, int $iBlockId): CheckPermissionsResponse
32 {
33 $response = new CheckPermissionsResponse();
34
35 $checkPermissionsResponse =
36 $this->checkElementPermission($elementId, $sectionId, '', $iBlockId)
37 ;
38 $elementRight = $checkPermissionsResponse->getElementRight();
39 $response->fillFromResponse($checkPermissionsResponse);
40
41 if ($response->isSuccess())
42 {
43 if (
44 ($elementId !== 0 && !$elementRight?->canRead())
45 || ($elementId === 0 && !$elementRight?->canAdd())
46 )
47 {
48 $response->addError(self::getAccessDeniedError());
49 }
50 }
51
52 return $response;
53 }
54
56 {
57 $response = new CheckPermissionsResponse();
58
59 $checkPermissionsResponse = (
61 ? $this->checkIBlockPermission($iBlockId)
63 );
64 $response->fillFromResponse($checkPermissionsResponse);
65
66 if ($response->isSuccess() && $this->isAccessDeniedPermission($response->getPermission()))
67 {
68 $response->addError(self::getAccessDeniedError());
69 }
70
71 return $response;
72 }
73
74 public function canUserAddElement(int $sectionId, int $iBlockId): CheckPermissionsResponse
75 {
76 return $this->checkElementPermission(0, $sectionId, ElementRight::ADD, $iBlockId);
77 }
78}
checkIBlockPermission(int $iBlockId=null, string $entityMethod=null)
isAccessDeniedPermission(string|int $permission)
checkIBlockTypePermission(string $iBlockTypeId=null)
checkElementPermission(int $elementId=0, int $sectionId=0, string $entityMethod=null, int $iBlockId=null,)
canUserReadElement(int $elementId, int $sectionId, int $iBlockId)