Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
sectionright.php
1<?
3
8
10{
12
13 const ACCESS_DENIED = "ACCESS_DENIED";
14
15 const ADD = "canAdd";
16 const READ = "canRead";
17 const EDIT = "canEdit";
18 const DELETE = "canDelete";
19
20 private $listsPermission;
21 private $rightParam;
22 private $socnetGroupClosed = false;
23
24 public function __construct(RightParam $rightParam)
25 {
26 $this->rightParam = $rightParam;
27
28 $this->socnetGroupClosed = $this->rightParam->getClosedStatusSocnetGroup();
29
30 $this->errorCollection = new ErrorCollection;
31 }
32
38 public function setListsPermission($listsPermission)
39 {
40 $this->listsPermission = $listsPermission;
41 }
42
48 public function canRead()
49 {
50 if(
51 $this->listsPermission < \CListPermissions::CAN_WRITE &&
52 !\CIBlockSectionRights::userHasRightTo(
53 $this->rightParam->getIblockId(), $this->rightParam->getEntityId(), "section_read")
54 )
55 {
56 $this->errorCollection->setError(new Error("Access denied", self::ACCESS_DENIED));
57 return false;
58 }
59 return true;
60 }
61
67 public function canEdit()
68 {
69 $canEdit = (
70 !$this->socnetGroupClosed &&
71 (
72 ($this->listsPermission >= \CListPermissions::CAN_WRITE) ||
73 \CIBlockSectionRights::userHasRightTo(
74 $this->rightParam->getIblockId(), $this->rightParam->getEntityId(), "section_edit")
75 )
76 );
77
78 if ($canEdit)
79 {
80 return true;
81 }
82 else
83 {
84 $this->errorCollection->setError(new Error("Access denied", self::ACCESS_DENIED));
85 return false;
86 }
87 }
88
94 public function canAdd()
95 {
96 $canAdd = (
97 !$this->socnetGroupClosed &&
98 (
99 ($this->listsPermission >= \CListPermissions::CAN_WRITE) ||
100 \CIBlockSectionRights::userHasRightTo(
101 $this->rightParam->getIblockId(), $this->rightParam->getEntityId(), "section_section_bind")
102 )
103 );
104
105 if ($canAdd)
106 {
107 return true;
108 }
109 else
110 {
111 $this->errorCollection->setError(new Error("Access denied", self::ACCESS_DENIED));
112 return false;
113 }
114 }
115
121 public function canDelete()
122 {
123 $canDelete = (
124 !$this->socnetGroupClosed &&
125 (
126 ($this->listsPermission >= \CListPermissions::CAN_WRITE) ||
127 \CIBlockSectionRights::userHasRightTo(
128 $this->rightParam->getIblockId(), $this->rightParam->getEntityId(), "section_delete")
129 )
130 );
131
132 if ($canDelete)
133 {
134 return true;
135 }
136 else
137 {
138 $this->errorCollection->setError(new Error("Access denied", self::ACCESS_DENIED));
139 return false;
140 }
141 }
142}
__construct(RightParam $rightParam)