Commit b85ac412 authored by Benjamin Rokseth's avatar Benjamin Rokseth
Browse files

koha: add WIP AddToqueue to MessageQueue

parent bb2a7eac
......@@ -20,4 +20,44 @@ sub GetByPatron {
return $self;
}
=head
params
letter
title
content
metadata
code
content_type
message_transport_type
borrowernumber
to_address
=cut
sub AddToQueue {
my ($self, $msg) = @_;
$self->{patron} or return;
my $q = "INSERT INTO message_queue
( borrowernumber, subject, content, metadata, letter_code, message_transport_type, status, time_queued, to_address, from_address, content_type )
VALUES (?,?,?,?,?,?,?,?,?,?,?)";
my $dbh = $self->dbh;
my $sth = $dbh->prepare($q);
my $content = $msg->{letter}->{content};
$content =~ s/\s+//g if(defined $content);
(!$content or $content eq '') and return;
my $result = $sth->execute(
$self->{patron}->{borrowernumber},
$msg->{letter}->{title}, # subject
$msg->{letter}->{content},
$msg->{letter}->{metadata} || "",
$msg->{letter}->{code} || "",
$msg->{message_transport_type},
"pending",
$msg->{to_address},
$msg->{from_address},
$msg->{letter}->{"content-type"}
) or Deichman::Exception::Patron->throw($dbh->errstr);
}
1;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment