Determine download all list in view.php, not via URL
authorMichael M Slusarz <slusarz@curecanti.org>
Thu, 18 Dec 2008 17:08:23 +0000 (10:08 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 18 Dec 2008 17:08:23 +0000 (10:08 -0700)
imp/lib/Contents.php
imp/lib/Views/ShowMessage.php
imp/message.php
imp/view.php

index f81d384..5f9f99f 100644 (file)
@@ -874,7 +874,6 @@ class IMP_Contents
 
     /**
      * Get download all list.
-     * NOT CURRENTLY USED
      *
      * @return array  An array of downloadable parts.
      */
index e0d90e2..c0cee60 100644 (file)
@@ -303,7 +303,7 @@ class IMP_Views_ShowMessage
                 ? _("Parts")
                 : sprintf(ngettext("%d Attachment", "%d Attachments", $atc_parts), $atc_parts);
             $result['atc_download'] = (count($display_ids) > 2)
-                ? Horde::link($imp_contents->urlView($imp_contents->getMIMEMessage(), 'download_all', array('params' => array('download_ids' => serialize($atc_parts))))) . '[' . _("Save All") . ']</a>'
+                ? Horde::link($imp_contents->urlView($imp_contents->getMIMEMessage(), 'download_all')) . '[' . _("Save All") . ']</a>'
                 : '';
         }
 
index a0b73b1..82cc6e3 100644 (file)
@@ -177,22 +177,13 @@ case 'add_address':
     }
     break;
 
-case 'strip_attachment':
-    $imp_message = &IMP_Message::singleton();
-    $result = $imp_message->stripPart($imp_mailbox, Util::getFormData('imapid'));
-    if (is_a($result, 'PEAR_Error')) {
-        $notification->push($result, 'horde.error');
-    }
-
-    break;
-
 case 'strip_all':
+case 'strip_attachment':
     $imp_message = &IMP_Message::singleton();
-    $result = $imp_message->stripPart($imp_mailbox);
+    $result = $imp_message->stripPart($imp_mailbox, ($actionID == 'strip_all') ? null : Util::getFormData('imapid'));
     if (is_a($result, 'PEAR_Error')) {
         $notification->push($result, 'horde.error');
     }
-
     break;
 }
 
@@ -705,7 +696,7 @@ if (!IMP::$printMode) {
         $a_template->set('show_parts_atc', Horde::widget(Util::addParameter($headersURL, array('show_parts' => 'atc')), _("Show Attachments Only"), 'widget', '', '', _("Show Attachments Only"), true));
     }
     if (count($display_ids) > 2) {
-        $a_template->set('download_all', Horde::widget($imp_contents->urlView($imp_contents->getMIMEMessage(), 'download_all', array('params' => array('download_ids' => serialize($atc_parts)))), _("Download All Attachments (in .zip file)"), 'widget', '', '', _("Download All Attachments (in .zip file)"), true));
+        $a_template->set('download_all', Horde::widget($imp_contents->urlView($imp_contents->getMIMEMessage(), 'download_all'), _("Download All Attachments (in .zip file)"), 'widget', '', '', _("Download All Attachments (in .zip file)"), true));
         if ($strip_atc) {
             $a_template->set('strip_all', Horde::widget(Util::addParameter(Util::removeParameter(Horde::selfUrl(true), array('actionID')), array('actionID' => 'strip_all', 'message_token' => $message_token)), _("Strip All Attachments"), 'widget', '', "return window.confirm('" . addslashes(_("Are you sure you wish to PERMANENTLY delete all attachments?")) . "');", _("Strip All Attachments"), true));
         }
index 13f8479..d40a5bd 100644 (file)
@@ -13,8 +13,6 @@
  *   'view_source'
  * 'ctype' - (string) The content-type to use instead of the content-type
  *           found in the original Horde_Mime_Part object.
- * 'download_ids' - (string) For 'download_all', the serialized list of IDs to
- *                  download.
  * 'id' - (string) The MIME part ID to display.
  * 'index - (integer) The index of the message.
  * 'mailbox' - (string) The mailbox of the message.
@@ -89,7 +87,7 @@ case 'download_all':
     }
 
     $tosave = array();
-    foreach (unserialize(Util::getFormData('download_ids')) as $val) {
+    foreach ($contents->downloadAllList() as $val) {
         $mime = $contents->getMIMEPart($val);
         $name = $mime->getName(true);
         if (!$name) {
@@ -98,10 +96,12 @@ case 'download_all':
         $tosave[] = array('data' => $mime->getContents(), 'name' => $name);
     }
 
-    $horde_compress = &Horde_Compress::singleton('zip');
-    $body = $horde_compress->compress($tosave);
-    $browser->downloadHeaders($zipfile, 'application/zip', false, strlen($body));
-    echo $body;
+    if (!empty($tosave)) {
+        $horde_compress = &Horde_Compress::singleton('zip');
+        $body = $horde_compress->compress($tosave);
+        $browser->downloadHeaders($zipfile, 'application/zip', false, strlen($body));
+        echo $body;
+    }
     exit;
 
 case 'download_attach':