Add IMP_Compose::hasDrafts()
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 30 Sep 2010 21:28:41 +0000 (15:28 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 30 Sep 2010 22:28:03 +0000 (16:28 -0600)
imp/lib/Ajax/Application.php
imp/lib/Compose.php

index 5738c3c..85c848f 100644 (file)
@@ -1641,7 +1641,7 @@ class IMP_Ajax_Application extends Horde_Core_Ajax_Application
         }
 
         /* Remove any auto-saved drafts. */
-        if ($GLOBALS['prefs']->getValue('auto_save_drafts')) {
+        if ($imp_compose->hasDrafts()) {
             $result->draft_delete = 1;
         }
 
index 0311294..89c6143 100644 (file)
@@ -450,6 +450,17 @@ class IMP_Compose
     }
 
     /**
+     * Does this message have any drafts associated with it?
+     *
+     * @return boolean  True if draft messages exist.
+     */
+    public function hasDrafts()
+    {
+        return (!empty($this->_metadata['draft_uid']) ||
+                !empty($this->_metadata['draft_uid_resume']));
+    }
+
+    /**
      * Builds and sends a MIME message.
      *
      * @param string $body     The message body.