Bug 17499: Add Koha-objects for messaging preferences
This patch adds Koha-objects for messaging preferences.
Adds simple validation for messaging preferences.
The validation includes
- throw exception if both borrowernumber or categorycode is given for a new pref
- throw exception if patron for the given borrowernumber is not found
- throw exception if category for the given categorycode is not found
- throw exception if days in advance cannot be configured but is given
- throw exception if days in advance configuration is invalid (value between 0-30)
- throw exception if digest is not available but attempted to set on
- throw exception if digest must be enabled but attempted to set off
- throw exception on duplicate messaging preference
Adds a method for getting available messaging options.
Adds a method for setting default messaging preferenes.
$patron->set_default_messaging_preferences (where $patron is a Koha::Patron)
...or...
Koha::Patron::Message::Preference->new_from_default({
borrowernumber => 123,
categorycode => "ABC",
message_attribute_id => 1,
});
Since messaging preference is a feature that has multiple related database tables,
usage via Koha-objects is sometimes frustrating. This patch adds easy access to
message transport types via
$preference->message_transport_types (for getting)
$preference->set({ message_transport_types => ['email', 'sms'] }) (for setting)
(also supports other calling conventions, see documentation for more)
Adds optional parameter message_name for Koha::Patron::Message::Preferences->find
and ->search. Simplifies the Koha-object usage by allowing developer to skip joins
and / or querying the message name via attribute_id from message_attributes table.
Includes test coverage for basic usage.
To test:
1. prove t/db_dependent/Koha/Patron/Message/*
Following Bug 17499, check also Bug 18595 that replaces C4::Members::Messaging
with these new Koha-objects.
Signed-off-by: Dominic Pichette <dominic@inlibro.com> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Michal Denar <black23@gmail.com> Signed-off-by: Sam Lau <samalau@gmail.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>