Changeset 4436b43 in github


Ignore:
Timestamp:
Aug 19, 2011 6:07:41 AM (22 months ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.7, release-0.8
Children:
8015bb94
Parents:
dd6a47c
Message:
  • Fixed selecting identity on reply/forward (#1487981)
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r5c9d1ff r4436b43  
    22=========================== 
    33 
     4- Fixed selecting identity on reply/forward (#1487981) 
    45- Add option to hide selected LDAP addressbook on the list 
    56- Add client-side checking of uploaded files size 
  • program/steps/mail/compose.inc

    rfe0cb65 r4436b43  
    226226if (count($MESSAGE->identities)) 
    227227{ 
    228   foreach ($MESSAGE->identities as $idx => $sql_arr) { 
    229     $email = mb_strtolower(rcube_idn_to_utf8($sql_arr['email'])); 
    230     $MESSAGE->identities[$idx]['email_ascii'] = $sql_arr['email']; 
     228  foreach ($MESSAGE->identities as $idx => $ident) { 
     229    $email = mb_strtolower(rcube_idn_to_utf8($ident['email'])); 
     230 
     231    $MESSAGE->identities[$idx]['email_ascii'] = $ident['email']; 
     232    $MESSAGE->identities[$idx]['ident']       = format_email_recipient($ident['email'], $ident['name']); 
    231233    $MESSAGE->identities[$idx]['email']       = $email; 
    232234  } 
     
    243245  // extract all recipients of the reply-message 
    244246  $a_recipients = array(); 
    245   if ($compose_mode == RCUBE_COMPOSE_REPLY && is_object($MESSAGE->headers)) 
     247  if (is_object($MESSAGE->headers) && in_array($compose_mode, array(RCUBE_COMPOSE_REPLY, RCUBE_COMPOSE_FORWARD))) 
    246248  { 
    247249    $a_to = $IMAP->decode_address_list($MESSAGE->headers->to); 
     
    261263 
    262264  $from_idx         = null; 
    263   $default_identity = 0; 
     265  $default_identity = null; 
    264266  $return_path      = $MESSAGE->headers->others['return-path']; 
    265267 
    266268  // Select identity 
    267   foreach ($MESSAGE->identities as $idx => $sql_arr) { 
     269  foreach ($MESSAGE->identities as $idx => $ident) { 
    268270    // save default identity ID 
    269     if ($sql_arr['standard']) { 
     271    if ($ident['standard']) { 
    270272      $default_identity = $idx; 
    271273    } 
    272     // we need ascii here 
    273     $email = $sql_arr['email_ascii']; 
    274     $ident = format_email_recipient($email, $sql_arr['name']); 
    275  
    276     // select identity 
    277     if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT, RCUBE_COMPOSE_REPLY))) { 
    278       if ($MESSAGE->headers->from == $ident) { 
     274 
     275    // use From header 
     276    if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) { 
     277      if ($MESSAGE->headers->from == $ident['email_ascii']) { 
    279278        $from_idx = $idx; 
    280279        break; 
    281280      } 
    282281    } 
    283     // set identity if it's one of the reply-message recipients 
    284     else if (in_array($email, $a_recipients) && ($from_idx === null || $sql_arr['standard'])) { 
     282    else if ($compose_mode == RCUBE_COMPOSE_REPLY && $MESSAGE->headers->from == $ident['email_ascii']) { 
    285283      $from_idx = $idx; 
    286     } 
    287     // set identity when replying to mailing list 
    288     else if (strpos($return_path, str_replace('@', '=', $email).'@') !== false) { 
     284      break; 
     285    } 
     286    // use reply-message recipients 
     287    else if (in_array($ident['email_ascii'], $a_recipients)) { 
    289288      $from_idx = $idx; 
    290289    } 
    291290  } 
    292291 
    293   // Still no ID, use first identity 
     292  // Fallback using Return-Path 
     293  if ($from_idx === null && $return_path) { 
     294    foreach ($MESSAGE->identities as $idx => $ident) { 
     295      if (strpos($return_path, str_replace('@', '=', $ident['email_ascii']).'@') !== false) { 
     296        $from_idx = $idx; 
     297        break; 
     298      } 
     299    } 
     300  } 
     301 
     302  // Still no ID, use default/first identity 
    294303  if ($from_idx === null) { 
    295     $from_idx = $default_identity; 
     304    $from_idx = $default_identity !== null ? $default_identity : key(reset($MESSAGE->identities)); 
    296305  } 
    297306 
Note: See TracChangeset for help on using the changeset viewer.