From e2e0c327019d43554bc6ec8a69ee5835c94f2e0e Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 7 Jun 2018 12:16:18 +0000 Subject: [PATCH] Bug 19524: Share patron lists between staff Some libraries would like to allow arbitrary lists to be used by all librarians with the 'manage_patron_lists' permission. Test Plan: 1) Apply this patch 2) Run updatedatabase.pl 3) Create or find two patrons with the manage_patron_lists permission 4) Using the first patron, create two new lists, mark one of them as shared 5) Log in as the second patron, browse to the patron lists page 6) Note the second patron can view, add and remove patrons from the shared list owned by the first patron Signed-off-by: George Williams Signed-off-by: Marcel de Rooy Signed-off-by: Nick Clemens --- Koha/List/Patron.pm | 10 +++++- .../en/modules/patron_lists/add-modify.tt | 9 ++++++ .../prog/en/modules/patron_lists/lists.tt | 17 ++++++++-- patron_lists/add-modify.pl | 5 +-- patron_lists/lists.pl | 5 ++- t/db_dependent/PatronLists.t | 31 ++++++++++++------- 6 files changed, 60 insertions(+), 17 deletions(-) diff --git a/Koha/List/Patron.pm b/Koha/List/Patron.pm index 1847973bdd..c6f43848a3 100644 --- a/Koha/List/Patron.pm +++ b/Koha/List/Patron.pm @@ -63,7 +63,15 @@ sub GetPatronLists { return; } - delete( $params->{owner} ) if ( C4::Context->IsSuperLibrarian() ); + delete $params->{owner} if C4::Context->IsSuperLibrarian(); + + if ( my $owner = $params->{owner} ) { + delete $params->{owner}; + $params->{'-or'} = [ + owner => $owner, + shared => 1, + ]; + } my $schema = Koha::Database->new()->schema(); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/add-modify.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/add-modify.tt index 570b309bc5..23ee885598 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/add-modify.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/add-modify.tt @@ -51,6 +51,15 @@ +
  • + + [% IF list.shared %] + + [% ELSE %] + + [% END %] +
  • +
  • Owner: [% loggedinusername %]
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt index f2cd32df5c..dcf3ca549f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt @@ -32,15 +32,26 @@ Name Patrons in list + Shared   [% FOREACH l IN lists %] + [% SET shared_by_other = l.owner.id != logged_in_user %] [% l.name |html%] [% l.patron_list_patrons_rs.count || 0 %] + + [% IF l.shared %] + [% IF shared_by_other %] + by [% INCLUDE 'patron-title.inc' patron=l.owner %] + [% ELSE %] + by you + [% END %] + [% END %] +