1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: 15: 16: 17: 18: 19: 20: 21: 22:
23: class IMP_Block_Summary extends Horde_Core_Block
24: {
25: 26:
27: public $updateable = true;
28:
29: 30:
31: public function __construct($app, $params = array())
32: {
33: parent::__construct($app, $params);
34:
35: $this->_name = _("Mailbox Summary");
36: }
37:
38: 39:
40: protected function _title()
41: {
42: return Horde::link(IMP::getInitialPage()->url) . $GLOBALS['registry']->get('name') . '</a>';
43: }
44:
45: 46:
47: protected function _params()
48: {
49: return array(
50: 'show_unread' => array(
51: 'type' => 'boolean',
52: 'name' => _("Only display mailboxes with unread messages in them?"),
53: 'default' => 0
54: )
55: );
56: }
57:
58: 59:
60: protected function _content()
61: {
62: global $injector;
63:
64:
65: IMP_Mailbox::get('INBOX')->filterOnDisplay();
66:
67:
68: $poll = $injector->getInstance('IMP_Ftree')->poll->getPollList(true);
69: $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);
70:
71: $anyUnseen = false;
72: $out = '';
73:
74: foreach ($poll as $mbox) {
75: $mbox_str = strval($mbox);
76:
77: if (isset($status[$mbox_str]) &&
78: (empty($this->_params['show_unread']) ||
79: !empty($status[$mbox_str]['unseen']))) {
80: $mbox_status = $status[$mbox_str];
81:
82: $label = $mbox->url('mailbox')->link() . $mbox->display_html . '</a>';
83: if (!empty($mbox_status['unseen'])) {
84: $label = '<strong>' . $label . '</strong>';
85: $anyUnseen = true;
86: }
87: $out .= '<tr><td>' . $label . '</td>';
88:
89: if (empty($mbox_status['unseen'])) {
90: $out .= '<td>-</td>';
91: } else {
92: $out .= '<td><strong>' . intval($mbox_status['unseen']) . '</strong>';
93: if (!empty($mbox_status['recent_total'])) {
94: $out .= ' (<span style="color:red">' . sprintf(ngettext("%d new", "%d new", $mbox_status['recent_total']), $mbox_status['recent_total']) . '</span>)';
95: }
96: $out .='</td>';
97: }
98:
99: $out .= '<td>' . intval($mbox_status['messages']) . '</td></tr>';
100: }
101: }
102:
103: if (!empty($this->_params['show_unread']) && !$anyUnseen) {
104: return '<em>' . _("No mailboxes with unseen messages") . '</em>';
105: }
106:
107: return '<table class="impBlockSummary"><thead><tr><th>' . _("Mailbox") . '</th><th>' . _("Unseen") . '</th><th>' . _("Total") . '</th></tr></thead><tbody>' .
108: $out .
109: '</tbody></table>';
110: }
111:
112: }
113: