Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
IblockCatalogPermissions.php
1<?php
2
4
7
14{
15 private bool $canRead = false;
16 private bool $canWrite = false;
17 private bool $canFullAccess = false;
24 private array $accessCodes;
25 private array $deleteAccessCodes;
26
31 public function __construct(array $accessCodes, array $deleteAccessCodes = [])
32 {
33 Loader::requireModule('iblock');
34
35 $this->accessCodes = $accessCodes;
36 $this->deleteAccessCodes = $deleteAccessCodes;
37 }
38
46 public function setRights(array $rights): void
47 {
48 foreach ($rights as $item)
49 {
50 if (!is_array($item))
51 {
52 continue;
53 }
54
55 $id = (int)($item['id'] ?? 0);
56 if (empty($id))
57 {
58 continue;
59 }
60
61 $value = (int)($item['value'] ?? 0);
62 if (empty($value))
63 {
64 continue;
65 }
66
67 if (
69 )
70 {
71 $this->canRead = true;
72 }
73 elseif (
77 )
78 {
79 $this->canWrite = true;
80 }
82 {
83 $this->canFullAccess = true;
84 }
85
86 if ($this->canRead && $this->canWrite && $this->canFullAccess)
87 {
88 break;
89 }
90 }
91 }
92
98 public function getCanRead(): bool
99 {
100 return $this->canRead;
101 }
102
108 public function getCanWrite(): bool
109 {
110 return $this->canWrite;
111 }
112
118 public function getCanFullAccess(): bool
119 {
120 return $this->canFullAccess;
121 }
122
128 public function getAccessCodes(): array
129 {
130 return $this->accessCodes;
131 }
132
138 public function getDeleteAccessCodes(): array
139 {
140 return $this->deleteAccessCodes;
141 }
142}