Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
mailboxdirectory.php
1
<?php
2
3
namespace
Bitrix\Mail\Internals\Entity
;
4
5
use
Bitrix\Mail\Helper\Mailbox
;
6
use
Bitrix\Mail\Internals\MailboxDirectoryTable
;
7
use
Bitrix\Mail\MailboxDirectory
as MailboxDirectoryManager;
8
use
Bitrix\Main\Localization\Loc
;
9
use
Bitrix\Main\Web\Json
;
10
use
Bitrix\Main\Text\Emoji
;
11
use JsonSerializable;
12
13
class
MailboxDirectory
extends
\Bitrix\Mail\Internals\EO_MailboxDirectory implements JsonSerializable
14
{
15
private
$children = [];
16
17
public
function
isSync
()
18
{
19
if
((
int
)$this->getIsSync() === (
int
)
MailboxDirectoryTable::ACTIVE
)
20
{
21
return
true
;
22
}
23
24
return
false
;
25
}
26
27
public
function
isDisabled
()
28
{
29
if
((
int
)$this->getIsDisabled() === (
int
)
MailboxDirectoryTable::ACTIVE
)
30
{
31
return
true
;
32
}
33
34
return
false
;
35
}
36
37
public
function
isHiddenSystemFolder
()
38
{
39
if
($this->
isDisabled
())
40
{
41
if
(in_array($this->
getPath
(),[
42
'[Gmail]'
,
43
]))
44
{
45
return
true
;
46
}
47
}
48
49
return
false
;
50
}
51
52
public
function
isSpam
()
53
{
54
if
((
int
)$this->getIsSpam() === (
int
)
MailboxDirectoryTable::ACTIVE
)
55
{
56
return
true
;
57
}
58
59
return
false
;
60
}
61
62
public
function
isTrash
()
63
{
64
if
((
int
)$this->getIsTrash() === (
int
)
MailboxDirectoryTable::ACTIVE
)
65
{
66
return
true
;
67
}
68
69
return
false
;
70
}
71
72
public
function
isDraft
()
73
{
74
if
((
int
)$this->getIsDraft() === (
int
)
MailboxDirectoryTable::ACTIVE
)
75
{
76
return
true
;
77
}
78
79
return
false
;
80
}
81
82
public
function
isOutcome
()
83
{
84
if
((
int
)$this->getIsOutcome() === (
int
)
MailboxDirectoryTable::ACTIVE
)
85
{
86
return
true
;
87
}
88
89
return
false
;
90
}
91
92
public
function
isInvisibleToCounters
()
93
{
94
if
($this->
isTrash
() || $this->
isSpam
() || $this->
isDraft
() || $this->
isOutcome
())
95
{
96
return
true
;
97
}
98
99
return
false
;
100
}
101
102
public
function
isIncome
()
103
{
104
if
((
int
)$this->getIsIncome() === (
int
)
MailboxDirectoryTable::ACTIVE
)
105
{
106
return
true
;
107
}
108
109
return
false
;
110
}
111
112
public
function
hasChildren
()
113
{
114
return
!empty($this->children);
115
}
116
117
public
function
getChildren
()
118
{
119
return
$this->children;
120
}
121
122
public
function
addChild
($dir)
123
{
124
$this->children[] = $dir;
125
126
return
$this;
127
}
128
129
public
function
getCountChildren
()
130
{
131
$count = 0;
132
133
foreach
($this->children as $child)
134
{
135
$count++;
136
137
if
($child->hasChildren())
138
{
139
$count += $child->getCountChildren();
140
}
141
}
142
143
return
$count;
144
}
145
146
public
function
getCountSyncChildren
()
147
{
148
$count = 0;
149
150
foreach
($this->children as $child)
151
{
152
if
($child->isSync())
153
{
154
$count++;
155
}
156
157
$count += $child->getCountSyncChildren();
158
}
159
160
return
$count;
161
}
162
163
public
function
getFormattedName
()
164
{
165
if
($this->getLevel() === 1)
166
{
167
return
$this->
getName
();
168
}
169
170
$path = explode($this->getDelimiter(), $this->
getPath
());
171
172
return
join(
' / '
, $path);
173
}
174
175
public
function
getPath
($emojiEncode =
false
)
176
{
177
if
(!$emojiEncode)
178
{
179
return
parent::getPath();
180
}
181
return
Emoji::encode(parent::getPath());
182
}
183
184
public
function
getName
()
185
{
186
$name = $this->sysGetValue(
'NAME'
);
187
$level = $this->getLevel();
188
189
if
(mb_strtolower($name) ==
'inbox'
&& $level === 1)
190
{
191
return
Loc::getMessage
(
'MAIL_CLIENT_INBOX_ALIAS'
);
192
}
193
194
return
$name;
195
}
196
197
public
function
isSyncLock
()
198
{
199
if
($this->getSyncLock() > time() -
Mailbox::getTimeout
())
200
{
201
return
true
;
202
}
203
204
return
false
;
205
}
206
207
public
function
startSyncLock
()
208
{
209
$this->setSyncLock(time());
210
211
if
(
MailboxDirectoryManager::setSyncLock
($this->getId(), $this->getSyncLock()) > 0)
212
{
213
return
true
;
214
}
215
216
return
false
;
217
}
218
219
public
function
stopSyncLock
()
220
{
221
$this->unsetSyncLock();
222
$this->setSyncLock(
null
);
223
224
$this->save();
225
}
226
230
public
function
jsonSerialize
()
231
{
232
return
[
233
'ID'
=> $this->getId(),
234
'MAILBOX_ID'
=> $this->getMailboxId(),
235
'NAME'
=> $this->
getName
(),
236
'FORMATTED_NAME'
=> $this->
getFormattedName
(),
237
'PATH'
=> $this->
getPath
(),
238
'FLAGS'
=> $this->getFlags(),
239
'DELIMITER'
=> $this->getDelimiter(),
240
'DIR_MD5'
=> $this->getDirMd5(),
241
'LEVEL'
=> $this->getLevel(),
242
'IS_DISABLED'
=> $this->
isDisabled
(),
243
'CHILDREN'
=> Json::decode(Json::encode($this->
getChildren
()))
244
];
245
}
246
}
Bitrix\Mail\Helper\Mailbox\getTimeout
static getTimeout()
Definition
mailbox.php:1981
Bitrix\Mail\Internals\Entity\MailboxDirectory
Definition
mailboxdirectory.php:14
Bitrix\Mail\Internals\Entity\MailboxDirectory\hasChildren
hasChildren()
Definition
mailboxdirectory.php:112
Bitrix\Mail\Internals\Entity\MailboxDirectory\isInvisibleToCounters
isInvisibleToCounters()
Definition
mailboxdirectory.php:92
Bitrix\Mail\Internals\Entity\MailboxDirectory\getCountChildren
getCountChildren()
Definition
mailboxdirectory.php:129
Bitrix\Mail\Internals\Entity\MailboxDirectory\isSyncLock
isSyncLock()
Definition
mailboxdirectory.php:197
Bitrix\Mail\Internals\Entity\MailboxDirectory\getName
getName()
Definition
mailboxdirectory.php:184
Bitrix\Mail\Internals\Entity\MailboxDirectory\isHiddenSystemFolder
isHiddenSystemFolder()
Definition
mailboxdirectory.php:37
Bitrix\Mail\Internals\Entity\MailboxDirectory\getPath
getPath($emojiEncode=false)
Definition
mailboxdirectory.php:175
Bitrix\Mail\Internals\Entity\MailboxDirectory\getFormattedName
getFormattedName()
Definition
mailboxdirectory.php:163
Bitrix\Mail\Internals\Entity\MailboxDirectory\addChild
addChild($dir)
Definition
mailboxdirectory.php:122
Bitrix\Mail\Internals\Entity\MailboxDirectory\isOutcome
isOutcome()
Definition
mailboxdirectory.php:82
Bitrix\Mail\Internals\Entity\MailboxDirectory\getChildren
getChildren()
Definition
mailboxdirectory.php:117
Bitrix\Mail\Internals\Entity\MailboxDirectory\stopSyncLock
stopSyncLock()
Definition
mailboxdirectory.php:219
Bitrix\Mail\Internals\Entity\MailboxDirectory\isSpam
isSpam()
Definition
mailboxdirectory.php:52
Bitrix\Mail\Internals\Entity\MailboxDirectory\isDisabled
isDisabled()
Definition
mailboxdirectory.php:27
Bitrix\Mail\Internals\Entity\MailboxDirectory\isIncome
isIncome()
Definition
mailboxdirectory.php:102
Bitrix\Mail\Internals\Entity\MailboxDirectory\jsonSerialize
jsonSerialize()
Definition
mailboxdirectory.php:230
Bitrix\Mail\Internals\Entity\MailboxDirectory\getCountSyncChildren
getCountSyncChildren()
Definition
mailboxdirectory.php:146
Bitrix\Mail\Internals\Entity\MailboxDirectory\isDraft
isDraft()
Definition
mailboxdirectory.php:72
Bitrix\Mail\Internals\Entity\MailboxDirectory\isSync
isSync()
Definition
mailboxdirectory.php:17
Bitrix\Mail\Internals\Entity\MailboxDirectory\isTrash
isTrash()
Definition
mailboxdirectory.php:62
Bitrix\Mail\Internals\Entity\MailboxDirectory\startSyncLock
startSyncLock()
Definition
mailboxdirectory.php:207
Bitrix\Mail\Internals\MailboxDirectoryTable
Definition
mailboxdirectory.php:25
Bitrix\Mail\Internals\MailboxDirectoryTable\ACTIVE
const ACTIVE
Definition
mailboxdirectory.php:26
Bitrix\Mail\MailboxDirectory\setSyncLock
static setSyncLock(int $id, int $time)
Definition
mailboxdirectory.php:350
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\Text\Emoji
Definition
emoji.php:10
Bitrix\Main\Web\Json
Definition
json.php:11
Bitrix\Mail\Helper\Mailbox
Definition
imap.php:3
Bitrix\Mail\Internals\Entity
Definition
blacklistemail.php:3
modules
mail
lib
internals
entity
mailboxdirectory.php
Создано системой
1.10.0