Catch login alerts that would otherwise be lost
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 5 Aug 2009 19:21:20 +0000 (13:21 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 5 Aug 2009 20:35:16 +0000 (14:35 -0600)
imp/lib/Imap.php

index 655a5cc..215dce2 100644 (file)
@@ -58,13 +58,23 @@ class IMP_Imap
      */
     public function __destruct()
     {
-        /* Only need to serialize object once a second. When we do serialize,
-         * make sure we login in order to ensure we have done the necessary
-         * initialization. */
+        /* Only need to serialize object once a session. When we do
+         * serialize, make sure we login in order to ensure we have done the
+         * necessary initialization. */
         if ($this->ob &&
             isset($_SESSION['imp']) &&
             !isset($_SESSION['imp']['imap_ob'])) {
             $this->ob->login();
+
+            /* First login may occur on a non-viewable page. However,
+             * any login alerts received should be displayed to the user at
+             * some point. We need to do an explicit grab of the alarms
+             * right now. */
+            $notification = Horde_Notification::singleton();
+            foreach ($GLOBALS['imp_imap']->ob->alerts() as $alert) {
+                $notification->push($alert, 'horde.warning');
+            }
+
             $_SESSION['imp']['imap_ob'] = serialize($this->ob);
         }
     }