<?if(VALID_DOCUMENT != 1) die('what?');?>
<script type="text/javascript" src="./rte/html2xhtml.js"></script>
<script type="text/javascript" src="./rte/html2text.js"></script>
<script type="text/javascript" src="./rte/richtext.js"></script>
<script type="text/javascript" src="./scripts/jquery.resizable.js"></script>
<script type="text/javascript" src="./scripts/jquery.autocomplete.js"></script>
<div id="info"></div>
<script type="text/javascript"><!--
$(document).ready(function(){
$('#raw_text').resizable();
$('#field-to,#field-cc,#field-bcc').autocomplete(
{ ajax_get:function(q,cont){ webmail_request('addressbook-query','q='+q, function(res){cont(res);}, 'json'); } ,
minchars : 1,
autowidth: true,
multi : true});
});
// init RTE
RTEConfig.init("./rte", "./themes/default.css");
var is_ie = (navigator.userAgent.toLowerCase().indexOf("msie") != -1);
var rte_editor = false;
function switchEditor(no_pre){
var raw_text = document.getElementById('raw_text');
// clean
if(rte_editor){
if(!no_pre &&
!confirm("Coverting this message to plain text will lose HTML formattings.\n"+
"Continue?")){
return;
}
// mime type to plain
document['compose_form']['mime-type'].value = 'text/plain';
// get source
var body = getRteSource(rte_editor,'text');
// remove rte
disableRte(rte_editor);
rte_editor = false;
// set textarea
$('#raw_div').show();
raw_text.value = body;
// change text for switch link
var link = document.getElementById('html-editor-switch');
link.removeChild(link.childNodes[0]);
link.appendChild(document.createTextNode('\u00AB Enable rich text formatting'));
// enable spell check
var spell = document.getElementById('spell-check-1');
spell.style.display = '';
var spell = document.getElementById('spell-check-2');
spell.style.display = '';
}
else{
// mime type to html
document['compose_form']['mime-type'].value = 'text/html';
// change text for switch link
var link = document.getElementById('html-editor-switch');
link.removeChild(link.childNodes[0]);
link.appendChild(document.createTextNode('\u00AB Disable rich text formatting'));
// no spell check
var spell = document.getElementById('spell-check-1');
spell.style.display = 'none';
var spell = document.getElementById('spell-check-2');
spell.style.display = 'none';
// take body
var body = raw_text.value;
// textare off
$('#raw_div').hide();
if(!no_pre){
body = body.replace(/&/g,"&");
body = body.replace(/ /g," ");
body = body.replace(/</g,"<");
body = body.replace(/>/g,">");
body = body.replace(/\n/g,"<br/>\n");
}
rte_editor = enableRichText('rte_div',body,'100%',300);
$('#'+rte_editor).resizable();
}
return true;
}
var num = 0;
function add_attachment(name){
num++;
uniq = "div_"+num;
str =
'<div id="'+uniq+'">'+
'<img src="./images/attach.gif"> '+
'<input type="file" name="'+name+'" accept="*/*" size="40">'+
' '+
'<a onClick="remove(\''+uniq+'\');">remove</a>'+
"</div>\n";
var newDiv = document.createElement('div');
newDiv.setAttribute('id',uniq);
var img = document.createElement('img');
img.setAttribute('src','./images/attach.gif');
newDiv.appendChild(img);
newDiv.appendChild(document.createTextNode(' '));
var inp = document.createElement('input');
inp.setAttribute('type','file'); inp.setAttribute('name',name);inp.setAttribute('size','40');
newDiv.appendChild(inp);
newDiv.appendChild(document.createTextNode(' '));
var rem = document.createElement('a');
rem.setAttribute('onClick',"remove('"+uniq+"')");
rem.onclick = new Function("remove('"+uniq+"')");
rem.appendChild(document.createTextNode('remove'));
newDiv.appendChild(rem);
var div = document.getElementById('files_div');
div.appendChild(newDiv);
document['compose_form']['attachments_num'].value++;
}
function remove(id){
var div = document.getElementById('files_div');
var forRemove = document.getElementById(id);
div.removeChild(forRemove);
document['compose_form']['attachments_num'].value--;
}
function address_chooser(type,el){
var off = $(el).offset();
$('iframe.address-chooser:visible').not('#address-chooser-'+type).hide();
$('#address-chooser-'+type).css({top:off.top+$(el).height(),left:off.left+2}).show();
}
function choose_one(val,type){
var el = parent.document.compose_form[type];
if(el.value != "") el.value += ",";
el.value += val;
}
function close_choose(type){
$('#address-chooser-'+type).hide();
}
// open spell check windows
function spell_check(){
var form = document['compose_form'];
updateText();
w = window.open("","spell_check","width=540,height=500,resizable,scrollbars");
if(!w.opener)
w.opener = window;
else
w.focus();
form.target='spell_check';
form['action'].value='compose-spell-check';
form.submit();
}
// postpone
function postpone(){
var form = document['compose_form'];
form.target='_self';
form['action'].value='compose-postpone';
my_submit();
}
// cancel composing
function cancel_compose(){
document.location.href= '<?=$_SERVER['PHP_SELF']?>?action=<?=($_REQUEST['standalone'] == 'true')?'preview-mail':'read-mail'?>&mailbox=<?=$_SESSION['last_mailbox']?>&mailkey=<?=$_SESSION['last_mailkey']?>';
}
function check_and_send(){
var form = document['compose_form'];
if(!form['to'].value && !form['cc'].value && !form['bcc'].value){
alert('Fill some destination addresses');
return;
}
if(!form['subject'].value && !confirm("No subject\nSend e-mail without subject?")){
return;
}
form.target='_self';
form['action'].value='compose-send';
my_submit();
}
function updateText(){
form = document['compose_form'];
if(rte_editor){
form['text'].value = getRteSource(rte_editor);
}
else{
form['text'].value = document.getElementById('raw_text').value;
}
}
function my_submit(){
form = document['compose_form'];
updateText();
form.submit();
return true;
}
//--></script>
<form action="<?=$_SERVER['PHP_SELF']?>" enctype="multipart/form-data" method="post" name="compose_form" id="compose_form">
<input type="hidden" name="action"/>
<input type="hidden" name="text"/>
<input type="hidden" name="mime-type" value="text/plain"/>
<?if($_REQUEST['standalone'] == 'true'){?>
<input type="hidden" name="standalone" value="true"/>
<?}?>
<?if(isset($reply_message_id)){?>
<input type="hidden" name="reply-message-id" value="<?=htmlspecialchars($reply_message_id)?>"/>
<?}?>
<table class="w100">
<tr><th colspan="2" class="title"><b>Compose</b></th></tr>
<tr>
<td><a onclick="address_chooser('to',this);" title="choose address">To</a></td>
<td class="w100">
<textarea tabindex="1" name="to" id="field-to" class="w100" autocomplete="off" style="height:4em"/><?=htmlspecialchars($to)?></textarea>
</td>
</tr>
<tr id="cc-row" <?=!$cc?'style="display:none"':''?>>
<td><a onclick="address_chooser('cc',this);" title="choose address">CC</a></td>
<td>
<textarea tabindex="2" name="cc" id="field-cc" class="w100" autocomplete="off" style="height:4em"/><?=htmlspecialchars($cc)?></textarea>
</td>
</tr>
<tr id="bcc-row" <?=!$bcc?'style="display:none"':''?>>
<td><a onclick="address_chooser('bcc',this);" title="choose address">BCC</a></td>
<td>
<textarea tabindex="3" name="bcc" id="field-bcc" class="w100" autocomplete="off" style="height:4em"/><?=htmlspecialchars($bcc)?></textarea>
</td>
</tr>
<tr>
<td class="small"></td>
<td class="small">
<?if(!$cc){?>
<a onclick="$(this).hide();$('#cc-row').show();">add Cc</a>
<?}?>
<?if(!$bcc){?>
<a onclick="$(this).hide();$('#bcc-row').show();">add Bcc</a>
<?}?>
</td>
</tr>
<tr><td colspan="2" class="regular">
<?if($_SESSION['preferences']->getRememberAddresses()){?>
<input type="checkbox" name="remember-addresses" value="true" checked="checked"/>Remember new addresses
<?}?>
<?if($_SESSION['preferences']->getUseDispositionNotification()){?>
<input type="checkbox" name="notify" value="true"/>Request read receipt
<?}?>
<?if($_SESSION['preferences']->getUseGnuPG()){?>
<input type="checkbox" name="encrypt" value="true" <?=$encrypt?'checked="checked"':''?>/>Encrypt message
<?
require_once('simple_gpg.php');
$gpg = new SimpleGPG();
$skey = $gpg->getSecretKey();
if($skey){
list($skey_id) = $gpg->getKeyInfo($skey);
$chk = $_SESSION['preferences']->getUseGnuPGSignature();
?>
<input type="checkbox" name="sign" value="true" onchange="$('#sign-warn').toggle();" <?=$chk?'checked':''?>/>Sign message
<?if(!Cache::haveCachedGPGPassphrase()){?>
<div class="red" id="sign-warn" style="<?=!$chk?'display:none;':''?>padding-left:10em;">
You need a passphrase to unlock<br/> the secret key <?=$skey_id?>
<input type="password" name="password"/>
</div>
<?}?>
<?}else{?>
<input type="checkbox" onchange="$('#sign-warn').toggle();"/>Sign message
<div class="red bold" id="sign-warn" style="display:none;padding-left:10em;">
In order to add digital signatures into your email,<br/>
you must to <?=action_link('gnupg','create or import private key')?> .<br/>
</div>
<?}?>
<?}?>
</td></tr>
<tr>
<td class="bold">Subject</td>
<td><input tabindex="4" name="subject" value="<?=htmlspecialchars($subject); ?>" type="text" class="w100"/></td>
</tr>
<?if(isset($attachmailbox) && isset($attachmailkey)){?>
<tr><td colspan="2">
<input name="attachmailbox" value="<?=$attachmailbox?>" type="hidden"/>
<input name="attachmailkey" value="<?=$attachmailkey?>" type="hidden"/>
<hr/>
<b>Attachments of mail №<?=$attachmailkey; ?> from <?=$attachmailbox; ?>:</b><br/>
<?foreach($mail->parts as $k=>$p){
if($p->if_for_forward())
print '<input type="checkbox" name="attach-parts[]" value="'.$k.'" checked="checked"/>'.
'<a href="'.$_SERVER['PHP_SELF'].'?action=get-part&mailbox='.$attachmailbox.'&mailkey='.$attachmailkey.'&part='.$p->part.'">'.
($p->filename?$p->filename:'untitled part').
'</a> , '.
strtolower($p->mime_type).' ['.bytes2string($p->size).']'.
"<br/>\n";
}?>
</td></tr>
<?}?>
<tr><td colspan="2">
<input type="hidden" name="MAX_FILE_SIZE" value="<?=MAXFILESIZE?>"/>
<input name="attachments_num" value="0" type="hidden"/>
<div id="files_div"></div>
<a onclick="add_attachment('attachment[]')">add new attachment</a>
<noscript>
<?for($i=0;$i<ATTACHMENTS_NUM;$i++){
print '<b>Attachment '.($i+1).'</b>'."\n";
print '<input type="file" size="20" name="attachment[]" accept="*/*"/><br/>';
}?>
</noscript>
</td></tr>
<tr><th colspan="2" class="left normal regular">
<input value="send" type="button" onclick="check_and_send();"/>
<input value="reset" type="reset"/>
<input value="spell check" type="button" onclick="spell_check()" id="spell-check-1"/>
<input value="postpone" type="button" onclick="postpone();"/>
<input value="cancel" type="button" onclick="cancel_compose();"/>
<a id="html-editor-switch" onclick="switchEditor();">« Enable rich formatting</a>
</th></tr>
<tr><td align="left" colspan="2">
<div id="rte_div"></div>
<div id="raw_div">
<textarea tabindex="5" id="raw_text" rows="17" nowrap="nowrap" class="w100"><?=h($text);?></textarea>
</div>
</td></tr>
<tr><th colspan="2" class="left normal regular">
<input tabindex="5" value="send" type="button" onclick="check_and_send();"/>
<input value="reset" type="reset"/>
<input value="spell check" type="button" onclick="spell_check();" id="spell-check-2"/>
<input value="postpone" type="button" onclick="postpone();"/>
<input value="cancel" type="button" onclick="cancel_compose();"/>
<br/>
<b>Priority: </b>
<select name="priority">
<?foreach($GLOBALS['EMAIL_PRIORITIES'] as $k=>$p){?>
<option value="<?=$k?>"><?=$p['name']?></option>
<?}?>
</select>
</th></tr>
</table>
</form>
<?if($init_html){?>
<script type="text/javascript">
switchEditor(true);
// setTimeout("switchEditor(true)",5);
</script>
<?}?>
<?foreach(array('to','cc','bcc') as $type){?>
<iframe width="400px" height="300px" id="address-chooser-<?=$type?>" src="<?=$_SERVER['PHP_SELF']?>?action=addressbook-choose&type=<?=$type?>&<?=sid()?>" marginwidth="0" marginheight="0" scrolling="auto" style="display:none;display:none;position: absolute;background-color: white;overflow-x: hidden;overflow-y: scroll;" class="address-chooser"></iframe>
<?}?>