6use Bitrix\Main\Entity\ReferenceField;
7use \Bitrix\Mail\Helper\MessageFolder;
16 $this->mailboxId = $mailboxId;
17 $this->messagesIds = $messagesIds;
22 return Mail\MailboxTable::getUserMailbox($this->mailboxId, $mailboxUserId);
27 $connection = Main\Application::getInstance()->getConnection();
28 $sqlHelper = $connection->getSqlHelper();
29 $sql =
'DELETE from ' . Mail\MailMessageUidTable::getTableName() .
30 ' WHERE MAILBOX_ID = ' . intval($this->mailboxId) .
31 " AND DIR_MD5 = '" . $sqlHelper->forSql(md5($folderCurrentName)) .
"'" .
33 $connection->query($sql);
34 return $connection->getAffectedRowsCount();
51 foreach ($this->messagesIds as $index => $messageId)
53 $messagesIds[$index] = $messageId;
56 if (empty($messagesIds) || empty($messages) || empty($mailbox))
63 foreach ($messages as $messageData)
66 'HEADER_MD5' => $messageData[
'HEADER_MD5'],
67 'MAILBOX_USER_ID' => $mailbox[
'USER_ID'],
72 $mailboxId = intval($this->mailboxId);
74 Mail\MailMessageUidTable::updateList(
76 '=MAILBOX_ID' => $mailboxId,
77 '@ID' => $messagesIds,
96 \Bitrix\Mail\Helper::updateMailboxUnseenCounter($mailboxId);
102 foreach ($messages as $message)
104 $messagesIds[] = $message[
'ID'];
106 if (empty($messagesIds))
112 foreach ($messages as $messageData)
115 'HEADER_MD5' => $messageData[
'HEADER_MD5'],
116 'MAILBOX_USER_ID' => $mailbox[
'USER_ID']
120 Mail\MailMessageUidTable::updateList(
122 '=MAILBOX_ID' => intval($this->mailboxId),
123 '@ID' => $messagesIds,
127 'DIR_MD5' => md5($folderNewName),
161 return intval($mail[
'MESSAGE_ID']);
169 $mailFieldsForEvent = [];
171 foreach ($messagesToDelete as $index => $item)
173 $mailFieldsForEvent[] = [
174 'HEADER_MD5' => $item[
'HEADER_MD5'],
175 'MESSAGE_ID' => $item[
'MESSAGE_ID'],
176 'MAILBOX_USER_ID' => $mailboxUserId,
179 Mail\MailMessageUidTable::deleteList(
181 '=MAILBOX_ID' => $this->mailboxId,
182 '@MESSAGE_ID' => $ids,
188 $connection = Main\Application::getInstance()->getConnection();
191 ' WHERE ID IN (' . implode(
',', $ids) .
');'
197 if (empty($this->messagesIds))
202 $messagesSelected = Mail\MailMessageUidTable::query()
203 ->addSelect(
'MESSAGE_ID')
204 ->where(
'MAILBOX_ID', $this->mailboxId)
205 ->whereIn(
'ID', $this->messagesIds)
206 ->whereNot(
'MSG_UID', 0)
207 ->where(
'MESSAGE_ID',
'>', 0)
208 ->addFilter(
'==DELETE_TIME', 0)
211 if ($messagesSelected)
213 $messagesSelectedIds = array_map(
216 return $item[
'MESSAGE_ID'];
220 if (empty($messagesSelectedIds))
224 $messages = Mail\MailMessageUidTable::query()
225 ->registerRuntimeField(
229 Mail\MailMessageTable::class,
230 [
'=this.MESSAGE_ID' =>
'ref.ID']
234 ->addSelect(
'MAILBOX_ID')
235 ->addSelect(
'DIR_MD5')
236 ->addSelect(
'DIR_UIDV')
237 ->addSelect(
'MSG_UID')
238 ->addSelect(
'HEADER_MD5')
239 ->addSelect(
'IS_SEEN')
240 ->addSelect(
'SESSION_ID')
241 ->addSelect(
'MESSAGE_ID')
242 ->addSelect(
'ref.FIELD_FROM',
'FIELD_FROM')
243 ->whereIn(
'MESSAGE_ID', $messagesSelectedIds)
244 ->where(
'MAILBOX_ID', $this->mailboxId)
245 ->whereNot(
'MSG_UID', 0)
static addMailsBatch(array $list, $userId=null)
static decreaseDirCounter($mailboxId, $dirWithMessagesId, $idsUnseenCount)
static getDirIdForMessages($mailboxId, $messagesIds)
static increaseDirCounter($mailboxId, $dirForMoveMessages=false, $dirForMoveMessagesId, $idsUnseenCount)
setMessagesSeen($isSeen, $messages, $mailbox)
updateMessageFieldsAfterMove($messages, $folderNewName, $mailbox)
markMessagesUnseen($messages, $mailbox)
addMailsToBlacklist($blacklistMails, $userId)
deleteOldMessages($folderCurrentName)
getMailbox($mailboxUserId=null)
deleteMailsCompletely($messagesToDelete, $mailboxUserId)
__construct($mailboxId, $messagesIds)
markMessagesSeen($messages, $mailbox)