Add ability to add attachments for advanced mobile browsers
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 16 Mar 2010 04:52:09 +0000 (22:52 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 16 Mar 2010 04:52:23 +0000 (22:52 -0600)
imp/compose-mimp.php
imp/config/hooks.php.dist
imp/docs/CHANGES
imp/templates/mimp/compose/compose.html

index e4ed603..90d8dcf 100644 (file)
@@ -91,6 +91,13 @@ foreach (array_keys($display_hdrs) as $val) {
     }
 }
 
+/* Add attachment. */
+if ($_SESSION['imp']['file_upload'] &&
+    !$imp_compose->addFilesFromUpload('upload_', $vars->a == _("Expand Names")) &&
+    ($vars->a != _("Expand Names"))) {
+    $vars->a = null;
+}
+
 /* Run through the action handlers. */
 switch ($vars->a) {
 // 'd' = draft
@@ -346,6 +353,19 @@ foreach ($display_hdrs as $key => $val) {
 $t->set('hdrs', $hdrs);
 $t->set('title', $title);
 
+/* Activate advanced compose attachments UI? */
+if ($_SESSION['imp']['file_upload']) {
+    try {
+        if (Horde::callHook('mimp_advanced', array('compose_attach'), 'imp')) {
+            $t->set('attach', true);
+            if ($atc_list = $imp_compose->getAttachments()) {
+                $imp_ui_mbox = new IMP_Ui_Mailbox();
+                $t->set('attach_data', sprintf("%s [%s] - %s", htmlspecialchars($atc_list[0]['part']->getName()), htmlspecialchars($atc_list[0]['part']->getType()), $imp_ui_mbox->getSize($atc_list[0]['part']->getBytes())));
+            }
+        }
+    } catch (Horde_Exception_HookNotSet $e) {}
+}
+
 require IMP_TEMPLATES . '/common-header.inc';
 IMP::status();
 echo $t->fetch(IMP_TEMPLATES . '/mimp/compose/compose.html');
index 1bd35a5..3287a71 100644 (file)
@@ -773,6 +773,10 @@ class IMP_Hooks
 //         case 'checkbox':
 //             // Activate the mailbox checkbox interface.
 //             return true;
+//
+//         case 'compose_attach':
+//             // Activate the compose attachment interface.
+//             return true;
 //         }
 //
 //         return false;
index 89483b0..e802fa3 100644 (file)
@@ -2,8 +2,10 @@
 v5.0-git
 --------
 
-[mms] Add checkbox interface to mailbox page for advanced mobile browsers
-      (MIMP).
+[mms] Add ability to add attachments to composed messages for advanced mobile
+      browsers - disabled by default (MIMP).
+[mms] Add checkbox interface to mailbox page for advanced mobile browsers -
+      disabled by default (MIMP).
 [mms] Add preference to allow viewing of all inline parts by default (MIMP).
 [mms] Add hook to alter composed message details before sending.
 [mms] DIMP now honors the 'allow_resume_all' configuration option.
index 80f34ab..7b96c78 100644 (file)
@@ -1,6 +1,6 @@
   <div><tag:title /></div>
   <hr />
-  <form action="<tag:url />" method="post">
+  <form action="<tag:url />" method="post" <if:attach><if:attach_data><else:attach_data>enctype="multipart/form-data"</else:attach_data></if:attach_data></if:attach>>
    <input type="hidden" name="composeCache" value="<tag:cacheid />" />
 <if:redirect>
    <input type="hidden" name="action" value="rc" />
     <input type="submit" name="a" value="<gettext>Expand Names</gettext>" />
     <input type="submit" name="a" value="<gettext>Cancel</gettext>" />
    </p>
+<if:attach>
+   <hr />
+   <p>
+    <gettext>Attach</gettext>:
+<if:attach_data>
+    <tag:attach_data />
+<else:attach_data>
+    <input name="upload_1" type="file" />
+</else:attach_data></if:attach_data>
+   </p>
+</if:attach>
   </form>
   <hr />
   <div><gettext>Menu</gettext></div>