|
Lines 20-25
package Koha::Patron::Message::Preferences;
Link Here
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Koha::Database; |
22 |
use Koha::Database; |
|
|
23 |
use Koha::Patron::Message::Attributes; |
| 23 |
use Koha::Patron::Message::Preference; |
24 |
use Koha::Patron::Message::Preference; |
| 24 |
use Koha::Patron::Message::Transports; |
25 |
use Koha::Patron::Message::Transports; |
| 25 |
|
26 |
|
|
Lines 35-40
Koha::Patron::Message::Preferences - Koha Patron Message Preferences object clas
Link Here
|
| 35 |
|
36 |
|
| 36 |
=cut |
37 |
=cut |
| 37 |
|
38 |
|
|
|
39 |
=head3 find_with_message_name |
| 40 |
|
| 41 |
Koha::Patron::Message::Preferences->find_with_message_name({ |
| 42 |
borrowernumber => 123, |
| 43 |
message_name => 'Hold_Filled', |
| 44 |
}); |
| 45 |
|
| 46 |
Converts C<message_name> into C<message_attribute_id> and continues find. |
| 47 |
|
| 48 |
=cut |
| 49 |
|
| 50 |
sub find_with_message_name { |
| 51 |
my ($self, $id) = @_; |
| 52 |
|
| 53 |
if (ref($id) eq "HASH" && $id->{'message_name'}) { |
| 54 |
my $attr = Koha::Patron::Message::Attributes->find({ |
| 55 |
message_name => $id->{'message_name'}, |
| 56 |
}); |
| 57 |
$id->{'message_attribute_id'} = ($attr) ? |
| 58 |
$attr->message_attribute_id : undef; |
| 59 |
delete $id->{'message_name'}; |
| 60 |
} |
| 61 |
|
| 62 |
return $self->SUPER::find($id); |
| 63 |
} |
| 64 |
|
| 38 |
=head3 get_options |
65 |
=head3 get_options |
| 39 |
|
66 |
|
| 40 |
my $messaging_options = Koha::Patron::Message::Preferences->get_options |
67 |
my $messaging_options = Koha::Patron::Message::Preferences->get_options |
|
Lines 69-74
sub get_options {
Link Here
|
| 69 |
return \@return; |
96 |
return \@return; |
| 70 |
} |
97 |
} |
| 71 |
|
98 |
|
|
|
99 |
=head3 search |
| 100 |
|
| 101 |
Koha::Patron::Message::Preferences->search_with_message_name({ |
| 102 |
borrowernumber => 123, |
| 103 |
message_name => 'Hold_Filled', |
| 104 |
}); |
| 105 |
|
| 106 |
Converts C<message_name> into C<message_attribute_id> and continues search. Use |
| 107 |
Koha::Patron::Message::Preferences->search with a proper join for more complicated |
| 108 |
searches. |
| 109 |
|
| 110 |
=cut |
| 111 |
|
| 112 |
sub search_with_message_name { |
| 113 |
my ($self, $params, $attributes) = @_; |
| 114 |
|
| 115 |
if (ref($params) eq "HASH" && $params->{'message_name'}) { |
| 116 |
my $attr = Koha::Patron::Message::Attributes->find({ |
| 117 |
message_name => $params->{'message_name'}, |
| 118 |
}); |
| 119 |
$params->{'message_attribute_id'} = ($attr) ? |
| 120 |
$attr->message_attribute_id : undef; |
| 121 |
delete $params->{'message_name'}; |
| 122 |
} |
| 123 |
|
| 124 |
return $self->SUPER::search($params, $attributes); |
| 125 |
} |
| 126 |
|
| 72 |
=head3 type |
127 |
=head3 type |
| 73 |
|
128 |
|
| 74 |
=cut |
129 |
=cut |