Convert IMP to the new Horde_Session API
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 8 Oct 2010 21:23:15 +0000 (15:23 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Sat, 9 Oct 2010 07:20:04 +0000 (01:20 -0600)
54 files changed:
imp/compose-dimp.php
imp/compose-mimp.php
imp/compose.php
imp/folders-mimp.php
imp/folders.php
imp/lib/Ajax/Application.php
imp/lib/Ajax/Imple/ContactAutoCompleter.php
imp/lib/Api.php
imp/lib/Application.php
imp/lib/Auth.php
imp/lib/Block/summary.php
imp/lib/Compose.php
imp/lib/Crypt/Pgp.php
imp/lib/Crypt/Smime.php
imp/lib/Filter.php
imp/lib/IMP.php
imp/lib/Imap.php
imp/lib/Imap/Acl.php
imp/lib/Imap/Flags.php
imp/lib/Imap/Tree.php
imp/lib/Injector/Factory/AuthImap.php
imp/lib/Injector/Factory/Compose.php
imp/lib/Injector/Factory/Imap.php
imp/lib/Injector/Factory/Imaptree.php
imp/lib/Injector/Factory/Mail.php
imp/lib/Injector/Factory/MailboxList.php
imp/lib/Injector/Factory/Quota.php
imp/lib/Injector/Factory/Search.php
imp/lib/Mailbox/List.php
imp/lib/Message.php
imp/lib/Mime/Viewer/Html.php
imp/lib/Mime/Viewer/Itip.php
imp/lib/Mime/Viewer/Pgp.php
imp/lib/Mime/Viewer/Plain.php
imp/lib/Mime/Viewer/Smime.php
imp/lib/Prefs/Identity.php
imp/lib/Prefs/Ui.php
imp/lib/Quota/Mdaemon.php
imp/lib/Search.php
imp/lib/Sentmail/Base.php
imp/lib/Tree/Flist.php
imp/lib/Ui/Block.php
imp/lib/Ui/Message.php
imp/lib/Views/Compose.php
imp/lib/Views/ListMessages.php
imp/mailbox-mimp.php
imp/mailbox.php
imp/message-mimp.php
imp/message.php
imp/search-basic.php
imp/search.php
imp/templates/dimp/index.inc
imp/templates/dimp/javascript_defs_dimp.php
imp/templates/imp/javascript_defs.php

index 5402772..85770cf 100644 (file)
@@ -130,7 +130,7 @@ case 'forward_both':
             break;
         }
 
