Enhancement #2925: Add ability to download attachments in MIMP.
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 20 Jan 2009 05:01:11 +0000 (22:01 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 20 Jan 2009 05:05:30 +0000 (22:05 -0700)
imp/docs/CHANGES
imp/lib/Contents.php
imp/message-mimp.php

index a1ebf98..6c324e6 100644 (file)
@@ -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).
index 5bdd7e4..10c8183 100644 (file)
@@ -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
index b171557..1cb849a 100644 (file)
@@ -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);
 }