From 0768025f9fdaecd22a0fe3fe49e29a2ee88c79db Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 24 Feb 2020 20:42:30 +0000 Subject: [PATCH] Bug 22823: Add get_effective_email method to Koha::Library Add a `get_effective_email` method to the Koha::Library object which returns the email address for the library which they are most likely to have access to. This method falls back through preferences `branchreplyto`, `branchemail`, `ReplytoDefault`, `KohaAdminEmailAddress`. --- Koha/Library.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Koha/Library.pm b/Koha/Library.pm index 1d0dc1ccaf..aa7d82e344 100644 --- a/Koha/Library.pm +++ b/Koha/Library.pm @@ -65,6 +65,24 @@ sub get_effective_marcorgcode { return $self->marcorgcode || C4::Context->preference("MARCOrgCode"); } +=head3 get_effective_email + + my $to_email = Koha::Library->get_effective_email; + +Returns an effective email address which should be accessible to librarians at the branch. + +=cut + +sub get_effective_email { + my ($self) = @_; + + return + $self->branchreplyto + || $self->branchemail + || C4::Context->preference('ReplytoDefault') + || C4::Context->preference('KohaAdminEmailAddress'); +} + =head3 library_groups Return the Library groups of this library -- 2.20.1