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