From 0dae3df686add2c0752ab839b9aa6c31717d010a Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 1 Dec 2008 15:27:41 -0700 Subject: [PATCH] Next batch of DIMP -> IMP fixes. --- imp/config/portal.php.dist | 4 +- imp/imp-dimp.php | 5 +- imp/index-dimp.php | 2 +- imp/lib/DIMP.php | 28 ++-- imp/lib/IMAP/Thread.php | 8 +- imp/lib/IMP.php | 168 +++++++++++++++------ imp/lib/Session.php | 5 + imp/lib/Views/ListMessages.php | 2 +- imp/lib/base.php | 20 +-- imp/templates/index/index.inc | 4 +- .../javascript/{mailbox.js => mailbox-dimp.js} | 3 +- imp/themes/{graphics => }/ie6_or_less-dimp.css | 0 imp/themes/{graphics => }/ie7-dimp.css | 0 imp/themes/{graphics => }/print-dimp.css | 0 imp/themes/{graphics => }/screen-dimp.css | 0 15 files changed, 166 insertions(+), 83 deletions(-) rename imp/templates/javascript/{mailbox.js => mailbox-dimp.js} (90%) rename imp/themes/{graphics => }/ie6_or_less-dimp.css (100%) rename imp/themes/{graphics => }/ie7-dimp.css (100%) rename imp/themes/{graphics => }/print-dimp.css (100%) rename imp/themes/{graphics => }/screen-dimp.css (100%) diff --git a/imp/config/portal.php.dist b/imp/config/portal.php.dist index b65348ce9..9a6535e14 100644 --- a/imp/config/portal.php.dist +++ b/imp/config/portal.php.dist @@ -20,14 +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 DIMP_BASE . '/lib/Block/foldersummary.php'; +require_once IMP_BASE . '/lib/Block/foldersummary.php'; $dimp_block_list[_("Folder Summary")] = array( 'ob' => new Horde_Block_dimp_foldersummary(array()) ); // Alternate DIMP block - shows details of 'msgs_shown' number of the most // recent unseen messages. -//require_once DIMP_BASE . '/lib/Block/newmail.php'; +//require_once IMP_BASE . '/lib/Block/newmail.php'; //$dimp_block_list[_("Newest Unseen Messages")] = array( // 'ob' => new Horde_Block_dimp_newmail(array('msgs_shown' => 3)) //); diff --git a/imp/imp-dimp.php b/imp/imp-dimp.php index bd18d538c..d15b7d808 100644 --- a/imp/imp-dimp.php +++ b/imp/imp-dimp.php @@ -34,8 +34,9 @@ function _generateDeleteResult($folder, $indices, $change) function _cacheID($folder) { - $imp_mailbox = &IMP_Mailbox::singleton($folder); - return $imp_mailbox->getCacheId(); +// $imp_mailbox = &IMP_Mailbox::singleton($folder); +// return $imp_mailbox->getCacheId(); + return false; } function _changed($folder, $compare, $indices = array(), $nothread = false) diff --git a/imp/index-dimp.php b/imp/index-dimp.php index ebb664076..f039b7790 100644 --- a/imp/index-dimp.php +++ b/imp/index-dimp.php @@ -18,7 +18,7 @@ $scripts = array( array('dragdrop.js', 'imp', true), array('dhtmlHistory.js', 'horde', true), array('redbox.js', 'horde', true), - array('mailbox-dimp.js', 'imp'), + array('mailbox-dimp.js', 'imp', false), array('DimpSlider.js', 'imp', true), array('unblockImages.js', 'imp', true) ); diff --git a/imp/lib/DIMP.php b/imp/lib/DIMP.php index b81c7cfab..2450d65b6 100644 --- a/imp/lib/DIMP.php +++ b/imp/lib/DIMP.php @@ -124,7 +124,7 @@ class DIMP */ protected function _includeDIMPJSVars() { - global $browser, $conf, $dimp_conf, $dimp_prefs, $prefs, $registry; + global $browser, $conf, $prefs, $registry; $compose_mode = (strstr($_SERVER['PHP_SELF'], 'compose-dimp.php') || strstr($_SERVER['PHP_SELF'], 'message-dimp.php')); $horde_webroot = $registry->get('webroot', 'horde'); @@ -171,18 +171,18 @@ class DIMP 'name' => $registry->get('name', 'dimp'), - 'preview_pref' => (bool)$dimp_prefs->getValue('show_preview'), + 'preview_pref' => (bool)$prefs->getValue('show_preview'), 'is_ie6' => ($browser->isBrowser('msie') && ($browser->getMajor() < 7)), - 'buffer_pages' => intval($dimp_conf['viewport']['buffer_pages']), - 'limit_factor' => intval($dimp_conf['viewport']['limit_factor']), - 'viewport_wait' => intval($dimp_conf['viewport']['viewport_wait']), - 'login_view' => $dimp_prefs->getValue('login_view'), - 'background_inbox' => !empty($dimp_conf['viewport']['background_inbox']), + 'buffer_pages' => intval($conf['viewport']['buffer_pages']), + 'limit_factor' => intval($conf['viewport']['limit_factor']), + 'viewport_wait' => intval($conf['viewport']['viewport_wait']), + 'login_view' => $prefs->getValue('login_view'), + 'background_inbox' => !empty($conf['viewport']['background_inbox']), // Turn debugging on? - 'debug' => !empty($dimp_conf['js']['debug']), + 'debug' => !empty($conf['js']['debug']), ); /* Gettext strings used in core javascript files. */ @@ -236,7 +236,7 @@ class DIMP 'close_draft' => $prefs->getValue('close_draft'), 'compose_cursor' => ($compose_cursor ? $compose_cursor : 'top'), - 'abook_url' => Horde::url($imp_webroot . '/contacts.php'), + 'abook_url' => Horde::applicationUrl('contacts.php'), 'specialchars_url' => Horde::url($horde_webroot . '/services/keyboard.php'), ); @@ -272,7 +272,7 @@ class DIMP function notify() { $GLOBALS['notification']->notify(array('listeners' => 'status')); - $msgs = $GLOBALS['dimp_listener']->getStack(true); + $msgs = $GLOBALS['imp_notify']->getStack(true); if (!count($msgs)) { return ''; } @@ -442,9 +442,9 @@ class DIMP $response->response = $data; if ($notify) { $GLOBALS['notification']->notify(array('listeners' => 'status')); - $stack = $GLOBALS['dimp_listener']->getStack(); + $stack = $GLOBALS['imp_notify']->getStack(); if (!empty($stack)) { - $response->msgs = $GLOBALS['dimp_listener']->getStack(); + $response->msgs = $GLOBALS['imp_notify']->getStack(); if (!(bool)$auto) { $response->msgs_noauto = true; } @@ -491,8 +491,8 @@ class DIMP */ function menuList() { - if (isset($GLOBALS['dimp_conf']['menu']['apps'])) { - $apps = $GLOBALS['dimp_conf']['menu']['apps']; + if (isset($GLOBALS['conf']['menu']['apps'])) { + $apps = $GLOBALS['conf']['menu']['apps']; if (is_array($apps) && count($apps)) { return $apps; } diff --git a/imp/lib/IMAP/Thread.php b/imp/lib/IMAP/Thread.php index a0c44d824..760f305a6 100644 --- a/imp/lib/IMAP/Thread.php +++ b/imp/lib/IMAP/Thread.php @@ -25,7 +25,7 @@ class IMP_IMAP_Thread * * @var array */ - protected $_imglist = array( + static protected $_imglist = array( '0' => 'blank.png', '1' => 'line.png', '2' => 'join.png', @@ -118,7 +118,7 @@ class IMP_IMAP_Thread public function getThreadImageTree($indices, $sortdir) { $tree = array(); - $imgs = $this->getImageUrls(false); + $imgs = self::getImageUrls(false); foreach ($this->getThreadTreeOb($indices, $sortdir) as $k => $v) { $tree[$k] = ''; for ($i = 0, $length = strlen($v); $i < $length; ++$i) { @@ -136,12 +136,12 @@ class IMP_IMAP_Thread * @return array An array with the image code as a key and the image url * as the value. */ - public function getImageUrls($ids = true) + static public function getImageUrls($ids = true) { $graphicsdir = $GLOBALS['registry']->getImageDir('horde'); $args = array(); - foreach ($this->_imglist as $key => $val) { + foreach (self::$_imglist as $key => $val) { if ($ids) { $args['id'] = 'thread_img_' . $key; } diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index de29d379b..39c3bf283 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -53,16 +53,16 @@ class IMP static public $printMode = false; /* displayFolder() cache. */ - static protected $_displaycache = array(); + static private $_displaycache = array(); /* hideDeletedMsgs() cache. */ - static protected $_delhide = null; + static private $_delhide = null; /* getAuthKey() cache. */ - static protected $_authkey = null; + static private $_authkey = null; /* _filesystemGC() cache. */ - static protected $_dirlist = array(); + static private $_dirlist = array(); /** * Makes sure the user has been authenticated to view the page. @@ -93,7 +93,7 @@ class IMP if (Util::getFormData('popup')) { Util::closeWindowJS(); } else { - $url = Util::addParameter(Auth::addLogoutParameters(IMP::logoutUrl()), 'url', Horde::selfUrl(true)); + $url = Util::addParameter(Auth::addLogoutParameters(self::logoutUrl()), 'url', Horde::selfUrl(true)); header('Location: ' . $url); } exit; @@ -147,7 +147,7 @@ class IMP { return ($GLOBALS['imp_search']->isSearchMbox($mbox)) ? $GLOBALS['imp_search']->getLabel($mbox) - : IMP::displayFolder($mbox); + : self::displayFolder($mbox); } /** @@ -234,8 +234,8 @@ class IMP if (!empty($options['new_folder']) && (!empty($GLOBALS['conf']['hooks']['permsdenied']) || - (IMP::hasPermission('create_folders') && - IMP::hasPermission('max_folders')))) { + (self::hasPermission('create_folders') && + self::hasPermission('max_folders')))) { $text .= '' . "\n"; $text .= '\n"; $text .= '' . "\n"; @@ -330,7 +330,7 @@ class IMP if (isset($args['to']) && (strpos($args['to'], 'mailto:') === 0)) { $mailto = @parse_url($args['to']); if (is_array($mailto)) { - $args['to'] = $mailto['path']; + $args['to'] = isset($mailto['path']) ? $mailto['path'] : ''; if (!empty($mailto['query'])) { parse_str($mailto['query'], $vals); foreach ($fields as $val) { @@ -355,7 +355,7 @@ class IMP if ($prefs->getValue('compose_popup')) { return true; } else { - $options += IMP::getComposeArgs(); + $options += self::getComposeArgs(); $url = Util::addParameter(Horde::applicationUrl('compose.php', true), $options, null, false); header('Location: ' . $url); @@ -410,7 +410,7 @@ class IMP */ static public function composeLink($args = array(), $extra = array()) { - $args = IMP::composeLinkArgs($args, $extra); + $args = self::composeLinkArgs($args, $extra); $is_mimp = ($_SESSION['imp']['view'] == 'mimp'); if (!$is_mimp && @@ -421,7 +421,7 @@ class IMP if (isset($args['to'])) { $args['to'] = addcslashes($args['to'], '\\"'); } - return "javascript:" . IMP::popupIMPString('compose.php', $args); + return "javascript:" . self::popupIMPString('compose.php', $args); } else { return Util::addParameter(Horde::applicationUrl($is_mimp ? 'compose-mimp.php' : 'compose.php'), $args); } @@ -573,11 +573,11 @@ class IMP $menu_search_url = Horde::applicationUrl('search.php'); $menu_mailbox_url = Horde::applicationUrl('mailbox.php'); - $spam_folder = IMP::folderPref($prefs->getValue('spam_folder'), true); + $spam_folder = self::folderPref($prefs->getValue('spam_folder'), true); $menu = new Menu(HORDE_MENU_MASK_ALL & ~HORDE_MENU_MASK_LOGIN); - $menu->add(IMP::generateIMPUrl($menu_mailbox_url, 'INBOX'), _("_Inbox"), 'folders/inbox.png'); + $menu->add(self::generateIMPUrl($menu_mailbox_url, 'INBOX'), _("_Inbox"), 'folders/inbox.png'); if (($_SESSION['imp']['protocol'] != 'pop') && $prefs->getValue('use_trash') && @@ -586,14 +586,14 @@ class IMP if ($prefs->getValue('use_vtrash')) { $mailbox = $GLOBALS['imp_search']->createSearchID($prefs->getValue('vtrash_id')); } else { - $trash_folder = IMP::folderPref($prefs->getValue('trash_folder'), true); + $trash_folder = self::folderPref($prefs->getValue('trash_folder'), true); if (($trash_folder !== null)) { $mailbox = $trash_folder; } } if (!empty($mailbox) && !$imp_imap->isReadOnly($mailbox)) { - $menu_trash_url = Util::addParameter(IMP::generateIMPUrl($menu_mailbox_url, $mailbox), array('actionID' => 'empty_mailbox', 'mailbox_token' => IMP::getRequestToken('imp.mailbox'))); + $menu_trash_url = Util::addParameter(self::generateIMPUrl($menu_mailbox_url, $mailbox), array('actionID' => 'empty_mailbox', 'mailbox_token' => self::getRequestToken('imp.mailbox'))); $menu->add($menu_trash_url, _("Empty _Trash"), 'empty_trash.png', null, null, "return window.confirm('" . addslashes(_("Are you sure you wish to empty your trash folder?")) . "');", '__noselection'); } } @@ -601,13 +601,13 @@ class IMP if (($_SESSION['imp']['protocol'] != 'pop') && !empty($spam_folder) && $prefs->getValue('empty_spam_menu')) { - $menu_spam_url = Util::addParameter(IMP::generateIMPUrl($menu_mailbox_url, $spam_folder), array('actionID' => 'empty_mailbox', 'mailbox_token' => IMP::getRequestToken('imp.mailbox'))); + $menu_spam_url = Util::addParameter(self::generateIMPUrl($menu_mailbox_url, $spam_folder), array('actionID' => 'empty_mailbox', 'mailbox_token' => self::getRequestToken('imp.mailbox'))); $menu->add($menu_spam_url, _("Empty _Spam"), 'empty_spam.png', null, null, "return window.confirm('" . addslashes(_("Are you sure you wish to empty your spam folder?")) . "');", '__noselection'); } if (empty($GLOBALS['conf']['hooks']['disable_compose']) || !Horde::callHook('_imp_hook_disable_compose', array(false), 'imp')) { - $menu->add(IMP::composeLink(array('mailbox' => $GLOBALS['imp_mbox']['mailbox'])), _("_New Message"), 'compose.png'); + $menu->add(self::composeLink(array('mailbox' => $GLOBALS['imp_mbox']['mailbox'])), _("_New Message"), 'compose.png'); } if ($conf['user']['allow_folders']) { @@ -642,7 +642,7 @@ class IMP /* If IMP doesn't provide Horde authentication then we need to use * IMP's logout screen since logging out should *not* end a Horde * session. */ - $logout_url = IMP::getLogoutUrl(); + $logout_url = self::getLogoutUrl(); $id = $menu->add($logout_url, _("_Log out"), 'logout.png', $registry->getImageDir('horde'), $logout_target); $menu->setPosition($id, HORDE_MENU_POS_LAST); @@ -667,13 +667,13 @@ class IMP $GLOBALS['conf']['user']['allow_folders'], true); if ($t->get('use_folders')) { $t->set('accesskey', $GLOBALS['prefs']->getValue('widget_accesskey') ? Horde::getAccessKey(_("Open Fo_lder")) : '', true); - $t->set('flist', IMP::flistSelect(array('selected' => $GLOBALS['imp_mbox']['mailbox'], 'inc_vfolder' => true))); + $t->set('flist', self::flistSelect(array('selected' => $GLOBALS['imp_mbox']['mailbox'], 'inc_vfolder' => true))); $menu_view = $GLOBALS['prefs']->getValue('menu_view'); $link = Horde::link('#', '', '', '', 'folderSubmit(true); return false;'); $t->set('flink', sprintf('', $link, ($menu_view != 'text') ? Horde::img('folders/folder_open.png', _("Open Folder"), ($menu_view == 'icon') ? array('title' => _("Open Folder")) : array()) : '', ($menu_view != 'icon') ? Horde::highlightAccessKey(_("Open Fo_lder"), $t->get('accesskey')) : '')); } - $t->set('menu_string', IMP::getMenu('string')); + $t->set('menu_string', self::getMenu('string')); echo $t->fetch(IMP_TEMPLATES . '/menu.html'); } @@ -698,7 +698,7 @@ class IMP */ static public function quota() { - $quotadata = IMP::quotaData(true); + $quotadata = self::quotaData(true); if (!empty($quotadata)) { $t = new IMP_Template(); $t->set('class', $quotadata['class']); @@ -803,8 +803,8 @@ class IMP $folders = array(); foreach ($var as $mb => $nm) { $folders[] = array( - 'url' => Util::addParameter(IMP::generateIMPUrl('mailbox.php', $mb), 'no_newmail_popup', 1), - 'name' => htmlspecialchars(IMP::displayFolder($mb)), + 'url' => Util::addParameter(self::generateIMPUrl('mailbox.php', $mb), 'no_newmail_popup', 1), + 'name' => htmlspecialchars(self::displayFolder($mb)), 'new' => (int)$nm, ); } @@ -813,7 +813,7 @@ class IMP if ($_SESSION['imp']['protocol'] != 'pop' && $GLOBALS['prefs']->getValue('use_vinbox') && ($vinbox_id = $GLOBALS['prefs']->getValue('vinbox_id'))) { - $t->set('vinbox', Horde::link(Util::addParameter(IMP::generateIMPUrl('mailbox.php', $GLOBALS['imp_search']->createSearchID($vinbox_id)), 'no_newmail_popup', 1))); + $t->set('vinbox', Horde::link(Util::addParameter(self::generateIMPUrl('mailbox.php', $GLOBALS['imp_search']->createSearchID($vinbox_id)), 'no_newmail_popup', 1))); } } else { $t->set('msg', ($var == 1) ? _("You have 1 new message.") : sprintf(_("You have %s new messages."), $var)); @@ -868,10 +868,10 @@ class IMP if (!is_array(current($indices))) { /* Build the list of indices/mailboxes if input is format #1. */ foreach ($indices as $msgIndex) { - if (strpos($msgIndex, IMP::IDX_SEP) === false) { + if (strpos($msgIndex, self::IDX_SEP) === false) { return false; } else { - list($val, $key) = explode(IMP::IDX_SEP, $msgIndex); + list($val, $key) = explode(self::IDX_SEP, $msgIndex); $msgList[$key][] = $val; } } @@ -879,7 +879,7 @@ class IMP /* We are dealing with format #2. */ foreach ($indices as $key => $val) { if ($GLOBALS['imp_search']->isSearchMbox($key)) { - $msgList += IMP::parseIndicesList($val); + $msgList += self::parseIndicesList($val); } else { /* Make sure we don't have any duplicate keys. */ $msgList[$key] = is_array($val) ? array_keys(array_flip($val)) : array($val); @@ -984,7 +984,7 @@ class IMP static public function generateIMPUrl($page, $mailbox, $index = null, $tmailbox = null, $encode = true) { - return Util::addParameter(Horde::applicationUrl($page), IMP::getIMPMboxParameters($mailbox, $index, $tmailbox), null, $encode); + return Util::addParameter(Horde::applicationUrl($page), self::getIMPMboxParameters($mailbox, $index, $tmailbox), null, $encode); } /** @@ -1029,7 +1029,7 @@ class IMP if ($GLOBALS['prefs']->getValue('use_vtrash')) { $delhide = !$GLOBALS['imp_search']->isVTrashFolder(); } else { - $sortpref = IMP::getSort(); + $sortpref = self::getSort(); $delhide = ($GLOBALS['prefs']->getValue('delhide') && !$GLOBALS['prefs']->getValue('use_trash') && ($GLOBALS['imp_search']->isSearchMbox() || @@ -1093,7 +1093,7 @@ class IMP } $search_mbox = $GLOBALS['imp_search']->isSearchMbox($mbox); - $prefmbox = $search_mbox ? $mbox : IMP::folderPref($mbox, false); + $prefmbox = $search_mbox ? $mbox : self::folderPref($mbox, false); $sortpref = @unserialize($GLOBALS['prefs']->getValue('sortpref')); $entry = (isset($sortpref[$prefmbox])) ? $sortpref[$prefmbox] : array(); @@ -1105,7 +1105,7 @@ class IMP ); /* Can't do threaded searches in search mailboxes. */ - if (!IMP::threadSortAvailable($mbox)) { + if (!self::threadSortAvailable($mbox)) { if ($ob['by'] == Horde_Imap_Client::SORT_THREAD) { $ob['by'] = Horde_Imap_Client::SORT_DATE; } @@ -1125,7 +1125,7 @@ class IMP if (!$ob['limit'] && (($ob['by'] == Horde_Imap_Client::SORT_TO) || ($ob['by'] == Horde_Imap_Client::SORT_FROM))) { - if (IMP::isSpecialFolder($mbox)) { + if (self::isSpecialFolder($mbox)) { /* If the preference is to sort by From Address, when we are in the Drafts or Sent folders, sort by To Address. */ if ($ob['by'] == Horde_Imap_Client::SORT_FROM) { @@ -1174,7 +1174,7 @@ class IMP $mbox = $GLOBALS['imp_mbox']['mailbox']; } - $prefmbox = ($GLOBALS['imp_search']->isSearchMbox()) ? $mbox : IMP::folderPref($mbox, false); + $prefmbox = ($GLOBALS['imp_search']->isSearchMbox()) ? $mbox : self::folderPref($mbox, false); if ($delete) { unset($sortpref[$prefmbox]); @@ -1237,7 +1237,7 @@ class IMP // If headers have already been sent, we need to output a //