43 $currentUser = \Bitrix\Main\Engine\CurrentUser::get();
45 $lastRcptResult = \Bitrix\Main\FinderDestTable::getList(array(
47 '=USER_ID' => $currentUser->getId(),
48 '=CONTEXT' =>
'MAIL_LAST_RCPT',
50 'select' => array(
'CODE'),
51 'order' => array(
'LAST_USE_DATE' =>
'DESC'),
55 $emailUsersIds = array();
56 while ($item = $lastRcptResult->fetch())
58 $emailUsersIds[] = (int) str_replace(
'MC',
'', $item[
'CODE']);
61 if (count($emailUsersIds) > 0)
63 $mailContacts = Mail\Internals\MailContactTable::getList([
65 '@ID' => $emailUsersIds,
66 '=USER_ID' => $currentUser->getId(),
68 'select' => [
'ID',
'NAME',
'EMAIL',
'ICON'],
72 $contactAvatars = $resultsMailContacts = [];
73 foreach ($mailContacts as $mailContact)
75 $resultsMailContacts[$mailContact[
'EMAIL']] = $mailContact;
77 foreach ($resultsMailContacts as $mailContact)
79 $email = $mailContact[
'EMAIL'];
80 if ($contactAvatars[$email] ===
null)
83 $APPLICATION->includeComponent(
'bitrix:mail.contact.avatar',
'', array(
84 'mailContact' => $mailContact,
86 $contactAvatars[$email] = ob_get_clean();
88 $id = static::buildUniqueEmailCode($email);
91 'entityType' =>
'email',
92 'entityId' => $mailContact[
'ID'],
93 'name' => htmlspecialcharsbx($mailContact[
'NAME']),
94 'iconCustom' => $contactAvatars[$email],
95 'email' => htmlspecialcharsbx($mailContact[
'EMAIL']),
96 'desc' => htmlspecialcharsbx($mailContact[
'EMAIL']),
122 $mailContacts = \Bitrix\Main\UserTable::getList(array(
131 'filter' => array_merge(
134 '=EXTERNAL_AUTH_ID' =>
'email',
139 'LAST_NAME' =>
'ASC',
144 $contactAvatars = array();
145 while ($mailContact = $mailContacts->fetch())
147 $email = $mailContact[
'EMAIL'];
148 if ($contactAvatars[$email] ===
null)
151 $APPLICATION->includeComponent(
'bitrix:mail.contact.avatar',
'',
153 'mailContact' => array(
154 'FILE_ID' => $mailContact[
'PERSONAL_PHOTO'],
155 'name' => \CUser::formatName(\CSite::getNameFormat(), $mailContact),
156 'email' => $mailContact[
'EMAIL'],
159 $contactAvatars[$email] = ob_get_clean();
162 $id = static::buildUniqueEmailCode($email);
163 $result[$id] = array(
165 'entityType' =>
'mailContacts',
166 'entityId' => $mailContact[
'ID'],
167 'name' => \CUser::formatName(\CSite::getNameFormat(), $mailContact,
true,
true),
168 'iconCustom' => $contactAvatars[$email],
169 'email' => htmlspecialcharsbx($mailContact[
'EMAIL']),
170 'desc' => htmlspecialcharsbx($mailContact[
'EMAIL']),
194 if (Main\Loader::includeModule(
'crm'))
196 $mailContacts = \Bitrix\Main\UserTable::getList(array(
205 'filter' => array_merge(
208 '=EXTERNAL_AUTH_ID' =>
'email',
213 'LAST_NAME' =>
'ASC',
218 $contactAvatars = array();
219 while ($mailContact = $mailContacts->fetch())
221 $email = $mailContact[
'EMAIL'];
227 $crmCommunications = \CSocNetLogDestination::searchCrmEntities(array(
229 'ENTITIES' => array(
'CONTACT'),
231 foreach ($crmCommunications as $communication)
233 $email = $communication[
'email'];
235 if ($contactAvatars[$email] ===
null)
238 $APPLICATION->includeComponent(
'bitrix:mail.contact.avatar',
'',
240 'mailContact' => array(
241 'FILE_ID' => $mailContact[
'PERSONAL_PHOTO'],
242 'name' => \CUser::formatName(\CSite::getNameFormat(), $mailContact),
246 $contactAvatars[$email] = ob_get_clean();
247 $communication[
'iconCustom'] = $contactAvatars[$email];
250 $id = static::buildUniqueEmailCode($email);
251 $communication[
'id'] = $id;
252 $result[$id] = $communication;