1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
call.php
См. документацию.
1<?php
2
3namespace Bitrix\Im\Model;
4
5use Bitrix\Im\Call\Call;
6use Bitrix\Main\Application;
7use Bitrix\Main\Type\DateTime;
8use Bitrix\Main\ORM\Query\Join;
9use Bitrix\Main\ORM\Data\DataManager;
10use Bitrix\Main\ORM\Fields\StringField;
11use Bitrix\Main\ORM\Fields\IntegerField;
12use Bitrix\Main\ORM\Fields\DatetimeField;
13use Bitrix\Main\ORM\Fields\BooleanField;
14use Bitrix\Main\ORM\Fields\EnumField;
15use Bitrix\Main\ORM\Fields\Relations\Reference;
16
34{
35 public static function getTableName(): string
36 {
37 return 'b_im_call';
38 }
39
40 public static function getMap(): array
41 {
42 return [
43 (new IntegerField('ID'))
44 ->configurePrimary()
45 ->configureAutocomplete(),
46
47 new IntegerField('TYPE'),
48
49 (new EnumField('SCHEME'))
50 ->configureValues([Call::SCHEME_CLASSIC, Call::SCHEME_JWT])
51 ->configureDefaultValue(Call::SCHEME_CLASSIC)
52 ->configureNullable(),
53
54 new IntegerField('INITIATOR_ID'),
55
56 (new StringField('IS_PUBLIC'))
57 ->configureDefaultValue('N'),
58
59 new StringField('PUBLIC_ID'),
60
61 new StringField('PROVIDER'),
62
63 new StringField('ENTITY_TYPE'),
64
65 new StringField('ENTITY_ID'),
66
67 new IntegerField('PARENT_ID'),
68
69 (new StringField('PARENT_UUID'))
70 ->configureSize(36),
71
72 new StringField('STATE'),
73
74 (new DatetimeField('START_DATE'))
75 ->configureDefaultValue(fn() => new DateTime()),
76
77 new DatetimeField('END_DATE'),
78
79 new IntegerField('CHAT_ID'),
80
81 new StringField('LOG_URL'),
82
83 (new StringField('UUID'))
84 ->configureSize(36),
85
86 (new StringField('SECRET_KEY'))
87 ->configureSize(10),
88
89 new StringField('ENDPOINT'),
90
91 (new BooleanField('RECORD_AUDIO'))
92 ->configureValues('N', 'Y')
94
95 (new BooleanField('AI_ANALYZE'))
96 ->configureValues('N', 'Y')
97 ->configureDefaultValue('N'),
98
99 (new Reference('CALL_USER',CallUserTable::class,
100 Join::on('this.ID', 'ref.CALL_ID')))
101 ->configureJoinType(Join::TYPE_INNER),
102 ];
103 }
104
111 public static function updateState(int $id, string $newState) : bool
112 {
113 $connection = Application::getConnection();
114 $sqlHelper = $connection->getSqlHelper();
115 $tableName = static::getTableName();
116 $newState = $sqlHelper->forSql($newState);
117
118 $update = "STATE = '$newState'";
119 if($newState === Call::STATE_FINISHED)
120 {
121 $update .= ", END_DATE = CURRENT_TIMESTAMP";
122 }
123
124 $query = "
125 UPDATE
126 $tableName
127 SET
128 $update
129 WHERE
130 ID = $id
131 AND STATE != '$newState'
132 ";
133
134 $connection->query($query);
135 return $connection->getAffectedRowsCount() === 1;
136 }
137
138}
$connection
Определения actionsdefinitions.php:38
static getMap()
Определения call.php:40
static updateState(int $id, string $newState)
Определения call.php:111
static getTableName()
Определения call.php:35
configureDefaultValue($value)
Определения scalarfield.php:248
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$query
Определения get_search.php:11