From 1b3c13aad655d5c1e2b04797ed8332e0e2ad1096 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Mon, 19 Jan 2009 22:01:11 -0700 Subject: [PATCH] Enhancement #2925: Add ability to download attachments in MIMP. --- imp/docs/CHANGES | 1 + imp/lib/Contents.php | 15 ++++++++++----- imp/message-mimp.php | 9 +++++++-- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index a1ebf9894..6c324e6d0 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,7 @@ v5.0-cvs -------- +[mms] Add ability to download attachments in MIMP (Request #2925). [mms] Revamp JS event handling model. [mms] ESC in DIMP search box now clears the search (Request #7196). [mms] Enhancements to status icon view (Request #7519) (DIMP). diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index 5bdd7e4b4..10c81833b 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -21,9 +21,10 @@ class IMP_Contents const SUMMARY_DESCRIP_NOLINK = 16; const SUMMARY_DESCRIP_NOLINK_NOHTMLSPECCHARS = 32; const SUMMARY_DOWNLOAD = 64; - const SUMMARY_DOWNLOAD_ZIP = 128; - const SUMMARY_IMAGE_SAVE = 256; - const SUMMARY_STRIP_LINK = 512; + const SUMMARY_DOWNLOAD_NOJS = 128; + const SUMMARY_DOWNLOAD_ZIP = 256; + const SUMMARY_IMAGE_SAVE = 512; + const SUMMARY_STRIP_LINK = 1024; /* Rendering mask entries. */ const RENDER_FULL = 1; @@ -471,6 +472,7 @@ class IMP_Contents * Output: parts = 'description' * * IMP_Contents::SUMMARY_DOWNLOAD + * IMP_Contents::SUMMARY_DOWNLOAD_NOJS * Output: parts = 'download' * * IMP_Contents::SUMMARY_DOWNLOAD_ZIP @@ -557,9 +559,12 @@ class IMP_Contents /* Download column. */ if ($is_atc && - ($mask & self::SUMMARY_DOWNLOAD) && (is_null($part['bytes']) || $part['bytes'])) { - $part['download'] = $this->linkView($mime_part, 'download_attach', '', array('class' => 'downloadAtc', 'dload' => true, 'jstext' => _("Download"))); + if ($mask & self::SUMMARY_DOWNLOAD) { + $part['download'] = $this->linkView($mime_part, 'download_attach', '', array('class' => 'downloadAtc', 'dload' => true, 'jstext' => _("Download"))); + } elseif ($mask & self::SUMMARY_DOWNLOAD_NOJS) { + $part['download'] = $this->urlView($mime_part, 'download_attach', array('dload' => true)); + } } /* Display the compressed download link only if size is greater diff --git a/imp/message-mimp.php b/imp/message-mimp.php index b1715574c..1cb849a1e 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -353,9 +353,14 @@ foreach ($display_headers as $head => $val) { } foreach ($atc_parts as $key) { - $summary = $imp_contents->getSummary($key, IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP_NOLINK_NOHTMLSPECCHARS); + $summary = $imp_contents->getSummary($key, IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP_NOLINK_NOHTMLSPECCHARS | IMP_Contents::SUMMARY_DOWNLOAD_NOJS); $hb->add(new Horde_Mobile_text(_("Attachment") . ': ', array('b'))); - $t = &$hb->add(new Horde_Mobile_text(sprintf('%s [%s] %s', $summary['description'], $summary['type'], $summary['size']) . "\n")); + if (empty($summary['download'])) { + $hb->add(new Horde_Mobile_text($summary['description'])); + } else { + $hb->add(new Horde_Mobile_link($summary['description'], $summary['download'])); + } + $t = &$hb->add(new Horde_Mobile_text(sprintf(' [%s] %s', $summary['type'], $summary['size']) . "\n")); $t->set('linebreaks', true); } -- 2.11.0