From 099d2b9fd4af3c7e7f1568af3c01c0b2e52cd9c3 Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Tue, 26 Mar 2013 14:38:07 -0400
Subject: [PATCH] Remove sig_above configuration option, use reply_mode only (#1489001)

---
 program/steps/mail/compose.inc |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 3f86c0d..5346959 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -139,7 +139,6 @@
 }
 // set current mailbox in client environment
 $OUTPUT->set_env('mailbox', $RCMAIL->storage->get_folder());
-$OUTPUT->set_env('sig_above', $RCMAIL->config->get('sig_above', false));
 $OUTPUT->set_env('top_posting', intval($RCMAIL->config->get('reply_mode')) > 0);
 $OUTPUT->set_env('recipients_separator', trim($RCMAIL->config->get('recipients_separator', ',')));
 
@@ -152,6 +151,7 @@
 // get reference message and set compose mode
 if ($msg_uid = $COMPOSE['param']['draft_uid']) {
   $compose_mode = RCUBE_COMPOSE_DRAFT;
+  $OUTPUT->set_env('draft_id', $msg_uid);
   $RCMAIL->storage->set_folder($CONFIG['drafts_mbox']);
 }
 else if ($msg_uid = $COMPOSE['param']['reply_uid']) {
@@ -452,7 +452,7 @@
   if (count($MESSAGE->identities))
   {
     $a_signatures = array();
-    $separator    = $RCMAIL->config->get('sig_above')
+    $separator    = intval($RCMAIL->config->get('reply_mode')) > 0
       && ($compose_mode == RCUBE_COMPOSE_REPLY || $compose_mode == RCUBE_COMPOSE_FORWARD) ? '---' : '-- ';
 
     $field_attrib['onchange'] = JS_OBJECT_NAME.".change_identity(this)";
@@ -559,8 +559,7 @@
   else if ($compose_mode == RCUBE_COMPOSE_FORWARD && $COMPOSE['as_attachment']) {
     $isHtml = rcmail_compose_editor_mode();
     $body = '';
-    if (empty($COMPOSE['attachments']))
-      rcmail_write_forward_attachments();
+    rcmail_write_forward_attachments();
   }
   // reply/edit/draft/forward
   else if ($compose_mode && ($compose_mode != RCUBE_COMPOSE_REPLY || $RCMAIL->config->get('reply_mode') != -1)) {
@@ -1062,6 +1061,11 @@
   $curr_mem  = function_exists('memory_get_usage') ? memory_get_usage() : 16*1024*1024; // safe value: 16MB
   $names     = array();
 
+  $loaded_attachments = array();
+  foreach ((array)$COMPOSE['attachments'] as $id => $attachment) {
+      $loaded_attachments[$attachment['name'] . $attachment['mimetype']] = $attachment;
+  }
+
   if ($COMPOSE['forward_uid'] == '*') {
     $index = $storage->index(null, rcmail_sort_column(), rcmail_sort_order());
     $COMPOSE['forward_uid'] = $index->get();
@@ -1096,6 +1100,10 @@
 
     $data = $path = null;
 
+    if (!empty($loaded_attachments[$name . 'message/rfc822'])) {
+      continue;
+    }
+
     // don't load too big attachments into memory
     if ($mem_limit > 0 && $message->size > $mem_limit - $curr_mem) {
       $temp_dir = unslashify($RCMAIL->config->get('temp_dir'));

--
Gitblit v1.9.1