Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
CheckChatOwner.php
1
<?php
2
3
namespace
Bitrix\Im\V2\Controller\Filter
;
4
5
use
Bitrix\Im\V2\Chat
;
6
use
Bitrix\Main\Engine\ActionFilter\Base
;
7
use
Bitrix\Main\Error
;
8
use
Bitrix\Main\Event
;
9
use
Bitrix\Main\EventResult
;
10
11
class
CheckChatOwner
extends
Base
12
{
13
public
function
onBeforeAction
(
Event
$event)
14
{
15
$currentUser = $this->
getAction
()->getCurrentUser();
16
$currentUserId = (int)(isset($currentUser) ? $currentUser->getId() :
null
);
17
18
if
($this->
getAction
()->getName() ===
'setOwner'
|| $this->
getAction
()->getName() ===
'setowner'
)
19
{
20
21
$arguments = $this->
getAction
()->getArguments();
25
$chat = $arguments[
'chat'
];
26
27
if
(!isset($arguments[
'ownerId'
]))
28
{
29
$this->
addError
(
new
Error
(
30
'Parameter ownerId is required'
,
31
Chat
\
ChatError::WRONG_PARAMETER
32
));
33
return
new
EventResult
(EventResult::ERROR,
null
,
null
, $this);
34
}
35
36
if
($chat->getAuthorId() === $currentUserId)
37
{
38
return
null
;
39
}
40
41
$manageSettings = $chat->getManageSettings();
42
if
($manageSettings ===
Chat::MANAGE_RIGHTS_MANAGERS
)
43
{
44
$selfRelation = $chat->getSelfRelation();
45
if
($selfRelation->getManager())
46
{
47
return
null
;
48
}
49
}
50
}
51
52
$this->
addError
(
new
Error
(
53
Chat
\
ChatError::ACCESS_DENIED
54
));
55
return
new
EventResult
(EventResult::ERROR,
null
,
null
, $this);
56
}
57
}
Bitrix\Im\Chat
Definition
chat.php:19
Bitrix\Im\V2\Chat\ChatError\WRONG_PARAMETER
const WRONG_PARAMETER
Definition
ChatError.php:12
Bitrix\Im\V2\Chat\ChatError\ACCESS_DENIED
const ACCESS_DENIED
Definition
ChatError.php:21
Bitrix\Im\V2\Chat\MANAGE_RIGHTS_MANAGERS
const MANAGE_RIGHTS_MANAGERS
Definition
Chat.php:135
Bitrix\Im\V2\Controller\Filter\CheckChatOwner
Definition
CheckChatOwner.php:12
Bitrix\Im\V2\Error
Definition
Error.php:8
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\ActionFilter\Base\onBeforeAction
onBeforeAction(Event $event)
Definition
base.php:66
Bitrix\Main\Error
Definition
error.php:14
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
CheckChatOwner.php
Создано системой
1.10.0