From 003901b79bc25894b29bfbb965799cbb1ead102d Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 9 Feb 2010 16:37:29 -0700 Subject: [PATCH] Move init() to a better location in the file --- imp/lib/Imap/Tree.php | 123 +++++++++++++++++++++++++------------------------- 1 file changed, 62 insertions(+), 61 deletions(-) diff --git a/imp/lib/Imap/Tree.php b/imp/lib/Imap/Tree.php index 66aa741fa..c0753ba45 100644 --- a/imp/lib/Imap/Tree.php +++ b/imp/lib/Imap/Tree.php @@ -223,6 +223,68 @@ class IMP_Imap_Tree } /** + * Initalize the tree. + */ + public function init() + { + $unsubmode = (($_SESSION['imp']['protocol'] == 'pop') || + !$GLOBALS['prefs']->getValue('subscribe') || + $_SESSION['imp']['showunsub']); + + /* Reset class variables to the defaults. */ + $this->changed = true; + $this->_currkey = $this->_currparent = $this->_subscribed = null; + $this->_currstack = $this->_tree = $this->_parent = array(); + $this->_showunsub = $this->_unsubview = $unsubmode; + + /* Create a placeholder element to the base of the tree list so we can + * keep track of whether the base level needs to be sorted. */ + $this->_tree[self::BASE_ELT] = array( + 'a' => self::ELT_NEED_SORT, + 'v' => self::BASE_ELT + ); + + /* Add INBOX and exit if folders aren't allowed or if we are using + * POP3. */ + if (empty($GLOBALS['conf']['user']['allow_folders']) || + ($_SESSION['imp']['protocol'] == 'pop')) { + $this->_insertElt($this->_makeElt('INBOX', self::ELT_IS_SUBSCRIBED)); + return; + } + + /* Add namespace elements. */ + foreach ($this->_namespaces as $key => $val) { + if ($val['type'] != 'personal' && + $GLOBALS['prefs']->getValue('tree_view')) { + $elt = $this->_makeElt( + ($val['type'] == 'other') ? self::OTHER_KEY : self::SHARED_KEY, + self::ELT_NOSELECT | self::ELT_NAMESPACE | self::ELT_NONIMAP | self::ELT_NOSHOW + ); + $elt['l'] = ($val['type'] == 'other') + ? _("Other Users' Folders") + : _("Shared Folders"); + + foreach ($this->_namespaces as $val2) { + if (($val2['type'] == $val['type']) && + ($val2['name'] != $val['name'])) { + $elt['a'] &= ~self::ELT_NOSHOW; + break; + } + } + + $this->_insertElt($elt); + } + } + + /* Create the list (INBOX and all other hierarchies). */ + $this->insert($this->_getList($this->_showunsub)); + + /* Add virtual folders to the tree. */ + $this->insertVFolders($GLOBALS['imp_search']->listQueries(IMP_Search::LIST_VFOLDER)); + } + + + /** * Returns the list of mailboxes on the server. * * @param boolean $showunsub Show unsubscribed mailboxes? @@ -376,67 +438,6 @@ class IMP_Imap_Tree } /** - * Initalize the tree. - */ - public function init() - { - $unsubmode = (($_SESSION['imp']['protocol'] == 'pop') || - !$GLOBALS['prefs']->getValue('subscribe') || - $_SESSION['imp']['showunsub']); - - /* Reset class variables to the defaults. */ - $this->changed = true; - $this->_currkey = $this->_currparent = $this->_subscribed = null; - $this->_currstack = $this->_tree = $this->_parent = array(); - $this->_showunsub = $this->_unsubview = $unsubmode; - - /* Create a placeholder element to the base of the tree list so we can - * keep track of whether the base level needs to be sorted. */ - $this->_tree[self::BASE_ELT] = array( - 'a' => self::ELT_NEED_SORT, - 'v' => self::BASE_ELT - ); - - /* Add INBOX and exit if folders aren't allowed or if we are using - * POP3. */ - if (empty($GLOBALS['conf']['user']['allow_folders']) || - ($_SESSION['imp']['protocol'] == 'pop')) { - $this->_insertElt($this->_makeElt('INBOX', self::ELT_IS_SUBSCRIBED)); - return; - } - - /* Add namespace elements. */ - foreach ($this->_namespaces as $key => $val) { - if ($val['type'] != 'personal' && - $GLOBALS['prefs']->getValue('tree_view')) { - $elt = $this->_makeElt( - ($val['type'] == 'other') ? self::OTHER_KEY : self::SHARED_KEY, - self::ELT_NOSELECT | self::ELT_NAMESPACE | self::ELT_NONIMAP | self::ELT_NOSHOW - ); - $elt['l'] = ($val['type'] == 'other') - ? _("Other Users' Folders") - : _("Shared Folders"); - - foreach ($this->_namespaces as $val2) { - if (($val2['type'] == $val['type']) && - ($val2['name'] != $val['name'])) { - $elt['a'] &= ~self::ELT_NOSHOW; - break; - } - } - - $this->_insertElt($elt); - } - } - - /* Create the list (INBOX and all other hierarchies). */ - $this->insert($this->_getList($this->_showunsub)); - - /* Add virtual folders to the tree. */ - $this->insertVFolders($GLOBALS['imp_search']->listQueries(IMP_Search::LIST_VFOLDER)); - } - - /** * Expand a mail folder. * * @param string $folder The folder name to expand. -- 2.11.0