Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
call.php
1
<?php
2
3
namespace
Bitrix\Im\Model
;
4
5
use Bitrix\Disk\Internals\Entity\Query;
6
use
Bitrix\Im\Call\Call
;
7
use
Bitrix\Main\Application
;
8
use
Bitrix\Main\Entity
;
9
use
Bitrix\Main\Type\Date
;
10
use
Bitrix\Main\Type\DateTime
;
11
28
class
CallTable
extends
Entity\DataManager
29
{
30
public
static
function
getTableName
()
31
{
32
return
'b_im_call'
;
33
}
34
35
public
static
function
getMap
()
36
{
37
return
array(
38
new
Entity
\
IntegerField
(
'ID'
, array(
39
'primary'
=>
true
,
40
'autocomplete'
=>
true
41
)),
42
new
Entity
\
IntegerField
(
'TYPE'
),
43
new
Entity
\
IntegerField
(
'INITIATOR_ID'
),
44
new
Entity
\
StringField
(
'IS_PUBLIC'
, array(
45
'default_value'
=>
'N'
46
)),
47
new
Entity
\
StringField
(
'PUBLIC_ID'
),
48
new
Entity
\
StringField
(
'PROVIDER'
),
49
new
Entity
\
StringField
(
'ENTITY_TYPE'
),
50
new
Entity
\
StringField
(
'ENTITY_ID'
),
51
new
Entity
\
IntegerField
(
'PARENT_ID'
),
52
new
Entity
\
StringField
(
'STATE'
),
53
new
Entity
\
DatetimeField
(
'START_DATE'
, array(
54
'default_value'
=>
function
()
55
{
56
return
new
DateTime
();
57
}
58
)),
59
new
Entity\DatetimeField(
'END_DATE'
),
60
new
Entity\IntegerField(
'CHAT_ID'
),
61
new
Entity\StringField(
'LOG_URL'
),
62
new
Entity\StringField(
63
'UUID'
,
64
[
65
'size'
=> 36,
66
]
67
),
68
new
Entity\StringField(
69
'SECRET_KEY'
,
70
[
71
'size'
=> 10,
72
]
73
),
74
new
Entity\StringField(
75
'ENDPOINT'
76
),
77
);
78
}
79
86
public
static
function
updateState
(
int
$id,
string
$newState) : bool
87
{
88
$connection =
Application::getConnection
();
89
$sqlHelper = $connection->getSqlHelper();
90
$tableName = static::getTableName();
91
$newState = $sqlHelper->forSql($newState);
92
93
$update =
"STATE = '$newState'"
;
94
if
($newState === Call::STATE_FINISHED)
95
{
96
$update .=
", END_DATE = CURRENT_TIMESTAMP"
;
97
}
98
99
$query =
"
100
UPDATE
101
$tableName
102
SET
103
$update
104
WHERE
105
ID = $id
106
AND STATE != '$newState'
107
"
;
108
109
$connection->query($query);
110
return
$connection->getAffectedRowsCount() === 1;
111
}
112
113
}
Bitrix\Im\Call\Call
Definition
call.php:22
Bitrix\Im\Model\CallTable
Definition
call.php:29
Bitrix\Im\Model\CallTable\getMap
static getMap()
Definition
call.php:35
Bitrix\Im\Model\CallTable\updateState
static updateState(int $id, string $newState)
Definition
call.php:86
Bitrix\Im\Model\CallTable\getTableName
static getTableName()
Definition
call.php:30
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getConnection
static getConnection($name="")
Definition
application.php:611
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\Main\Type\Date
Definition
date.php:9
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Im\V2\Sync\Entity
Definition
Entity.php:6
Bitrix\Im\Model
Definition
alias.php:2
modules
im
lib
model
call.php
Создано системой
1.10.0