93 public static function replace($siteId, $mailboxId, array $list)
99 $DB->query(sprintf(
"DELETE FROM b_mail_blacklist WHERE MAILBOX_ID = %u", $mailboxId));
103 $DB->query(sprintf(
"DELETE FROM b_mail_blacklist WHERE SITE_ID = '%s' AND MAILBOX_ID = 0", $DB->forSql($siteId)));
108 foreach ($list as $item)
111 'SITE_ID' => $siteId,
112 'MAILBOX_ID' => $mailboxId,
113 'ITEM_TYPE' => Blacklist\ItemType::resolveByValue($item),
114 'ITEM_VALUE' => $item,
132 if (is_null($userId))
138 foreach ($list as $index => $item)
141 'SITE_ID' => SITE_ID,
143 'USER_ID' => $userId,
144 'ITEM_TYPE' => Blacklist\ItemType::resolveByValue($item),
145 'ITEM_VALUE' => $item,
147 $addList[] = $itemToAdd;
150 if (count($addList) === 0)
154 $keys = implode(
', ', array_keys(current($addList)));
156 foreach ($addList as $item)
161 "'" . $sqlHelper->forSql($item[
'SITE_ID']) .
"'",
162 (
int)$item[
'MAILBOX_ID'],
163 (
int)$item[
'USER_ID'],
165 "'" . $sqlHelper->forSql($item[
'ITEM_VALUE']) .
"'",
169 $values = implode(
'), (', $values);
171 $tableName = static::getTableName();
172 $sql = $sqlHelper->getInsertIgnore($tableName,
"($keys)",
" VALUES($values)");
186 $filter = [
'LOGIC' =>
'OR'];
187 $userMailboxes = \Bitrix\Mail\MailboxTable::getUserMailboxes();
188 if (!empty($userMailboxes))
190 $mailboxesIds = array_column($userMailboxes,
'ID');
191 if ($includeAddressesForAllUsers)
196 '@MAILBOX_ID' => $mailboxesIds,
200 $newStyleAddressesFilter = [];
201 $userIds = [$userId];
202 $newStyleAddressesFilter[
'=MAILBOX_ID'] = 0;
204 if ($includeAddressesForAllUsers)
208 $newStyleAddressesFilter[
'@USER_ID'] = $userIds;
209 $mailsQuery = \Bitrix\Mail\BlacklistTable::query()
211 $filter[] = $newStyleAddressesFilter;
212 return $mailsQuery->setFilter([$filter]);