Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
iblockright.php
1<?
3
8
10{
12
13 const ACCESS_DENIED = "ACCESS_DENIED";
14
15 const READ = "canRead";
16 const EDIT = "canEdit";
17
18 private $listsPermission;
19 private $rightParam;
20
21 public function __construct(RightParam $rightParam)
22 {
23 $this->rightParam = $rightParam;
24
25 $this->errorCollection = new ErrorCollection;
26 }
27
33 public function setListsPermission($listsPermission)
34 {
35 $this->listsPermission = $listsPermission;
36 }
37
43 public function canRead()
44 {
45 if (
46 $this->listsPermission < \CListPermissions::CAN_READ
47 && !(
48 \CIBlockRights::userHasRightTo(
49 $this->rightParam->getIblockId(),
50 $this->rightParam->getIblockId(),
51 'element_read'
52 )
53 )
54 )
55 {
56 $this->errorCollection->setError(new Error('Access denied', self::ACCESS_DENIED));
57
58 return false;
59 }
60
61 return true;
62 }
63
69 public function canEdit()
70 {
71 if(
72 (
73 $this->rightParam->getIblockId() &&
74 $this->listsPermission < \CListPermissions::IS_ADMIN &&
75 !\CIBlockRights::userHasRightTo(
76 $this->rightParam->getIblockId(), $this->rightParam->getIblockId(), "iblock_edit")
77 ) ||
78 (
79 !$this->rightParam->getIblockId() && $this->listsPermission < \CListPermissions::IS_ADMIN
80 )
81 )
82 {
83 $this->errorCollection->setError(new Error("Access denied", self::ACCESS_DENIED));
84 return false;
85 }
86 return true;
87 }
88}
setListsPermission($listsPermission)
__construct(RightParam $rightParam)