1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
syncinternalmanager.php
См. документацию.
1<?php
2
3namespace Bitrix\Mail\ImapCommands;
4
5use Bitrix\Mail\Helper\Mailbox;
6use Bitrix\Mail\Internals\MailboxDirectoryTable;
7use Bitrix\Main;
8use Bitrix\Main\Localization\Loc;
9
10Loc::loadMessages(__FILE__);
11
17{
18 const FLAG_UNSEEN = 'unseen';
19 const FLAG_SEEN = 'seen';
20
21 protected $userId;
22 protected $mailbox;
23 protected $mailboxId;
24 protected $mailboxUserId;
25 protected $messagesIds;
26 protected $messages;
27 private $isInit;
29 protected $repository;
31 protected $mailboxHelper;
32
33 public function __construct($mailboxId, $messagesIds, $userId = null)
34 {
35 $this->mailboxId = $mailboxId;
36 if (!is_array($messagesIds))
37 {
39 }
40 $this->messagesIds = $messagesIds;
41 $this->userId = $userId;
42 $this->repository = $this->getRepository();
43 $this->mailboxHelper = $this->getMailClientHelper();
44 }
45
46 public function setUserId($userId)
47 {
48 $this->userId = $userId;
49 }
50
51 protected function getRepository()
52 {
53 return new Repository($this->mailboxId, $this->messagesIds);
54 }
55
56 protected function getMailClientHelper($throwExceptions = true)
57 {
58 return Mailbox::createInstance($this->mailboxId, $throwExceptions);
59 }
60
61 protected function initData($folderType = null)
62 {
63 if ($this->isInit)
64 {
65 return new Main\Result();
66 }
67 $this->isInit = true;
68 $result = new Main\Result();
69
70 $this->mailbox = $this->repository->getMailbox($this->mailboxUserId);
71 if (!$this->mailbox)
72 {
73 return $result->addError(new Main\Error(Loc::getMessage('MAIL_CLIENT_MAILBOX_NOT_FOUND'),
74 'MAIL_CLIENT_MAILBOX_NOT_FOUND'));
75 }
76
77 if ($folderType)
78 {
79 $folder = $this->getDirPathByType($folderType);
80 if (!$folder)
81 {
82 $errorCode = 'MAIL_CLIENT_' . ($folderType == MailboxDirectoryTable::TYPE_TRASH ? 'TRASH' : 'SPAM') . '_FOLDER_NOT_SELECTED_ERROR';
83 return $result->addError(new Main\Error(
84 Loc::getMessage($errorCode),
85 $errorCode));
86 }
87 }
88 if (is_null($this->messages))
89 {
90 $this->messages = $this->repository->getMessages();
91 }
92
93 if (empty($this->messages))
94 {
95 return $result->addError(new Main\Error(Loc::getMessage('MAIL_CLIENT_MESSAGES_NOT_FOUND'),
96 'MAIL_CLIENT_MESSAGES_NOT_FOUND'));
97 }
98 $this->fillMessagesEmails();
99
100 $folders = [];
101 foreach ($this->messages as $index => $message)
102 {
103 if (in_array($message['ID'], $this->messagesIds, true))
104 {
105 $folders[$message['DIR_MD5']] = $message['DIR_MD5'];
106 }
107 }
108 if (count($folders) > 1)
109 {
110 return $result->addError(new Main\Error(Loc::getMessage('MAIL_CLIENT_MESSAGES_MULTIPLE_FOLDERS'),
111 'MAIL_CLIENT_MESSAGES_MULTIPLE_FOLDERS'));
112 }
113 return $result;
114 }
115
116 protected function getDirPathByType($dirType)
117 {
118 return $this->mailboxHelper->getDirsHelper()->getDirPathByType($dirType);
119 }
120
121 protected function getDirByPath($path)
122 {
123 return $this->mailboxHelper->getDirsHelper()->getDirByPath($path);
124 }
125
126 protected function fillMessagesEmails()
127 {
128 foreach ($this->messages as $index => $message)
129 {
130 $address = new Main\Mail\Address($message['FIELD_FROM']);
131 $this->messages[$index]['EMAIL'] = $address->getEmail();
132 }
133 }
134}
$path
Определения access_edit.php:21
__construct($mailboxId, $messagesIds, $userId=null)
Определения syncinternalmanager.php:33
getMailClientHelper($throwExceptions=true)
Определения syncinternalmanager.php:56
Определения error.php:15
$result
Определения get_property_values.php:14
$message
Определения payment.php:8
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936