Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
CheckChatManageUpdate.php
1
<?php
2
3
namespace
Bitrix\Im\V2\Controller\Filter
;
4
5
use
Bitrix\Im\V2\Chat
;
6
use
Bitrix\Im\V2\Chat\ChatError
;
7
use
Bitrix\Main\Engine\ActionFilter\Base
;
8
use
Bitrix\Main\Engine\Response\Converter
;
9
use
Bitrix\Main\Event
;
10
use
Bitrix\Main\EventResult
;
11
12
class
CheckChatManageUpdate
extends
Base
13
{
14
public
function
onBeforeAction
(
Event
$event)
15
{
16
$arguments = $this->
getAction
()->getArguments();
17
$arguments[
'rightsLevel'
] = (
new
Converter
(Converter::TO_UPPER))->process($arguments[
'rightsLevel'
] ??
''
);
18
$this->
getAction
()->setArguments($arguments);
19
$rightsLevel = $arguments[
'rightsLevel'
];
20
$actionName = $this->
getAction
()->getName();
21
if
($this->inArrayCaseInsensitive($actionName, [
'setManageUsersAdd'
,
'setManageUsersDelete'
,
'setManageUI'
],
true
))
22
{
23
if
(in_array(
24
$rightsLevel,
25
[
Chat::MANAGE_RIGHTS_MEMBER
,
Chat::MANAGE_RIGHTS_MANAGERS
,
Chat::MANAGE_RIGHTS_OWNER
],
26
true
27
))
28
{
29
return
null
;
30
}
31
}
32
33
if
($actionName ===
'setManageSettings'
|| $actionName ===
'setmanagesettings'
)
34
{
35
if
(in_array(
36
$rightsLevel,
37
[
Chat::MANAGE_RIGHTS_MANAGERS
,
Chat::MANAGE_RIGHTS_OWNER
],
38
true
39
))
40
{
41
return
null
;
42
}
43
}
44
45
$this->
addError
(
new
ChatError
(
46
ChatError::WRONG_PARAMETER
47
));
48
return
new
EventResult
(EventResult::ERROR,
null
,
null
, $this);
49
}
50
57
private
function
inArrayCaseInsensitive(
string
$needle, array $haystack,
bool
$strict =
true
): bool
58
{
59
$needle = mb_strtolower($needle);
60
$haystack = array_map(
'mb_strtolower'
, $haystack);
61
62
return
in_array($needle, $haystack, $strict);
63
}
64
}
Bitrix\Im\V2\Chat\ChatError
Definition
ChatError.php:9
Bitrix\Im\V2\Chat\ChatError\WRONG_PARAMETER
const WRONG_PARAMETER
Definition
ChatError.php:12
Bitrix\Im\V2\Chat\MANAGE_RIGHTS_MEMBER
const MANAGE_RIGHTS_MEMBER
Definition
Chat.php:133
Bitrix\Im\V2\Chat\MANAGE_RIGHTS_MANAGERS
const MANAGE_RIGHTS_MANAGERS
Definition
Chat.php:135
Bitrix\Im\V2\Chat\MANAGE_RIGHTS_OWNER
const MANAGE_RIGHTS_OWNER
Definition
Chat.php:134
Bitrix\Im\V2\Controller\Filter\CheckChatManageUpdate
Definition
CheckChatManageUpdate.php:13
Bitrix\Im\V2\Controller\Filter\CheckChatManageUpdate\onBeforeAction
onBeforeAction(Event $event)
Definition
CheckChatManageUpdate.php:14
Bitrix\Im\V2\Sync\Event
Definition
Event.php:9
Bitrix\Main\Engine\ActionFilter\Base
Definition
base.php:15
Bitrix\Main\Engine\ActionFilter\Base\addError
addError(Error $error)
Definition
base.php:80
Bitrix\Main\Engine\ActionFilter\Base\getAction
getAction()
Definition
base.php:48
Bitrix\Main\Engine\Response\Converter
Definition
converter.php:8
Bitrix\Main\Event
Definition
event.php:5
Bitrix\Main\EventResult
Definition
eventresult.php:5
Bitrix\Im\V2\Chat
Definition
ChannelChat.php:3
Bitrix\Im\V2\Controller\Filter
Definition
ActionUuidHandler.php:3
modules
im
lib
V2
Controller
Filter
CheckChatManageUpdate.php
Создано системой
1.10.0