Changeset da142bb in github
- Timestamp:
- Feb 15, 2011 5:09:14 AM (2 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- ab0b51a1
- Parents:
- 3e26373
- Files:
-
- 2 edited
-
CHANGELOG (modified) (1 diff)
-
program/steps/mail/compose.inc (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
CHANGELOG
r3e26373 rda142bb 2 2 =========================== 3 3 4 - Replying to a sent message puts the old recipient as the new recipient (#1487074) 4 5 - Fulltext search over (almost) all data for contacts 5 6 - Extend address book with rich contact information -
program/steps/mail/compose.inc
re8d5bdc rda142bb 218 218 } 219 219 220 // process $MESSAGE body/attachments, set $MESSAGE_BODY/$HTML_MODE vars and some session data 221 $MESSAGE_BODY = rcmail_prepare_message_body(); 222 223 224 /****** compose mode functions ********/ 225 226 function rcmail_compose_headers($attrib) 227 { 228 global $IMAP, $MESSAGE, $DB, $compose_mode; 229 static $sa_recipients = array(); 230 231 list($form_start, $form_end) = get_form_tags($attrib); 232 233 $out = ''; 234 $part = strtolower($attrib['part']); 235 236 switch ($part) 220 $MESSAGE->compose = array(); 221 222 // get user's identities 223 $MESSAGE->identities = $USER->list_identities(); 224 if (count($MESSAGE->identities)) 225 { 226 foreach ($MESSAGE->identities as $idx => $sql_arr) { 227 $email = mb_strtolower(rcube_idn_to_utf8($sql_arr['email'])); 228 $MESSAGE->identities[$idx]['email_ascii'] = $sql_arr['email']; 229 $MESSAGE->identities[$idx]['email'] = $email; 230 } 231 } 232 233 // Set From field value 234 if (!empty($_POST['_from'])) { 235 $MESSAGE->compose['from'] = get_input_value('_from', RCUBE_INPUT_POST); 236 } 237 else if (!empty($_SESSION['compose']['param']['from'])) { 238 $MESSAGE->compose['from'] = $_SESSION['compose']['param']['from']; 239 } 240 else if (count($MESSAGE->identities)) { 241 // extract all recipients of the reply-message 242 $a_recipients = array(); 243 if ($compose_mode == RCUBE_COMPOSE_REPLY && is_object($MESSAGE->headers)) 237 244 { 238 case 'from': 239 return $form_start . rcmail_compose_header_from($attrib); 240 241 case 'to': 242 $fname = '_to'; 243 $header = $param = 'to'; 244 245 // we have a set of recipients stored is session 246 if (($mailto_id = $_SESSION['compose']['param']['mailto']) && $_SESSION['mailto'][$mailto_id]) 247 $fvalue = urldecode($_SESSION['mailto'][$mailto_id]); 248 249 case 'cc': 250 if (!$fname) { 251 $fname = '_cc'; 252 $header = $param = 'cc'; 253 } 254 case 'bcc': 255 if (!$fname) { 256 $fname = '_bcc'; 257 $header = $param = 'bcc'; 258 } 259 260 $allow_attrib = array('id', 'class', 'style', 'cols', 'rows', 'tabindex'); 261 $field_type = 'html_textarea'; 245 $a_to = $IMAP->decode_address_list($MESSAGE->headers->to); 246 foreach ($a_to as $addr) { 247 if (!empty($addr['mailto'])) 248 $a_recipients[] = strtolower($addr['mailto']); 249 } 250 251 if (!empty($MESSAGE->headers->cc)) { 252 $a_cc = $IMAP->decode_address_list($MESSAGE->headers->cc); 253 foreach ($a_cc as $addr) { 254 if (!empty($addr['mailto'])) 255 $a_recipients[] = strtolower($addr['mailto']); 256 } 257 } 258 } 259 260 $from_idx = null; 261 $default_identity = 0; 262 $return_path = $MESSAGE->headers->others['return-path']; 263 264 // Select identity 265 foreach ($MESSAGE->identities as $idx => $sql_arr) { 266 // save default identity ID 267 if ($sql_arr['standard']) { 268 $default_identity = $idx; 269 } 270 // we need ascii here 271 $email = $sql_arr['email_ascii']; 272 $ident = format_email_recipient($email, $sql_arr['name']); 273 274 // select identity 275 if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) { 276 if ($MESSAGE->headers->from == $ident) { 277 $from_idx = $idx; 278 break; 279 } 280 } 281 // reply to self, force To header value 282 else if ($compose_mode == RCUBE_COMPOSE_REPLY && $MESSAGE->headers->from == $ident) { 283 $from_idx = $idx; 284 $MESSAGE->compose['to'] = $MESSAGE->headers->to; 262 285 break; 263 264 case 'replyto': 265 case 'reply-to': 266 $fname = '_replyto'; 267 $param = 'replyto'; 268 $header = 'reply-to'; 269 270 case 'followupto': 271 case 'followup-to': 272 if (!$fname) { 273 $fname = '_followupto'; 274 $param = 'followupto'; 275 $header = 'mail-followup-to'; 276 } 277 278 $allow_attrib = array('id', 'class', 'style', 'size', 'tabindex'); 279 $field_type = 'html_inputfield'; 280 break; 281 } 282 283 if ($fname && !empty($_POST[$fname])) { 284 $fvalue = get_input_value($fname, RCUBE_INPUT_POST, TRUE); 285 } 286 else if ($fname && !$fvalue && !empty($_SESSION['compose']['param'][$param])) { 287 $fvalue = $_SESSION['compose']['param'][$param]; 288 } 289 else if ($header && $compose_mode == RCUBE_COMPOSE_REPLY) { 286 } 287 // set identity if it's one of the reply-message recipients 288 else if (in_array($email, $a_recipients) && ($from_idx === null || $sql_arr['standard'])) { 289 $from_idx = $idx; 290 } 291 // set identity when replying to mailing list 292 else if (strpos($return_path, str_replace('@', '=', $email).'@') !== false) { 293 $from_idx = $idx; 294 } 295 } 296 297 // Still no ID, use first identity 298 if ($from_idx === null) { 299 $from_idx = $default_identity; 300 } 301 302 $ident = $MESSAGE->identities[$from_idx]; 303 $from_id = $ident['identity_id']; 304 305 $MESSAGE->compose['from_email'] = $ident['email']; 306 $MESSAGE->compose['from'] = $from_id; 307 } 308 309 // Set other headers 310 $a_recipients = array(); 311 $parts = array('to', 'cc', 'bcc', 'replyto', 'followupto'); 312 313 foreach ($parts as $header) { 314 $fvalue = ''; 315 316 // we have a set of recipients stored is session 317 if ($header == 'to' && ($mailto_id = $_SESSION['compose']['param']['mailto']) 318 && $_SESSION['mailto'][$mailto_id] 319 ) { 320 $fvalue = urldecode($_SESSION['mailto'][$mailto_id]); 321 } 322 else if (!empty($_POST['_'.$header])) { 323 $fvalue = get_input_value('_'.$header, RCUBE_INPUT_POST, TRUE); 324 } 325 else if (!empty($_SESSION['compose']['param'][$header])) { 326 $fvalue = $_SESSION['compose']['param'][$header]; 327 } 328 else if ($compose_mode == RCUBE_COMPOSE_REPLY) { 290 329 // get recipent address(es) out of the message headers 291 330 if ($header == 'to') { … … 293 332 $mailreplyto = $MESSAGE->headers->others['mail-reply-to']; 294 333 295 if ($MESSAGE->reply_all == 'list' && $mailfollowup) 334 if ($MESSAGE->compose['to']) 335 $fvalue = $MESSAGE->compose['to']; 336 else if ($MESSAGE->reply_all == 'list' && $mailfollowup) 296 337 $fvalue = $mailfollowup; 297 338 else if ($MESSAGE->reply_all == 'list' … … 305 346 $fvalue = $MESSAGE->headers->from; 306 347 } 307 // add recip ent of original message if reply to all348 // add recipient of original message if reply to all 308 349 else if ($header == 'cc' && !empty($MESSAGE->reply_all) && $MESSAGE->reply_all != 'list') { 309 350 if ($v = $MESSAGE->headers->to) … … 312 353 $fvalue .= (!empty($fvalue) ? ', ' : '') . $v; 313 354 } 314 315 // split recipients and put them back together in a unique way 316 if (!empty($fvalue)) { 317 $to_addresses = $IMAP->decode_address_list($fvalue); 318 $fvalue = ''; 319 320 foreach ($to_addresses as $addr_part) { 321 if (empty($addr_part['mailto'])) 322 continue; 323 324 $mailto = rcube_idn_to_utf8($addr_part['mailto']); 325 326 if (!in_array($mailto, $sa_recipients) 327 && (!$MESSAGE->compose_from 328 || !in_array_nocase($mailto, $MESSAGE->compose_from) 329 || (count($to_addresses)==1 && $header=='to')) // allow reply to yourself 330 ) { 331 if ($addr_part['name'] && $addr_part['mailto'] != $addr_part['name']) 332 $string = format_email_recipient($mailto, $addr_part['name']); 333 else 334 $string = $mailto; 335 $fvalue .= (strlen($fvalue) ? ', ':'') . $string; 336 $sa_recipients[] = $addr_part['mailto']; 337 } 338 } 339 } 340 } 341 else if ($header && in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) { 355 } 356 else if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) { 342 357 // get drafted headers 343 358 if ($header=='to' && !empty($MESSAGE->headers->to)) … … 347 362 else if ($header=='bcc' && !empty($MESSAGE->headers->bcc)) 348 363 $fvalue = $MESSAGE->get_header('bcc'); 349 else if ($header=='reply -to' && !empty($MESSAGE->headers->others['mail-reply-to']))364 else if ($header=='replyto' && !empty($MESSAGE->headers->others['mail-reply-to'])) 350 365 $fvalue = $MESSAGE->get_header('mail-reply-to'); 351 else if ($header=='reply -to' && !empty($MESSAGE->headers->replyto))366 else if ($header=='replyto' && !empty($MESSAGE->headers->replyto)) 352 367 $fvalue = $MESSAGE->get_header('reply-to'); 353 else if ($header==' mail-followup-to' && !empty($MESSAGE->headers->others['mail-followup-to']))368 else if ($header=='followupto' && !empty($MESSAGE->headers->others['mail-followup-to'])) 354 369 $fvalue = $MESSAGE->get_header('mail-followup-to'); 355 356 $addresses = $IMAP->decode_address_list($fvalue); 357 $fvalue = ''; 358 359 foreach ($addresses as $addr_part) { 370 } 371 372 // split recipients and put them back together in a unique way 373 if (!empty($fvalue) && in_array($header, array('to', 'cc', 'bcc'))) { 374 $to_addresses = $IMAP->decode_address_list($fvalue); 375 $fvalue = array(); 376 377 foreach ($to_addresses as $addr_part) { 360 378 if (empty($addr_part['mailto'])) 361 379 continue; 362 380 363 $mailto = rcube_idn_to_utf8($addr_part['mailto']); 364 365 if ($addr_part['name'] && $addr_part['mailto'] != $addr_part['name']) 366 $string = format_email_recipient($mailto, $addr_part['name']); 367 else 368 $string = $mailto; 369 $fvalue .= (strlen($fvalue) ? ', ':'') . $string; 370 } 381 $mailto = mb_strtolower(rcube_idn_to_utf8($addr_part['mailto'])); 382 383 if (!in_array($mailto, $a_recipients) 384 && (empty($MESSAGE->compose['from_email']) || $mailto != $MESSAGE->compose['from_email']) 385 ) { 386 if ($addr_part['name'] && $addr_part['mailto'] != $addr_part['name']) 387 $string = format_email_recipient($mailto, $addr_part['name']); 388 else 389 $string = $mailto; 390 391 $fvalue[] = $string; 392 $a_recipients[] = $addr_part['mailto']; 393 } 394 } 395 396 $fvalue = implode(', ', $fvalue); 397 } 398 399 $MESSAGE->compose[$header] = $fvalue; 400 } 401 unset($a_recipients); 402 403 // process $MESSAGE body/attachments, set $MESSAGE_BODY/$HTML_MODE vars and some session data 404 $MESSAGE_BODY = rcmail_prepare_message_body(); 405 406 407 /****** compose mode functions ********/ 408 409 function rcmail_compose_headers($attrib) 410 { 411 global $MESSAGE; 412 413 list($form_start, $form_end) = get_form_tags($attrib); 414 415 $out = ''; 416 $part = strtolower($attrib['part']); 417 418 switch ($part) 419 { 420 case 'from': 421 return $form_start . rcmail_compose_header_from($attrib); 422 423 case 'to': 424 case 'cc': 425 case 'bcc': 426 $fname = '_' . $part; 427 $header = $param = $part; 428 429 $allow_attrib = array('id', 'class', 'style', 'cols', 'rows', 'tabindex'); 430 $field_type = 'html_textarea'; 431 break; 432 433 case 'replyto': 434 case 'reply-to': 435 $fname = '_replyto'; 436 $param = 'replyto'; 437 $header = 'reply-to'; 438 439 case 'followupto': 440 case 'followup-to': 441 if (!$fname) { 442 $fname = '_followupto'; 443 $param = 'followupto'; 444 $header = 'mail-followup-to'; 445 } 446 447 $allow_attrib = array('id', 'class', 'style', 'size', 'tabindex'); 448 $field_type = 'html_inputfield'; 449 break; 371 450 } 372 451 … … 381 460 // create teaxtarea object 382 461 $input = new $field_type($field_attrib); 383 $out = $input->show($ fvalue);462 $out = $input->show($MESSAGE->compose[$param]); 384 463 } 385 464 … … 393 472 function rcmail_compose_header_from($attrib) 394 473 { 395 global $ IMAP, $MESSAGE, $DB, $USER, $OUTPUT, $compose_mode;396 474 global $MESSAGE, $OUTPUT; 475 397 476 // pass the following attributes to the form class 398 477 $field_attrib = array('name' => '_from'); … … 401 480 $field_attrib[$attr] = $value; 402 481 403 // extract all recipients of the reply-message 404 $a_recipients = array(); 405 if ($compose_mode == RCUBE_COMPOSE_REPLY && is_object($MESSAGE->headers)) 406 { 407 $MESSAGE->compose_from = array(); 408 409 $a_to = $IMAP->decode_address_list($MESSAGE->headers->to); 410 foreach ($a_to as $addr) 411 { 412 if (!empty($addr['mailto'])) 413 $a_recipients[] = strtolower($addr['mailto']); 414 } 415 416 if (!empty($MESSAGE->headers->cc)) 417 { 418 $a_cc = $IMAP->decode_address_list($MESSAGE->headers->cc); 419 foreach ($a_cc as $addr) 420 { 421 if (!empty($addr['mailto'])) 422 $a_recipients[] = strtolower($addr['mailto']); 423 } 424 } 425 } 426 427 // get this user's identities 428 $user_identities = $USER->list_identities(); 429 430 if (count($user_identities)) 482 if (count($MESSAGE->identities)) 431 483 { 432 484 $a_signatures = array(); … … 436 488 437 489 // create SELECT element 438 foreach ($ user_identities as $sql_arr)490 foreach ($MESSAGE->identities as $sql_arr) 439 491 { 440 $email = mb_strtolower(rcube_idn_to_utf8($sql_arr['email']));441 492 $identity_id = $sql_arr['identity_id']; 442 $select_from->add(format_email_recipient($ email, $sql_arr['name']), $identity_id);493 $select_from->add(format_email_recipient($sql_arr['email'], $sql_arr['name']), $identity_id); 443 494 444 495 // add signature to array … … 453 504 } 454 505 } 455 456 if ($compose_mode == RCUBE_COMPOSE_REPLY && is_array($MESSAGE->compose_from)) 457 $MESSAGE->compose_from[] = $email; 458 } 459 460 $from_id = 0; 461 462 // overwrite identity selection with post parameter 463 if (!empty($_POST['_from'])) 464 $from_id = get_input_value('_from', RCUBE_INPUT_POST); 465 else if (!empty($_SESSION['compose']['param']['from'])) 466 $from_id = $_SESSION['compose']['param']['from']; 467 else { 468 $return_path = $MESSAGE->headers->others['return-path']; 469 470 // Set identity 471 foreach ($user_identities as $sql_arr) { 472 // set draft's identity 473 if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) { 474 if ($MESSAGE->headers->from == format_email_recipient($sql_arr['email'], $sql_arr['name'])) { 475 $from_id = $sql_arr['identity_id']; 476 break; 477 } 478 } 479 // set identity if it's one of the reply-message recipients (with prio for default identity) 480 else if (in_array($sql_arr['email'], $a_recipients) && (empty($from_id) || $sql_arr['standard'])) 481 $from_id = $sql_arr['identity_id']; 482 // set identity when replying to mailing list 483 else if (strpos($return_path, str_replace('@', '=', $sql_arr['email']).'@') !== false) 484 $from_id = $sql_arr['identity_id']; 485 486 if ($from_id) 487 break; 488 } 489 } 490 491 $out = $select_from->show($from_id); 506 } 507 508 $out = $select_from->show($MESSAGE->compose['from']); 492 509 493 510 // add signatures to client … … 498 515 $field_attrib['class'] = 'from_address'; 499 516 $input_from = new html_inputfield($field_attrib); 500 $out = $input_from->show($ _POST['_from']);517 $out = $input_from->show($MESSAGE->compose['from']); 501 518 } 502 519
Note: See TracChangeset
for help on using the changeset viewer.
