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