/
Summary.php
112 lines (95 loc) · 3.41 KB
/
Summary.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/**
* Copyright 2005-2014 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @category Horde
* @copyright 2005-2014 Horde LLC
* @license http://www.horde.org/licenses/gpl GPL
* @package IMP
*/
/**
* Block: show mailbox summary.
*
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @copyright 2005-2014 Horde LLC
* @license http://www.horde.org/licenses/gpl GPL
* @package IMP
*/
class IMP_Block_Summary extends Horde_Core_Block
{
/**
*/
public $updateable = true;
/**
*/
public function __construct($app, $params = array())
{
parent::__construct($app, $params);
$this->_name = _("Mailbox Summary");
}
/**
*/
protected function _title()
{
return Horde::link(IMP::getInitialPage()->url) . $GLOBALS['registry']->get('name') . '</a>';
}
/**
*/
protected function _params()
{
return array(
'show_unread' => array(
'type' => 'boolean',
'name' => _("Only display mailboxes with unread messages in them?"),
'default' => 0
)
);
}
/**
*/
protected function _content()
{
global $injector;
/* Filter on INBOX display. INBOX is always polled. */
IMP_Mailbox::get('INBOX')->filterOnDisplay();
/* Get list of mailboxes to poll. */
$poll = $injector->getInstance('IMP_Ftree')->poll->getPollList(true);
$status = $injector->getInstance('IMP_Factory_Imap')->create()->status($poll, Horde_Imap_Client::STATUS_UNSEEN | Horde_Imap_Client::STATUS_MESSAGES | Horde_Imap_Client::STATUS_RECENT_TOTAL);
$anyUnseen = false;
$out = '';
foreach ($poll as $mbox) {
$mbox_str = strval($mbox);
if (isset($status[$mbox_str]) &&
(empty($this->_params['show_unread']) ||
!empty($status[$mbox_str]['unseen']))) {
$mbox_status = $status[$mbox_str];
$label = $mbox->url('mailbox')->link() . $mbox->display_html . '</a>';
if (!empty($mbox_status['unseen'])) {
$label = '<strong>' . $label . '</strong>';
$anyUnseen = true;
}
$out .= '<tr><td>' . $label . '</td>';
if (empty($mbox_status['unseen'])) {
$out .= '<td>-</td>';
} else {
$out .= '<td><strong>' . intval($mbox_status['unseen']) . '</strong>';
if (!empty($mbox_status['recent_total'])) {
$out .= ' (<span style="color:red">' . sprintf(ngettext("%d new", "%d new", $mbox_status['recent_total']), $mbox_status['recent_total']) . '</span>)';
}
$out .='</td>';
}
$out .= '<td>' . intval($mbox_status['messages']) . '</td></tr>';
}
}
if (!empty($this->_params['show_unread']) && !$anyUnseen) {
return '<em>' . _("No mailboxes with unseen messages") . '</em>';
}
return '<table class="impBlockSummary"><thead><tr><th>' . _("Mailbox") . '</th><th>' . _("Unseen") . '</th><th>' . _("Total") . '</th></tr></thead><tbody>' .
$out .
'</tbody></table>';
}
}