|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @author Christoph Wurst <[email protected]> |
|
5
|
|
|
* @author Lukas Reschke <[email protected]> |
|
6
|
|
|
* @author Thomas Imbreckx <[email protected]> |
|
7
|
|
|
* @author Thomas Müller <[email protected]> |
|
8
|
|
|
* |
|
9
|
|
|
* Mail |
|
10
|
|
|
* |
|
11
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
12
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
13
|
|
|
* as published by the Free Software Foundation. |
|
14
|
|
|
* |
|
15
|
|
|
* This program is distributed in the hope that it will be useful, |
|
16
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18
|
|
|
* GNU Affero General Public License for more details. |
|
19
|
|
|
* |
|
20
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
21
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
22
|
|
|
* |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
namespace OCA\Mail; |
|
26
|
|
|
|
|
27
|
|
|
use Horde_Imap_Client_Mailbox; |
|
28
|
|
|
use Horde_Imap_Client_Search_Query; |
|
29
|
|
|
use Horde_Imap_Client_Socket; |
|
30
|
|
|
use Horde_Imap_Client; |
|
31
|
|
|
|
|
32
|
|
|
class SearchMailbox extends Mailbox { |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @param Horde_Imap_Client_Socket $conn |
|
36
|
|
|
* @param Horde_Imap_Client_Mailbox $mailBox |
|
37
|
|
|
* @param array $attributes |
|
38
|
|
|
* @param string $delimiter |
|
39
|
|
|
*/ |
|
40
|
6 |
|
public function __construct($conn, $mailBox, $attributes, $delimiter = '/') { |
|
41
|
6 |
|
$attributes[] = Horde_Imap_Client::SPECIALUSE_FLAGGED; |
|
42
|
6 |
|
parent::__construct($conn, $mailBox, $attributes, $delimiter); |
|
43
|
6 |
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @param int $from |
|
47
|
|
|
* @param int $count |
|
48
|
|
|
* @param string $filter |
|
49
|
|
|
* @return mixed |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getMessages($from = 0, $count = 2, $filter = '') { |
|
52
|
|
|
$query = new Horde_Imap_Client_Search_Query(); |
|
53
|
|
|
$query->flag('FLAGGED'); |
|
54
|
|
|
if ($filter) { |
|
55
|
|
|
$query->text($filter, false); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
return parent::getMessages($from, $count, $query); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return string |
|
63
|
|
|
*/ |
|
64
|
7 |
|
public function getFolderId() { |
|
65
|
7 |
|
return parent::getFolderId() . '/FLAGGED'; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* @return null |
|
70
|
|
|
*/ |
|
71
|
3 |
|
public function getParent() { |
|
72
|
3 |
|
return null; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param int $flags |
|
77
|
|
|
* @return mixed |
|
78
|
|
|
*/ |
|
79
|
3 |
|
public function getStatus($flags = \Horde_Imap_Client::STATUS_ALL) { |
|
80
|
3 |
|
$status = parent::getStatus($flags); |
|
81
|
3 |
|
$status['unseen'] = 0; |
|
82
|
|
|
|
|
83
|
3 |
|
return $status; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|