From df8c626194789a61214771c8b5ac07fa870bdc8b Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 4 Aug 2009 21:39:02 -0600 Subject: [PATCH] Move appendNamespace() to IMP_Imap::. --- imp/folders.php | 2 +- imp/lib/Api.php | 8 ++++---- imp/lib/IMP.php | 17 ----------------- imp/lib/Imap.php | 18 ++++++++++++++++++ imp/rss.php | 2 +- 5 files changed, 24 insertions(+), 23 deletions(-) diff --git a/imp/folders.php b/imp/folders.php index c6dad3611..ea395709b 100644 --- a/imp/folders.php +++ b/imp/folders.php @@ -194,7 +194,7 @@ case 'rename_folder': !empty($old_names) && ($iMax == count($old_names))) { for ($i = 0; $i < $iMax; ++$i) { - $imp_folder->rename(trim($old_names[$i], "\r\n"), Horde_String::convertCharset(IMP::appendNamespace(trim($new_names[$i], "\r\n")), $charset, 'UTF7-IMAP')); + $imp_folder->rename(trim($old_names[$i], "\r\n"), Horde_String::convertCharset($imp_imap->appendNamespace(trim($new_names[$i], "\r\n")), $charset, 'UTF7-IMAP')); } } break; diff --git a/imp/lib/Api.php b/imp/lib/Api.php index b3bc34bf7..0b050e4fe 100644 --- a/imp/lib/Api.php +++ b/imp/lib/Api.php @@ -506,9 +506,9 @@ class IMP_Api extends Horde_Registry_Api $sent_mail_default = $GLOBALS['prefs']->getValue('sent_mail_folder'); if (empty($sent_mail_folder) && !empty($sent_mail_new)) { - $sent_mail_folder = IMP::appendNamespace($sent_mail_new); + $sent_mail_folder = $GLOBALS['imp_imap']->appendNamespace($sent_mail_new); } elseif (($sent_mail_folder == '-1') && !empty($sent_mail_default)) { - $sent_mail_folder = IMP::appendNamespace($sent_mail_default); + $sent_mail_folder = $GLOBALS['imp_imap']->appendNamespace($sent_mail_default); } if (!empty($sent_mail_folder)) { @@ -538,7 +538,7 @@ class IMP_Api extends Horde_Registry_Api $GLOBALS['prefs']->setValue($pref, ''); } else { if (empty($folder) && !empty($new)) { - $folder = IMP::appendNamespace($new); + $folder = $GLOBALS['imp_imap']->appendNamespace($new); $imp_folder = IMP_Folder::singleton(); if (!$imp_folder->create($folder, $GLOBALS['prefs']->getValue('subscribe'))) { $folder = null; @@ -967,7 +967,7 @@ class IMP_Api extends Horde_Registry_Api } $imp_folder = IMP_Folder::singleton(); - return $imp_folder->create(IMP::appendNamespace($folder), $GLOBALS['prefs']->getValue('subscribe')); + return $imp_folder->create($GLOBALS['imp_imap']->appendNamespace($folder), $GLOBALS['prefs']->getValue('subscribe')); } /** diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 97372ab8d..189d0a33f 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -884,23 +884,6 @@ class IMP } /** - * Make sure a user-entered mailbox contains namespace information. - * - * @param string $mbox The user-entered mailbox string. - * - * @return string The mailbox string with any necessary namespace info - * added. - */ - static public function appendNamespace($mbox) - { - $ns_info = $GLOBALS['imp_imap']->getNamespace($mbox, false); - if (is_null($ns_info)) { - $ns_info = $GLOBALS['imp_imap']->defaultNamespace(); - } - return $ns_info['name'] . $mbox; - } - - /** * Generates a URL with necessary mailbox/UID information. * * @param string $page Page name to link to. diff --git a/imp/lib/Imap.php b/imp/lib/Imap.php index 1a2cbef8f..f85d6dcf6 100644 --- a/imp/lib/Imap.php +++ b/imp/lib/Imap.php @@ -388,4 +388,22 @@ class IMP_Imap return $this->_nsdefault; } + + /** + * Make sure a user-entered mailbox contains namespace information. + * + * @param string $mbox The user-entered mailbox string. + * + * @return string The mailbox string with any necessary namespace info + * added. + */ + static public function appendNamespace($mbox) + { + $ns_info = $this->getNamespace($mbox, false); + if (is_null($ns_info)) { + $ns_info = $this->defaultNamespace(); + } + return $ns_info['name'] . $mbox; + } + } diff --git a/imp/rss.php b/imp/rss.php index d899b554a..357ea59ca 100644 --- a/imp/rss.php +++ b/imp/rss.php @@ -32,7 +32,7 @@ if (!empty($request)) { $request_parts = explode('/-/', $request); if (!empty($request_parts[0])) { $ns_info = $imp_imap->getNamespace(); - $mailbox = IMP::appendNamespace(preg_replace('/\//', $ns_info['delimiter'], trim($request_parts[0], '/'))); + $mailbox = $imp_imap->appendNamespace(preg_replace('/\//', $ns_info['delimiter'], trim($request_parts[0], '/'))); /* Make sure mailbox exists or else exit immediately. */ $imp_folder = IMP_Folder::singleton(); -- 2.11.0