Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
letter.php
1<?php
9
16
17Loc::loadMessages(__FILE__);
18
35class 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 {
219 }
220
227 public static function onAfterUpdate(Entity\Event $event)
228 {
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 {
285 }
286}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static syncFiles(int $entityId, int $entityType, string $template, bool $deleteFiles=true, bool $onDeleteEntity=false)
Definition filetable.php:72
static onDelete(Entity\Event $event)
Definition letter.php:238
static onBeforeUpdate(Entity\Event $event)
Definition letter.php:216
static onAfterAdd(Entity\Event $event)
Definition letter.php:205
static onAfterUpdate(Entity\Event $event)
Definition letter.php:227
static onAfterDelete(Entity\Event $event)
Definition letter.php:282
static onDelete(Entity\Event $event)
static onBeforeUpdate(Entity\Event $event)
static onAfterAdd(Entity\Event $event)
static onAfterUpdate(Entity\Event $event)
static onAfterDelete(Entity\Event $event)