Add mimp_download_confirm pref
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 16 Nov 2009 19:49:04 +0000 (12:49 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 16 Nov 2009 19:49:04 +0000 (12:49 -0700)
Determines at what size an attachment download in mimp should trigger
the download confirmation page.

imp/config/prefs.php.dist
imp/message-mimp.php

index 6272ffa..da4b1d4 100644 (file)
@@ -197,7 +197,7 @@ $prefGroups['mimp'] = array(
     'label' => _("Minimalist View Options"),
     'desc' => _("Configure options for the minimalist view."),
     'members' => array('mimp_preview_msg', 'mimp_max_from_chars',
-                       'mimp_max_subj_chars')
+                       'mimp_max_subj_chars', 'mimp_download_confirm')
 );
 
 $prefGroups['standard'] = array(
@@ -1611,6 +1611,14 @@ $_prefs['mimp_max_subj_chars'] = array(
     'desc' => _("In the mailbox view, how many characters of Subject: lines should we show before truncating?")
 );
 
+$_prefs['mimp_download_confirm'] = array(
+    'value' => 0,
+    'locked' => true,
+    'shared' => false,
+    'type' => 'number',
+    'desc' => _("Only show download confirmation page if message part is greater than this size, in bytes. Set to 0 to always require the confirmation page.")
+);
+
 // End Minimalist View Options
 
 // Standard View Options
index cd528b6..a7655c8 100644 (file)
@@ -395,12 +395,18 @@ 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 | IMP_Contents::SUMMARY_DOWNLOAD_NOJS);
+    $summary = $imp_contents->getSummary($key, IMP_Contents::SUMMARY_BYTES | IMP_Contents::SUMMARY_SIZE | IMP_Contents::SUMMARY_DESCRIP_NOLINK_NOHTMLSPECCHARS | IMP_Contents::SUMMARY_DOWNLOAD_NOJS);
     $hb->add(new Horde_Mobile_text(_("Attachment") . ': ', array('b')));
     if (empty($summary['download'])) {
         $hb->add(new Horde_Mobile_text($summary['description']));
     } else {
-        $hb->add(new Horde_Mobile_link($summary['description'], Horde_Util::addParameter($self_link, array('a' => 'c', 'atc' => $key))));
+        /* Preference: if set, only show download confirmation screen if
+         * attachment over a certain size. */
+        $download_link = ($summary['bytes'] > $prefs->getValue('mimp_download_confirm'))
+            ? Horde_Util::addParameter($self_link, array('a' => 'c', 'atc' => $key))
+            : $summary['download'];
+
+        $hb->add(new Horde_Mobile_link($summary['description'], $download_link);
     }
     $t = &$hb->add(new Horde_Mobile_text(sprintf(' [%s] %s', $summary['type'], $summary['size']) . "\n"));
     $t->set('linebreaks', true);