alecpl
2011-09-27 90a6aff022c62e1cbcc5b7fc4baf7b982d7f2ffe
- Fix bug where when replying always the last identity is used (#1488101)


2 files modified
19 ■■■■ changed files
program/js/common.js 2 ●●● patch | view | raw | blame | history
program/steps/mail/compose.inc 17 ●●●● patch | view | raw | blame | history
program/js/common.js
@@ -620,7 +620,7 @@
    begin += 2;  
  }
  var end = document.cookie.indexOf(";", begin);
  var end = dc.indexOf(";", begin);
  if (end == -1)
    end = dc.length;
program/steps/mail/compose.inc
@@ -242,21 +242,27 @@
  $MESSAGE->compose['from'] = $_SESSION['compose']['param']['from'];
}
else if (count($MESSAGE->identities)) {
  // extract all recipients of the reply-message
  $a_recipients = array();
  $a_names      = array();
  // extract all recipients of the reply-message
  if (is_object($MESSAGE->headers) && in_array($compose_mode, array(RCUBE_COMPOSE_REPLY, RCUBE_COMPOSE_FORWARD)))
  {
    $a_to = $IMAP->decode_address_list($MESSAGE->headers->to);
    foreach ($a_to as $addr) {
      if (!empty($addr['mailto']))
      if (!empty($addr['mailto'])) {
        $a_recipients[] = strtolower($addr['mailto']);
        $a_names[]      = $addr['name'];
      }
    }
    if (!empty($MESSAGE->headers->cc)) {
      $a_cc = $IMAP->decode_address_list($MESSAGE->headers->cc);
      foreach ($a_cc as $addr) {
        if (!empty($addr['mailto']))
        if (!empty($addr['mailto'])) {
          $a_recipients[] = strtolower($addr['mailto']);
          $a_names[]      = $addr['name'];
        }
      }
    }
  }
@@ -285,10 +291,13 @@
      break;
    }
    // use replied message recipients
    else if (in_array($ident['email_ascii'], $a_recipients)) {
    else if (($found = array_search($ident['email_ascii'], $a_recipients)) !== false) {
      // match identity name, prefer default identity
      if ($from_idx === null || ($a_names[$found] && $ident['name'] && $a_names[$found] == $ident['name'])) {
      $from_idx = $idx;
    }
  }
  }
  // Fallback using Return-Path
  if ($from_idx === null && $return_path) {