Changeset 8fa58e7 in github for program/steps/mail/compose.inc
- Timestamp:
- May 17, 2008 1:46:43 PM (5 years ago)
- Branches:
- master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
- Children:
- 26539d5f
- Parents:
- e2f958c
- File:
-
- 1 edited
-
program/steps/mail/compose.inc (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
program/steps/mail/compose.inc
r885ebb8 r8fa58e7 6 6 | | 7 7 | This file is part of the RoundCube Webmail client | 8 | Copyright (C) 2005-200 7, RoundCube Dev. - Switzerland |8 | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland | 9 9 | Licensed under the GNU GPL | 10 10 | | … … 86 86 { 87 87 // similar as in program/steps/mail/show.inc 88 $MESSAGE = array('UID' => $msg_uid); 89 $MESSAGE['headers'] = &$IMAP->get_headers($msg_uid); 90 $MESSAGE['structure'] = &$IMAP->get_structure($msg_uid); 91 92 if (!empty($MESSAGE['headers']->charset)) 93 $IMAP->set_charset($MESSAGE['headers']->charset); 88 $MESSAGE = new rcube_message($msg_uid); 89 90 if (!empty($MESSAGE->headers->charset)) 91 $IMAP->set_charset($MESSAGE->headers->charset); 94 92 95 $MESSAGE['subject'] = $IMAP->decode_header($MESSAGE['headers']->subject);96 $MESSAGE['parts'] = $IMAP->get_mime_numbers($MESSAGE['structure']);97 98 93 if ($compose_mode == RCUBE_COMPOSE_REPLY) 99 94 { 100 95 $_SESSION['compose']['reply_uid'] = $msg_uid; 101 $_SESSION['compose']['reply_msgid'] = $MESSAGE ['headers']->messageID;102 $_SESSION['compose']['references'] = trim($MESSAGE ['headers']->references . " " . $MESSAGE['headers']->messageID);96 $_SESSION['compose']['reply_msgid'] = $MESSAGE->headers->messageID; 97 $_SESSION['compose']['references'] = trim($MESSAGE->headers->references . " " . $MESSAGE->headers->messageID); 103 98 104 99 if (!empty($_GET['_all'])) 105 $MESSAGE ['reply_all']= 1;100 $MESSAGE->reply_all = 1; 106 101 } 107 102 else if ($compose_mode == RCUBE_COMPOSE_FORWARD) … … 174 169 { 175 170 // get recipent address(es) out of the message headers 176 if ($header=='to' && !empty($MESSAGE ['headers']->replyto))177 $fvalue = $MESSAGE ['headers']->replyto;178 179 else if ($header=='to' && !empty($MESSAGE ['headers']->from))180 $fvalue = $MESSAGE ['headers']->from;171 if ($header=='to' && !empty($MESSAGE->headers->replyto)) 172 $fvalue = $MESSAGE->headers->replyto; 173 174 else if ($header=='to' && !empty($MESSAGE->headers->from)) 175 $fvalue = $MESSAGE->headers->from; 181 176 182 177 // add recipent of original message if reply to all 183 else if ($header=='cc' && !empty($MESSAGE ['reply_all']))184 { 185 if ($v = $MESSAGE ['headers']->to)178 else if ($header=='cc' && !empty($MESSAGE->reply_all)) 179 { 180 if ($v = $MESSAGE->headers->to) 186 181 $fvalue .= $v; 187 182 188 if ($v = $MESSAGE ['headers']->cc)183 if ($v = $MESSAGE->headers->cc) 189 184 $fvalue .= (!empty($fvalue) ? ', ' : '') . $v; 190 185 } … … 197 192 foreach ($to_addresses as $addr_part) 198 193 { 199 if (!empty($addr_part['mailto']) && !in_array($addr_part['mailto'], $sa_recipients) && (!$MESSAGE ['FROM'] || !in_array($addr_part['mailto'], $MESSAGE['FROM'])))194 if (!empty($addr_part['mailto']) && !in_array($addr_part['mailto'], $sa_recipients) && (!$MESSAGE->compose_from || !in_array($addr_part['mailto'], $MESSAGE->compose_from))) 200 195 { 201 196 $fvalue .= (strlen($fvalue) ? ', ':'').$addr_part['string']; … … 208 203 { 209 204 // get drafted headers 210 if ($header=='to' && !empty($MESSAGE ['headers']->to))211 $fvalue = $ IMAP->decode_header($MESSAGE['headers']->to);212 213 if ($header=='cc' && !empty($MESSAGE ['headers']->cc))214 $fvalue = $ IMAP->decode_header($MESSAGE['headers']->cc);215 216 if ($header=='bcc' && !empty($MESSAGE ['headers']->bcc))217 $fvalue = $ IMAP->decode_header($MESSAGE['headers']->bcc);205 if ($header=='to' && !empty($MESSAGE->headers->to)) 206 $fvalue = $MESSAGE->get_header('to'); 207 208 if ($header=='cc' && !empty($MESSAGE->headers->cc)) 209 $fvalue = $MESSAGE->get_header('cc'); 210 211 if ($header=='bcc' && !empty($MESSAGE->headers->bcc)) 212 $fvalue = $MESSAGE->get_header('bcc'); 218 213 } 219 214 … … 242 237 function rcmail_compose_header_from($attrib) 243 238 { 244 global $IMAP, $MESSAGE, $DB, $USER, $OUTPUT, $ CONFIG, $compose_mode;239 global $IMAP, $MESSAGE, $DB, $USER, $OUTPUT, $compose_mode; 245 240 246 241 // pass the following attributes to the form class … … 252 247 // extract all recipients of the reply-message 253 248 $a_recipients = array(); 254 if ($compose_mode == RCUBE_COMPOSE_REPLY && is_object($MESSAGE ['headers']))255 { 256 $MESSAGE ['FROM']= array();257 258 $a_to = $IMAP->decode_address_list($MESSAGE ['headers']->to);249 if ($compose_mode == RCUBE_COMPOSE_REPLY && is_object($MESSAGE->headers)) 250 { 251 $MESSAGE->compose_from = array(); 252 253 $a_to = $IMAP->decode_address_list($MESSAGE->headers->to); 259 254 foreach ($a_to as $addr) 260 255 { … … 263 258 } 264 259 265 if (!empty($MESSAGE ['headers']->cc))266 { 267 $a_cc = $IMAP->decode_address_list($MESSAGE ['headers']->cc);260 if (!empty($MESSAGE->headers->cc)) 261 { 262 $a_cc = $IMAP->decode_address_list($MESSAGE->headers->cc); 268 263 foreach ($a_cc as $addr) 269 264 { … … 307 302 $from_id = $sql_arr['identity_id']; 308 303 309 if ($compose_mode == RCUBE_COMPOSE_REPLY && is_array($MESSAGE ['FROM']))310 $MESSAGE ['FROM'][] = $sql_arr['email'];311 312 if ($compose_mode == RCUBE_COMPOSE_DRAFT && strstr($MESSAGE ['headers']->from, $sql_arr['email']))304 if ($compose_mode == RCUBE_COMPOSE_REPLY && is_array($MESSAGE->compose_from)) 305 $MESSAGE->compose_from[] = $sql_arr['email']; 306 307 if ($compose_mode == RCUBE_COMPOSE_DRAFT && strstr($MESSAGE->headers->from, $sql_arr['email'])) 313 308 $from_id = $sql_arr['identity_id']; 314 309 } … … 357 352 // use posted message body 358 353 if (!empty($_POST['_message'])) 359 { 360 $body = get_input_value('_message', RCUBE_INPUT_POST, TRUE); 361 } 362 // compose reply-body 363 else if ($compose_mode == RCUBE_COMPOSE_REPLY) 364 { 365 $hasHtml = rcmail_has_html_part($MESSAGE['parts']); 366 if ($hasHtml && $CONFIG['htmleditor']) 367 { 368 $body = rcmail_first_html_part($MESSAGE); 354 { 355 $body = get_input_value('_message', RCUBE_INPUT_POST, true); 356 } 357 else if ($compose_mode) 358 { 359 if ($isHtml && $MESSAGE->has_html_part()) 360 { 361 $body = $MESSAGE->first_html_part(); 369 362 $isHtml = true; 370 }363 } 371 364 else 372 {373 $body = rcmail_first_text_part($MESSAGE);365 { 366 $body = $MESSAGE->first_text_part(); 374 367 $isHtml = false; 375 } 376 377 $body = rcmail_create_reply_body($body, $isHtml); 378 } 379 // forward message body inline 380 else if ($compose_mode == RCUBE_COMPOSE_FORWARD) 381 { 382 $hasHtml = rcmail_has_html_part($MESSAGE['parts']); 383 if ($hasHtml && $CONFIG['htmleditor']) 384 { 385 $body = rcmail_first_html_part($MESSAGE); 386 $isHtml = true; 387 } 388 else 389 { 390 $body = rcmail_first_text_part($MESSAGE); 391 $isHtml = false; 392 } 393 394 $body = rcmail_create_forward_body($body, $isHtml); 395 } 396 else if ($compose_mode == RCUBE_COMPOSE_DRAFT) 397 { 398 $hasHtml = rcmail_has_html_part($MESSAGE['parts']); 399 if ($hasHtml && $CONFIG['htmleditor']) 400 { 401 $body = rcmail_first_html_part($MESSAGE); 402 $isHtml = true; 403 } 404 else 405 { 406 $body = rcmail_first_text_part($MESSAGE); 407 $isHtml = false; 408 } 409 410 $body = rcmail_create_draft_body($body, $isHtml); 411 } 368 } 369 370 // compose reply-body 371 if ($compose_mode == RCUBE_COMPOSE_REPLY) 372 $body = rcmail_create_reply_body($body, $isHtml); 373 // forward message body inline 374 else if ($compose_mode == RCUBE_COMPOSE_FORWARD) 375 $body = rcmail_create_forward_body($body, $isHtml); 376 // load draft message body 377 else if ($compose_mode == RCUBE_COMPOSE_DRAFT) 378 $body = rcmail_create_draft_body($body, $isHtml); 379 } 412 380 413 381 $tinylang = substr($_SESSION['language'], 0, 2); 414 382 if (!file_exists('program/js/tiny_mce/langs/'.$tinylang.'.js')) 415 {416 383 $tinylang = 'en'; 417 }418 384 419 385 $OUTPUT->include_script('tiny_mce/tiny_mce.js'); … … 423 389 $out = $form_start ? "$form_start\n" : ''; 424 390 425 $saveid = new html_hiddenfield(array('name' => '_draft_saveid', 'value' => $compose_mode==RCUBE_COMPOSE_DRAFT ? str_replace(array('<','>'), "", $MESSAGE ['headers']->messageID) : ''));391 $saveid = new html_hiddenfield(array('name' => '_draft_saveid', 'value' => $compose_mode==RCUBE_COMPOSE_DRAFT ? str_replace(array('<','>'), "", $MESSAGE->headers->messageID) : '')); 426 392 $out .= $saveid->show(); 427 393 … … 501 467 // add title line 502 468 $prefix = sprintf("\n\n\nOn %s, %s wrote:\n", 503 $MESSAGE['headers']->date,504 $IMAP->decode_header($MESSAGE['headers']->from));469 $MESSAGE->headers->date, 470 $MESSAGE->get_header('from')); 505 471 506 472 // try to remove the signature … … 514 480 else 515 481 { 516 $prefix = sprintf("<br><br>On %s, %s wrote:<br><blockquote type=\"cite\" " . 517 "style=\"padding-left: 5px; border-left: #1010ff 2px solid; " . 518 "margin-left: 5px; width: 100%%\">", 519 $MESSAGE['headers']->date, 520 $IMAP->decode_header($MESSAGE['headers']->from)); 521 482 $prefix = sprintf("<br /><br />On %s, %s wrote:<br />\n", 483 $MESSAGE->headers->date, 484 Q($MESSAGE->get_header('from'))); 485 $prefix .= '<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%">'; 522 486 $suffix = "</blockquote>"; 523 487 } … … 531 495 global $IMAP, $MESSAGE; 532 496 533 if (! $bodyIsHtml)497 if (!$bodyIsHtml) 534 498 { 535 499 // soft-wrap message first … … 537 501 538 502 $prefix = sprintf("\n\n\n-------- Original Message --------\nSubject: %s\nDate: %s\nFrom: %s\nTo: %s\n\n", 539 $MESSAGE['subject'],540 $MESSAGE['headers']->date,541 $IMAP->decode_header($MESSAGE['headers']->from),542 $IMAP->decode_header($MESSAGE['headers']->to));503 $MESSAGE->subject, 504 $MESSAGE->headers->date, 505 $MESSAGE->get_header('from'), 506 $MESSAGE->get_header('to')); 543 507 } 544 508 else 545 509 { 546 510 $prefix = sprintf( 547 "<br><br>-------- Original Message --------" .511 "<br><br>-------- Original Message --------" . 548 512 "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tbody>" . 549 513 "<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">Subject: </th><td>%s</td></tr>" . … … 552 516 "<tr><th align=\"right\" nowrap=\"nowrap\" valign=\"baseline\">To: </th><td>%s</td></tr>" . 553 517 "</tbody></table><br>", 554 Q($MESSAGE['subject']),555 Q($MESSAGE['headers']->date),556 Q($IMAP->decode_header($MESSAGE['headers']->from)),557 Q($IMAP->decode_header($MESSAGE['headers']->to)));518 Q($MESSAGE->subject), 519 Q($MESSAGE->headers->date), 520 Q($MESSAGE->get_header('from')), 521 Q($MESSAGE->get_header('to'))); 558 522 } 559 523 560 524 // add attachments 561 if (!isset($_SESSION['compose']['forward_attachments']) && is_array($MESSAGE ['parts']))525 if (!isset($_SESSION['compose']['forward_attachments']) && is_array($MESSAGE->mime_parts)) 562 526 rcmail_write_compose_attachments($MESSAGE); 563 527 … … 568 532 function rcmail_create_draft_body($body, $bodyIsHtml) 569 533 { 570 global $ IMAP, $MESSAGE;534 global $MESSAGE; 571 535 572 536 /** 573 537 * add attachments 574 * sizeof($MESSAGE ['parts']can be 1 - e.g. attachment, but no text!538 * sizeof($MESSAGE->mime_parts can be 1 - e.g. attachment, but no text! 575 539 */ 576 540 if (!isset($_SESSION['compose']['forward_attachments']) 577 && is_array($MESSAGE ['parts'])578 && count($MESSAGE ['parts']) > 0)541 && is_array($MESSAGE->mime_parts) 542 && count($MESSAGE->mime_parts) > 0) 579 543 rcmail_write_compose_attachments($MESSAGE); 580 544 … … 585 549 function rcmail_write_compose_attachments(&$message) 586 550 { 587 global $ IMAP, $CONFIG;588 589 $temp_dir = unslashify($ CONFIG['temp_dir']);551 global $RCMAIL, $IMAP; 552 553 $temp_dir = unslashify($RCMAIL->config->get('temp_dir')); 590 554 591 555 if (!is_array($_SESSION['compose']['attachments'])) 592 556 $_SESSION['compose']['attachments'] = array(); 593 557 594 foreach ( $message['parts']as $pid => $part)558 foreach ((array)$message->mime_parts as $pid => $part) 595 559 { 596 560 if ($part->ctype_primary != 'message' && … … 601 565 if ($fp = fopen($tmp_path, 'w')) 602 566 { 603 fwrite($fp, $ IMAP->get_message_part($message['UID'], $pid, $part->encoding));567 fwrite($fp, $message->get_part_content($pid)); 604 568 fclose($fp); 605 569 … … 613 577 } 614 578 615 $_SESSION['compose']['forward_attachments'] = TRUE;579 $_SESSION['compose']['forward_attachments'] = true; 616 580 } 617 581 … … 619 583 function rcmail_compose_subject($attrib) 620 584 { 621 global $ CONFIG, $MESSAGE, $compose_mode;585 global $MESSAGE, $compose_mode; 622 586 623 587 list($form_start, $form_end) = get_form_tags($attrib); … … 636 600 else if ($compose_mode == RCUBE_COMPOSE_REPLY) 637 601 { 638 if (eregi('^re:', $MESSAGE ['subject']))639 $subject = $MESSAGE ['subject'];602 if (eregi('^re:', $MESSAGE->subject)) 603 $subject = $MESSAGE->subject; 640 604 else 641 $subject = 'Re: '.$MESSAGE ['subject'];605 $subject = 'Re: '.$MESSAGE->subject; 642 606 } 643 607 … … 645 609 else if ($compose_mode == RCUBE_COMPOSE_FORWARD) 646 610 { 647 if (eregi('^fwd:', $MESSAGE ['subject']))648 $subject = $MESSAGE ['subject'];611 if (eregi('^fwd:', $MESSAGE->subject)) 612 $subject = $MESSAGE->subject; 649 613 else 650 $subject = 'Fwd: '.$MESSAGE ['subject'];614 $subject = 'Fwd: '.$MESSAGE->subject; 651 615 } 652 616 653 617 // creeate a draft-subject 654 618 else if ($compose_mode == RCUBE_COMPOSE_DRAFT) 655 $subject = $MESSAGE ['subject'];619 $subject = $MESSAGE->subject; 656 620 657 621 $out = $form_start ? "$form_start\n" : ''; … … 671 635 $attrib['id'] = 'rcmAttachmentList'; 672 636 673 // allow the following attributes to be added to the <ul> tag 674 $attrib_str = create_attrib_string($attrib, array('id', 'class', 'style')); 675 676 $out = '<ul'. $attrib_str . ">\n"; 637 $out = "\n"; 677 638 678 639 if (is_array($_SESSION['compose']['attachments'])) 679 640 { 680 641 if ($attrib['deleteicon']) 681 $button = sprintf('<img src="%s%s" alt="%s" border="0" style="padding-right:2px;vertical-align:middle" />',682 $CONFIG['skin_path'],683 $attrib['deleteicon'],684 rcube_label('delete'));642 $button = html::img(array( 643 'src' => $CONFIG['skin_path'] . $attrib['deleteicon'], 644 'alt' => rcube_label('delete'), 645 'style' => "border:0;padding-right:2px;vertical-align:middle")); 685 646 else 686 $button = rcube_label('delete');647 $button = Q(rcube_label('delete')); 687 648 688 649 foreach ($_SESSION['compose']['attachments'] as $id => $a_prop) 689 $out .= sprintf('<li id="rcmfile%d"><a href="#delete" onclick="return %s.command(\'remove-attachment\',\'rcmfile%d\', this)" title="%s">%s</a>%s</li>', 690 $id, 691 JS_OBJECT_NAME, 692 $id, 693 Q(rcube_label('delete')), 694 $button, 695 Q($a_prop['name'])); 650 $out .= html::tag('li', array('id' => "rcmfile".$id), 651 html::a(array( 652 'href' => "#delete", 653 'title' => rcube_label('delete'), 654 'onclick' => sprintf("return %s.command(\'remove-attachment\',\'rcmfile%d\', this)", JS_OBJECT_NAME, $id)), 655 $button) . Q($a_prop['name'])); 696 656 } 697 657 698 658 $OUTPUT->add_gui_object('attachmentlist', $attrib['id']); 699 659 700 $out .= '</ul>'; 701 return $out; 660 return html::tag('ul', $attrib, $out, html::$common_attrib); 702 661 } 703 662 … … 753 712 array(5, 4, 0, 2, 1)); 754 713 755 $sel = isset($_POST['_priority']) ? $_POST['_priority'] : intval($MESSAGE ['headers']->priority);714 $sel = isset($_POST['_priority']) ? $_POST['_priority'] : intval($MESSAGE->headers->priority); 756 715 757 716 $out = $form_start ? "$form_start\n" : ''; … … 778 737 779 738 $out = $form_start ? "$form_start\n" : ''; 780 $out .= $checkbox->show($MESSAGE ['headers']->mdn_to ? 1 : 0);739 $out .= $checkbox->show($MESSAGE->headers->mdn_to ? 1 : 0); 781 740 $out .= $form_end ? "\n$form_end" : ''; 782 741 … … 794 753 ); 795 754 796 // determine whether HTML or plain text should be checked 797 if ($CONFIG['htmleditor']) 798 { 799 $useHtml = true; 800 } 801 else 802 { 803 $useHtml = false; 804 } 805 806 if ($compose_mode == RCUBE_COMPOSE_REPLY || 807 $compose_mode == RCUBE_COMPOSE_FORWARD || 808 $compose_mode == RCUBE_COMPOSE_DRAFT) 809 { 810 $hasHtml = rcmail_has_html_part($MESSAGE['parts']); 811 $useHtml = ($hasHtml && $CONFIG['htmleditor']); 812 } 813 755 // determine whether HTML or plain text should be checked 756 $useHtml = $CONFIG['htmleditor'] ? true : false; 757 758 if ($compose_mode) 759 $useHtml = ($useHtml && $MESSAGE->has_html_part()); 760 761 $selector = ''; 814 762 $chosenvalue = $useHtml ? 'html' : 'plain'; 815 816 $selector = ''; 817 818 $attrib['name'] = '_editorSelect'; 819 $attrib['onclick'] = 'return rcmail_toggle_editor(this)'; 763 $radio = new html_radiobutton(array('name' => '_editorSelect', 'onclick' => 'return rcmail_toggle_editor(this)')); 820 764 foreach ($choices as $value => $text) 821 765 { 822 766 $attrib['id'] = '_' . $value; 823 767 $attrib['value'] = $value; 824 $rb = new html_radiobutton($attrib); 825 $selector .= sprintf("%s<label for=\"%s\">%s</label>", 826 $rb->show($chosenvalue), 827 $attrib['id'], 828 rcube_label($text)); 768 $selector .= $radio->show($chosenvalue, $attrib) . html::label($attrib['id'], Q(rcube_label($text))); 829 769 } 830 770
Note: See TracChangeset
for help on using the changeset viewer.