-        $rte = $show_editor = ($prefs->getValue('compose_html') && $_SESSION['imp']['rteavail']);
+        $rte = $show_editor = ($prefs->getValue('compose_html') && $session['imp:rteavail']);
     } else {
         try {
             $contents = $imp_ui->getContents($vars);
@@ -192,7 +192,7 @@ case 'resume':
     break;
 
 case 'new':
-    $rte = $show_editor = ($prefs->getValue('compose_html') && $_SESSION['imp']['rteavail']);
+    $rte = $show_editor = ($prefs->getValue('compose_html') && $session['imp:rteavail']);
     break;
 }
 
index d974fe9..0400ba9 100644 (file)
@@ -101,7 +101,7 @@ foreach (array_keys($display_hdrs) as $val) {
 }
 
 /* Add attachment. */
-if ($_SESSION['imp']['file_upload'] &&
+if ($session['imp:file_upload'] &&
     !$imp_compose->addFilesFromUpload('upload_', $vars->a == _("Expand Names")) &&
     ($vars->a != _("Expand Names"))) {
     $vars->a = null;
@@ -378,7 +378,7 @@ $t->set('hdrs', $hdrs);
 $t->set('title', $title);
 
 /* Activate advanced compose attachments UI? */
-if ($_SESSION['imp']['file_upload']) {
+if ($session['imp:file_upload']) {
     try {
         if (Horde::callHook('mimp_advanced', array('compose_attach'), 'imp')) {
             $t->set('attach', true);
index 7751ed2..fdf8dcb 100644 (file)
@@ -145,7 +145,7 @@ $isPopup = ($prefs->getValue('compose_popup') || $vars->popup);
 /* Determine the composition type - text or HTML.
    $rtemode is null if browser does not support it. */
 $rtemode = null;
-if ($_SESSION['imp']['rteavail']) {
+if ($session['imp:rteavail']) {
     if ($prefs->isLocked('compose_html')) {
         $rtemode = $prefs->getValue('compose_html');
     } else {
@@ -160,7 +160,7 @@ if ($_SESSION['imp']['rteavail']) {
 }
 
 /* Update the file attachment information. */
-if ($_SESSION['imp']['file_upload']) {
+if ($session['imp:file_upload']) {
     /* Only notify if we are reloading the compose screen. */
     $notify = !in_array($vars->actionID, array('send_message', 'save_draft'));
 
@@ -711,7 +711,7 @@ if ($redirect) {
     /* Prepare the compose template. */
     $tabindex = 0;
 
-    $t->set('file_upload', $_SESSION['imp']['file_upload']);
+    $t->set('file_upload', $session['imp:file_upload']);
     $t->set('forminput', Horde_Util::formInput());
 
     $hidden = array(
@@ -726,8 +726,8 @@ if ($redirect) {
         'user' => $registry->getAuth()
     );
 
-    if ($_SESSION['imp']['file_upload']) {
-        $hidden['MAX_FILE_SIZE'] = $_SESSION['imp']['file_upload'];
+    if (isset($session['imp:file_upload'])) {
+        $hidden['MAX_FILE_SIZE'] = $session['imp:file_upload'];
     }
     foreach (array('page', 'start', 'popup') as $val) {
         $hidden[$val] = htmlspecialchars($vars->$val);
@@ -869,7 +869,7 @@ if ($redirect) {
             'label' => ''
         );
     }
-    if ($_SESSION['imp']['file_upload']) {
+    if ($session['imp:file_upload']) {
         $url = new Horde_Url('#attachments');
         $compose_options[] = array(
             'url' => $url->link(array('class' => 'widget')),
@@ -956,7 +956,7 @@ if ($redirect) {
         $t->set('vcard', Horde::label('vcard', _("Attach your contact information to the message?")));
         $t->set('attach_vcard', $vars->vcard);
     }
-    if ($_SESSION['imp']['file_upload']) {
+    if ($session['imp:file_upload']) {
         $localeinfo = Horde_Nls::getLocaleInfo();
         try {
             $t->set('selectlistlink', $registry->call('files/selectlistLink', array(_("Attach Files"), 'widget', 'compose', true)));
index 37dc1c5..a33ad41 100644 (file)
@@ -29,7 +29,7 @@ if (empty($conf['user']['allow_folders'])) {
 
 /* Decide whether or not to show all the unsubscribed folders */
 $subscribe = $prefs->getValue('subscribe');
-$showAll = (!$subscribe || $_SESSION['imp']['showunsub']);
+$showAll = (!$subscribe || $session['imp:showunsub']);
 
 /* Initialize the IMP_Imap_Tree object. */
 $imptree = $injector->getInstance('IMP_Imap_Tree');
@@ -38,7 +38,7 @@ $mask = 0;
 /* Toggle subscribed view, if necessary. */
 if ($subscribe && Horde_Util::getFormData('ts')) {
     $showAll = !$showAll;
-    $_SESSION['imp']['showunsub'] = $showAll;
+    $session['imp:showunsub'] = $showAll;
     $imptree->showUnsubscribed($showAll);
     if ($showAll) {
         $mask |= IMP_Imap_Tree::FLIST_UNSUB;
index e4f7ffd..e1499f0 100644 (file)
@@ -30,7 +30,7 @@ if (!$conf['user']['allow_folders']) {
 
 /* Decide whether or not to show all the unsubscribed folders */
 $subscribe = $prefs->getValue('subscribe');
-$showAll = (!$subscribe || $_SESSION['imp']['showunsub']);
+$showAll = (!$subscribe || $session['imp:showunsub']);
 
 $vars = Horde_Variables::getDefaultVariables();
 
@@ -204,7 +204,7 @@ case 'unsubscribe_folder':
 case 'toggle_subscribed_view':
     if ($subscribe) {
         $showAll = !$showAll;
-        $_SESSION['imp']['showunsub'] = $showAll;
+        $session['imp:showunsub'] = $showAll;
         $imaptree->showUnsubscribed($showAll);
     }
     break;
@@ -331,7 +331,7 @@ $folders_token = Horde::getRequestToken('imp.folders');
 $folders_url_ob = new Horde_Url($folders_url);
 $folders_url_ob->add('folders_token', $folders_token);
 
-if ($_SESSION['imp']['file_upload'] && ($vars->actionID == 'import_mbox')) {
+if ($session['imp:file_upload'] && ($vars->actionID == 'import_mbox')) {
     $title = _("Folder Navigator");
     $menu = IMP::menu();
     require IMP_TEMPLATES . '/common-header.inc';
@@ -389,7 +389,7 @@ if ($prefs->getValue('subscribe')) {
 }
 $a_template->set('nav_poll', !$prefs->isLocked('nav_poll') && !$prefs->getValue('nav_poll_all'));
 $a_template->set('notrash', !$prefs->getValue('use_trash'));
-$a_template->set('file_upload', $_SESSION['imp']['file_upload']);
+$a_template->set('file_upload', $session['imp:file_upload']);
 $a_template->set('expand_all', Horde::widget($folders_url_ob->copy()->add(array('actionID' => 'expand_all_folders', 'folders_token' => $folders_token)), _("Expand All Folders"), 'widget', '', '', _("Expand All"), true));
 $a_template->set('collapse_all', Horde::widget($folders_url_ob->copy()->add(array('actionID' => 'collapse_all_folders', 'folders_token' => $folders_token)), _("Collapse All Folders"), 'widget', '', '', _("Collapse All"), true));
 
index 79238f5..333d6ed 100644 (file)
@@ -1534,7 +1534,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
         $result->action = 'addAttachment';
         $result->success = 0;
 
-        if ($_SESSION['imp']['file_upload'] &&
+        if ($GLOBALS['session']['imp:file_upload'] &&
             $imp_compose->addFilesFromUpload('file_')) {
             $result->atc = end(IMP_Dimp::getAttachmentInfo($imp_compose));
             $result->success = 1;
@@ -2058,8 +2058,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
      */
     protected function _getQuota()
     {
-        if (isset($_SESSION['imp']['imap']['quota']) &&
-            is_array($_SESSION['imp']['imap']['quota'])) {
+        if ($GLOBALS['session']['imp:imap_quota']) {
             $quotadata = IMP::quotaData(false);
             if (!empty($quotadata)) {
                 return array(
index 0acbecf..79b7e35 100644 (file)
@@ -40,7 +40,7 @@ class IMP_Ajax_Imple_ContactAutoCompleter extends Horde_Core_Ajax_Imple_AutoComp
             ? 0
             : $GLOBALS['conf']['compose']['ac_browser'];
 
-        if ($ac_browser && !isset($_SESSION['imp']['cache']['ac_ajax'])) {
+        if ($ac_browser && empty($GLOBALS['session']['imp:ac_ajax'])) {
             $success = $use_ajax = true;
             $sparams = IMP::getAddressbookSearchParams();
             foreach ($sparams['fields'] as $val) {
@@ -55,10 +55,10 @@ class IMP_Ajax_Imple_ContactAutoCompleter extends Horde_Core_Ajax_Imple_AutoComp
                 $addrlist = IMP_Compose::getAddressList();
                 $use_ajax = count($addrlist) > $ac_browser;
             }
-            $_SESSION['imp']['cache']['ac_ajax'] = $use_ajax;
+            $GLOBALS['session']['imp:ac_ajax'] = $use_ajax;
         }
 
-        if (!$ac_browser || $_SESSION['imp']['cache']['ac_ajax']) {
+        if (!$ac_browser || $GLOBALS['session']['imp:ac_ajax']) {
             $ret['ajax'] = 'ContactAutoCompleter';
             $ret['params']['minChars'] = intval($GLOBALS['conf']['compose']['ac_threshold'] ? $GLOBALS['conf']['compose']['ac_threshold'] : 1);
         } else {
index 234694a..9afb469 100644 (file)
@@ -181,12 +181,13 @@ class IMP_Api extends Horde_Registry_Api
      */
     public function server()
     {
-        $imap_obj = unserialize($_SESSION['imp']['imap_ob'][$_SESSION['imp']['server_key']]);
+        $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
+
         return array(
-            'hostspec' => $imap_obj->getParam('hostspec'),
-            'port' => $imap_obj->getParam('port'),
-            'protocol' => $_SESSION['imp']['protocol'],
-            'secure' => $imap_obj->getParam('secure')
+            'hostspec' => $imap_ob->ob->getParam('hostspec'),
+            'port' => $imap_ob->ob->getParam('port'),
+            'protocol' => $GLOBALS['session']['imp:protocol'],
+            'secure' => $imap_ob->ob->getParam('secure')
         );
     }
 
@@ -227,7 +228,7 @@ class IMP_Api extends Horde_Registry_Api
      */
     public function flagList($mailbox = null)
     {
-        if ($_SESSION['imp']['protocol'] == 'pop') {
+        if ($GLOBALS['session']['imp:protocol'] == 'pop') {
             return array();
         }
 
index b1e8f9c..95714ad 100644 (file)
@@ -65,7 +65,7 @@ class IMP_Application extends Horde_Registry_Application
     {
         /* Methods only available if admin config is set for this
          * server/login. */
-        if (empty($_SESSION['imp']['imap']['admin'])) {
+        if (!$GLOBALS['session']['imp:imap_admin']) {
             $this->disabled = array_merge($this->disabled, array('authAddUser', 'authRemoveUser', 'authUserList'));
         }
     }
@@ -148,10 +148,8 @@ class IMP_Application extends Horde_Registry_Application
     public function logout()
     {
         /* Clean up dangling IMP_Compose objects. */
-        if (!empty($_SESSION['imp']['cache']['compose'])) {
-            foreach (array_keys($_SESSION['imp']['cache']['compose']) as $key) {
-                $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($key)->destroy('cancel');
-            }
+        foreach (array_keys($GLOBALS['session']['imp:compose_cache;array']) as $key) {
+            $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Compose')->create($key)->destroy('cancel');
         }
     }
 
@@ -235,7 +233,7 @@ class IMP_Application extends Horde_Registry_Application
             'url' => IMP::generateIMPUrl($menu_mailbox_url, 'INBOX')
         ));
 
-        if ($_SESSION['imp']['protocol'] != 'pop') {
+        if ($GLOBALS['session']['imp:protocol'] != 'pop') {
             if ($prefs->getValue('use_trash') &&
                 ($trash_folder = $prefs->getValue('trash_folder')) &&
                 $prefs->getValue('empty_trash_menu')) {
@@ -283,7 +281,7 @@ class IMP_Application extends Horde_Registry_Application
             ));
         }
 
-        if ($_SESSION['imp']['protocol'] != 'pop') {
+        if ($GLOBALS['session']['imp:protocol'] != 'pop') {
             $menu->addArray(array(
                 'icon' => 'search.png',
                 'text' =>_("_Search"),
@@ -392,7 +390,7 @@ class IMP_Application extends Horde_Registry_Application
         ));
 
         if ($new_session) {
-            $_SESSION['imp']['cache']['select_view'] = empty($credentials['imp_select_view'])
+            $GLOBALS['session']['imp:select_view'] = empty($credentials['imp_select_view'])
                 ? ''
                 : $credentials['imp_select_view'];
         }
@@ -586,7 +584,7 @@ class IMP_Application extends Horde_Registry_Application
             )
         );
 
-        if ($_SESSION['imp']['protocol'] == 'pop') {
+        if ($GLOBALS['session']['imp:protocol'] == 'pop') {
             return;
         }
 
index 74ea49a..edf0191 100644 (file)
@@ -58,7 +58,7 @@ class IMP_Auth
 
             /* _createSession() will create the imp session variable, so there
              * is no concern for an infinite loop here. */
-            if (!isset($_SESSION['imp'])) {
+            if (!isset($GLOBALS['session']['imp:server_key'])) {
                 self::_createSession($credentials);
                 return true;
             }
@@ -162,7 +162,7 @@ class IMP_Auth
             empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? '' : ' (forwarded for [' . $_SERVER['HTTP_X_FORWARDED_FOR'] . '])',
             $imap_ob ? $imap_ob->getParam('hostspec') : '',
             $imap_ob ? $imap_ob->getParam('port') : '',
-            empty($_SESSION['imp']['protocol']) ? '' : ' [' . $_SESSION['imp']['protocol'] . ']'
+            isset($GLOBALS['session:imp']['protocol']) ? ' [' . $GLOBALS['session']['imp:protocol'] . ']' : ''
         );
 
         Horde::logMessage($msg, $level);
@@ -172,28 +172,32 @@ class IMP_Auth
      * Set up the IMP session. Handle authentication, if required, and only do
      * enough work to see if the user can log in.
      *
-     * Creates the 'imp' session variable with the following entries:
+     * The following is the list of session variables in the imp namespace:
      * <pre>
-     * 'cache' - (array) Various IMP libraries can use this variable to cache
-     *           data.
-     * 'file_upload' - (integer) If file uploads are allowed, the max size.
-     * 'filteravail' - (boolean) Can we apply filters manually?
-     * 'imap' - (array) Config for various IMAP resources (acl, admin,
-     *          namespace, quota, thread)
-     * 'imap_ob' - (array) The serialized Horde_Imap_Client objects. Stored
-     *             by server key.
-     * 'maildomain' - (string) See config/backends.php.
-     * 'notepadavail' - (boolean) Is listing of notepads available?
-     * 'protocol' - (string) Either 'imap' or 'pop'.
-     * 'rteavail' - (boolean) Is the HTML editor available?
-     * 'search' - (string) The serialized IMP_Search object.
-     * 'server_key' - (string) Server used to login.
-     * 'smime' - (array) Settings related to the S/MIME viewer.
-     * 'smtp' - (array) SMTP options ('host' and 'port')
-     * 'showunsub' - (boolean) Show unsusubscribed mailboxes on the folders
-     *               screen.
-     * 'tasklistavail' - (boolean) Is listing of tasklists available?
-     * 'view' - (string) The imp view mode (dimp, imp, or mimp)
+     * compose_cache - (array) TODO
+     * file_upload - (integer) If file uploads are allowed, the max size.
+     * filteravail - (boolean) Can we apply filters manually?
+     * imap_acl - (boolean) TODO
+     * imap_admin - (array) TODO [params]
+     * imap_namespace - (array) TODO
+     * imap_ob/* - (Horde_Imap_Client_Base) The IMAP client objects. Stored by
+     *             server key.
+     * imap_quota - (array) TODO [driver, hide_when_unlimited, params]
+     * imap_thread - (string) TODO
+     * maildomain - (string) See config/backends.php.
+     * notepadavail - (boolean) Is listing of notepads available?
+     * pgp - (array) TODO
+     * protocol - (string) Either 'imap' or 'pop'.
+     * rteavail - (boolean) Is the HTML editor available?
+     * search - (IMP_Search) The IMP_Search object.
+     * select_view - (string) TODO
+     * server_key - (string) Server used to login.
+     * smime - (array) Settings related to the S/MIME viewer.
+     * smtp - (array) SMTP options ('host' and 'port')
+     * showunsub - (boolean) Show unsusubscribed mailboxes on the folders
+     *             screen.
+     * tasklistavail - (boolean) Is listing of tasklists available?
+     * view - (string) The imp view mode (dimp, imp, or mimp)
      * </pre>
      *
      * @param array $credentials  An array of login credentials.
@@ -207,15 +211,7 @@ class IMP_Auth
      */
     static protected function _createSession($credentials)
     {
-        global $conf;
-
-        /* Create the imp session variable. */
-        $_SESSION['imp'] = array(
-            'cache' => array(),
-            'imap' => array(),
-            'server_key' => $credentials['server'],
-            'showunsub' => false
-        );
+        $GLOBALS['session']['imp:server_key'] = $credentials['server'];
 
         /* Load the server configuration. */
         $ptr = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->loadServerConfig($credentials['server']);
@@ -231,7 +227,7 @@ class IMP_Auth
                 'userId' => $credentials['userId']
             ));
         } catch (Horde_Auth_Exception $e) {
-            unset($_SESSION['imp']);
+            unset($GLOBALS['session']['imp:']);
             throw $e;
         }
     }
@@ -333,7 +329,7 @@ class IMP_Auth
      */
     static public function getInitialPage($url = false)
     {
-        switch ($_SESSION['imp']['view']) {
+        switch ($GLOBALS['session']['imp:view']) {
         case 'dimp':
             $page = 'index-dimp.php';
             break;
@@ -343,7 +339,7 @@ class IMP_Auth
             break;
 
         default:
-            $init_url = ($_SESSION['imp']['protocol'] == 'pop')
+            $init_url = ($GLOBALS['session']['imp:protocol'] == 'pop')
                 ? 'INBOX'
                 : $GLOBALS['prefs']->getValue('initial_page');
 
@@ -381,98 +377,102 @@ class IMP_Auth
      */
     static public function authenticateCallback()
     {
-        global $conf;
-
-        $sess = &$_SESSION['imp'];
+        global $conf, $session;
 
         $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
-        $ptr = $imp_imap->loadServerConfig($sess['server_key']);
+        $ptr = $imp_imap->loadServerConfig($session['imp:server_key']);
         if ($ptr === false) {
             throw new Horde_Auth_Exception('', Horde_Auth::REASON_FAILED);
         }
 
         /* Set the protocol. */
-        $sess['protocol'] = isset($ptr['protocol'])
+        $session['imp:protocol'] = isset($ptr['protocol'])
             ? $ptr['protocol']
             : 'imap';
 
         /* Set the maildomain. */
         $maildomain = $GLOBALS['prefs']->getValue('mail_domain');
-        $sess['maildomain'] = $maildomain
+        $session['imp:maildomain'] = $maildomain
             ? $maildomain
             : $ptr['maildomain'];
 
         /* Store some basic IMAP server information. */
-        if ($sess['protocol'] == 'imap') {
+        if ($session['imp:protocol'] == 'imap') {
             foreach (array('acl', 'admin', 'namespace', 'quota') as $val) {
-                if (isset($ptr[$val])) {
-                    $sess['imap'][$val] = $ptr[$val];
+                if (!empty($ptr[$val])) {
+                    $tmp = $ptr[$val];
 
                     /* 'admin' and 'quota' have password entries - encrypt
                      * these entries in the session if they exist. */
                     foreach (array('password', 'admin_password') as $key) {
                         if (isset($ptr[$val]['params'][$key])) {
                             $secret = $GLOBALS['injector']->getInstance('Horde_Secret');
-                            $sess['imap'][$val]['params'][$key] = $secret->write($secret->getKey('imp'), $ptr[$val]['params'][$key]);
+                            $tmp['params'][$key] = $secret->write($secret->getKey('imp'), $ptr[$val]['params'][$key]);
                         }
                     }
+
+                    $session['imp:imap_' . $val] = $tmp;
                 }
             }
 
             /* Set the IMAP threading algorithm. */
-            $sess['imap']['thread'] = in_array(isset($ptr['thread']) ? strtoupper($ptr['thread']) : 'REFERENCES', $imp_imap->queryCapability('THREAD'))
+            $session['imp:imap_thread'] = in_array(isset($ptr['thread']) ? strtoupper($ptr['thread']) : 'REFERENCES', $imp_imap->queryCapability('THREAD'))
                 ? 'REFERENCES'
                 : 'ORDEREDSUBJECT';
         }
 
         /* Set the SMTP options, if needed. */
         if ($conf['mailer']['type'] == 'smtp') {
-            $sess['smtp'] = array();
+            $smtp = array();
             foreach (array('smtphost' => 'host', 'smtpport' => 'port') as $key => $val) {
                 if (!empty($ptr[$key])) {
-                    $sess['smtp'][$val] = $ptr[$key];
+                    $smtp[$val] = $ptr[$key];
                 }
             }
+
+            if (!empty($smtp)) {
+                $session['imp:smtp'] = $smtp;
+            }
         }
 
         /* Does the server allow file uploads? If yes, store the
          * value, in bytes, of the maximum file size. */
-        $sess['file_upload'] = $GLOBALS['browser']->allowFileUploads();
+        $session['imp:file_upload'] = $GLOBALS['browser']->allowFileUploads();
 
         /* Is the 'mail/canApplyFilters' API call available? */
         try {
             if ($GLOBALS['registry']->call('mail/canApplyFilters')) {
-                $sess['filteravail'] = true;
+                $session['imp:filteravail'] = true;
             }
         } catch (Horde_Exception $e) {}
 
         /* Is the 'tasks/listTasklists' call available? */
         if ($conf['tasklist']['use_tasklist'] &&
             $GLOBALS['registry']->hasMethod('tasks/listTasklists')) {
-            $sess['tasklistavail'] = true;
+            $session['imp:tasklistavail'] = true;
         }
 
         /* Is the 'notes/listNotepads' call available? */
         if ($conf['notepad']['use_notepad'] &&
             $GLOBALS['registry']->hasMethod('notes/listNotepads')) {
-            $sess['notepadavail'] = true;
+            $session['imp:notepadavail'] = true;
         }
 
         /* Is the HTML editor available? */
         $imp_ui = new IMP_Ui_Compose();
-        $sess['rteavail'] = $GLOBALS['injector']->getInstance('Horde_Editor')->supportedByBrowser();
+        $session['imp:rteavail'] = $GLOBALS['injector']->getInstance('Horde_Editor')->supportedByBrowser();
 
         /* Determine view. */
         $setcookie = false;
         if (empty($conf['user']['force_view'])) {
             if (empty($conf['user']['select_view']) ||
-                empty($sess['cache']['select_view'])) {
+                !$session['imp:select_view']) {
                 $view = $GLOBALS['browser']->isMobile()
                     ? 'mimp'
                     : ($GLOBALS['prefs']->getValue('dynamic_view') ? 'dimp' : 'imp');
             } else {
                 $setcookie = true;
-                $view = $sess['cache']['select_view'];
+                $view = $session['imp:select_view'];
             }
         } else {
             $view = $conf['user']['force_view'];
@@ -481,11 +481,12 @@ class IMP_Auth
         self::setViewMode($view);
 
         if ($setcookie) {
-            setcookie('default_imp_view', $sess['view'], time() + 30 * 86400, $conf['cookie']['path'], $conf['cookie']['domain']);
+            setcookie('default_imp_view', $session['imp:view'], time() + 30 * 86400, $conf['cookie']['path'], $conf['cookie']['domain']);
         }
 
         /* Indicate that notifications should use AJAX mode. */
-        if ($sess['view'] == 'dimp') {
+        if ($session['imp:view'] == 'dimp') {
+            // TODO
             $_SESSION['horde_notification']['override'] = array(
                 IMP_BASE . '/lib/Notification/Listener/AjaxStatus.php',
                 'IMP_Notification_Listener_AjaxStatus'
@@ -522,7 +523,7 @@ class IMP_Auth
             $GLOBALS['notification']->push(_("Your browser is too old to display the dynamic mode. Using traditional mode instead."), 'horde.warning');
         }
 
-        $_SESSION['imp']['view'] = $view;
+        $GLOBALS['session']['imp:view'] = $view;
     }
 
 }
index c5f10a1..91fd0b1 100644 (file)
@@ -39,7 +39,7 @@ class Horde_Block_imp_summary extends Horde_Block
     protected function _content()
     {
         $imp_ui = new IMP_Ui_Block();
-        list($html_out, $newmsgs) = $imp_ui->folderSummary($_SESSION['imp']['view']);
+        list($html_out, $newmsgs) = $imp_ui->folderSummary($GLOBALS['session']['imp:view']);
 
         $html = '<table cellspacing="0" width="100%">';
 
index 7791741..277561c 100644 (file)
@@ -193,7 +193,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
                 $addr = $headers[$k];
                 if ($session) {
                     try {
-                        Horde_Mime::encodeAddress(self::formatAddr($addr), $charset, $_SESSION['imp']['maildomain']);
+                        Horde_Mime::encodeAddress(self::formatAddr($addr), $charset, $GLOBALS['session']['imp:maildomain']);
                     } catch (Horde_Mime_Exception $e) {
                         throw new IMP_Compose_Exception(sprintf(_("Saving the draft failed. The %s header contains an invalid e-mail address: %s."), $k, $e->getMessage()), $e->getCode());
                     }
@@ -218,7 +218,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
             $imp_imap = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
             try {
                 $imap_url = $imp_imap->getUtils()->createUrl(array(
-                    'type' => $_SESSION['imp']['protocol'],
+                    'type' => $GLOBALS['session']['imp:protocol'],
                     'username' => $imp_imap->getParam('username'),
                     'hostspec' => $imp_imap->getParam('hostspec'),
                     'mailbox' => $this->getMetadata('mailbox'),
@@ -241,7 +241,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
         }
 
         return $base->toString(array(
-            'defserver' => $session ? $_SESSION['imp']['maildomain'] : null,
+            'defserver' => $session ? $GLOBALS['session']['imp:maildomain'] : null,
             'headers' => $draft_headers
         ));
     }
@@ -332,7 +332,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
             $reply_type = 'forward';
         }
 
-        if ($_SESSION['imp']['view'] == 'mimp') {
+        if ($GLOBALS['session']['imp:view'] == 'mimp') {
             $compose_html = false;
         } elseif ($prefs->getValue('compose_html')) {
             $compose_html = true;
@@ -403,7 +403,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
             $imap_url = $imp_imap->getUtils()->parseUrl(rtrim(ltrim($val, '<'), '>'));
 
             try {
-                if (($imap_url['type'] == $_SESSION['imp']['protocol']) &&
+                if (($imap_url['type'] == $GLOBALS['session']['imp:protocol']) &&
                     ($imap_url['username'] == $imp_imap->getParam('username')) &&
                     // Ignore hostspec and port, since these can change
                     // even though the server is the same. UIDVALIDITY should
@@ -491,7 +491,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
             }
         }
 
-        $barefrom = Horde_Mime_Address::bareAddress($header['from'], $_SESSION['imp']['maildomain']);
+        $barefrom = Horde_Mime_Address::bareAddress($header['from'], $GLOBALS['session']['imp:maildomain']);
         $encrypt = empty($opts['encrypt']) ? 0 : $opts['encrypt'];
         $recipients = implode(', ', $recip['list']);
 
@@ -669,7 +669,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
             }
 
             /* Generate the message string. */
-            $fcc = $mime_message->toString(array('defserver' => $_SESSION['imp']['maildomain'], 'headers' => $headers, 'stream' => true));
+            $fcc = $mime_message->toString(array('defserver' => $GLOBALS['session']['imp:maildomain'], 'headers' => $headers, 'stream' => true));
 
             $imp_folder = $GLOBALS['injector']->getInstance('IMP_Folder');
 
@@ -800,11 +800,11 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
 
         /* Properly encode the addresses we're sending to. */
         try {
-            $email = Horde_Mime::encodeAddress($email, is_null($message) ? 'UTF-8' : $message->getHeaderCharset(), $_SESSION['imp']['maildomain']);
+            $email = Horde_Mime::encodeAddress($email, is_null($message) ? 'UTF-8' : $message->getHeaderCharset(), $GLOBALS['session']['imp:maildomain']);
 
             /* Validate the recipient addresses. */
             Horde_Mime_Address::parseAddressList($email, array(
-                'defserver' => $_SESSION['imp']['maildomain'],
+                'defserver' => $GLOBALS['session']['imp:maildomain'],
                 'validate' => true
             ));
         } catch (Horde_Mime_Exception $e) {
@@ -835,7 +835,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
         }
 
         try {
-            $r_array = Horde_Mime::encodeAddress($recipients, 'UTF-8', $_SESSION['imp']['maildomain']);
+            $r_array = Horde_Mime::encodeAddress($recipients, 'UTF-8', $GLOBALS['session']['imp:maildomain']);
             $r_array = Horde_Mime_Address::parseAddressList($r_array, array('validate' => true));
         } catch (Horde_Mime_Exception $e) {}
 
@@ -988,7 +988,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
         // Make sure we have a valid host.
         $host = trim($ob['host']);
         if (empty($host)) {
-            $host = $_SESSION['imp']['maildomain'];
+            $host = $GLOBALS['session']['imp:maildomain'];
         }
 
         // Convert IDN hosts to ASCII.
@@ -1504,7 +1504,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
             $msg_post = '';
         }
 
-        if ($_SESSION['imp']['view'] == 'mimp') {
+        if ($GLOBALS['session']['imp:view'] == 'mimp') {
             $compose_html = false;
         } elseif (!empty($opts['format'])) {
             $compose_html = ($opts['format'] == 'html');
@@ -1660,7 +1660,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
             " -----\n" . $this->_getMsgHeaders($h) . "\n";
         $msg_post = "\n\n----- " . _("End forwarded message") . " -----\n";
 
-        if ($_SESSION['imp']['view'] == 'mimp') {
+        if ($GLOBALS['session']['imp:view'] == 'mimp') {
             $compose_html = false;
         } elseif (!empty($opts['format'])) {
             $compose_html = ($opts['format'] == 'html');
@@ -2220,7 +2220,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
      */
     public function maxAttachmentSize()
     {
-        $size = $_SESSION['imp']['file_upload'];
+        $size = $GLOBALS['session']['imp:file_upload'];
 
         if (!empty($GLOBALS['conf']['compose']['attach_size_limit'])) {
             return min($size, max($GLOBALS['conf']['compose']['attach_size_limit'] - $this->sizeOfAttachments(), 0));
@@ -2444,7 +2444,7 @@ class IMP_Compose implements ArrayAccess, Countable, Iterator
         $body_id = null;
         $mode = 'text';
 
-        if (!empty($options['html']) && $_SESSION['imp']['rteavail']) {
+        if (!empty($options['html']) && $GLOBALS['session']['imp:rteavail']) {
             $body_id = $contents->findBody('html');
             if (!is_null($body_id)) {
                 $mode = 'html';
index b014e1a..934d946 100644 (file)
@@ -394,12 +394,13 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
             $id = 'personal';
         }
 
-        if (!isset($_SESSION['imp']['cache']['pgp'][$type][$id])) {
+        if (!($cache = $GLOBALS['session']['imp:pgp']) ||
+            !isset($cache[$type][$id])) {
             return null;
         }
 
         $secret = $GLOBALS['injector']->getInstance('Horde_Secret');
-        return $secret->read($secret->getKey('imp'), $_SESSION['imp']['cache']['pgp'][$type][$id]);
+        return $secret->read($secret->getKey('imp'), $cache[$type][$id]);
     }
 
     /**
@@ -423,7 +424,11 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
         }
 
         $secret = $GLOBALS['injector']->getInstance('Horde_Secret');
-        $_SESSION['imp']['cache']['pgp'][$type][$id] = $secret->write($secret->getKey('imp'), $passphrase);
+
+        $cache = $GLOBALS['session']['imp:pgp;array'];
+        $cache[$type][$id] = $secret->write($secret->getKey('imp'), $passphrase);
+        $GLOBALS['session']['imp:pgp'] = $cache;
+
         return true;
     }
 
@@ -438,10 +443,13 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
      */
     public function unsetPassphrase($type, $id = null)
     {
-        if (($type == 'symmetric') && !is_null($id)) {
-            unset($_SESSION['imp']['cache']['pgp']['symmetric'][$id]);
-        } else {
-            unset($_SESSION['imp']['cache']['pgp'][$type]);
+        if ($cache = $GLOBALS['session']['imp:pgp']) {
+            if (($type == 'symmetric') && !is_null($id)) {
+                unset($cache['symmetric'][$id]);
+            } else {
+                unset($cache[$type]);
+            }
+            $GLOBALS['session']['imp:pgp'] = $cache;
         }
     }
 
@@ -516,7 +524,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp
         $addr_list = array();
 
         foreach ($addresses as $val) {
-            $addrOb = Horde_Mime_Address::bareAddress($val, $_SESSION['imp']['maildomain'], true);
+            $addrOb = Horde_Mime_Address::bareAddress($val, $GLOBALS['session']['imp:maildomain'], true);
             $key_addr = array_pop($addrOb);
 
             /* Get the public key for the address. */
index 9442340..1e4d339 100644 (file)
@@ -134,7 +134,7 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
     protected function _encryptParameters($address)
     {
         /* We can only encrypt if we are sending to a single person. */
-        $addrOb = Horde_Mime_Address::bareAddress($address, $_SESSION['imp']['maildomain'], true);
+        $addrOb = Horde_Mime_Address::bareAddress($address, $GLOBALS['session']['imp:maildomain'], true);
         $key_addr = array_pop($addrOb);
 
         $public_key = $this->getPublicKey($key_addr);
@@ -265,24 +265,23 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
      */
     public function getPassphrase()
     {
+        global $session;
+
         $private_key = $GLOBALS['prefs']->getValue('smime_private_key');
         if (empty($private_key)) {
             return false;
         }
 
-        if (isset($_SESSION['imp']['smime']['passphrase'])) {
+        if (isset($session['imp:smime_passphrase'])) {
             $secret = $GLOBALS['injector']->getInstance('Horde_Secret');
-            return $secret->read($secret->getKey('imp'), $_SESSION['imp']['smime']['passphrase']);
-        } elseif (isset($_SESSION['imp']['smime']['null_passphrase'])) {
-            return ($_SESSION['imp']['smime']['null_passphrase']) ? null : false;
-        } else {
-            $result = $this->verifyPassphrase($private_key, null);
-            if (!isset($_SESSION['imp']['smime'])) {
-                $_SESSION['imp']['smime'] = array();
-            }
-            $_SESSION['imp']['smime']['null_passphrase'] = ($result) ? null : false;
-            return $_SESSION['imp']['smime']['null_passphrase'];
+            return $secret->read($secret->getKey('imp'), $session['imp:smime_passphrase']);
+        } elseif (!isset($session['imp:smime_null_passphrase'])) {
+            $session['imp:smime_null_passphrase'] = ($this->verifyPassphrase($private_key, null)
+                ? null
+                : false;
         }
+
+        return $session['imp:smime_null_passphrase'];
     }
 
     /**
@@ -298,12 +297,8 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
             return false;
         }
 
-        if (!isset($_SESSION['imp']['smime'])) {
-            $_SESSION['imp']['smime'] = array();
-        }
-
         $secret = $GLOBALS['injector']->getInstance('Horde_Secret');
-        $_SESSION['imp']['smime']['passphrase'] = $secret->write($secret->getKey('imp'), $passphrase);
+        $GLOBALS['session']['imp:smime_passphrase'] = $secret->write($secret->getKey('imp'), $passphrase);
 
         return true;
     }
@@ -313,7 +308,9 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime
      */
     public function unsetPassphrase()
     {
-        unset($_SESSION['imp']['smime']['null_passphrase'], $_SESSION['imp']['smime']['passphrase']);
+        global $session;
+
+        unset($session['imp:smime_null_passphrase'], $session['imp:smime_passphrase']);
     }
 
     /**
index 2e06206..5ac137c 100644 (file)
@@ -33,7 +33,7 @@ class IMP_Filter
      */
     public function filter($mbox)
     {
-        if (empty($_SESSION['imp']['filteravail'])) {
+        if (!$GLOBALS['session']['imp:filteravail']) {
             return;
         }
 
index 70765bf..f6d4e29 100644 (file)
@@ -89,8 +89,8 @@ class IMP
      */
     static public function getViewMode()
     {
-        return isset($_SESSION['imp']['view'])
-            ? $_SESSION['imp']['view']
+        return ($view = $GLOBALS['session']['imp:view'])
+            ? $view
             : 'imp';
     }
 
@@ -426,7 +426,7 @@ class IMP
     {
         $t = $GLOBALS['injector']->createInstance('Horde_Template');
         $t->set('forminput', Horde_Util::formInput());
-        $t->set('use_folders', ($_SESSION['imp']['protocol'] != 'pop') && $GLOBALS['conf']['user']['allow_folders'], true);
+        $t->set('use_folders', ($GLOBALS['session']['imp:protocol'] != 'pop') && $GLOBALS['conf']['user']['allow_folders'], true);
         if ($t->get('use_folders')) {
             Horde::addScriptFile('imp.js', 'imp');
             $menu_view = $GLOBALS['prefs']->getValue('menu_view');
@@ -480,8 +480,7 @@ class IMP
      */
     static public function quotaData($long = true)
     {
-        if (!isset($_SESSION['imp']['imap']['quota']) ||
-            !is_array($_SESSION['imp']['imap']['quota'])) {
+        if (!$GLOBALS['session']['imp:imap_quota']) {
             return false;
         }
 
@@ -519,7 +518,7 @@ class IMP
             $ret['percent'] = sprintf("%.2f", $ret['percent']);
         } else {
             // Hide unlimited quota message?
-            if (!empty($_SESSION['imp']['quota']['hide_when_unlimited'])) {
+            if ($GLOBALS['session']['imp:quota_hide_when_unlimited']) {
                 return false;
             }
 
@@ -757,7 +756,7 @@ class IMP
         /* Restrict POP3 sorting to sequence only.  Although possible to
          * abstract other sorting methods, all other methods require a
          * download of all messages, which is too much overhead.*/
-        if ($_SESSION['imp']['protocol'] == 'pop') {
+        if ($GLOBALS['session']['imp:protocol'] == 'pop') {
             $ob['by'] = Horde_Imap_Client::SORT_SEQUENCE;
             return $ob;
         }
@@ -810,7 +809,7 @@ class IMP
          * Horde_Imap_Client_Socket has a built-in ORDEREDSUBJECT
          * implementation. We will always prefer REFERENCES, but will fallback
          * to ORDEREDSUBJECT if the server doesn't support THREAD sorting. */
-        return (($_SESSION['imp']['protocol'] == 'imap') &&
+        return (($GLOBALS['session']['imp:protocol'] == 'imap') &&
                 !$GLOBALS['injector']->getInstance('IMP_Search')->isSearchMbox($mbox));
     }
 
@@ -973,7 +972,7 @@ class IMP
             $t->set('folders', $folders);
 
             $imp_search = $GLOBALS['injector']->getInstance('IMP_Search');
-            if (($_SESSION['imp']['protocol'] != 'pop') &&
+            if (($GLOBALS['session']['imp:protocol'] != 'pop') &&
                 ($vinbox = $imp_search['vinbox']) &&
                 $vinbox->enabled) {
                 $t->set('vinbox', self::generateIMPUrl('mailbox.php', strval($vinbox))->link());
index 93886ff..4505122 100644 (file)
@@ -73,8 +73,8 @@ class IMP_Imap
     public function shutdown()
     {
         /* Only need to serialize object once a session. */
-        if ($this->ob && isset($_SESSION['imp'])) {
-            $_SESSION['imp']['imap_ob'][$this->_serverkey] = serialize($this->ob);
+        if ($this->ob) {
+            $GLOBALS['session']['imp:imap_ob/' . $this->_serverkey] = $this->ob;
         }
     }
 
@@ -86,24 +86,23 @@ class IMP_Imap
      */
     protected function _loadImapObject()
     {
+        global $session;
+
         if (!is_null($this->ob)) {
             return true;
         }
 
-        if (empty($_SESSION['imp']) ||
-            empty($_SESSION['imp']['imap_ob'][$this->_serverkey])) {
-            return false;
-        }
-
         try {
-            $this->ob = @unserialize($_SESSION['imp']['imap_ob'][$this->_serverkey]);
+            if (!($this->ob = $GLOBALS['session']['imp:imap_ob/' . $this->_serverkey])) {
+                return false;
+            }
         } catch (Exception $e) {
             /* Throw fatal error here - should never reach here and if we
              * do, we are out of luck. */
             throw new IMP_Exception(_("Could not acquire mail server credentials from the session."));
         }
 
-        $this->_postcreate($_SESSION['imp']['protocol']);
+        $this->_postcreate($session['imp:protocol']);
 
         return true;
     }
@@ -238,7 +237,7 @@ class IMP_Imap
             /* This check can only be done for regular IMAP mailboxes. */
             // TODO: POP3 also?
             if (!$res &&
-                ($_SESSION['imp']['protocol'] == 'imap') &&
+                ($GLOBALS['session']['imp:protocol'] == 'imap') &&
                 !$GLOBALS['injector']->getInstance('IMP_Search')->isSearchMbox($mailbox)) {
                 try {
                     $status = $this->ob->status($mailbox, Horde_Imap_Client::STATUS_UIDNOTSTICKY);
@@ -263,18 +262,19 @@ class IMP_Imap
      */
     public function checkUidvalidity($mailbox)
     {
+        global $session;
+
         // TODO: POP3 also?
-        if ($_SESSION['imp']['protocol'] == 'pop') {
+        if ($session['imp:protocol'] == 'pop') {
             return;
         }
 
         if (!isset($this->_uidvalid[$mailbox])) {
             $status = $this->ob->status($mailbox, Horde_Imap_Client::STATUS_UIDVALIDITY);
-            $ptr = &$_SESSION['imp']['cache'];
-            $val = isset($ptr['uidvalid'][$mailbox])
-                ? $ptr['uidvalid'][$mailbox]
+            $val = isset($session['imp:uidvalid/' . $mailbox])
+                ? $session['imp:uidvalid/' . $mailbox]
                 : null;
-            $ptr['uidvalid'][$mailbox] = $status['uidvalidity'];
+            $session['imp:uidvalid/' . $mailbox] = $status['uidvalidity'];
 
             $this->_uidvalid[$mailbox] = (!is_null($val) && ($status['uidvalidity'] != $val));
         }
@@ -283,7 +283,7 @@ class IMP_Imap
             throw new IMP_Exception(_("Mailbox structure on server has changed."));
         }
 
-        return $_SESSION['imp']['cache']['uidvalid'][$mailbox];
+        return $session['imp:uidvalid/' . $mailbox];
     }
 
     /**
@@ -294,7 +294,7 @@ class IMP_Imap
     public function getNamespaceList()
     {
         try {
-            return $this->ob->getNamespaces(!empty($_SESSION['imp']['imap']['namespace']) ? $_SESSION['imp']['imap']['namespace'] : array());
+            return $this->ob->getNamespaces($GLOBALS['session']['imp:imap_namespace;array']);
         } catch (Horde_Imap_Client_Exception $e) {
             // @todo Error handling
             return array();
@@ -313,7 +313,7 @@ class IMP_Imap
      */
     public function getNamespace($mailbox = null, $personal = false)
     {
-        if ($_SESSION['imp']['protocol'] == 'pop') {
+        if ($GLOBALS['session']['imp:protocol'] == 'pop') {
             return null;
         }
 
@@ -343,7 +343,7 @@ class IMP_Imap
      */
     public function defaultNamespace()
     {
-        if ($_SESSION['imp']['protocol'] == 'pop') {
+        if ($GLOBALS['session']['imp:protocol'] == 'pop') {
             return null;
         }
 
index 8a3da2f..9664510 100644 (file)
@@ -37,11 +37,11 @@ class IMP_Imap_Acl
      */
     public function __construct()
     {
-        if ($_SESSION['imp']['protocol'] != 'imap') {
+        if ($GLOBALS['session']['imp:protocol'] != 'imap') {
             throw new IMP_Exception(_("ACL requires an IMAP server."));
         }
 
-        if (empty($_SESSION['imp']['imap']['acl'])) {
+        if (!$GLOBALS['session']['imp:imap_acl']) {
             throw new IMP_Exception(_("ACLs not configured for this server."));
         }
 
index d80fe42..c957560 100644 (file)
@@ -329,7 +329,7 @@ class IMP_Imap_Flags
             }
         }
 
-        if ($_SESSION['imp']['protocol'] == 'imap') {
+        if ($GLOBALS['session']['imp:protocol'] == 'imap') {
             $flaglist = empty($options['flags'])
                 ? array()
                 : array_map('strtolower', $options['flags']);
index 858d622..237b2ac 100644 (file)
@@ -164,7 +164,7 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
      */
     public function __construct()
     {
-        if ($_SESSION['imp']['protocol'] == 'imap') {
+        if ($GLOBALS['session']['imp:protocol'] == 'imap') {
             $ns = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->getNamespaceList();
             $ptr = reset($ns);
             $this->_delimiter = $ptr['delimiter'];
@@ -181,9 +181,11 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
      */
     public function init()
     {
-        $unsubmode = (($_SESSION['imp']['protocol'] == 'pop') ||
-                      !$GLOBALS['prefs']->getValue('subscribe') ||
-                      $_SESSION['imp']['showunsub']);
+        global $conf, $injector, $prefs, $session;
+
+        $unsubmode = (($session['imp:protocol'] == 'pop') ||
+                      !$prefs->getValue('subscribe') ||
+                      $session['imp:showunsub']);
 
         /* Reset class variables to the defaults. */
         $this->changed = true;
@@ -201,16 +203,15 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
 
         /* 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')) {
+        if (empty($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')) {
+            if (($val['type'] != 'personal') && $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
@@ -235,7 +236,7 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
         $this->_insert($this->_getList($this->_showunsub), $this->_showunsub ? null : true);
 
         /* Add virtual folders to the tree. */
-        $imp_search = $GLOBALS['injector']->getInstance('IMP_Search');
+        $imp_search = $injector->getInstance('IMP_Search');
         $imp_search->setIteratorFilter(IMP_Search::LIST_VFOLDER);
         $this->updateVFolders(iterator_to_array($imp_search));
     }
@@ -334,7 +335,7 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable
             ? $label
             : substr($label, $pos + 1);
 
-        if ($_SESSION['imp']['protocol'] != 'pop') {
+        if ($GLOBALS['session']['imp:protocol'] != 'pop') {
             try {
                 $this->_setInvisible($elt, !Horde::callHook('display_folder', array($elt['v']), 'imp'));
             } catch (Horde_Exception_HookNotSet $e) {}
index 059e94d..0554cdd 100644 (file)
@@ -40,9 +40,11 @@ class IMP_Injector_Factory_AuthImap
             throw new IMP_Exception('No server parameters found.');
         }
 
+        $aparams = $GLOBALS['session']['imp:imap_admin;array'];
+
         $params = array_merge(
             $params,
-            $_SESSION['imp']['imap']['admin']['params'],
+            (isset($aparams['params']) ? $aparams['params'] : array()),
             array(
                 'default_user' => $GLOBALS['registry']->getAuth(),
                 'logger' => $injector->getInstance('Horde_Log_Logger')
index 53fedae..2bf01a8 100644 (file)
@@ -82,6 +82,8 @@ class IMP_Injector_Factory_Compose
      */
     public function shutdown()
     {
+        $cache = $GLOBALS['session']['imp:compose_cache:array'];
+        $changed = false;
         $obs = $this->_injector->getInstance('Horde_SessionObjects');
 
         foreach ($this->_instances as $key => $val) {
@@ -89,15 +91,21 @@ class IMP_Injector_Factory_Compose
             case 'changed':
                 $val->changed = '';
                 $obs->overwrite($key, $val, false);
-
-                $_SESSION['imp']['cache']['compose'][$key] = 1;
+                $cache[$key] = 1;
+                $changed = true;
                 break;
 
             case 'deleted':
                 $obs->prune($key);
-                unset($_SESSION['imp']['cache']['compose'][$key]);
+                unset($cache[$key]);
+                $changed = true;
                 break;
             }
+
+        }
+
+        if ($changed) {
+            $GLOBALS['session']['imp:compose_cache'] = $cache;
         }
     }
 
index a8b9de9..6461294 100644 (file)
@@ -44,10 +44,8 @@ class IMP_Injector_Factory_Imap
      */
     public function create($id = null)
     {
-        if (is_null($id)) {
-            $id = isset($_SESSION['imp'])
-                ? $_SESSION['imp']['server_key']
-                : 'default';
+        if (is_null($id) && !($id = $GLOBALS['session']['imp:server_key'])) {
+            $id = 'default';
         }
 
         if (!isset($this->_instances[$id])) {
index 7a8535e..e4f6bfb 100644 (file)
@@ -34,13 +34,13 @@ class IMP_Injector_Factory_Imaptree
      */
     public function create(Horde_Injector $injector)
     {
+        global $session;
+
         $instance = null;
 
         /* If an IMP_Imap_Tree object is currently stored in the cache,
          * re-create that object.  Else, create a new instance. */
-        if (empty($_SESSION['imp']['cache']['tree'])) {
-            $_SESSION['imp']['cache']['tree'] = strval(new Horde_Support_Randomid());
-        } else {
+        if (isset($session['imp:tree'])) {
             /* Since IMAP tree generation is so expensive/time-consuming,
              * fallback to storing in the session even if no permanent cache
              * backend is setup. */
@@ -48,11 +48,14 @@ class IMP_Injector_Factory_Imaptree
             if ($cache instanceof Horde_Cache_Null) {
                 $cache = $injector->getInstance('Horde_Cache_Session');
             }
+
             try {
-                $instance = @unserialize($cache->get($_SESSION['imp']['cache']['tree'], 86400));
+                $instance = @unserialize($cache->get($session['imp:tree'], 86400));
             } catch (Exception $e) {
                 Horde::logMessage('Could not unserialize stored IMP_Imap_Tree object.', 'DEBUG');
             }
+        } else {
+            $session['imp:tree'] = strval(new Horde_Support_Randomid());
         }
 
         if (!($instance instanceof IMP_Imap_Tree)) {
@@ -78,7 +81,7 @@ class IMP_Injector_Factory_Imaptree
             if ($cache instanceof Horde_Cache_Null) {
                 $cache = $injector->getInstance('Horde_Cache_Session');
             }
-            $cache->set($_SESSION['imp']['cache']['tree'], serialize($instance), 86400);
+            $cache->set($GLOBALS['session']['imp:tree'], serialize($instance), 86400);
         }
     }
 
index ad8ff2c..96fd7ff 100644 (file)
@@ -42,9 +42,7 @@ class IMP_Injector_Factory_Mail
 
         /* Force the SMTP host and port value to the current SMTP server if
          * one has been selected for this connection. */
-        if (!empty($_SESSION['imp']['smtp'])) {
-            $params = array_merge($params, $_SESSION['imp']['smtp']);
-        }
+        $params = array_merge($params, $GLOBALS['session']['imp:smtp;array']);
 
         /* If SMTP authentication has been requested, use either the username
          * and password provided in the configuration or populate the username
index 62abbf8..c0d7b0f 100644 (file)
@@ -67,14 +67,13 @@ class IMP_Injector_Factory_MailboxList
 
             case 'imp':
             case 'mimp':
-                $ob = null;
-                if (isset($_SESSION['imp']['cache']['imp_mailbox'][$mailbox])) {
-                    try {
-                        $ob = @unserialize($_SESSION['imp']['cache']['imp_mailbox'][$mailbox]);
-                    } catch (Exception $e) {}
+                try {
+                    $ob = $GLOBALS['session']['imp:imp_mailbox/' . $mailbox];
+                } catch (Exception $e) {
+                    $ob = null;
                 }
 
-                if (!$ob) {
+                if (is_null($ob)) {
                     $ob = new IMP_Mailbox_List_Track($mailbox);
                 }
                 break;
@@ -108,7 +107,7 @@ class IMP_Injector_Factory_MailboxList
              * unseen flag). */
             foreach ($this->_instances as $key => $val) {
                 if ($val->changed) {
-                    $_SESSION['imp']['cache']['imp_mailbox'][$key] = serialize($val);
+                    $GLOBALS['session']['imp:imp_mailbox/' . $key] = $val;
                 }
             }
         }
index 29d85ec..bdd8a69 100644 (file)
@@ -31,12 +31,18 @@ class IMP_Injector_Factory_Quota
      * Return the IMP_Quota instance.
      *
      * @return IMP_Quota  The singleton instance.
+     * @throws IMP_Exception
      */
     public function create(Horde_Injector $injector)
     {
-        $driver = $_SESSION['imp']['imap']['quota']['driver'];
-        $params = isset($_SESSION['imp']['imap']['quota']['params'])
-            ? $_SESSION['imp']['imap']['quota']['params']
+        $qparams = $GLOBALS['session']['imp:imap_quota'];
+
+        if (!isset($qparams['driver'])) {
+            throw new IMP_Exception('Quota config missing driver parameter.');
+        }
+        $driver = $qparams['driver'];
+        $params = isset($qparams['params'])
+            ? $qparams['params']
             : array();
 
         /* If 'password' exists in params, it has been encrypted in the
@@ -46,9 +52,11 @@ class IMP_Injector_Factory_Quota
             $params['password'] = $secret->read($secret->getKey('imp'), $params['password']);
         }
 
+        $imap_ob = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+
         switch (Horde_String::lower($driver)) {
         case 'imap':
-            $params['imap_ob'] = $injector->getInstance('IMP_Injector_Factory_Imap')->create();
+            $params['imap_ob'] = $imap_ob;
             $params['mbox'] = $injector->getInstance('IMP_Search')->isSearchMbox(IMP::$mailbox)
                 ? 'INBOX'
                 : IMP::$mailbox;
@@ -59,7 +67,7 @@ class IMP_Injector_Factory_Quota
             break;
         }
 
-        $params['username'] = $injector->getInstance('IMP_Injector_Factory_Imap')->create()->getParam('username');
+        $params['username'] = $imap_ob->getParam('username');
 
         return IMP_Quota::factory($driver, $params);
     }
index 7240948..363ea9b 100644 (file)
@@ -34,21 +34,18 @@ class IMP_Injector_Factory_Search
      */
     public function create(Horde_Injector $injector)
     {
-        $instance = null;
-
-        if (!empty($_SESSION['imp']['search'])) {
-            try {
-                $instance = @unserialize($_SESSION['imp']['search']);
-            } catch (Exception $e) {
-                Horde::logMessage('Could not unserialize stored IMP_Search object.', 'DEBUG');
-            }
+        try {
+            $instance = $GLOBALS['session']['imp:search'];
+        } catch (Exception $e) {
+            Horde::logMessage('Could not unserialize stored IMP_Search object.', 'DEBUG');
+            $instance = null;
         }
 
         if (is_null($instance)) {
             $instance = new IMP_Search();
         }
 
-        register_shutdown_function(array($this, 'shutdown'), $instance, $injector);
+        register_shutdown_function(array($this, 'shutdown'), $instance);
 
         return $instance;
     }
@@ -56,14 +53,13 @@ class IMP_Injector_Factory_Search
     /**
      * Store serialized version of object in the current session.
      *
-     * @param IMP_Search $instance      Tree object.
-     * @param Horde_Injector $injector  Injector object.
+     * @param IMP_Search $instance  Search object.
      */
-    public function shutdown($instance, $injector)
+    public function shutdown($instance)
     {
         /* Only need to store the object if the object has changed. */
         if ($instance->changed) {
-            $_SESSION['imp']['search'] = serialize($instance);
+            $GLOBALS['session']['imp:search'] = $instance;
         }
     }
 
index f93ff29..8520258 100644 (file)
@@ -271,7 +271,7 @@ class IMP_Mailbox_List implements Countable, Serializable
                 $threadob = $this->getThreadOb();
                 $this->_sorted = $threadob->messageList((bool)$sortpref['dir']);
             } else {
-                if (($_SESSION['imp']['protocol'] != 'pop') &&
+                if (($GLOBALS['session']['imp:protocol'] != 'pop') &&
                     IMP::hideDeletedMsgs($this->_mailbox)) {
                     $query = new Horde_Imap_Client_Search_Query();
                     $query->flag('\\deleted', false);
@@ -410,8 +410,8 @@ class IMP_Mailbox_List implements Countable, Serializable
                     $page = ceil($start / $page_size);
                 } else {
                     /* Search for the last visited page first. */
-                    if (isset($_SESSION['imp']['cache']['mbox_page'][$this->_mailbox])) {
-                        $page = $_SESSION['imp']['cache']['mbox_page'][$this->_mailbox];
+                    if (isset($GLOBALS['session']['imp:mbox_page/' . $this->_mailbox])) {
+                        $page = $GLOBALS['session']['imp:mbox_page/' . $this->_mailbox];
                     } elseif ($this->_searchmbox) {
                         $page = 1;
                     } else {
@@ -456,7 +456,7 @@ class IMP_Mailbox_List implements Countable, Serializable
         }
 
         /* Store the page value now. */
-        $_SESSION['imp']['cache']['mbox_page'][$this->_mailbox] = $ret['page'];
+        $GLOBALS['session']['imp:mbox_page/' . $this->_mailbox] = $ret['page'];
 
         return $ret;
     }
@@ -521,7 +521,7 @@ class IMP_Mailbox_List implements Countable, Serializable
     {
         if (is_null($this->_threadob)) {
             try {
-                $this->_threadob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->thread($this->_mailbox, array('criteria' => $_SESSION['imp']['imap']['thread']));
+                $this->_threadob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create()->thread($this->_mailbox, array('criteria' => $GLOBALS['session']['imp:imap_thread']));
             } catch (Horde_Imap_Client_Exception $e) {
                 $GLOBALS['notification']->push($e);
                 return new Horde_Imap_Client_Thread(array(), 'uid');
index 73ead06..49d733e 100644 (file)
@@ -32,7 +32,7 @@ class IMP_Message
      */
     public function __construct()
     {
-        if ($_SESSION['imp']['protocol'] == 'pop') {
+        if ($GLOBALS['session']['imp:protocol'] == 'pop') {
             $this->_usepop = true;
         }
     }
index e6f3273..9be8de0 100644 (file)
@@ -78,7 +78,7 @@ class IMP_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
         $data = $this->_IMPrender(true);
 
         /* Catch case where using mimp on a javascript browser. */
-        if ($_SESSION['imp']['view'] != 'mimp') {
+        if ($GLOBALS['session']['imp:view'] != 'mimp') {
             $uid = strval(new Horde_Support_Randomid());
 
             Horde::addScriptFile('imp.js', 'imp');
@@ -136,7 +136,7 @@ class IMP_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
 
         /* Don't do IMP DOM processing if in mimp mode or converting to
          * text. */
-        if (($_SESSION['imp']['view'] == 'mimp') ||
+        if (($GLOBALS['session']['imp:view'] == 'mimp') ||
             (!$inline && Horde_Util::getFormData('convert_text'))) {
             $this->_imptmp = null;
         } else {
@@ -173,7 +173,7 @@ class IMP_Mime_Viewer_Html extends Horde_Mime_Viewer_Html
 
         /* Sanitize the HTML. */
         $data = $this->_cleanHTML($data, array(
-            'noprefetch' => ($inline && ($_SESSION['imp']['view'] != 'mimp')),
+            'noprefetch' => ($inline && ($GLOBALS['session']['imp:view'] != 'mimp')),
             'phishing' => $inline
         ));
 
index 2d65d39..40d1880 100644 (file)
@@ -419,7 +419,7 @@ class IMP_Mime_Viewer_Itip extends Horde_Mime_Viewer_Base
         }
 
         // Create the HTML to display the iCal file.
-        if ($_SESSION['imp']['view'] != 'imp' && !$full) {
+        if (!$full && ($GLOBALS['session']['imp:view'] != 'imp')) {
             $url = $this->getConfigParam('imp_contents')->urlView($this->_mimepart, 'view_attach', array('params' => array('ajax' => 1, 'mode' => IMP_Contents::RENDER_INLINE)));
             $onsubmit = ' onsubmit="DimpCore.submitForm(\'impMimeViewerItip\');return false"';
         } else {
index 25bb9e6..a459cd4 100644 (file)
@@ -394,7 +394,7 @@ class IMP_Mime_Viewer_Pgp extends Horde_Mime_Viewer_Base
                 ? 'mimePartWrapValid'
                 : 'mimePartWrapInvalid';
         } else {
-            switch ($_SESSION['imp']['view']) {
+            switch ($GLOBALS['session']['imp:view']) {
             case 'imp':
                 $status[] = Horde::link(IMP::selfUrl()->add(array('pgp_verify_msg' => 1))) . _("Click HERE to verify the message.") . '</a>';
                 break;
index e8a6440..a105869 100644 (file)
@@ -98,7 +98,7 @@ class IMP_Mime_Viewer_Plain extends Horde_Mime_Viewer_Plain
         $text = IMP::filterText($text);
 
         /* Done processing if in mimp mode. */
-        if ($_SESSION['imp']['view'] == 'mimp') {
+        if ($GLOBALS['session']['imp:view'] == 'mimp') {
             return array(
                 $mime_id => array(
                     'data' => $text,
index 905f9c4..b63310e 100644 (file)
@@ -310,7 +310,7 @@ class IMP_Mime_Viewer_Smime extends Horde_Mime_Viewer_Base
                 $status[] = $e->getMessage();
             }
         } else {
-            switch ($_SESSION['imp']['view']) {
+            switch ($GLOBALS['session']['imp:view']) {
             case 'imp':
                 $status[] = Horde::link(IMP::selfUrl()->add('smime_verify_msg', 1)) . _("Click HERE to verify the data.") . '</a>';
                 break;
index cc1da4d..1d47281 100644 (file)
@@ -127,7 +127,7 @@ class Imp_Prefs_Identity extends Horde_Core_Prefs_Identity
         }
 
         try {
-            $ob = Horde_Mime_Address::parseAddressList($address, array('defserver' => $_SESSION['imp']['maildomain']));
+            $ob = Horde_Mime_Address::parseAddressList($address, array('defserver' => $GLOBALS['session']['imp:maildomain']));
         } catch (Horde_Mime_Exception $e) {
             throw new Horde_Exception (_("Your From address is not a valid email address. This can be fixed in your Personal Information preferences page."));
         }
@@ -207,7 +207,7 @@ class Imp_Prefs_Identity extends Horde_Core_Prefs_Identity
             }
 
             if (!strstr($val, '@')) {
-                $val .= '@' . $_SESSION['imp']['maildomain'];
+                $val .= '@' . $GLOBALS['session']['imp:maildomain'];
             }
 
             $this->_cached['fromList'][$ident] = $val;
index 99ee3e3..c112019 100644 (file)
@@ -51,8 +51,7 @@ class IMP_Prefs_Ui
             break;
 
         case 'delmove':
-            if (isset($_SESSION['imp']['protocol']) &&
-                ($_SESSION['imp']['protocol'] == 'pop')) {
+            if ($GLOBALS['session']['imp:protocol'] == 'pop') {
                 $tmp = $ui->prefs['delete_spam_after_report']['enum'];
                 unset($tmp[2]);
                 $ui->override['delete_spam_after_report'] = $tmp;
@@ -68,9 +67,9 @@ class IMP_Prefs_Ui
      */
     public function prefsInit($ui)
     {
-        global $conf, $prefs, $registry;
+        global $conf, $prefs, $registry, $session;
 
-        $pop3 = (isset($_SESSION['imp']['protocol']) && ($_SESSION['imp']['protocol'] == 'pop'));
+        $pop3 = ($session['imp:protocol'] == 'pop');
 
         switch ($ui->group) {
         case 'accounts':
@@ -148,7 +147,7 @@ class IMP_Prefs_Ui
             break;
 
         case 'filters':
-            if (empty($_SESSION['imp']['filteravail'])) {
+            if (!$session['imp:filteravail']) {
                 $ui->suppress[] = 'filter_on_login';
                 $ui->suppress[] = 'filter_on_display';
                 $ui->suppress[] = 'filter_any_mailbox';
@@ -182,7 +181,7 @@ class IMP_Prefs_Ui
             }
 
             if ($prefs->isLocked('signature_html') ||
-                empty($_SESSION['imp']['rteavail'])) {
+                !$session['imp:rteavail']) {
                 $ui->suppress[] = 'signature_html_select';
             } else {
                 Horde::addScriptFile('signaturehtml.js', 'imp');
@@ -527,14 +526,14 @@ class IMP_Prefs_Ui
      */
     public function prefsCallback($ui)
     {
-        global $prefs;
+        global $notification, $prefs, $registry, $session;
 
         /* Always check to make sure we have a valid trash folder if delete to
          * trash is active. */
         if (($prefs->isDirty('use_trash') || $prefs->isDirty('trash_folder')) &&
             $prefs->getValue('use_trash') &&
             !$prefs->getValue('trash_folder')) {
-            $GLOBALS['notification']->push(_("You have activated move to Trash but no Trash folder is defined. You will be unable to delete messages until you set a Trash folder in the preferences."), 'horde.warning');
+            $notification->push(_("You have activated move to Trash but no Trash folder is defined. You will be unable to delete messages until you set a Trash folder in the preferences."), 'horde.warning');
         }
 
         switch ($ui->group) {
@@ -543,7 +542,7 @@ class IMP_Prefs_Ui
                 $maildomain = preg_replace('/[^-\.a-z0-9]/i', '', $prefs->getValue('mail_domain'));
                 $prefs->setValue('maildomain', $maildomain);
                 if (!empty($maildomain)) {
-                    $_SESSION['imp']['maildomain'] = $maildomain;
+                    $session['imp:maildomain'] = $maildomain;
                 }
             }
             break;
@@ -556,7 +555,7 @@ class IMP_Prefs_Ui
 
         case 'dimp':
             if ($prefs->isDirty('dynamic_view')) {
-                $_SESSION['imp']['view'] = $prefs->getValue('dynamic_view')
+                $session['imp:view'] = $prefs->getValue('dynamic_view')
                     ? 'dimp'
                     : ($GLOBALS['browser']->isMobile() ? 'mimp' : 'imp');
             }
@@ -564,13 +563,13 @@ class IMP_Prefs_Ui
 
         case 'display':
             if ($prefs->isDirty('tree_view')) {
-                $GLOBALS['registry']->getApiInstance('imp', 'application')->mailboxesChanged();
+                $registry->getApiInstance('imp', 'application')->mailboxesChanged();
             }
             break;
 
         case 'server':
             if ($prefs->isDirty('subscribe')) {
-                $GLOBALS['registry']->getApiInstance('imp', 'application')->mailboxesChanged();
+                $registry->getApiInstance('imp', 'application')->mailboxesChanged();
             }
             break;
         }
@@ -749,9 +748,7 @@ class IMP_Prefs_Ui
 
         $t->set('canedit', $canEdit);
 
-        if (empty($_SESSION['imp']['imap']['admin'])) {
-            $t->set('noadmin', true);
-        } else {
+        if ($session['imp:imap_admin']) {
             $current_users = array_keys($curr_acl);
             $new_user = array();
 
@@ -762,6 +759,8 @@ class IMP_Prefs_Ui
                 $new_user[] = htmlspecialchars($user);
             }
             $t->set('new_user', $new_user);
+        } else {
+            $t->set('noadmin', true);
         }
 
         $rightsval = array();
@@ -1144,7 +1143,7 @@ class IMP_Prefs_Ui
                     '$("create_pgp_key").observe("click", function(e) { if (!window.confirm(' . Horde_Serialize::serialize(_("Key generation may take a long time to complete.  Continue with key generation?"), Horde_Serialize::JSON, 'UTF-8') . ')) { e.stop(); } })'
                 ), 'dom');
 
-                if ($_SESSION['imp']['file_upload']) {
+                if ($GLOBALS['session']['imp:file_upload']) {
                     $cacheSess = $GLOBALS['injector']->getInstance('Horde_SessionObjects');
                     Horde::addInlineScript(array(
                         '$("import_pgp_personal").observe("click", function(e) { ' . Horde::popupJs($pgp_url, array('params' => array('actionID' => 'import_personal_public_key', 'reload' => $cacheSess->storeOid($ui->selfUrl()->setRaw(true), false)), 'height' => 275, 'width' => 750, 'urlencode' => true)) . '; e.stop(); })'
@@ -1244,7 +1243,7 @@ class IMP_Prefs_Ui
             $t->set('pubkey_list', $plist);
         }
 
-        if ($_SESSION['imp']['file_upload']) {
+        if ($GLOBALS['session']['imp:file_upload']) {
             $t->set('can_import', true);
             $t->set('no_source', !$GLOBALS['prefs']->getValue('add_source'));
             if (!$t->get('no_source')) {
@@ -1526,7 +1525,7 @@ class IMP_Prefs_Ui
                 Horde::addInlineScript(array(
                     '$("delete_smime_personal").observe("click", function(e) { if (!window.confirm(' . Horde_Serialize::serialize(_("Are you sure you want to delete your keypair? (This is NOT recommended!)"), Horde_Serialize::JSON, 'UTF-8') . ')) { e.stop(); } })'
                 ), 'dom');
-            } elseif ($_SESSION['imp']['file_upload']) {
+            } elseif ($GLOBALS['session']['imp:file_upload']) {
                 $cacheSess = $GLOBALS['injector']->getInstance('Horde_SessionObjects');
                 $t->set('import-cert-help', Horde_Help::link('imp', 'smime-import-personal-certs'));
 
@@ -1598,7 +1597,7 @@ class IMP_Prefs_Ui
             $t->set('pubkey_list', $plist);
         }
 
-        if ($_SESSION['imp']['file_upload']) {
+        if ($GLOBALS['session']['imp:file_upload']) {
             $t->set('can_import', true);
             $t->set('no_source', !$GLOBALS['prefs']->getValue('add_source'));
             if (!$t->get('no_source')) {
@@ -1705,7 +1704,7 @@ class IMP_Prefs_Ui
 
         if (isset($data['sources'])) {
             $prefs->setValue('search_sources', $data['sources']);
-            unset($_SESSION['imp']['cache']['ac_ajax']);
+            unset($GLOBALS['session']['imp:ac_ajax']);
             $updated = true;
         }
 
index 643401b..b8e6f2a 100644 (file)
@@ -46,7 +46,7 @@ class IMP_Quota_Mdaemon extends IMP_Quota_Base
         $imap_ob = $GLOBALS['injector']->getInstance('IMP_Injector_Factory_Imap')->create();
         $userDetails = $this->_getUserDetails(
             $this->_params['username'],
-            $_SESSION['imp']['maildomain']
+            $GLOBALS['session']['imp:maildomain']
         );
 
         if ($userDetails !== false) {
index 7ab1fea..9de1b5d 100644 (file)
@@ -163,7 +163,8 @@ class IMP_Search implements ArrayAccess, Iterator, Serializable
          * Although there is a fallback to a PHP-based display sort, for
          * performance reasons only do a display sort if it is supported
          * on the server. */
-        if (($_SESSION['imp']['protocol'] == 'imap') && !empty($opts['sort'])) {
+        if (($GLOBALS['session']['imp:protocol'] == 'imap') &&
+            !empty($opts['sort'])) {
             $sort_cap = $imp_imap->queryCapability('SORT');
 
             if (is_array($sort_cap) && in_array('DISPLAY', $sort_cap)) {
index 74c1792..3722950 100644 (file)
@@ -48,7 +48,7 @@ abstract class IMP_Sentmail_Base
         }
 
         foreach ($recipients as $addresses) {
-            $addresses = Horde_Mime_Address::bareAddress($addresses, $_SESSION['imp']['maildomain'], true);
+            $addresses = Horde_Mime_Address::bareAddress($addresses, $GLOBALS['session']['imp:maildomain'], true);
             foreach ($addresses as $recipient) {
                 $this->_log($action, $message_id, $recipient, $success);
             }
index cc8466c..f21a95b 100644 (file)
@@ -119,7 +119,7 @@ class IMP_Tree_Flist extends Horde_Tree_Select
 
         /* Add the list of editable tasklists to the list. */
         if ($this->getOption('inc_tasklists') &&
-            !empty($_SESSION['imp']['tasklistavail'])) {
+            $GLOBALS['session']['imp:tasklistavail']) {
             try {
                 $tasklists = $registry->call('tasks/listTasklists', array(false, Horde_Perms::EDIT));
 
@@ -138,7 +138,7 @@ class IMP_Tree_Flist extends Horde_Tree_Select
 
         /* Add the list of editable notepads to the list. */
         if ($this->getOption('inc_notepads') &&
-            !empty($_SESSION['imp']['notepadavail'])) {
+            $GLOBALS['session']['imp:notepadavail']) {
             try {
                 $notepads = $registry->call('notes/listNotepads', array(false, Horde_Perms::EDIT));
 
index 5c7c64b..db5d01d 100644 (file)
@@ -49,7 +49,7 @@ class IMP_Ui_Block
         foreach ($poll as $folder) {
             if (isset($status[$folder]) &&
                 (($folder == 'INBOX') ||
-                 ($_SESSION['imp']['protocol'] != 'pop')) &&
+                 ($GLOBALS['session']['imp:protocol'] != 'pop')) &&
                 (empty($this->_params['show_unread']) ||
                  !empty($status[$folder]['unseen']))) {
                 if (!empty($status[$folder]['recent'])) {
index 1e6f79f..66ce235 100644 (file)
@@ -320,7 +320,7 @@ class IMP_Ui_Message
 
         $add_link = null;
         $addr_array = array();
-        $mimp_view = ($_SESSION['imp']['view'] == 'mimp');
+        $mimp_view = ($GLOBALS['session']['imp:view'] == 'mimp');
 
         /* Set up the add address icon link if contact manager is
          * available. */
@@ -389,7 +389,7 @@ class IMP_Ui_Message
             }
         }
 
-        if ($_SESSION['imp']['view'] == 'mimp') {
+        if ($GLOBALS['session']['imp:view'] == 'mimp') {
             return implode(', ', $addr_array);
         }
 
@@ -653,7 +653,7 @@ class IMP_Ui_Message
      */
     public function moveAfterAction()
     {
-        return (($_SESSION['imp']['protocol'] != 'pop') &&
+        return (($GLOBALS['session']['imp:protocol'] != 'pop') &&
                 !IMP::hideDeletedMsgs(IMP::$mailbox) &&
                 !$GLOBALS['prefs']->getValue('use_trash'));
     }
index 6e0b98f..098c4d0 100644 (file)
@@ -75,7 +75,7 @@ class IMP_Views_Compose
                 $result['js'][] = 'DIMP.conf_compose.qreply = 1';
             }
 
-            if ($_SESSION['imp']['rteavail']) {
+            if ($GLOBALS['session']['imp:rteavail']) {
                 $t->set('compose_html', $prefs->getValue('compose_html'));
                 $t->set('rte', true);
 
index a79918d..46f685b 100644 (file)
@@ -100,7 +100,7 @@ class IMP_Views_ListMessages
 
         /* Run filters now. */
         if (!$is_search &&
-            !empty($_SESSION['imp']['filteravail']) &&
+            $GLOBALS['session']['imp:filteravail'] &&
             !empty($args['applyfilter']) ||
             (($mbox == 'INBOX') &&
              $GLOBALS['prefs']->getValue('filter_on_display'))) {
@@ -409,7 +409,7 @@ class IMP_Views_ListMessages
         while (list(,$ob) = each($overview['overview'])) {
             /* Initialize the header fields. */
             $msg = array(
-                'imapuid' => (($_SESSION['imp']['protocol'] == 'pop') ? $ob['uid'] : intval($ob['uid'])),
+                'imapuid' => (($GLOBALS['session']['imp:protocol'] == 'pop') ? $ob['uid'] : intval($ob['uid'])),
                 'view' => $ob['mailbox'],
             );
 
index 3c65cda..8af14cc 100644 (file)
@@ -110,8 +110,7 @@ case 's':
 
 // 'rs' = run search
 case 'rs':
-    if (!empty($vars->search) &&
-        ($_SESSION['imp']['protocol'] == 'imap')) {
+    if (!empty($vars->search) && ($session['imp:protocol'] == 'imap')) {
         /* Create the search query and reset the global mailbox variable. */
         $q_ob = $imp_search->createQuery(
             array(new IMP_Search_Element_Text($vars->search, false)),
@@ -245,7 +244,7 @@ if (!$search_mbox && IMP::threadSortAvailable(IMP::$mailbox)) {
 }
 
 /* Add search link. */
-if ($_SESSION['imp']['protocol'] == 'imap') {
+if ($session['imp:protocol'] == 'imap') {
     if ($search_mbox) {
         $orig_mbox = reset($imp_search[IMP::$mailbox]->mboxes);
         $menu[] = array(sprintf(_("New Search in %s"), IMP::getLabel($orig_mbox)), IMP::generateIMPUrl('mailbox-mimp.php', $orig_mbox)->add('a', 's'));
index 3e58000..8667a64 100644 (file)
@@ -202,7 +202,7 @@ case 'view_messages':
 $mailbox_token = Horde::getRequestToken('imp.mailbox');
 
 /* Deal with filter options. */
-if (!$readonly && !empty($_SESSION['imp']['filteravail'])) {
+if (!$readonly && $session['imp:filteravail']) {
     /* Only allow filter on display for INBOX. */
     if ((IMP::$mailbox == 'INBOX') &&
         $prefs->getValue('filter_on_display')) {
@@ -391,7 +391,7 @@ if (isset($filter_url)) {
     $hdr_template->set('filter_img', Horde::img('filters.png', _("Apply Filters")));
 }
 $hdr_template->set('search', false);
-if ($_SESSION['imp']['protocol'] != 'pop') {
+if ($session['imp:protocol'] != 'pop') {
     $hdr_template->set('search_img', Horde::img('search.png', _("Search")));
 
     if (!$search_mbox) {
@@ -470,7 +470,7 @@ if ($pageOb['msgcount']) {
     $n_template->set('sessiontag', Horde_Util::formInput());
     $n_template->set('use_folders', $conf['user']['allow_folders']);
     $n_template->set('readonly', $readonly);
-    $n_template->set('use_pop', $_SESSION['imp']['protocol'] == 'pop');
+    $n_template->set('use_pop', $session['imp:protocol'] == 'pop');
 
     if (!$n_template->get('use_pop')) {
         $tmp = $imp_flags->getFlagList($search_mbox ? null : IMP::$mailbox);
index 546f564..43dc51b 100644 (file)
@@ -114,7 +114,7 @@ try {
 $envelope = $fetch_ret[$uid]['envelope'];
 $flags = $flags_ret[$uid]['flags'];
 $mime_headers = reset($fetch_ret[$uid]['headertext']);
-$use_pop = ($_SESSION['imp']['protocol'] == 'pop');
+$use_pop = ($session['imp:protocol'] == 'pop');
 
 /* Parse the message. */
 try {
index e2fa863..bf80b7e 100644 (file)
@@ -241,7 +241,7 @@ if (is_null($fetch_ret) || !isset($fetch_ret[$uid]['headertext'])) {
 $envelope = $fetch_ret[$uid]['envelope'];
 $flags = $flags_ret[$uid]['flags'];
 $mime_headers = reset($fetch_ret[$uid]['headertext']);
-$use_pop = ($_SESSION['imp']['protocol'] == 'pop');
+$use_pop = ($session['imp:protocol'] == 'pop');
 
 /* Get the title/mailbox label of the mailbox page. */
 $page_label = IMP::getLabel(IMP::$mailbox);
index 0e1cede..61326cb 100644 (file)
@@ -19,11 +19,11 @@ Horde_Registry::appInit('imp', array(
 ));
 
 /* This is an IMP-only script. */
-if ($_SESSION['imp']['view'] != 'imp') {
+if ($session['imp:view'] != 'imp') {
     exit;
 }
 
-if ($_SESSION['imp']['protocol'] == 'pop') {
+if ($session['imp:protocol'] == 'pop') {
     $notification->push(_("Searching is not available with a POP3 server."), 'horde.error');
     $from_message_page = true;
     $actionID = $start = null;
index c755083..5851992 100644 (file)
@@ -135,7 +135,7 @@ $constants = array(
 /* Load basic search if javascript is not enabled or searching is not allowed
  * (basic page will do the required redirection in the latter case). */
 if (!$browser->hasFeature('javascript') ||
-    ($_SESSION['imp']['protocol'] == 'pop')) {
+    ($session['imp:protocol'] == 'pop')) {
     require IMP_BASE . '/search-basic.php';
     exit;
 }
@@ -144,7 +144,7 @@ $imp_flags = $injector->getInstance('IMP_Imap_Flags');
 $imp_search = $injector->getInstance('IMP_Search');
 $vars = Horde_Variables::getDefaultVariables();
 
-$dimp_view = ($_SESSION['imp']['view'] == 'dimp');
+$dimp_view = ($session['imp:view'] == 'dimp');
 $js_vars = array();
 $search_mailbox = isset($vars->search_mailbox)
     ? $vars->search_mailbox
@@ -332,7 +332,7 @@ $js_vars['ImpSearch.selected'] = array($search_mailbox);
 $t = $injector->createInstance('Horde_Template');
 $t->setOption('gettext', true);
 $t->set('action', Horde::url('search.php'));
-$t->set('virtualfolder', $_SESSION['imp']['protocol'] != 'pop');
+$t->set('virtualfolder', $session['imp:protocol'] != 'pop');
 
 /* Determine if we are editing a search query. */
 if ($vars->edit_query && $imp_search->isSearchMbox($vars->edit_query)) {
index 70fa52f..637da7b 100644 (file)
@@ -15,7 +15,7 @@ $has_blacklist = $registry->hasMethod('mail/blacklistFrom');
 $has_whitelist = $registry->hasMethod('mail/whitelistFrom');
 
 // Quota information
-$show_quota = (isset($_SESSION['imp']['imap']['quota']) && is_array($_SESSION['imp']['imap']['quota']));
+$show_quota = $session['imp:imap_quota'];
 
 // Get application folders list.
 $application_folders = array();
@@ -60,7 +60,7 @@ function _simpleButton($id, $text, $image, $nodisplay = false)
     <?php echo _simpleButton('composelink', _("_New Message"), 'dimpactionCompose') ?>
     <?php echo _simpleButton('checkmaillink', _("_Get Mail"), 'dimpactionCheckmail') ?>
     <?php echo _simpleButton('alertsloglink', _("Alerts _Log"), 'infoIcon') ?>
-<?php if (!empty($_SESSION['imp']['filteravail'])): ?>
+<?php if ($session['imp:filteravail']): ?>
     <?php echo _simpleButton('applyfilterlink', _("Apply Filters"), 'filtersIcon') ?>
 <?php endif; ?>
    </ul>
@@ -110,7 +110,7 @@ function _simpleButton($id, $text, $image, $nodisplay = false)
      </ul>
     </div>
 <?php endif; ?>
-<?php if ($_SESSION['imp']['protocol'] != 'pop'): ?>
+<?php if ($session['imp:protocol'] != 'pop'): ?>
     <div class="sepfull"></div>
     <ul class="folderlist" id="normalfolders">
      <li class="folder" id="folderopts">
@@ -169,7 +169,7 @@ function _simpleButton($id, $text, $image, $nodisplay = false)
      </div>
 
      <div class="dimpActions">
-<?php if ($_SESSION['imp']['protocol'] != 'pop'): ?>
+<?php if ($session['imp:protocol'] != 'pop'): ?>
       <div id="qsearch">
        <span id="qsearch_icon"></span>
        <form action="#" method="post">
@@ -487,7 +487,7 @@ function _simpleButton($id, $text, $image, $nodisplay = false)
  <a id="ctx_mboxsort_none"><?php echo _("Clear Sort") ?></a>
 </div>
 
-<?php if ($_SESSION['imp']['protocol'] != 'pop'): ?>
+<?php if ($session['imp:protocol'] != 'pop'): ?>
 <div class="context" id="ctx_qsearchopts" style="display:none">
  <a id="ctx_qsearchopts_by"><?php echo _("Search By") ?></a>
  <div class="sep"></div>
index 7cefe8e..06a2a3c 100644 (file)
@@ -81,7 +81,7 @@ $code['conf'] = array_filter(array(
     'login_view' => $GLOBALS['prefs']->getValue('dimp_login_view'),
     'mbox_expand' => intval($GLOBALS['prefs']->getValue('nav_expanded') == 2),
     'name' => $GLOBALS['registry']->get('name', 'imp'),
-    'pop3' => intval((isset($_SESSION['imp']) && ($_SESSION['imp']['protocol'] == 'pop'))),
+    'pop3' => intval($GLOBALS['session']['imp:protocol'] == 'pop'),
     'popup_height' => 610,
     'popup_width' => 820,
     'preview_pref' => $GLOBALS['prefs']->getValue('dimp_show_preview'),
index b7e61ca..027345b 100644 (file)
@@ -11,7 +11,7 @@
 $code = array(
 /* Variables used in core javascript files. */
     'conf' => array(
-        'pop3' => intval((isset($_SESSION['imp']) && ($_SESSION['imp']['protocol'] == 'pop'))),
+        'pop3' => intval($GLOBALS['session']['imp:protocol'] == 'pop'),
         'fixed_folders' => empty($GLOBALS['conf']['server']['fixed_folders'])
             ? array()
             : $GLOBALS['conf']['server']['fixed_folders'],