121 if (!($userId > 0 || (is_object($USER) && $USER->isAuthorized())))
128 $userId = $USER->getId();
131 static $mailboxes = [];
132 static $userMailboxes = [];
134 if (!array_key_exists($userId, $userMailboxes))
136 $userMailboxes[$userId] = [];
138 (new \CAccess)->updateCodes([
'USER_ID' => $userId]);
140 $res = static::getList([
143 '=USER_ID' => $userId,
146 '=SERVER_TYPE' =>
'imap',
153 while ($mailbox = $res->fetch())
155 static::normalizeEmail($mailbox);
157 $mailboxes[$mailbox[
'ID']] = $mailbox;
158 $userMailboxes[$userId][] = $mailbox[
'ID'];
164 foreach ($userMailboxes[$userId] as $mailboxId)
166 $result[$mailboxId] = $mailboxes[$mailboxId];
176 if (!($userId > 0 || (is_object($USER) && $USER->isAuthorized())))
183 $userId = $USER->getId();
186 static $mailboxes = [];
187 static $userMailboxes = [];
189 if (!array_key_exists($userId, $userMailboxes))
191 $userMailboxes[$userId] = [];
193 (new \CAccess)->updateCodes([
'USER_ID' => $userId]);
195 $res = static::getList([
197 new Entity\ReferenceField(
199 'Bitrix\Mail\Internals\MailboxAccessTable',
201 '=this.ID' =>
'ref.MAILBOX_ID',
204 'join_type' =>
'LEFT',
207 new Entity\ReferenceField(
209 'Bitrix\Main\UserAccess',
211 'this.ACCESS.ACCESS_CODE' =>
'ref.ACCESS_CODE',
214 'join_type' =>
'LEFT',
221 '!=USER_ID' => $userId,
222 '=USER_ACCESS.USER_ID' => $userId,
225 '=SERVER_TYPE' =>
'imap',
232 while ($mailbox = $res->fetch())
234 static::normalizeEmail($mailbox);
236 $mailboxes[$mailbox[
'ID']] = $mailbox;
237 $userMailboxes[$userId][] = $mailbox[
'ID'];
243 foreach ($userMailboxes[$userId] as $mailboxId)
245 $result[$mailboxId] = $mailboxes[$mailboxId];
261 if (!($userId > 0 || (is_object($USER) && $USER->isAuthorized())))
268 $userId = $USER->getId();
271 $sharedMailboxes = static::getTheSharedMailboxes($userId);
272 $ownersMailboxes = static::getTheOwnersMailboxes($userId);
274 return $ownersMailboxes + $sharedMailboxes;