Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
mailsflagsmanager.php
1<?php
2
4
8use CUserCounter;
9
15{
16 public function markMailsUnseen()
17 {
18 $result = $this->initData();
19 if (!$result->isSuccess())
20 {
21 return $result;
22 }
23 $result = $this->setMessagesFlag(static::FLAG_UNSEEN);
24 if ($result->isSuccess())
25 {
26 $this->updateLeftMenuCounter();
27 }
28 return $result;
29 }
30
31 public function markMailsSeen()
32 {
33 $result = $this->initData();
34 if (!$result->isSuccess())
35 {
36 return $result;
37 }
38 $result = $this->setMessagesFlag(static::FLAG_SEEN);
39 if ($result->isSuccess())
40 {
41 $this->updateLeftMenuCounter();
42 }
43 return $result;
44 }
45
46 private function setMessagesFlag($flag)
47 {
48 $result = new Main\Result();
49
50 if ($flag === static::FLAG_SEEN)
51 {
52 $result = $this->mailboxHelper->markSeen($this->messages);
53 }
54 elseif ($flag === static::FLAG_UNSEEN)
55 {
56 $result = $this->mailboxHelper->markUnseen($this->messages);
57 }
58
59 if ($result->isSuccess())
60 {
61 if ($flag === static::FLAG_SEEN)
62 {
63 $this->repository->markMessagesSeen($this->messages, $this->mailbox);
64 }
65 elseif ($flag === static::FLAG_UNSEEN)
66 {
67 $this->repository->markMessagesUnseen($this->messages, $this->mailbox);
68 }
69
70 return new Main\Result();
71 }
72 return (new Main\Result())->addError(new Main\Error(Loc::getMessage('MAIL_CLIENT_SYNC_ERROR'), 'MAIL_CLIENT_SYNC_ERROR'));
73 }
74
75 private function updateLeftMenuCounter()
76 {
77 CUserCounter::set(
78 Main\Engine\CurrentUser::get()->getId(),
79 'mail_unseen',
80 Mail\Helper\Message::getCountersForUserMailboxes(Main\Engine\CurrentUser::get()->getId(), true),
81 $this->mailbox['LID']
82 );
83 }
84
85 public function setMessages($messages)
86 {
87 $this->messages = $messages;
88 }
89}
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29