From: Michael M Slusarz Date: Mon, 27 Jul 2009 17:27:10 +0000 (-0600) Subject: Bug #8447: Move IMP initialization to function X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=c07dc3fd3f1ea04331e70e87009e185ffc895870;p=horde.git Bug #8447: Move IMP initialization to function --- diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 0f9d578e4..44c421603 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -50,6 +50,68 @@ class IMP /* filesystemGC() cache. */ static private $_dirlist = array(); + /* Has init previously been called? */ + static private $_init = false; + + /** + * Performs IMP initialization. + */ + static public function initialize() + { + if (self::$_init) { + return; + } + + if (!defined('IMP_TEMPLATES')) { + $registry = Horde_Registry::singleton(); + define('IMP_TEMPLATES', $registry->get('templates')); + } + + // Start compression. + if (!Horde_Util::nonInputVar('imp_no_compress')) { + Horde::compressOutput(); + } + + // TODO: Remove once this can be autoloaded + require_once 'Horde/Identity.php'; + + // Initialize global $imp_imap object. + if (!isset($GLOBALS['imp_imap'])) { + $GLOBALS['imp_imap'] = new IMP_Imap(); + } + + // Initialize some message parsing variables. + Horde_Mime::$brokenRFC2231 = !empty($GLOBALS['conf']['mailformat']['brokenrfc2231']); + + // Set default message character set, if necessary + if ($def_charset = $GLOBALS['prefs']->getValue('default_msg_charset')) { + Horde_Mime_Part::$defaultCharset = $def_charset; + Horde_Mime_Headers::$defaultCharset = $def_charset; + } + + $GLOBALS['notification'] = Horde_Notification::singleton(); + $viewmode = isset($_SESSION['imp']['view']) + ? $_SESSION['imp']['view'] + : 'imp'; + + if ($viewmode == 'mimp') { + $GLOBALS['imp_notify'] = $GLOBALS['notification']->attach('status', null, 'Horde_Notification_Listener_Mobile'); + } else { + $GLOBALS['imp_notify'] = $GLOBALS['notification']->attach('status', array('viewmode' => $viewmode), 'IMP_Notification_Listener_Status'); + if ($viewmode == 'imp') { + $GLOBALS['notification']->attach('audio'); + } + } + + // Initialize global $imp_mbox array. + $GLOBALS['imp_mbox'] = IMP::getCurrentMailboxInfo(); + + // Initialize IMP_Search object. + $GLOBALS['imp_search'] = new IMP_Search(array('id' => (isset($_SESSION['imp']) && IMP_Search::isSearchMbox($GLOBALS['imp_mbox']['mailbox'])) ? $GLOBALS['imp_mbox']['mailbox'] : null)); + + self::$_init = true; + } + /** * Returns the plain text label that is displayed for the current mailbox, * replacing virtual search mailboxes with an appropriate description and diff --git a/imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php b/imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php index 310d5effd..9a61c5446 100644 --- a/imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php +++ b/imp/lib/LoginTasks/Task/DeleteAttachmentsMonthly.php @@ -15,6 +15,8 @@ class IMP_LoginTasks_Task_DeleteAttachmentsMonthly extends Horde_LoginTasks_Task */ public function __construct() { + IMP::initialize(); + $this->active = $GLOBALS['prefs']->getValue('delete_attachments_monthly'); if ($this->active && $GLOBALS['prefs']->isLocked('delete_attachments_monthly')) { diff --git a/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php b/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php index 43022ae92..27715d9c8 100644 --- a/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php +++ b/imp/lib/LoginTasks/Task/DeleteSentmailMonthly.php @@ -17,6 +17,8 @@ class IMP_LoginTasks_Task_DeleteSentmailMonthly extends Horde_LoginTasks_Task */ public function __construct() { + IMP::initialize(); + $this->active = $GLOBALS['prefs']->getValue('delete_sentmail_monthly'); if ($this->active && $GLOBALS['prefs']->isLocked('delete_sentmail_monthly')) { diff --git a/imp/lib/LoginTasks/Task/PurgeSentmail.php b/imp/lib/LoginTasks/Task/PurgeSentmail.php index 11b08d82f..01d939493 100644 --- a/imp/lib/LoginTasks/Task/PurgeSentmail.php +++ b/imp/lib/LoginTasks/Task/PurgeSentmail.php @@ -18,6 +18,8 @@ class IMP_LoginTasks_Task_PurgeSentmail extends Horde_LoginTasks_Task */ public function __construct() { + IMP::initialize(); + $this->active = $GLOBALS['prefs']->getValue('purge_sentmail'); if ($this->active) { $this->interval = $GLOBALS['prefs']->getValue('purge_sentmail_interval'); diff --git a/imp/lib/LoginTasks/Task/PurgeSpam.php b/imp/lib/LoginTasks/Task/PurgeSpam.php index 244ff3235..3a6068553 100644 --- a/imp/lib/LoginTasks/Task/PurgeSpam.php +++ b/imp/lib/LoginTasks/Task/PurgeSpam.php @@ -18,6 +18,8 @@ class IMP_LoginTasks_Task_PurgeSpam extends Horde_LoginTasks_Task */ public function __construct() { + IMP::initialize(); + $this->active = $GLOBALS['prefs']->getValue('purge_spam'); if ($this->active) { $this->interval = $GLOBALS['prefs']->getValue('purge_spam_interval'); diff --git a/imp/lib/LoginTasks/Task/PurgeTrash.php b/imp/lib/LoginTasks/Task/PurgeTrash.php index 6fad9477a..00f8f8955 100644 --- a/imp/lib/LoginTasks/Task/PurgeTrash.php +++ b/imp/lib/LoginTasks/Task/PurgeTrash.php @@ -17,6 +17,8 @@ class IMP_LoginTasks_Task_PurgeTrash extends Horde_LoginTasks_Task */ public function __construct() { + IMP::initialize(); + $this->active = $GLOBALS['prefs']->getValue('purge_trash'); if ($this->active) { $this->interval = $GLOBALS['prefs']->getValue('purge_trash_interval'); diff --git a/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php b/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php index 0f03d5ad6..b62572db6 100644 --- a/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php +++ b/imp/lib/LoginTasks/Task/RenameSentmailMonthly.php @@ -17,6 +17,8 @@ class IMP_LoginTasks_Task_RenameSentmailMonthly extends Horde_LoginTasks_Task */ public function __construct() { + IMP::initialize(); + $this->active = $GLOBALS['prefs']->getValue('rename_sentmail_monthly'); if ($this->active && $GLOBALS['prefs']->isLocked('rename_sentmail_monthly')) { diff --git a/imp/lib/base.php b/imp/lib/base.php index ef46859e9..c2060bbeb 100644 --- a/imp/lib/base.php +++ b/imp/lib/base.php @@ -114,46 +114,5 @@ try { Horde_Auth::authenticationFailureRedirect('imp', $e); } -$conf = &$GLOBALS['conf']; -if (!defined('IMP_TEMPLATES')) { - define('IMP_TEMPLATES', $registry->get('templates')); -} - -// Start compression. -if (!Horde_Util::nonInputVar('imp_no_compress')) { - Horde::compressOutput(); -} - -/* Some stuff that only needs to be initialized if we are authenticated. */ -// TODO: Remove once this can be autoloaded -require_once 'Horde/Identity.php'; - -// Initialize global $imp_imap object. -if (!isset($GLOBALS['imp_imap'])) { - $GLOBALS['imp_imap'] = new IMP_Imap(); -} - -// Initialize some message parsing variables. -Horde_Mime::$brokenRFC2231 = !empty($GLOBALS['conf']['mailformat']['brokenrfc2231']); - -// Set default message character set, if necessary -if ($def_charset = $GLOBALS['prefs']->getValue('default_msg_charset')) { - Horde_Mime_Part::$defaultCharset = $def_charset; - Horde_Mime_Headers::$defaultCharset = $def_charset; -} - -$notification = Horde_Notification::singleton(); -if ($viewmode == 'mimp') { - $GLOBALS['imp_notify'] = $notification->attach('status', null, 'Horde_Notification_Listener_Mobile'); -} else { - $GLOBALS['imp_notify'] = $notification->attach('status', array('viewmode' => $viewmode), 'IMP_Notification_Listener_Status'); - if ($viewmode == 'imp') { - $notification->attach('audio'); - } -} - -// Initialize global $imp_mbox array. -$GLOBALS['imp_mbox'] = IMP::getCurrentMailboxInfo(); - -// Initialize IMP_Search object. -$GLOBALS['imp_search'] = new IMP_Search(array('id' => (isset($_SESSION['imp']) && IMP_Search::isSearchMbox($GLOBALS['imp_mbox']['mailbox'])) ? $GLOBALS['imp_mbox']['mailbox'] : null)); +// All other initialization occurs in IMP::initialize(). +IMP::initialize();