Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
letter.php
1
<?php
8
namespace
Bitrix\Sender\Internals\Model
;
9
10
use
Bitrix\Main\Entity
;
11
use
Bitrix\Main\Localization\Loc
;
12
use
Bitrix\Main\Type
;
13
use
Bitrix\Sender\FileTable
;
14
use
Bitrix\Sender\MailingChainTable
;
15
use
Bitrix\Sender\Message\iBase
;
16
17
Loc::loadMessages
(__FILE__);
18
35
class
LetterTable
extends
Entity\DataManager
36
{
37
const
STATUS_NEW
=
'N'
;
38
const
STATUS_READY
=
'R'
;
39
const
STATUS_SEND
=
'S'
;
40
const
STATUS_PAUSE
=
'P'
;
41
const
STATUS_WAIT
=
'W'
;
42
const
STATUS_HALT
=
'H'
;
43
const
STATUS_PLAN
=
'T'
;
44
const
STATUS_END
=
'Y'
;
45
const
STATUS_CANCEL
=
'C'
;
46
50
public
static
function
getTableName
()
51
{
52
return
'b_sender_mailing_chain'
;
53
}
54
58
public
static
function
getMap
()
59
{
60
return
array(
61
'ID'
=> array(
62
'data_type'
=>
'integer'
,
63
'autocomplete'
=>
true
,
64
'primary'
=>
true
,
65
),
66
'CAMPAIGN_ID'
=> array(
67
'data_type'
=>
'integer'
,
68
'column_name'
=>
'MAILING_ID'
,
69
'required'
=>
true
,
70
),
71
72
'MESSAGE_CODE'
=> array(
73
'data_type'
=>
'string'
,
74
'required'
=>
true
,
75
'default_value'
=>
function
()
76
{
77
return
iBase::CODE_MAIL;
78
},
79
),
80
'MESSAGE_ID'
=> array(
81
'data_type'
=>
'string'
,
82
),
83
84
'TEMPLATE_TYPE'
=> array(
85
'data_type'
=>
'string'
,
86
),
87
'TEMPLATE_ID'
=> array(
88
'data_type'
=>
'string'
,
89
),
90
91
'POSTING_ID'
=> array(
92
'data_type'
=>
'integer'
,
93
),
94
'PARENT_ID'
=> array(
95
'data_type'
=>
'integer'
,
96
),
97
'CREATED_BY'
=> array(
98
'data_type'
=>
'integer'
,
99
),
100
'UPDATED_BY'
=> array(
101
'data_type'
=>
'integer'
,
102
),
103
'DATE_INSERT'
=> array(
104
'data_type'
=>
'datetime'
,
105
'default_value'
=>
new
Type
\
DateTime
(),
106
),
107
'DATE_UPDATE'
=> array(
108
'data_type'
=>
'datetime'
,
109
'default_value'
=>
new
Type
\
DateTime
(),
110
),
111
'STATUS'
=> array(
112
'data_type'
=>
'string'
,
113
'required'
=>
true
,
114
'default_value'
=> static::STATUS_NEW,
115
),
116
'REITERATE'
=> array(
117
'data_type'
=>
'boolean'
,
118
'default_value'
=>
'N'
,
119
'values'
=> array(
'N'
,
'Y'
)
120
),
121
'IS_TRIGGER'
=> array(
122
'data_type'
=>
'boolean'
,
123
'default_value'
=>
'N'
,
124
'values'
=> array(
'N'
,
'Y'
)
125
),
126
'IS_ADS'
=> array(
127
'data_type'
=>
'boolean'
,
128
'default_value'
=>
'N'
,
129
'values'
=> array(
'N'
,
'Y'
)
130
),
131
'LAST_EXECUTED'
=> array(
132
'data_type'
=>
'datetime'
,
133
),
134
'TITLE'
=> array(
135
'data_type'
=>
'string'
,
136
'title'
=>
Loc::getMessage
(
'SENDER_ENTITY_MAILING_CHAIN_FIELD_TITLE_TITLE1'
),
137
'save_data_modification'
=> array(
'\Bitrix\Main\Text\Emoji'
,
'getSaveModificator'
),
138
'fetch_data_modification'
=> array(
'\Bitrix\Main\Text\Emoji'
,
'getFetchModificator'
),
139
),
140
141
'AUTO_SEND_TIME'
=> array(
142
'data_type'
=>
'datetime'
,
143
),
144
'DAYS_OF_WEEK'
=> array(
145
'data_type'
=>
'string'
,
146
),
147
'DAYS_OF_MONTH'
=> array(
148
'data_type'
=>
'string'
,
149
),
150
'MONTHS_OF_YEAR'
=> array(
151
'data_type'
=>
'string'
,
152
),
153
'TIMES_OF_DAY'
=> array(
154
'data_type'
=>
'string'
,
155
),
156
'TIME_SHIFT'
=> array(
157
'data_type'
=>
'integer'
,
158
),
159
160
'ERROR_MESSAGE'
=> array(
161
'data_type'
=>
'string'
,
162
),
163
164
'SEARCH_CONTENT'
=> array(
165
'data_type'
=>
'text'
,
166
'save_data_modification'
=> array(
'\Bitrix\Main\Text\Emoji'
,
'getSaveModificator'
),
167
'fetch_data_modification'
=> array(
'\Bitrix\Main\Text\Emoji'
,
'getFetchModificator'
),
168
),
169
170
'MESSAGE'
=> array(
171
'data_type'
=> MessageTable::class,
172
'reference'
=> array(
'=this.MESSAGE_ID'
=>
'ref.ID'
),
173
),
174
'CAMPAIGN'
=> array(
175
'data_type'
=>
'Bitrix\Sender\MailingTable'
,
176
'reference'
=> array(
'=this.CAMPAIGN_ID'
=>
'ref.ID'
),
177
),
178
'CURRENT_POSTING'
=> array(
179
'data_type'
=>
'Bitrix\Sender\PostingTable'
,
180
'reference'
=> array(
'=this.POSTING_ID'
=>
'ref.ID'
),
181
),
182
'POSTING'
=> array(
183
'data_type'
=>
'Bitrix\Sender\PostingTable'
,
184
'reference'
=> array(
'=this.ID'
=>
'ref.MAILING_CHAIN_ID'
),
185
),
186
'CREATED_BY_USER'
=> array(
187
'data_type'
=>
'Bitrix\Main\UserTable'
,
188
'reference'
=> array(
'=this.CREATED_BY'
=>
'ref.ID'
),
189
),
190
'WAITING_RECIPIENT'
=> array(
191
'data_type'
=>
'boolean'
,
192
'default_value'
=>
'N'
,
193
'values'
=> array(
'N'
,
'Y'
)
194
),
195
);
196
}
197
198
205
public
static
function
onAfterAdd
(
Entity
\
Event
$event)
206
{
207
return
MailingChainTable::onAfterAdd
($event);
208
}
209
216
public
static
function
onBeforeUpdate
(
Entity
\
Event
$event)
217
{
218
return
MailingChainTable::onBeforeUpdate
($event);
219
}
220
227
public
static
function
onAfterUpdate
(
Entity
\
Event
$event)
228
{
229
return
MailingChainTable::onAfterUpdate
($event);
230
}
231
238
public
static
function
onDelete
(
Entity
\
Event
$event)
239
{
240
$data = $event->getParameters();
241
$fields = static::getRowById($data[
'primary'
][
'ID'
]);
242
if
($fields)
243
{
244
$fileQuery = MessageFieldTable::getById([
245
'MESSAGE_ID'
=> $fields[
'MESSAGE_ID'
],
246
'CODE'
=>
'ATTACHMENT'
,
247
]);
248
249
if
($row = $fileQuery->fetch())
250
{
251
$files = explode(
","
, $row[
'VALUE'
]);
252
253
foreach
($files as $file)
254
{
255
if
((
int
)$file)
256
{
257
\CFile::Delete((
int
)$file);
258
}
259
}
260
}
261
262
$messageQuery = MessageFieldTable::getById([
263
'MESSAGE_ID'
=> $fields[
'MESSAGE_ID'
],
264
'CODE'
=>
'MESSAGE'
,
265
]);
266
267
if
($row = $messageQuery->fetch())
268
{
269
FileTable::syncFiles
($data[
'primary'
][
'ID'
], 0, $row[
'VALUE'
],
true
,
true
);
270
}
271
272
MessageTable::delete($fields[
'MESSAGE_ID'
]);
273
}
274
275
return
MailingChainTable::onDelete
($event);
276
}
277
282
public
static
function
onAfterDelete
(
Entity
\
Event
$event)
283
{
284
MailingChainTable::onAfterDelete
($event);
285
}
286
}
Bitrix\Main\Event
Definition
event.php:5
Bitrix\Main\FileTable
Definition
file.php:45
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Entity
Definition
entity.php:26
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Sender\FileTable\syncFiles
static syncFiles(int $entityId, int $entityType, string $template, bool $deleteFiles=true, bool $onDeleteEntity=false)
Definition
filetable.php:72
Bitrix\Sender\Internals\Model\LetterTable
Definition
letter.php:36
Bitrix\Sender\Internals\Model\LetterTable\onDelete
static onDelete(Entity\Event $event)
Definition
letter.php:238
Bitrix\Sender\Internals\Model\LetterTable\onBeforeUpdate
static onBeforeUpdate(Entity\Event $event)
Definition
letter.php:216
Bitrix\Sender\Internals\Model\LetterTable\STATUS_SEND
const STATUS_SEND
Definition
letter.php:39
Bitrix\Sender\Internals\Model\LetterTable\getMap
static getMap()
Definition
letter.php:58
Bitrix\Sender\Internals\Model\LetterTable\STATUS_HALT
const STATUS_HALT
Definition
letter.php:42
Bitrix\Sender\Internals\Model\LetterTable\STATUS_END
const STATUS_END
Definition
letter.php:44
Bitrix\Sender\Internals\Model\LetterTable\STATUS_CANCEL
const STATUS_CANCEL
Definition
letter.php:45
Bitrix\Sender\Internals\Model\LetterTable\STATUS_PAUSE
const STATUS_PAUSE
Definition
letter.php:40
Bitrix\Sender\Internals\Model\LetterTable\STATUS_PLAN
const STATUS_PLAN
Definition
letter.php:43
Bitrix\Sender\Internals\Model\LetterTable\onAfterAdd
static onAfterAdd(Entity\Event $event)
Definition
letter.php:205
Bitrix\Sender\Internals\Model\LetterTable\STATUS_NEW
const STATUS_NEW
Definition
letter.php:37
Bitrix\Sender\Internals\Model\LetterTable\STATUS_READY
const STATUS_READY
Definition
letter.php:38
Bitrix\Sender\Internals\Model\LetterTable\STATUS_WAIT
const STATUS_WAIT
Definition
letter.php:41
Bitrix\Sender\Internals\Model\LetterTable\onAfterUpdate
static onAfterUpdate(Entity\Event $event)
Definition
letter.php:227
Bitrix\Sender\Internals\Model\LetterTable\onAfterDelete
static onAfterDelete(Entity\Event $event)
Definition
letter.php:282
Bitrix\Sender\Internals\Model\LetterTable\getTableName
static getTableName()
Definition
letter.php:50
Bitrix\Sender\MailingChainTable
Definition
mailingchain.php:32
Bitrix\Sender\MailingChainTable\onDelete
static onDelete(Entity\Event $event)
Definition
mailingchain.php:430
Bitrix\Sender\MailingChainTable\onBeforeUpdate
static onBeforeUpdate(Entity\Event $event)
Definition
mailingchain.php:391
Bitrix\Sender\MailingChainTable\onAfterAdd
static onAfterAdd(Entity\Event $event)
Definition
mailingchain.php:356
Bitrix\Sender\MailingChainTable\onAfterUpdate
static onAfterUpdate(Entity\Event $event)
Definition
mailingchain.php:404
Bitrix\Sender\MailingChainTable\onAfterDelete
static onAfterDelete(Entity\Event $event)
Definition
mailingchain.php:485
Bitrix\Sender\Message\iBase
Definition
ibase.php:16
Bitrix\Main\Type
Definition
collection.php:2
Bitrix\Sender\Internals\Model
Definition
abuse.php:3
modules
sender
lib
internals
model
letter.php
Создано системой
1.10.0