From: Michael M Slusarz Date: Thu, 15 Jan 2009 06:20:07 +0000 (-0700) Subject: Change to Horde 4 conventions; autoloading X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=15fa241c98f4cf84e8c3de566382e3907483493e;p=horde.git Change to Horde 4 conventions; autoloading --- diff --git a/imp/config/portal.php.dist b/imp/config/portal.php.dist index e60c98dc7..6e25c02c7 100644 --- a/imp/config/portal.php.dist +++ b/imp/config/portal.php.dist @@ -20,16 +20,14 @@ $collection = new Horde_Block_Collection(); $dimp_block_list = array(); // Show a folder summary of the mailbox. All polled folders are displayed. -require_once IMP_BASE . '/lib/Block/foldersummary.php'; $dimp_block_list[_("Folder Summary")] = array( - 'ob' => new Horde_Block_imp_foldersummary(array()) + 'ob' => new IMP_Block_Foldersummary(array()) ); // Alternate DIMP block - shows details of 'msgs_shown' number of the most // recent unseen messages. -//require_once IMP_BASE . '/lib/Block/newmail.php'; //$dimp_block_list[_("Newest Unseen Messages")] = array( -// 'ob' => new Horde_Block_imp_newmail(array('msgs_shown' => 3)) +// 'ob' => new IMP_Block_Newmail(array('msgs_shown' => 3)) //); // Show a contact search box. diff --git a/imp/lib/Block/Foldersummary.php b/imp/lib/Block/Foldersummary.php new file mode 100644 index 000000000..be1ad273d --- /dev/null +++ b/imp/lib/Block/Foldersummary.php @@ -0,0 +1,77 @@ +getValue('filter_on_display')) { + IMP_Filter::filter('INBOX'); + } + + /* Get list of mailboxes to poll. */ + $imptree = &IMP_IMAP_Tree::singleton(); + $folders = $imptree->getPollList(true, true); + + $anyUnseen = false; + $newmsgs = array(); + $html = ''; + + foreach ($folders as $folder) { + if (($folder == 'INBOX') || + ($_SESSION['imp']['protocol'] != 'pop')) { + $info = $imptree->getElementInfo($folder); + if (!empty($info)) { + if (empty($this->_params['show_unread']) || + !empty($info['unseen'])) { + if (!empty($info['newmsg'])) { + $newmsgs[$folder] = $info['newmsg']; + } + $html .= ''; + } + } + } + } + + $html .= '
'; + if (!empty($info['unseen'])) { + $html .= ''; + $anyUnseen = true; + } + $html .= '' . IMP::displayFolder($folder) . ''; + if (!empty($info['unseen'])) { + $html .= ''; + } + $html .= '' . + (!empty($info['unseen']) ? '' . $info['unseen'] . '' : '0') . + (!empty($this->_params['show_total']) ? '(' . $info['messages'] . ')' : '') . + '
'; + + if (count($newmsgs) == 0 && !empty($this->_params['show_unread'])) { + if (count($folders) == 0) { + $html = _("No folders are being checked for new mail."); + } elseif (!$anyUnseen) { + $html = '' . _("No folders with unseen messages") . ''; + } elseif ($GLOBALS['prefs']->getValue('nav_popup')) { + $html = '' . _("No folders with new messages") . ''; + } + } + + return $html; + } + +} diff --git a/imp/lib/Block/Newmail.php b/imp/lib/Block/Newmail.php new file mode 100644 index 000000000..2bdf45632 --- /dev/null +++ b/imp/lib/Block/Newmail.php @@ -0,0 +1,73 @@ + + */ +class IMP_Block_Newmail extends Horde_Block +{ + var $_app = 'imp'; + + function _content() + { + $GLOBALS['authentication'] = 'none'; + require_once dirname(__FILE__) . '/../base.php'; + + if (!IMP::checkAuthentication(true)) { + return ''; + } + + /* Filter on INBOX display, if requested. */ + if ($GLOBALS['prefs']->getValue('filter_on_display')) { + IMP_Filter::filter('INBOX'); + } + + $query = new Horde_Imap_Client_Search_Query(); + $query->flag('\\seen', false); + $ids = $GLOBALS['imp_search']->runSearchQuery($query, 'INBOX', Horde_Imap_Client::SORT_ARRIVAL, 1); + + $html = ''; + if (empty($ids)) { + $html .= ''; + } else { + require_once 'Horde/Identity.php'; + + $charset = NLS::getCharset(); + $imp_ui = new IMP_UI_Mailbox('INBOX'); + $shown = empty($this->_params['msgs_shown']) ? 3 : $this->_params['msgs_shown']; + + try { + $fetch_ret = $GLOBALS['imp_imap']->ob->fetch('INBOX', array( + Horde_Imap_Client::FETCH_ENVELOPE => true + ), array('ids' => array_slice($ids, 0, $shown))); + reset($fetch_ret); + } catch (Horde_Imap_Client_Exception $e) { + $fetch_ret = array(); + } + + while (list($uid, $ob) = each($fetch_ret)) { + $date = $imp_ui->getDate($ob['envelope']['date']); + $from = $imp_ui->getFrom($ob, array('specialchars' => $charset)); + $subject = $imp_ui->getSubject($ob['envelope']['subject'], true); + + $html .= '' . + ''; + } + + $more_msgs = count($ids) - $shown; + $text = ($more_msgs > 0) + ? sprintf(ngettext("%d more unseen message...", "%d more unseen messages...", $more_msgs), $more_msgs) + : _("Go to your Inbox..."); + $html .= ''; + } + + return $html . '
' . _("No unread messages") . '
' . + '' . $from['from'] . '
' . + $subject . '
' . htmlspecialchars($date, ENT_QUOTES, $charset) . '
' . $text . '
'; + } + +} diff --git a/imp/lib/Block/foldersummary.php b/imp/lib/Block/foldersummary.php deleted file mode 100644 index a6c4eaa4d..000000000 --- a/imp/lib/Block/foldersummary.php +++ /dev/null @@ -1,77 +0,0 @@ -getValue('filter_on_display')) { - IMP_Filter::filter('INBOX'); - } - - /* Get list of mailboxes to poll. */ - $imptree = &IMP_IMAP_Tree::singleton(); - $folders = $imptree->getPollList(true, true); - - $anyUnseen = false; - $newmsgs = array(); - $html = ''; - - foreach ($folders as $folder) { - if (($folder == 'INBOX') || - ($_SESSION['imp']['protocol'] != 'pop')) { - $info = $imptree->getElementInfo($folder); - if (!empty($info)) { - if (empty($this->_params['show_unread']) || - !empty($info['unseen'])) { - if (!empty($info['newmsg'])) { - $newmsgs[$folder] = $info['newmsg']; - } - $html .= ''; - } - } - } - } - - $html .= '
'; - if (!empty($info['unseen'])) { - $html .= ''; - $anyUnseen = true; - } - $html .= '' . IMP::displayFolder($folder) . ''; - if (!empty($info['unseen'])) { - $html .= ''; - } - $html .= '' . - (!empty($info['unseen']) ? '' . $info['unseen'] . '' : '0') . - (!empty($this->_params['show_total']) ? '(' . $info['messages'] . ')' : '') . - '
'; - - if (count($newmsgs) == 0 && !empty($this->_params['show_unread'])) { - if (count($folders) == 0) { - $html = _("No folders are being checked for new mail."); - } elseif (!$anyUnseen) { - $html = '' . _("No folders with unseen messages") . ''; - } elseif ($GLOBALS['prefs']->getValue('nav_popup')) { - $html = '' . _("No folders with new messages") . ''; - } - } - - return $html; - } - -} diff --git a/imp/lib/Block/newmail.php b/imp/lib/Block/newmail.php deleted file mode 100644 index c27d7db88..000000000 --- a/imp/lib/Block/newmail.php +++ /dev/null @@ -1,74 +0,0 @@ - - */ -class Horde_Block_imp_newmail extends Horde_Block -{ - var $_app = 'imp'; - - function _content() - { - $GLOBALS['authentication'] = 'none'; - require_once dirname(__FILE__) . '/../base.php'; - - if (!IMP::checkAuthentication(true)) { - return ''; - } - - /* Filter on INBOX display, if requested. */ - if ($GLOBALS['prefs']->getValue('filter_on_display')) { - IMP_Filter::filter('INBOX'); - } - - $query = new Horde_Imap_Client_Search_Query(); - $query->flag('\\seen', false); - $ids = $GLOBALS['imp_search']->runSearchQuery($query, 'INBOX', Horde_Imap_Client::SORT_ARRIVAL, 1); - - $html = ''; - if (empty($ids)) { - $html .= ''; - } else { - require_once 'Horde/Identity.php'; - - $charset = NLS::getCharset(); - $imp_ui = new IMP_UI_Mailbox('INBOX'); - $shown = empty($this->_params['msgs_shown']) ? 3 : $this->_params['msgs_shown']; - - try { - $fetch_ret = $GLOBALS['imp_imap']->ob->fetch('INBOX', array( - Horde_Imap_Client::FETCH_ENVELOPE => true - ), array('ids' => array_slice($ids, 0, $shown))); - reset($fetch_ret); - } catch (Horde_Imap_Client_Exception $e) { - $fetch_ret = array(); - } - - while (list($uid, $ob) = each($fetch_ret)) { - $date = $imp_ui->getDate($ob['envelope']['date']); - $from = $imp_ui->getFrom($ob, array('specialchars' => $charset)); - $subject = $imp_ui->getSubject($ob['envelope']['subject'], true); - - $html .= '' . - ''; - } - - $more_msgs = count($ids) - $shown; - $text = ($more_msgs > 0) - ? sprintf(ngettext("%d more unseen message...", "%d more unseen messages...", $more_msgs), $more_msgs) - : _("Go to your Inbox..."); - $html .= ''; - } - - return $html . '
' . _("No unread messages") . '
' . - '' . $from['from'] . '
' . - $subject . '
' . htmlspecialchars($date, ENT_QUOTES, $charset) . '
' . $text . '
'; - } - -}