📄 compose.inc
字号:
<?php
/** * @copyright Intermesh 2003 * @author Merijn Schering <mschering@intermesh.nl> * @version $Revision: 1.131 $ $Date: 2006/03/29 11:23:56 $ * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */
if ($ab_module) {
echo $ab->enable_contact_selector();
}
//replace signatures when user changed his mail account
$old_signature = isset ($_REQUEST['old_signature']) ? $_REQUEST['old_signature'] : '';
if ($sendaction == 'change_mail_from' && $old_signature != '') {
$mail_body = str_replace($old_signature, $signature, $mail_body);
}
//check for the templates plugin
if ($sendaction == 'load_template') {
require_once ($GO_CONFIG->class_path.'mail/mimeDecode.class.inc');
$template_body = '';
if ($template_id > 0) {
//if contact_id is not set but email is check if there's contact info available
if ($mail_to != '' && $contact_id == 0) {
if ($contact = $ab->get_contact_by_email($mail_to, $GO_SECURITY->user_id)) {
$contact_id = $contact['id'];
}
}
$template = $tp->get_template($template_id);
//get the raw mime message and decode it.
$part_number = 0;
$url_replacements = array ();
$attachments = array ();
$params['include_bodies'] = true;
$params['decode_bodies'] = true;
$params['decode_headers'] = true;
$params['input'] = $template['content'];
$structure = Mail_mimeDecode :: decode($params);
$notification_check = isset ($structure->headers['disposition-notification-to']) ? true : false;
$_SESSION['url_replacements'] = array ();
//loop through all parts
if (isset ($structure->parts)) {
foreach ($structure->parts as $part) {
$disposition = isset ($part->disposition) ? $part->disposition : '';
//text part and no attachment so it must be the body
if ($part->ctype_primary == 'text' && $disposition != 'attachment') {
//convert text to html
if (eregi('plain', $part->ctype_primary)) {
$text_part = nl2br($part->body);
} else {
$text_part = $part->body;
}
$template_body .= $text_part;
} else {
//save attachments to a temporarily file
$tmp_file = $GO_CONFIG->tmpdir.md5(uniqid(time()));
$fp = fopen($tmp_file, "w");
fwrite($fp, $part->body);
fclose($fp);
$filename = isset ($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
$content_id = isset ($part->headers['content-id']) ? trim($part->headers['content-id']) : '';
if ($content_id != '') {
if (strpos($content_id, '>')) {
$content_id = substr($part->headers['content-id'], 1, strlen($part->headers['content-id']) - 2);
}
//replace inline images identified by a content id with the url to display the part by Group-Office
$url_replacement['id'] = $content_id;
$url_replacement['url'] = $ab_module['url'].'templates/mime_part.php?template_id='.$template_id.'&part_number='.$part_number;
$_SESSION['url_replacements'][] = $url_replacement;
}
$email->register_attachment($tmp_file, $filename, strlen($part->body), $part->ctype_primary.'/'.$part->ctype_secondary, $disposition, $content_id);
}
$part_number ++;
}
}
elseif (isset ($structure->body)) {
//convert text to html
if (eregi('plain', $structure->ctype_primary)) {
$text_part = nl2br($structure->body);
} else {
$text_part = $structure->body;
}
$template_body .= $text_part;
}
unset ($structure);
//replace inline images with the url to display the part by Group-Office
if (isset ($_SESSION['url_replacements'])) {
for ($i = 0; $i < count($_SESSION['url_replacements']); $i ++) {
$template_body = str_replace('cid:'.$_SESSION['url_replacements'][$i]['id'], $_SESSION['url_replacements'][$i]['url'], $template_body);
}
}
//get the addressbook language file
require_once ($GO_LANGUAGE->get_language_file('addressbook'));
if ($mailing_group_id == 0) {
if ($company_id > 0) {
$template_body = $tp->replace_company_data_fields($template_body, $company_id);
} else {
$template_body = $tp->replace_data_fields($template_body, $contact_id);
}
}
if ($pos = strpos($mail_body, '<body')) {
$end_body_pos = strpos($mail_body, '>', $pos);
$first_part = substr($mail_body, 0, $end_body_pos);
$last_part = substr($mail_body, $end_body_pos +1);
$mail_body = $first_part.$template_body.$last_part;
} else {
$mail_body = $template_body.$mail_body;
}
}
}
?>
<form name="sendform" enctype="multipart/form-data" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden" name="sendaction" value="" />
<input type="hidden" name="show_cc" value="<?php echo $show_cc; ?>" />
<input type="hidden" name="show_bcc" value="<?php echo $show_bcc; ?>" />
<?php
if ($uid > 0) {
echo '<input type="hidden" name="uid" value="'.$uid.'" />';
echo '<input type="hidden" name="mailbox" value="'.$_REQUEST['mailbox'].'" />';
echo '<input type="hidden" name="action" value="'.$_REQUEST['action'].'" />';
}
echo '<input type="hidden" name="old_signature" value="'.htmlspecialchars($signature).'" />';
if (isset ($feedback))
echo $feedback;
?>
<input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $GO_CONFIG->max_attachment_size; ?>" />
<table cellspacing="2" cellpadding="1" border="0" width="100%" height="100%">
<?php
if ($count > 1) {
echo '<tr><td>'.$ml_from.':</td><td colspan="2">';
$dropbox = new dropbox();
$dropbox->add_arrays($ids, $names);
$dropbox->print_dropbox('mail_from', $mail_from, 'onchange="javascript:change_mail_from()"');
echo '</td></tr>';
}
elseif ($count > 0) {
echo '<input type="hidden" name="mail_from" value="'.$ids[0].'" />';
}
if ($mailing_group_id > 0 && $mailing_group = $tp->get_mailing_group($mailing_group_id)) {
echo '<input type="hidden" name="mailing_group_id" value="'.$mailing_group_id.'" />';
echo '<tr><td>'.$ml_to.': </td><td>'.$mailing_group['name'].'</td></tr>';
} else {
?>
<tr>
<td valign="top">
<?php
if ($ab_module) {
echo '<a class="normal" href="'.$ab->select_contacts('document.sendform.mail_to', $GO_CONFIG->control_url.'select/add.php').'">';
echo '<img src="'.$GO_THEME->images['addressbook_small'].'" width="16" height="16" border="0" align="absmiddle" '.'style="padding-right: 3px;" />'.$ml_to.'</a> : ';
} else {
echo $ml_to.': ';
}
if ($show_cc == 'false' || $show_bcc == 'false') {
echo '<span id="show_buttons">(';
if ($show_cc == 'false') {
echo '<a class="normal" id="cc_opener" href="javascript:show_cc();">CC</a>';
}
if ($show_cc == 'false' && $show_bcc == 'false') {
echo '<span id="sep"> | </span>';
}
if ($show_bcc == 'false') {
echo '<a class="normal" id="bcc_opener" href="javascript:show_bcc();">BCC</a>';
}
echo ')</span>';
}
?>
</td>
<td colspan="2">
<textarea <?php if(isset($autocomplete_contacts)) echo 'onfocus="document.onkeypress = kH;" onkeydown="actb_checkkey(event);" onkeyup="actb_tocomplete(this,event,autocomplete_contacts)" onblur="actb_removedisp(this);document.onkeypress = \'\';"'; ?> class="textbox" type="text" name="mail_to" style="width:100%;height:46px;"><?php echo (isset($mail_to) ? htmlspecialchars($mail_to) : ''); ?></textarea>
</td>
</tr>
<tr <?php if($show_cc == 'false') echo 'style="display:none;"'; ?> id="cc_row">
<td valign="top">
<?php
if ($ab_module) {
echo '<a class="normal" href="'.$ab->select_contacts('document.sendform.mail_cc', $GO_CONFIG->control_url.'select/add.php').'">';
echo '<img src="'.$GO_THEME->images['addressbook_small'].'" width="16" height="16" border="0" align="absmiddle" '.'style="padding-right: 3px;" />CC</a> :';
} else {
echo 'CC :';
}
?>
</td>
<td colspan="2">
<textarea <?php if(isset($autocomplete_contacts)) echo 'onfocus="document.onkeypress = kH;" onkeydown="actb_checkkey(event);" onkeyup="actb_tocomplete(this,event,autocomplete_contacts)" onblur="actb_removedisp(this);document.onkeypress=\'\';"'; ?> class="textbox" type="text" name="mail_cc" style="width:100%;height:46px;"><?php echo (isset($mail_cc) ? htmlspecialchars( $mail_cc) : '') ?></textarea>
</td>
</tr>
<tr <?php if($show_bcc == 'false') echo 'style="display:none;"'; ?> id="bcc_row">
<td valign="top">
<?php
if ($ab_module) {
echo '<a class="normal" href="'.$ab->select_contacts('document.sendform.mail_bcc', $GO_CONFIG->control_url.'select/add.php').'">';
echo '<img src="'.$GO_THEME->images['addressbook_small'].'" width="16" height="16" border="0" align="absmiddle" '.'style="padding-right: 3px;" />BCC</a> :';
} else {
echo 'BCC :';
}
?>
</td>
<td colspan="2"><textarea <?php if(isset($autocomplete_contacts)) echo 'onfocus="document.onkeypress = kH;" onkeydown="actb_checkkey(event);" onkeyup="actb_tocomplete(this,event,autocomplete_contacts)" onblur="actb_removedisp(this);document.onkeypress=\'\';"'; ?>class="textbox" type="text" name="mail_bcc" style="width:100%;height:46px;"><?php echo (isset($mail_bcc) ? htmlspecialchars($mail_bcc) : '') ?></textarea></td>
</tr>
<?php
} //endif mailing_group_id
?>
<tr>
<td ><?php echo $ml_subject ?> : </td>
<td colspan="2"><input class="textbox" type="text" name="mail_subject" style="width:100%" value="<?php echo (isset($mail_subject) ? htmlspecialchars($mail_subject) : '') ?>" /></td>
</tr>
<tr>
<td valign="top"><?php echo $ml_priority ?> : </td>
<td valign="top">
<?php
$priority = isset ($_POST['priority']) ? $_POST['priority'] : '3';
$dropbox = new dropbox();
$dropbox->add_value('1', $ml_high);
$dropbox->add_value('3', $ml_normal);
$dropbox->add_value('5', $ml_low);
$dropbox->print_dropbox('priority', $priority);
echo '</td><td align="right">';
$checkbox = new checkbox('notification','notification', 'true', $ml_notification, $notification_check);echo $checkbox->get_html();
?>
</td>
</tr>
<tr>
<td>
<?php
if ($wysiwyg) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -