From a5de175a9ee0c9d9d30123e1ce3321053285daa1 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 18 Dec 2008 10:08:23 -0700 Subject: [PATCH] Determine download all list in view.php, not via URL --- imp/lib/Contents.php | 1 - imp/lib/Views/ShowMessage.php | 2 +- imp/message.php | 15 +++------------ imp/view.php | 14 +++++++------- 4 files changed, 11 insertions(+), 21 deletions(-) diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index f81d38454..5f9f99f05 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -874,7 +874,6 @@ class IMP_Contents /** * Get download all list. - * NOT CURRENTLY USED * * @return array An array of downloadable parts. */ diff --git a/imp/lib/Views/ShowMessage.php b/imp/lib/Views/ShowMessage.php index e0d90e25f..c0cee60c5 100644 --- a/imp/lib/Views/ShowMessage.php +++ b/imp/lib/Views/ShowMessage.php @@ -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") . ']' + ? Horde::link($imp_contents->urlView($imp_contents->getMIMEMessage(), 'download_all')) . '[' . _("Save All") . ']' : ''; } diff --git a/imp/message.php b/imp/message.php index a0b73b131..82cc6e3c0 100644 --- a/imp/message.php +++ b/imp/message.php @@ -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)); } diff --git a/imp/view.php b/imp/view.php index 13f847953..d40a5bd29 100644 --- a/imp/view.php +++ b/imp/view.php @@ -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': -- 2.11.0