Patch to allow overriding of email message & subject for inbox messages (see http://www.plainblack.com/webgui/dev/discuss/overriding-inbox-emails/3)

This commit is contained in:
Patrick Donelan 2008-09-06 05:01:37 +00:00
parent dd22207f22
commit 1dec37292a

View file

@ -76,6 +76,14 @@ A groupId of a group attached to this message.
A userId that created this message. Defaults to '3' (Admin).
=head4 emailMessage
Email message to use rather than inbox message contents.
=head4 emailSubject
Email subject to use rather than inbox message subject.
=cut
sub create {
@ -95,17 +103,21 @@ sub create {
$self->{_properties}{completedBy} = $session->user->userId;
$self->{_properties}{completedOn} = time();
}
$self->{_messageId} = $self->{_properties}{messageId} = $session->db->setRow("inbox","messageId",$self->{_properties});
$self->{_messageId} = $self->{_properties}{messageId} = $session->db->setRow("inbox","messageId",$self->{_properties});
my $subject = (defined $properties->{emailSubject}) ? $properties->{emailSubject} : $self->{_properties}{subject};
my $mail = WebGUI::Mail::Send->create($session, {
toUser=>$self->{_properties}{userId},
toGroup=>$self->{_properties}{groupId},
subject=>$self->{_properties}{subject}
subject=>$subject,
});
if (defined $mail) {
if ($self->{_properties}{message} =~ m/\<.*\>/) {
$mail->addHtml($self->{_properties}{message});
my $msg = (defined $properties->{emailMessage}) ? $properties->{emailMessage} : $self->{_properties}{message};
if ($msg =~ m/\<.*\>/) {
$mail->addHtml($msg);
} else {
$mail->addText($self->{_properties}{message});
$mail->addText($msg);
}
$mail->addFooter;
$mail->queue;