Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
role.php
1
<?php
2
namespace
Bitrix\Landing\Internals
;
3
4
use \Bitrix\Main\Entity;
5
use \Bitrix\Main\Localization\Loc;
6
7
Loc::loadMessages
(__FILE__);
8
25
class
RoleTable
extends
Entity\DataManager
26
{
31
public
static
function
getTableName
()
32
{
33
return
'b_landing_role'
;
34
}
35
40
public
static
function
getMap
()
41
{
42
return
array(
43
'ID'
=>
new
Entity
\
IntegerField
(
'ID'
, array(
44
'title'
=>
'ID'
,
45
'primary'
=>
true
,
46
'autocomplete'
=>
true
,
47
)),
48
'TITLE'
=>
new
Entity
\
StringField
(
'TITLE'
, array(
49
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_ROLE_TITLE'
)
50
)),
51
'XML_ID'
=>
new
Entity
\
StringField
(
'XML_ID'
, array(
52
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_ROLE_XML_ID'
)
53
)),
54
'TYPE'
=>
new
Entity
\
StringField
(
'TYPE'
, array(
55
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_ROLE_TYPE'
)
56
)),
57
'ACCESS_CODES'
=>
new
Entity
\
StringField
(
'ACCESS_CODES'
, array(
58
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_ROLE_ACCESS_CODES'
),
59
'serialized'
=>
true
60
)),
61
'ADDITIONAL_RIGHTS'
=>
new
Entity
\
StringField
(
'ADDITIONAL_RIGHTS'
, array(
62
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_ROLE_ADDITIONAL_RIGHTS'
),
63
'serialized'
=>
true
64
)),
65
'CREATED_BY_ID'
=>
new
Entity
\
IntegerField
(
'CREATED_BY_ID'
, array(
66
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_CREATED_BY_ID'
),
67
'required'
=>
true
68
)),
69
'CREATED_BY'
=>
new
Entity
\ReferenceField(
70
'CREATED_BY'
,
71
'Bitrix\Main\UserTable'
,
72
array(
'=this.CREATED_BY_ID'
=>
'ref.ID'
)
73
),
74
'MODIFIED_BY_ID'
=>
new
Entity
\
IntegerField
(
'MODIFIED_BY_ID'
, array(
75
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_MODIFIED_BY_ID'
),
76
'required'
=>
true
77
)),
78
'MODIFIED_BY'
=>
new
Entity
\ReferenceField(
79
'MODIFIED_BY'
,
80
'Bitrix\Main\UserTable'
,
81
array(
'=this.MODIFIED_BY_ID'
=>
'ref.ID'
)
82
),
83
'DATE_CREATE'
=>
new
Entity
\
DatetimeField
(
'DATE_CREATE'
, array(
84
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_DATE_CREATE'
),
85
'required'
=>
true
86
)),
87
'DATE_MODIFY'
=>
new
Entity
\
DatetimeField
(
'DATE_MODIFY'
, array(
88
'title'
=>
Loc::getMessage
(
'LANDING_TABLE_FIELD_DATE_MODIFY'
),
89
'required'
=>
true
90
))
91
);
92
}
93
99
public
static
function
onAfterDelete
(
Entity
\
Event
$event)
100
{
101
$result =
new
Entity\EventResult();
102
$primary = $event->getParameter(
'primary'
);
103
104
// delete all inner landings
105
if
($primary)
106
{
107
$res = RightsTable::getList(array(
108
'select'
=> array(
109
'ID'
110
),
111
'filter'
=> array(
112
'ROLE_ID'
=> $primary[
'ID'
]
113
)
114
));
115
while
($row = $res->fetch())
116
{
117
RightsTable::delete($row[
'ID'
]);
118
}
119
}
120
121
\Bitrix\Landing\Rights::refreshAdditionalRights();
122
123
return
$result;
124
}
125
131
public
static
function
OnBeforeAdd
(
Entity
\
Event
$event)
132
{
133
$result =
new
Entity\EventResult();
134
$fields = $event->getParameter(
'fields'
);
135
136
// check title
137
if
(
138
(
139
!isset($fields[
'TITLE'
]) ||
140
!trim($fields[
'TITLE'
])
141
) &&
142
(
143
!isset($fields[
'XML_ID'
]) ||
144
!trim($fields[
'XML_ID'
])
145
)
146
)
147
{
148
$result->setErrors(array(
149
new
Entity
\
EntityError
(
150
Loc::getMessage
(
'LANDING_TABLE_ERROR_TITLE_REQUIRED'
),
151
'TITLE_REQUIRED'
152
)
153
));
154
}
155
156
$result->modifyFields([
157
'TYPE'
=> \
Bitrix
\
Landing
\
Site
\Type::getFilterType(
true
)
158
]);
159
160
return
$result;
161
}
162
168
public
static
function
OnBeforeUpdate
(
Entity
\
Event
$event)
169
{
170
$result =
new
Entity\EventResult();
171
$primary = $event->getParameter(
'primary'
);
172
$fields = $event->getParameter(
'fields'
);
173
174
// check title
175
if
(
176
$primary[
'ID'
] &&
177
(
178
isset($fields[
'TITLE'
]) &&
179
!trim($fields[
'TITLE'
])
180
)
181
)
182
{
183
$row = self::getList([
184
'filter'
=> [
185
'ID'
=> $primary[
'ID'
]
186
]
187
])->fetch();
188
if
(
189
$row &&
190
!trim($row[
'XML_ID'
])
191
)
192
{
193
$result->setErrors(array(
194
new
Entity
\
EntityError
(
195
Loc::getMessage
(
'LANDING_TABLE_ERROR_TITLE_REQUIRED'
),
196
'TITLE_REQUIRED'
197
)
198
));
199
}
200
unset($primary, $fields, $row);
201
202
return
$result;
203
}
204
205
unset($primary, $fields);
206
207
return
$result;
208
}
209
}
Bitrix\Landing\Controller\Landing
Definition
landing.php:8
Bitrix\Landing\Internals\RoleTable
Definition
role.php:26
Bitrix\Landing\Internals\RoleTable\getMap
static getMap()
Definition
role.php:40
Bitrix\Landing\Internals\RoleTable\OnBeforeAdd
static OnBeforeAdd(Entity\Event $event)
Definition
role.php:131
Bitrix\Landing\Internals\RoleTable\OnBeforeUpdate
static OnBeforeUpdate(Entity\Event $event)
Definition
role.php:168
Bitrix\Landing\Internals\RoleTable\onAfterDelete
static onAfterDelete(Entity\Event $event)
Definition
role.php:99
Bitrix\Landing\Internals\RoleTable\getTableName
static getTableName()
Definition
role.php:31
Bitrix\Landing\Restriction\Site
Definition
site.php:15
Bitrix\Main\Event
Definition
event.php:5
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\EntityError
Definition
entityerror.php:12
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\ORM\Fields\DatetimeField
Definition
datetimefield.php:22
Bitrix\Main\ORM\Fields\IntegerField
Definition
integerfield.php:20
Bitrix\Main\ORM\Fields\StringField
Definition
stringfield.php:20
Bitrix\Landing\Internals
Definition
base.php:2
Bitrix
modules
landing
lib
internals
role.php
Создано системой
1.10.0