1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
messagefolder.php
См. документацию.
1<?php
2
3namespace Bitrix\Mail\Helper;
4use Bitrix\Mail\Internals\Entity\MailboxDirectory;
5use Bitrix\Main;
6use Bitrix\Main\Localization\Loc;
7use Bitrix\Mail\Internals\MailboxDirectoryTable;
8use Bitrix\Mail\Internals\MailCounterTable;
9
14{
15 const TRASH = 'trash';
16 const SPAM = 'spam';
17 const INCOME = 'income';
18 const OUTCOME = 'outcome';
19 const DRAFTS = 'drafts';
20
21
22 public static function increaseDirCounter($mailboxId, ?MailboxDirectory $dirForMoveMessages, $dirForMoveMessagesId, $idsUnseenCount): void
23 {
24 if ($idsUnseenCount > 0 && (is_null($dirForMoveMessages) || !$dirForMoveMessages->isInvisibleToCounters()))
25 {
27 '=MAILBOX_ID' => $mailboxId,
28 '=ENTITY_TYPE' => 'DIR',
29 '=ENTITY_ID' => $dirForMoveMessagesId
30 ])
31 )
32 {
34 [
35 'MAILBOX_ID' => $mailboxId,
36 'ENTITY_TYPE' => 'DIR',
37 'ENTITY_ID' => $dirForMoveMessagesId
38 ],
39 [
40 "VALUE" => new \Bitrix\Main\DB\SqlExpression("?# + $idsUnseenCount", "VALUE")
41 ]
42 );
43 }
44 else
45 {
47 'MAILBOX_ID' => $mailboxId,
48 'ENTITY_TYPE' => 'DIR',
49 'ENTITY_ID' => $dirForMoveMessagesId,
50 "VALUE" => $idsUnseenCount,
51 ]);
52 }
53 }
54 }
55
56 public static function decreaseDirCounter($mailboxId, $dirWithMessagesId, $idsUnseenCount): void
57 {
58 if($dirWithMessagesId)
59 {
61 '=MAILBOX_ID' => $mailboxId,
62 '=ENTITY_TYPE' => 'DIR',
63 '=ENTITY_ID' => $dirWithMessagesId,
64 '>=VALUE' => $idsUnseenCount
65 ]))
66 {
68 [
69 'MAILBOX_ID' => $mailboxId,
70 'ENTITY_TYPE' => 'DIR',
71 'ENTITY_ID' => $dirWithMessagesId
72 ],
73 [
74 "VALUE" => new \Bitrix\Main\DB\SqlExpression("CASE WHEN ?# >= $idsUnseenCount THEN ?# - $idsUnseenCount ELSE 0 END", "VALUE", "VALUE")
75 ]
76 );
77 }
78 }
79 }
80
81 public static function getDirIdForMessages($mailboxId, $messagesIds)
82 {
83 $dirWithMessagesId = MailboxDirectoryTable::getList([
84 'runtime' => array(
86 'UID',
87 'Bitrix\Mail\MailMessageUidTable',
88 [
89 '=this.DIR_MD5' => 'ref.DIR_MD5',
90 '=this.MAILBOX_ID' => 'ref.MAILBOX_ID',
91 ],
92 [
93 'join_type' => 'INNER',
94 ]
95 ),
96 ),
97 'select' => [
98 'ID',
99 ],
100 'filter' => [
101 '@UID.ID' => $messagesIds,
102 '=MAILBOX_ID' => $mailboxId,
103 ],
104 'limit' => 1,
105 ])->fetchAll();
106
107 if(isset($dirWithMessagesId[0]['ID']))
108 {
109 return $dirWithMessagesId[0]['ID'];
110 }
111 return false;
112 }
113
119 public static function getFolderNameByHash($messageFolderHash, $mailboxOptions)
120 {
121 $folderName = '';
122 if (!empty($mailboxOptions['imap']['dirsMd5']))
123 {
124 $names = array_filter(
125 $mailboxOptions['imap']['dirsMd5'],
126 function ($hash) use ($messageFolderHash)
127 {
128 return $hash == $messageFolderHash;
129 }
130 );
131 if (count($names) == 1)
132 {
133 $folderName = array_keys($names)[0];
134 }
135 }
136 return $folderName;
137 }
138
139 public static function getFolderHashByType($folderType, $mailboxOptions)
140 {
141 $folderHash = '';
142 if (!empty($mailboxOptions['imap']['dirsMd5']))
143 {
144 $name = static::getFolderNameByType($folderType, $mailboxOptions);
145 $hashes = array_filter(
146 $mailboxOptions['imap']['dirsMd5'],
147 function ($_name) use ($name)
148 {
149 return $_name == $name;
150 },
151 ARRAY_FILTER_USE_KEY
152 );
153 if (count($hashes) == 1)
154 {
155 $folderHash = array_values($hashes)[0];
156 }
157 }
158
159 return $folderHash;
160 }
161
162 public static function getFolderNameByType($folderType, $mailboxOptions)
163 {
164 if (!empty($mailboxOptions['imap']) && is_array($mailboxOptions['imap']))
165 {
166 $imapOptions = $mailboxOptions['imap'];
167 if (!empty($imapOptions[$folderType]) && isset($imapOptions[$folderType][0]))
168 {
169 return $imapOptions[$folderType][0];
170 }
171 }
172 return null;
173 }
174
175 public static function getDisabledFolders($mailboxOptions)
176 {
177 $disabled = empty($mailboxOptions['imap']['disabled']) ? [] : $mailboxOptions['imap']['disabled'];
178 $ignore = empty($mailboxOptions['imap']['ignore']) ? [] : $mailboxOptions['imap']['ignore'];
179 return array_merge($disabled, $ignore);
180 }
181
182 public static function isDisabledFolder($folder, $mailboxOptions)
183 {
184 return in_array($folder, static::getDisabledFolders($mailboxOptions), true);
185 }
186
187 public static function getFormattedPath(array $path, $mailboxOptions)
188 {
189 $root = array_shift($path);
190
191 if (mb_strtolower($root) == 'inbox' && !static::isDisabledFolder($root, $mailboxOptions))
192 {
193 $root = Loc::getMessage('MAIL_CLIENT_INBOX_ALIAS');
194 }
195
196 array_unshift($path, $root);
197
198 return $path;
199 }
200
201 public static function getFormattedName(array $path, $mailboxOptions, $full = true)
202 {
203 $path = static::getFormattedPath($path, $mailboxOptions);
204
205 return $full ? join(' / ', $path) : end($path);
206 }
207
208}
$path
Определения access_edit.php:21
$hash
Определения ajax_redirector.php:8
static getFolderNameByType($folderType, $mailboxOptions)
Определения messagefolder.php:162
static getFolderHashByType($folderType, $mailboxOptions)
Определения messagefolder.php:139
static getFormattedPath(array $path, $mailboxOptions)
Определения messagefolder.php:187
static getDisabledFolders($mailboxOptions)
Определения messagefolder.php:175
static isDisabledFolder($folder, $mailboxOptions)
Определения messagefolder.php:182
static decreaseDirCounter($mailboxId, $dirWithMessagesId, $idsUnseenCount)
Определения messagefolder.php:56
static getFormattedName(array $path, $mailboxOptions, $full=true)
Определения messagefolder.php:201
static getFolderNameByHash($messageFolderHash, $mailboxOptions)
Определения messagefolder.php:119
static getDirIdForMessages($mailboxId, $messagesIds)
Определения messagefolder.php:81
static increaseDirCounter($mailboxId, ?MailboxDirectory $dirForMoveMessages, $dirForMoveMessagesId, $idsUnseenCount)
Определения messagefolder.php:22
static add($data)
Определения mailcounter.php:38
static getCount($filter=array(), array $cache=array())
Определения datamanager.php:516
static update($primary, array $data)
Определения datamanager.php:1256
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$name
Определения menu_edit.php:35
Определения arrayresult.php:2
</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