1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
accesseventhandler.php
См. документацию.
1
<?php
2
3
4
namespace
Bitrix\Main\Access\Auth;
5
6
7
use Bitrix\HumanResources\Config\Storage;
8
use Bitrix\Iblock\SectionTable;
9
use Bitrix\Main\Access\AccessCode;
10
use Bitrix\Main\Loader;
11
use Bitrix\Main\UserAccessTable;
12
13
class
AccessEventHandler
14
{
15
public
static
function
onBeforeIBlockSectionUpdate
(&
$fields
)
16
{
17
if
(
18
!is_array(
$fields
)
19
|| !array_key_exists(
'IBLOCK_ID'
,
$fields
)
20
|| !array_key_exists(
'UF_HEAD'
,
$fields
)
21
|| !array_key_exists(
'ID'
,
$fields
)
22
|| self::isHumanResourcesUsed()
23
)
24
{
25
return
;
26
}
27
28
$iblockId
= (int) \COption::GetOptionInt(
'intranet'
,
'iblock_structure'
);
29
if
(
30
!
$iblockId
31
|| (
int
)
$fields
[
'IBLOCK_ID'
] !==
$iblockId
32
)
33
{
34
return
;
35
}
36
37
$ufHead = (int)
$fields
[
'UF_HEAD'
];
38
if
($ufHead > 0)
39
{
40
(
new
AccessAuthProvider
())->DeleteByUser($ufHead);
41
}
42
43
$accessCode =
AccessCode::ACCESS_DIRECTOR
.
$fields
[
'ID'
];
44
self::deleteByAccessCode($accessCode);
45
}
46
47
public
static
function
onBeforeIBlockSectionDelete
($sectionId)
48
{
49
$sectionId = (int) $sectionId;
50
if
($sectionId < 1 || self::isHumanResourcesUsed())
51
{
52
return
;
53
}
54
55
$iblockId
= (int) \COption::GetOptionInt(
'intranet'
,
'iblock_structure'
);
56
if
(!
$iblockId
)
57
{
58
return
;
59
}
60
61
if
(!
Loader::includeModule
(
'iblock'
))
62
{
63
return
;
64
}
65
66
$res
= SectionTable::getList([
67
'filter'
=> [
68
'=IBLOCK_ID'
=>
$iblockId
,
69
'=ID'
=> $sectionId
70
]
71
]);
72
if
(!
$res
->getSelectedRowsCount())
73
{
74
return
;
75
}
76
77
$accessCode =
AccessCode::ACCESS_DIRECTOR
. $sectionId;
78
self::deleteByAccessCode($accessCode);
79
}
80
81
public
static
function
onBeforeIBlockSectionAdd
(&
$fields
)
82
{
83
if
(
84
!is_array(
$fields
)
85
|| !array_key_exists(
'IBLOCK_ID'
,
$fields
)
86
|| !array_key_exists(
'UF_HEAD'
,
$fields
)
87
|| !array_key_exists(
'IBLOCK_SECTION_ID'
,
$fields
)
88
|| self::isHumanResourcesUsed()
89
)
90
{
91
return
;
92
}
93
94
$ufHead = (int)
$fields
[
'UF_HEAD'
];
95
if
($ufHead < 1)
96
{
97
return
;
98
}
99
(
new
AccessAuthProvider
())->DeleteByUser($ufHead);
100
}
101
102
private
static
function
deleteByAccessCode(
string
$accessCode)
103
{
104
// find users by access codes
105
$res
= UserAccessTable::getList([
106
'filter'
=> [
107
'=ACCESS_CODE'
=> $accessCode
108
],
109
'select'
=> [
'USER_ID'
]
110
]);
111
112
$provider
=
new
AccessAuthProvider
();
113
while
($row =
$res
->fetch())
114
{
115
$provider
->DeleteByUser($row[
'USER_ID'
]);
116
}
117
}
118
122
public
static
function
isHumanResourcesUsed
(): bool
123
{
124
return
Loader::includeModule
(
'humanresources'
)
125
&& Storage::instance()->isCompanyStructureConverted();
126
}
127
}
$provider
if(!Loader::includeModule('messageservice')) $provider
Определения
callback_ednaruimhpx.php:21
Bitrix\Main\Access\AccessCode\ACCESS_DIRECTOR
const ACCESS_DIRECTOR
Определения
accesscode.php:15
Bitrix\Main\Access\Auth\AccessAuthProvider
Определения
accessauthprovider.php:23
Bitrix\Main\Access\Auth\AccessEventHandler
Определения
accesseventhandler.php:14
Bitrix\Main\Access\Auth\AccessEventHandler\onBeforeIBlockSectionDelete
static onBeforeIBlockSectionDelete($sectionId)
Определения
accesseventhandler.php:47
Bitrix\Main\Access\Auth\AccessEventHandler\isHumanResourcesUsed
static isHumanResourcesUsed()
Определения
accesseventhandler.php:122
Bitrix\Main\Access\Auth\AccessEventHandler\onBeforeIBlockSectionUpdate
static onBeforeIBlockSectionUpdate(&$fields)
Определения
accesseventhandler.php:15
Bitrix\Main\Access\Auth\AccessEventHandler\onBeforeIBlockSectionAdd
static onBeforeIBlockSectionAdd(&$fields)
Определения
accesseventhandler.php:81
Bitrix\Main\Loader\includeModule
static includeModule($moduleName)
Определения
loader.php:67
$res
$res
Определения
filter_act.php:7
$iblockId
$iblockId
Определения
iblock_catalog_edit.php:30
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
main
lib
access
auth
accesseventhandler.php
Создано системой
1.14.0