Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
jitsilite.php
1
<?php
2
3
4
namespace
Bitrix\Im\Controller
;
5
6
7
use
Bitrix\Im\Alias
;
8
use
Bitrix\Im\Dialog
;
9
use
Bitrix\Im\User
;
10
use
Bitrix\Main\Engine\Action
;
11
use
Bitrix\Main\Engine\Controller
;
12
use
Bitrix\Main\Engine\CurrentUser
;
13
use
Bitrix\Main\Error
;
14
use
Bitrix\Main\Loader
;
15
use
Bitrix\Main\Localization\Loc
;
16
17
class
JitsiLite
extends
Controller
18
{
19
protected
function
processBeforeAction
(
Action
$action): bool
20
{
21
if
(!Loader::includeModule(
'im'
))
22
{
23
$this->
addError
(
new
Error
(
"Module IM is not installed"
));
24
25
return
false
;
26
}
27
28
if
(
User::getInstance
()->isExtranet())
29
{
30
$this->
addError
(
new
Error
(
"You dont have access to this action"
));
31
32
return
false
;
33
}
34
35
return
true
;
36
}
37
38
public
function
createConferenceAction
(
string
$dialogId,
CurrentUser
$currentUser)
39
{
40
if
(!\
Bitrix
\Im\
Dialog::hasAccess
($dialogId, $currentUser->
getId
()))
41
{
42
$this->
addError
(
new
Error
(
"You must be a member of the chat to call it"
));
43
44
return
null
;
45
}
46
47
$chatId =
Dialog::getChatId
($dialogId);
48
49
$aliasData =
Alias::addUnique
([
50
"ENTITY_TYPE"
=>
Alias::ENTITY_TYPE_JITSICONF
,
51
"ENTITY_ID"
=> $chatId
52
]);
53
54
$message =
Loc::getMessage
(
"IM_JITSI_LITE_INVITE_TO_CONF"
);
55
56
$keyboard = new \Bitrix\Im\Bot\Keyboard();
57
$keyboard->addButton([
58
"TEXT"
=>
Loc::getMessage
(
"IM_JITSI_LITE_OPEN_CONF"
),
59
"FUNCTION"
=>
"if ('BXIM' in window) {BXIM.openVideoconf('{$aliasData['ALIAS']}')} else {ChatUtils.openVideoconf('{$aliasData['ALIAS']}')};"
,
60
"BG_COLOR"
=>
"#29619b"
,
61
"TEXT_COLOR"
=>
"#fff"
,
62
"DISPLAY"
=>
"LINE"
,
63
]);
64
65
\CIMChat::AddMessage([
66
"FROM_USER_ID"
=> $currentUser->
getId
(),
67
"TO_CHAT_ID"
=> $chatId,
68
"MESSAGE"
=> $message,
69
"SYSTEM"
=>
'Y'
,
70
"KEYBOARD"
=> $keyboard,
71
]);
72
73
return
[
74
'ALIAS_DATA'
=> $aliasData
75
];
76
}
77
}
Bitrix\Im\Alias
Definition
alias.php:8
Bitrix\Im\Alias\addUnique
static addUnique(array $fields)
Definition
alias.php:55
Bitrix\Im\Alias\ENTITY_TYPE_JITSICONF
const ENTITY_TYPE_JITSICONF
Definition
alias.php:14
Bitrix\Im\Controller\JitsiLite
Definition
jitsilite.php:18
Bitrix\Im\Controller\JitsiLite\createConferenceAction
createConferenceAction(string $dialogId, CurrentUser $currentUser)
Definition
jitsilite.php:38
Bitrix\Im\Controller\JitsiLite\processBeforeAction
processBeforeAction(Action $action)
Definition
jitsilite.php:19
Bitrix\Im\Dialog
Definition
dialog.php:9
Bitrix\Im\Dialog\getChatId
static getChatId($dialogId, $userId=null)
Definition
dialog.php:91
Bitrix\Im\Dialog\hasAccess
static hasAccess($dialogId, $userId=null)
Definition
dialog.php:143
Bitrix\Im\User
Definition
user.php:10
Bitrix\Im\User\getInstance
static getInstance($userId=null)
Definition
user.php:44
Bitrix\Im\V2\Error
Definition
Error.php:8
Bitrix\Main\Engine\Action
Definition
action.php:17
Bitrix\Main\Engine\Controller
Definition
controller.php:32
Bitrix\Main\Engine\Controller\addError
addError(Error $error)
Definition
controller.php:1051
Bitrix\Main\Engine\CurrentUser
Definition
currentuser.php:8
Bitrix\Main\Engine\CurrentUser\getId
getId()
Definition
currentuser.php:45
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Loader
Definition
loader.php:12
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Im\Controller
Definition
call.php:3
Bitrix\Sender\Internals\QueryController
Definition
action.php:8
Bitrix
modules
im
lib
controller
jitsilite.php
Создано системой
1.10.0