Show compose.html syntax highlighted
% # vim: set syntax=mason:
<%args>
$to => ''
$cc => ''
$bcc => ''
$subject => ''
$message => ''
$forward => ''
$forwardsize => 0
$ref => '' # A reference to the message you are forwarding
@attachments => ()
@sizes => ()
$error => 0
$reply => 0
$new => 0
$richtext => 0
</%args>
<& /mail/header.mhtml, message => $error, title => 'Compose', compose => 1 &>
% 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 (siw && siw.selectingSomething)
answer = false;
return answer;
}
// -->
</script>
% }
<form method="post" action="/mail/process_compose.html"
id="header" name="compose_form"
onSubmit="return checkForm()"
enctype="multipart/form-data">
<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">
<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" name="to" value="<% $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="<% $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="<% $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="<% $subject |h %>" type="text" size="80">
</div>
</td>
</tr>
<tr>
<td colspan="2">
<textarea class="message_field" rows="20" cols="72" name="message"><% $message |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">
<input type="submit" name="cancel" value="Cancel">
<p>To attach a file, click on Browse to find the file, then click
Attach. Your total message size is limited to
<% $config->get('max_message_size') %>
bytes.</p>
<input type="file" name="file">
<input type="submit" name="attach" value="Attach">
<input type="hidden" name="ref" value="<% $ref |h %>">
<input type="hidden" name="reply" value="<% $reply |h %>">
% if($forward || @attachments) {
<input type="hidden" name="forward" value="<% $forward |h %>">
<input type="hidden" name="forwardsize" value="<% $forwardsize |h %>">
<table class="attachments">
<tr>
<th>
Attachment
</th>
<th>
Size
</th>
</tr>
% if($forward) {
<tr>
<td>
Forwarded message (with attachments)
</td>
<td><% $forwardsize |h %></td>
</tr>
% }
% my $total = $forwardsize;
% for(my $i =0; $i < $#attachments+1; $i++) { $total += $sizes[$i];
<tr>
<td>
<% mimewords_to_utf8($attachments[$i]) |h %>
<input type="hidden" name="attachments" value="<% $attachments[$i] |h %>">
<input type="hidden" name="sizes" value="<% $sizes[$i] |h %>">
</td>
<td>
<% $sizes[$i] %> bytes
<a href="<% build_url('/mail/remove_attachment.html',
{ attachment => $i }) %>">remove</a>
</td>
</tr>
% }
<tr>
<th>
Total
</th>
<th>
<% $total %> (<% $config->get('max_message_size') - $total %> remaining)
</th>
</tr>
</table>
% }
</div>
</form>
% if(!$richtext) {
<script type="text/javascript" language="javascript">
<!--
// Put the cursor at the beginning of the composition
document.forms[0].message.selectionStart = 0;
document.forms[0].message.selectionEnd = 0;
// -->
</script>
% }
<script type="text/javascript" language="JavaScript" src="/static/wick.js"></script>
<& /mail/footer.mhtml &>
<%init>
my $logger = Log::Log4perl->get_logger('alphamail');
my $user = Apache::SiteControl->getCurrentUser($r);
my $folder = $user->getAttribute('lastfolder') || 'inbox';
my $sigs = new AlphaMail::Signature($user->getUsername(), $user->getAttribute('imap'), $config);
my $book = new AlphaMail::AddressBook($user->getUsername(), $user->getAttribute('imap'), $config);
my $addresses = $book->get_all->{addresses};
my $lists = $book->get_all->{lists};
my @addresses;
for my $k (keys %$addresses)
{
push @addresses, $addresses->{$k}->format;
}
for my $k (keys %$lists) {
push @addresses, $k;
}
map { s/"/\\"/g } @addresses;
if($new) { # Force a new composition
clear_composition($r, $user, $config);
}
# If we have incoming data, clear any old composition and save the new:
if($to || $cc || $bcc || $subject || @attachments || $message || $richtext) {
# Fix parameter encodings!
eval { $to = Encode::decode_utf8($to); };
eval { $cc = Encode::decode_utf8($cc); };
eval { $bcc = Encode::decode_utf8($bcc); };
eval { $subject = Encode::decode_utf8($subject); };
eval { $message = Encode::decode_utf8($message); };
my @a = ();
for my $a (@attachments) {
eval { $a = Encode::decode_utf8($a); };
push @a, $a;
}
@attachments = @a;
$logger->debug("Clearing composition");
clear_composition($r, $user, $config);
$logger->debug("Saving composition");
save_composition($r, $user, $to, $cc, $bcc, $subject, $message, $reply,
$forward, $forwardsize, $ref, \@attachments, \@sizes, $richtext);
} else { # Load any existing composition
$logger->debug("Loading composition");
my $composition = load_composition($r, $user);
$to = $composition->{to};
$cc = $composition->{cc};
$bcc = $composition->{bcc};
$ref = $composition->{"ref"};
$forward = $composition->{forwardflag};
$forwardsize = $composition->{forwardsize};
$reply = $composition->{replyflag};
$subject = $composition->{subject};
$message = $composition->{message};
@attachments = @{$composition->{attachments}} if($composition->{attachments});
@sizes = @{$composition->{sizes}} if($composition->{sizes});
$richtext = $composition->{richtext};
}
if(!$message) {
$message = "\n" . $sigs->getSignature;
}
local $" = ", ";
</%init>
<%once>
use AlphaMail::SessionUtil qw(save_composition load_composition clear_composition);
use AlphaMail::MailTool qw(mimewords_to_utf8);
use Encode;
</%once>
See more files for this project here