Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
contactsstepper.php
1<?php
2
3namespace Bitrix\Mail\Helper;
4
8
10{
11 protected static $moduleId = 'mail';
12
13 public function execute(array &$option)
14 {
15 $option['steps'] = Mail\MailMessageTable::getCount(array(
16 '<=ID' => $option['lastId'] > 0 ? $option['lastId'] : 0,
17 ));
18 $option['count'] = Mail\MailMessageTable::getCount();
19
20 if ($option['steps'] >= $option['count'])
21 {
22 return false;
23 }
24
25 $res = Mail\MailMessageTable::getList(array(
26 'select' => array(
27 'ID',
28 'FIELD_FROM', 'FIELD_REPLY_TO',
29 'FIELD_TO', 'FIELD_CC', 'FIELD_BCC',
30 'MAILBOX_USER_ID' => 'MAILBOX.USER_ID',
31 ),
32 'filter' => array(
33 '>ID' => $option['lastId'] > 0 ? $option['lastId'] : 0,
34 ),
35 'order' => array('ID' => 'ASC'),
36 'limit' => 1000,
37 ));
38
39
40 $contacts = array();
41 while ($item = $res->fetch())
42 {
43 $option['steps']++;
44 $option['lastId'] = $item['ID'];
45
46 @array_push(
47 $contacts,
48 ...MailContact::getContactsData($item['FIELD_FROM'], $item['MAILBOX_USER_ID'], MailContactTable::ADDED_TYPE_FROM),
49 ...MailContact::getContactsData($item['FIELD_REPLY_TO'], $item['MAILBOX_USER_ID'], MailContactTable::ADDED_TYPE_REPLY_TO),
50 ...MailContact::getContactsData($item['FIELD_TO'], $item['MAILBOX_USER_ID'], MailContactTable::ADDED_TYPE_TO),
51 ...MailContact::getContactsData($item['FIELD_CC'], $item['MAILBOX_USER_ID'], MailContactTable::ADDED_TYPE_CC),
52 ...MailContact::getContactsData($item['FIELD_BCC'], $item['MAILBOX_USER_ID'], MailContactTable::ADDED_TYPE_BCC)
53 );
54
55 if (count($contacts) >= 100)
56 {
58
59 $contacts = array();
60 }
61 }
62
64
65 return true;
66 }
67
68}
static getContactsData($mailsField, $userId, $addedFrom)
static addContactsBatch($contactsData)