Show compose.html syntax highlighted
% # vim: set syntax=mason:
<%args>
$to => ''
$subject => ''
$new => 0
$message => ''
$spelling_checked => 0
</%args>
<& /mail/header.mhtml, message => $message, title => 'Compose', compose => 1,
confirm_controls => 'Abort this compose?' &>
% if($user->getAttribute('javascript')) {
<script type="text/javascript" language="JavaScript">
<!--
var collection = [ <% join(",\n", map { qq(") . mimewords_to_utf8($_) . qq(") } @addresses) %> ];
function checkForm() {
answer = true;
if(typeof(siw) != "undefined")
if(siw && typeof(siw.selectingSomething) != "undefined")
if(siw.selectingSomething)
answer = false;
return answer;
}
function addAttachment() {
var fin = document.getElementById('fileInputNode');
var linkNode = document.getElementById('attachmentLinkNode');
linkNode.style.display = "none";
fin.style.display = "block";
return 1;
}
function dropAttachment(id) {
var att = document.getElementById(id);
var parent = att.parentNode;
parent.removeChild(att);
}
// -->
</script>
% }
<form method="post" action="<% $base %>/mail/process_compose.html"
id="header" name="compose_form"
onSubmit="return checkForm()"
enctype="multipart/form-data">
<div class="controls">
<!-- "Invisible" button used to prevent sends when a users hits enter
in some browsers -->
<input style="position: absolute; top: -40px; left:-40px; width: 0px; height: 0px;" name="noop" type="submit" value="">
<input name="send" type="submit" value="Send Message">
<input type="hidden" name="spelling_checked" value="<% $spelling_checked %>">
<input type="submit" name="address" value="Use Address Book">
<input type="submit" name="spellcheck" value="Check Spelling">
% if($drafts ne 'none') {
<input type="submit" name="save" value="Save Draft">
% }
<input type="submit" name="cancel" value="Cancel">
</div>
<table onkeydown="return suppressArrows(event)" class="composition_form">
<tr>
<td class="composition_field_label">
<div class="composition_field_label">
To:
</div>
</td>
<td>
<div class="composition_input">
<input autocomplete="off" type="text" class="wickEnabled" id="to" name="to" value="<% $composition->{to} |h %>">
</div>
</td>
</tr><tr>
<td class="composition_field_label">
<div class="composition_field_label">
Cc:
</div>
</td>
<td>
<div class="composition_input">
<input autocomplete="off" type="text" class="wickEnabled" name="cc" value="<% $composition->{cc} |h %>">
</div>
</td>
</tr><tr>
<td class="composition_field_label">
<div class="composition_field_label">
Bcc:
</div>
</td>
<td>
<div class="composition_input">
<input autocomplete="off" type="text" class="wickEnabled" name="bcc" value="<% $composition->{bcc} |h %>">
</div>
</td>
</tr>
<tr>
<td class="composition_field_label">
<div class="composition_field_label">
Subject:
</div>
</td>
<td>
<div class="composition_input">
<input class="addr_field" name="subject" value="<% $composition->getSubject() |h %>" type="text" size="80">
</div>
</td>
</tr>
<tr>
<td></td>
<td>
% if($composition->hasAttachments()) {
% for(my $i =0; $i < @{$attachments}; $i++) {
% if($user->getAttribute('javascript')) {
<div id="attachment_<% $i %>">
<input type="hidden" name="attachment_<% $i %>" value="1">
<% mimewords_to_utf8($attachments->[$i]{filename}) |h %>
(<% size_with_units($attachments->[$i]{size}) %>)
<a class="simlink" onclick="dropAttachment('<% "attachment_$i" %>');">remove</a>
<br>
</div>
% } else {
<input type="checkbox" checked name="attachment_<% $i %>" value="1">
<% mimewords_to_utf8($attachments->[$i]{filename}) |h %>
(<% size_with_units($attachments->[$i]{size}) %>) (uncheck and click update to remove)<br>
% }
% }
% }
<div id="attachment_files">
% if($user->getAttribute('javascript')) {
<A id="attachmentLinkNode" class="simlink" onclick="addAttachment()">Attach a<% $composition->hasAttachments() ? "nother":"" %> file...</A>
<div id="fileInputNode">
<input onchange="setMessage('Uploading attachment...please wait') && document.compose_form.submit()" type="file" name="file">
</div>
<SCRIPT LANGUAGE="JavaScript">
<!--
document.getElementById('fileInputNode').style.display = "none";
// -->
</SCRIPT>
% } else {
<div id="fileInputNode">
<input type="file" name="file">
</div>
<input type="submit" name="add_another" value="Add another">
<input type="submit" name="update" value="Update">
% }
</div>
</td>
</tr>
<tr>
<td colspan="2">
<textarea onfocus="ie_cursorhack()" class="message_field" rows="20" cols="72" name="body" id="body"><% $composition->getBody |h %></textarea>
</td>
</tr>
</table>
<div class="controls">
<input name="send" type="submit" value="Send Message">
<input type="submit" name="address" value="Use Address Book">
<input type="submit" name="spellcheck" value="Check Spelling">
% if($drafts ne 'none') {
<input type="submit" name="save" value="Save Draft">
% }
<input type="submit" name="cancel" value="Cancel">
</div>
</form>
<script type="text/javascript" language="javascript">
<!--
// Put the cursor at the beginning of the composition
var theBody = document.getElementById('body');
var firstfld = document.getElementById('to');
var posset = 0;
theBody.selectionStart = 0;
theBody.selectionEnd = 0;
firstfld.focus();
firstfld.select();
function ie_cursorhack()
{
if(posset) return;
posset = 1;
if(theBody.createTextRange) {
var range = theBody.createTextRange();
range.collapse(true);
range.select();
}
}
// -->
</script>
<script type="text/javascript" language="JavaScript" src="<% $base %>/static/wick.js"></script>
<& /mail/footer.mhtml &>
<%init>
my $user = Apache2::SiteControl->getCurrentUser($r);
if(!$user || !$user->isa('Apache2::SiteControl::User')) {
$logger->error("Unable to find a user for the given session key. r, m:" . Dumper($r, $m));
$m->redirect("/");
}
my $folder = $user->getAttribute('lastfolder') || 'inbox';
my $book = new AlphaMail::AddressBook($user->getUsername(), $user->getAttribute('mx'), $config);
my $addresses = $book->get_all->{addresses};
my $lists = $book->get_all->{lists};
my @addresses;
my $reply_address;
my $prefs = new AlphaMail::Preferences($user->getUsername(),
$user->getAttribute('mx'), $config);
my ($cc, $bcc);
my $attachments;
my $drafts = $prefs->get('drafts_folder', $config->get("default_drafts", 'none'));
my $composition = new AlphaMail::Message($user, $config);
if($new || $to || $subject) { # Incoming subject/to field. Force a new composition
$composition->setBody('');
$composition->setAddresses($to, '', '');
$composition->setSubject($subject);
$composition->save();
} else {
$composition->load();
$logger->debug("Loading composition");
($to, $cc, $bcc) = $composition->getAddresses();
$subject = $composition->getSubject;
$attachments = $composition->getAttachments;
}
if($prefs->get('replyto') =~ m/\@/) {
$reply_address = $prefs->get('replyto');
} else {
$reply_address = $user->getUsername() . '@' . $user->getAttribute('mx');
}
for my $k (keys %$addresses)
{
push @addresses, $addresses->{$k}->format;
}
for my $k (keys %$lists) {
push @addresses, $k;
}
map { s/"/\\"/g } @addresses;
</%init>
<%once>
use AlphaMail::MailTool qw(mimewords_to_utf8);
use AlphaMail::HTMLHelper qw(size_with_units);
use Encode;
our $logger = Log::Log4perl->get_logger('alphamail');
our $base = $config->get('base_uri');
</%once>
See more files for this project here