Lines 198-208
sub message_transport_types {
Link Here
|
198 |
if ($self->{'_message_transport_types'}) { |
198 |
if ($self->{'_message_transport_types'}) { |
199 |
return $self->{'_message_transport_types'}; |
199 |
return $self->{'_message_transport_types'}; |
200 |
} |
200 |
} |
201 |
map { $self->{'_message_transport_types'}->{$_->message_transport_type} = |
201 |
map { |
202 |
Koha::Patron::Message::Transports->find({ |
202 |
my $transport = Koha::Patron::Message::Transports->find({ |
203 |
message_attribute_id => $self->message_attribute_id, |
203 |
message_attribute_id => $self->message_attribute_id, |
204 |
message_transport_type => $_->message_transport_type, |
204 |
message_transport_type => $_->message_transport_type, |
205 |
is_digest => $self->wants_digest})->letter_code } |
205 |
is_digest => $self->wants_digest |
|
|
206 |
}); |
207 |
unless ($transport) { |
208 |
my $logger = Koha::Logger->get; |
209 |
$logger->warn( |
210 |
$self->message_name . ' has no transport with '. |
211 |
$_->message_transport_type . ' (digest: '. |
212 |
($self->wants_digest ? 'yes':'no').').' |
213 |
); |
214 |
} |
215 |
$self->{'_message_transport_types'}->{$_->message_transport_type} |
216 |
= $transport ? $transport->letter_code : ' '; |
217 |
} |
206 |
Koha::Patron::Message::Transport::Preferences->search({ |
218 |
Koha::Patron::Message::Transport::Preferences->search({ |
207 |
borrower_message_preference_id => $self->borrower_message_preference_id, |
219 |
borrower_message_preference_id => $self->borrower_message_preference_id, |
208 |
})->as_list; |
220 |
})->as_list; |
Lines 354-360
sub validate {
Link Here
|
354 |
if (defined $self->wants_digest) { |
366 |
if (defined $self->wants_digest) { |
355 |
my $transports = Koha::Patron::Message::Transports->search({ |
367 |
my $transports = Koha::Patron::Message::Transports->search({ |
356 |
message_attribute_id => $self->message_attribute_id, |
368 |
message_attribute_id => $self->message_attribute_id, |
357 |
is_digest => $self->wants_digest, |
369 |
is_digest => $self->wants_digest ? 1 : 0, |
358 |
}); |
370 |
}); |
359 |
Koha::Exceptions::BadParameter->throw( |
371 |
Koha::Exceptions::BadParameter->throw( |
360 |
error => (!$self->wants_digest ? 'No d' : 'D').'igest not available '. |
372 |
error => (!$self->wants_digest ? 'No d' : 'D').'igest not available '. |
Lines 377-387
sub _set_message_transport_types {
Link Here
|
377 |
$self->_validate_message_transport_types({ message_transport_types => $types }); |
389 |
$self->_validate_message_transport_types({ message_transport_types => $types }); |
378 |
foreach my $type (@$types) { |
390 |
foreach my $type (@$types) { |
379 |
unless (exists $self->{'_message_transport_types'}->{$type}) { |
391 |
unless (exists $self->{'_message_transport_types'}->{$type}) { |
380 |
$self->{'_message_transport_types'}->{$type} = |
392 |
my $transport = Koha::Patron::Message::Transports->find({ |
381 |
Koha::Patron::Message::Transports->find({ |
|
|
382 |
message_attribute_id => $self->message_attribute_id, |
393 |
message_attribute_id => $self->message_attribute_id, |
383 |
message_transport_type => $type, |
394 |
message_transport_type => $type, |
384 |
is_digest => $self->wants_digest})->letter_code; |
395 |
is_digest => $self->wants_digest |
|
|
396 |
}); |
397 |
unless ($transport) { |
398 |
Koha::Exceptions::ObjectNotFound->throw( |
399 |
error => 'No transport configured for '. |
400 |
$type . ' (digest: '. |
401 |
($self->wants_digest ? 'yes':'no').').' |
402 |
); |
403 |
} |
404 |
$self->{'_message_transport_types'}->{$type} |
405 |
= $transport->letter_code; |
385 |
} |
406 |
} |
386 |
} |
407 |
} |
387 |
return $self; |
408 |
return $self; |
Lines 405-423
sub _validate_message_transport_types {
Link Here
|
405 |
parameter => 'message_transport_type', |
426 |
parameter => 'message_transport_type', |
406 |
); |
427 |
); |
407 |
} |
428 |
} |
408 |
my $tmp = (ref($self) eq __PACKAGE__) ? $self->unblessed : $params; |
|
|
409 |
unless (Koha::Patron::Message::Transports->find({ |
410 |
message_transport_type => $type, |
411 |
message_attribute_id => $tmp->{'message_attribute_id'}, |
412 |
is_digest => $tmp->{'wants_digest'}, |
413 |
})) { |
414 |
Koha::Exceptions::BadParameter->throw( |
415 |
error => "Message transport option '$type' (". |
416 |
($tmp->{'wants_digest'} ? 'digest':'no digest').") for ". |
417 |
$self->message_name . 'does not exist', |
418 |
parameter => 'message_transport_type', |
419 |
); |
420 |
} |
421 |
} |
429 |
} |
422 |
return $types; |
430 |
return $types; |
423 |
} |
431 |
} |