Bugzilla – Attachment 62838 Details for
Bug 18403
Hide patron information if not part of the logged in user library group
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18403: Only display libraries from group in dropdown lists
Bug-18403-Only-display-libraries-from-group-in-dro.patch (text/plain), 12.95 KB, created by
Martin Renvoize (ashimema)
on 2017-04-28 15:30:07 UTC
(
hide
)
Description:
Bug 18403: Only display libraries from group in dropdown lists
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2017-04-28 15:30:07 UTC
Size:
12.95 KB
patch
obsolete
>From 022b69b90869f82d82bff8f89f5eababa6411ae5 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 5 Apr 2017 14:11:02 -0300 >Subject: [PATCH] Bug 18403: Only display libraries from group in dropdown > lists > >From where patrons it's about patrons, we do not want to display the libraries >from all the system, but only the ones from the group. > >Test plan: >- See the overdues (circ/overdue.pl) and make sure you can only see overdues from >patrons part of your group (do not forget to test the CSV export). >- Search for patrons, the 'library' filters (headers and left side) should only >display libraries from your group >- Search for article request by patron's library: only the libraries from your >group should be displayed > >Signed-off-by: Jon McGowan <jon.mcgowan@ptfs-europe.com> >--- > Koha/Libraries.pm | 29 ++++++++++++++++++++-- > Koha/Template/Plugin/Branches.pm | 3 ++- > circ/overdue.pl | 12 +++++++-- > .../prog/en/includes/patron-search.inc | 2 +- > .../prog/en/modules/circ/article-requests.tt | 2 +- > .../intranet-tmpl/prog/en/modules/circ/overdue.tt | 11 +++++--- > .../prog/en/modules/circ/view_holdsqueue.tt | 2 +- > .../prog/en/modules/common/patron_search.tt | 2 +- > .../prog/en/modules/members/member.tt | 2 +- > .../prog/en/modules/members/memberentrygen.tt | 2 +- > 10 files changed, 52 insertions(+), 15 deletions(-) > >diff --git a/Koha/Libraries.pm b/Koha/Libraries.pm >index fa2bf17..927368e 100644 >--- a/Koha/Libraries.pm >+++ b/Koha/Libraries.pm >@@ -45,10 +45,35 @@ Koha::Libraries - Koha Library Object set class > sub search_filtered { > my ( $self, $params, $attributes ) = @_; > >- if ( C4::Context::only_my_library ) { >- $params->{branchcode} = C4::Context->userenv->{branch}; >+ my @branchcodes; >+ if ( my $userenv = C4::Context->userenv ) { >+ if ( C4::Context::only_my_library ) { >+ push @branchcodes, $userenv->{branch}; >+ } >+ else { >+ my $logged_in_user = Koha::Patrons->find( $userenv->{number} ); >+ unless ( >+ $logged_in_user->can( >+ { borrowers => 'view_borrower_infos_from_any_libraries' } >+ ) >+ ) >+ { >+ if ( my $library_groups = $logged_in_user->library->library_groups ) >+ { >+ while ( my $library_group = $library_groups->next ) { >+ push @branchcodes, >+ $library_group->parent->children->get_column('branchcode'); >+ } >+ } >+ else { >+ push @branchcodes, $userenv->{branch}; >+ } >+ } >+ } > } > >+ $params->{branchcode} = { -in => \@branchcodes } if @branchcodes; >+ delete $params->{only_from_group}; > return $self->SUPER::search( $params, $attributes ); > } > >diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm >index edbad11..bc73d55 100644 >--- a/Koha/Template/Plugin/Branches.pm >+++ b/Koha/Template/Plugin/Branches.pm >@@ -59,10 +59,11 @@ sub all { > my ( $self, $params ) = @_; > my $selected = $params->{selected}; > my $unfiltered = $params->{unfiltered} || 0; >+ my $only_from_group = $params->{only_from_group} || 0; > > my $libraries = $unfiltered > ? Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed >- : Koha::Libraries->search_filtered( {}, { order_by => ['branchname'] } )->unblessed; >+ : Koha::Libraries->search_filtered( { only_from_group => $only_from_group }, { order_by => ['branchname'] } )->unblessed; > > for my $l ( @$libraries ) { > if ( defined $selected and $l->{branchcode} eq $selected >diff --git a/circ/overdue.pl b/circ/overdue.pl >index 68abc84..fac07c2 100755 >--- a/circ/overdue.pl >+++ b/circ/overdue.pl >@@ -63,6 +63,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > } > ); > >+our $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"; >+ > my $dbh = C4::Context->dbh; > > my $req; >@@ -297,6 +299,7 @@ if ($noreport) { > my $dt = dt_from_string($data->{date_due}, 'sql'); > > push @overduedata, { >+ patron => Koha::Patrons->find( $data->{borrowernumber} ), > duedate => output_pref($dt), > borrowernumber => $data->{borrowernumber}, > barcode => $data->{barcode}, >@@ -370,14 +373,19 @@ sub build_csv { > my @lines = (); > > # build header ... >- my @keys = qw /duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country >- branchcode itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice streetnumber streettype/; >+ my @keys = >+ qw ( duedate title author borrowertitle firstname surname phone barcode email address address2 zipcode city country >+ branchcode itemcallnumber biblionumber borrowernumber itemnum issuedate replacementprice streetnumber streettype); > my $csv = Text::CSV_XS->new(); > $csv->combine(@keys); > push @lines, $csv->string(); > >+ my @private_keys = qw( dueborrowertitle firstname surname phone email address address2 zipcode city country streetnumber streettype ); > # ... and rest of report > foreach my $overdue ( @{ $overdues } ) { >+ unless ( $logged_in_user->can_see_patron_infos( $overdue->{patron} ) ) { >+ $overdue->{$_} = undef for @private_keys; >+ } > push @lines, $csv->string() if $csv->combine(map { $overdue->{$_} } @keys); > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index 337f550..f8e62e4 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -85,7 +85,7 @@ > > <p> > <label for="branchcode">Library: </label> >- [% SET branches = Branches.all( selected => branchcode_filter ) %] >+ [% SET branches = Branches.all( selected => branchcode_filter, only_my_group => 1 ) %] > <select name="branchcode_filter" id="branchcode"> > [% IF branches.size != 1 %] > <option value="">Any</option> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt >index b695dc6..b9cf08f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/article-requests.tt >@@ -124,7 +124,7 @@ > <form id="ar-branchcode-form" method="post"> > <select name="branchcode" id="branchcode"> > <option value="">All libraries</option> >- [% FOREACH b IN Branches.all %] >+ [% FOREACH b IN Branches.all( only_from_group => 1 ) %] > [% IF b.branchcode == branchcode %] > <option value="[% b.branchcode %]" selected="selected">[% b.branchname %]</option> > [% ELSE %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt >index 5e5f466..2043867 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/overdue.tt >@@ -121,9 +121,12 @@ > [% FOREACH overdueloo IN overdueloop %] > <tr> > <td>[% overdueloo.duedate %]</td> >- <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% overdueloo.borrowernumber %]">[% overdueloo.surname %][% IF (overdueloo.firstname) %], [% overdueloo.firstname %][% END %] ([% overdueloo.cardnumber %])</a> >- [% IF ( overdueloo.email ) %][<a href="mailto:[% overdueloo.email %]?subject=[% INCLUDE subject %] [% overdueloo.title |html %]">email</a>][% END %] >- [% IF ( overdueloo.phone ) %]([% overdueloo.phone %])[% ELSIF ( overdueloo.mobile ) %]([% overdueloo.mobile %])[% ELSIF ( overdueloo.phonepro ) %]([% overdueloo.phonepro %])[% END %]</td> >+ <td> >+ [% INCLUDE 'patron-title.inc' patron=overdueloo.patron hide_patron_infos_if_needed=1 link_to="circulation_reserves" %] >+ [% IF logged_in_user.can_see_patron_infos( overdueloo.patron ) %] >+ [% IF ( overdueloo.email ) %][<a href="mailto:[% overdueloo.email %]?subject=[% INCLUDE subject %] [% overdueloo.title |html %]">email</a>][% END %] >+ [% IF ( overdueloo.phone ) %]([% overdueloo.phone %])[% ELSIF ( overdueloo.mobile ) %]([% overdueloo.mobile %])[% ELSIF ( overdueloo.phonepro ) %]([% overdueloo.phonepro %])[% END %]</td> >+ [% END %] > <td>[% IF overdueloo.branchcode %][% Branches.GetName( overdueloo.branchcode ) %][% END %]</td> > <td>[% INCLUDE 'biblio-default-view.inc' biblionumber = overdueloo.biblionumber %][% overdueloo.title |html %] [% overdueloo.subtitle %]</a> [% IF ( overdueloo.author ) %], by [% overdueloo.author %][% END %][% IF ( overdueloo.enumchron ) %], [% overdueloo.enumchron %][% END %]</td> > <td><a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% overdueloo.biblionumber %]&itemnumber=[% overdueloo.itemnum %]#item[% overdueloo.itemnum %]">[% overdueloo.barcode %]</a></td> >@@ -237,7 +240,7 @@ > <label>Library of the patron:</label> > <select name="branch" id="branch"> > <option value="">Any</option> >- [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter ) %] >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => branchfilter, only_from_group => 1 ) %] > </select> > </li> > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt >index 509e5ba..aa3d4cd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/view_holdsqueue.tt >@@ -206,7 +206,7 @@ $(document).ready(function() { > <label for="branchlimit">Library: </label> > <select name="branchlimit" id="branchlimit"> > <option value="">All</option> >- [% PROCESS options_for_libraries libraries => Branches.all() %] >+ [% PROCESS options_for_libraries libraries => Branches.all( only_from_group => 1 ) %] > </select> > </li> > <!-- FIXME Not working yet >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt >index 8b52cac..d67c06d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/common/patron_search.tt >@@ -195,7 +195,7 @@ function filterByFirstLetterSurname(letter) { > <li> > <label for="branchcode_filter">Library:</label> > <select id="branchcode_filter"> >- [% SET libraries = Branches.all() %] >+ [% SET libraries = Branches.all( only_from_group => 1 ) %] > [% IF libraries.size != 1 %] > <option value="">Any</option> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt >index 07fd341..d7c33c6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tt >@@ -502,7 +502,7 @@ function filterByFirstLetterSurname(letter) { > </li> > <li> > <label for="branchcode_filter">Library:</label> >- [% SET branches = Branches.all( selected => branchcode_filter ) %] >+ [% SET branches = Branches.all( selected => branchcode_filter, only_from_group => 1 ) %] > <select id="branchcode_filter"> > [% IF branches.size != 1 %] > <option value="">Any</option> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index efa2a8a..ca399b6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -634,7 +634,7 @@ $(document).ready(function() { > <li> > <label for="libraries" class="required">Library:</label> > <select name="branchcode" size="1" id="libraries"> >- [% PROCESS options_for_libraries libraries => Branches.all( selected => userbranch ) %] >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => userbranch, only_from_group => 1 ) %] > </select> > <span class="required">Required</span> > </li> >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18403
:
62010
|
62011
|
62012
|
62013
|
62014
|
62015
|
62016
|
62017
|
62018
|
62019
|
62020
|
62021
|
62022
|
62023
|
62024
|
62025
|
62026
|
62027
|
62028
|
62029
|
62030
|
62031
|
62032
|
62033
|
62302
|
62303
|
62830
|
62831
|
62832
|
62833
|
62834
|
62835
|
62836
|
62837
|
62838
|
62839
|
62840
|
62841
|
62842
|
62843
|
62844
|
62845
|
62846
|
62847
|
62848
|
62849
|
62850
|
62851
|
62852
|
62853
|
62854
|
62855
|
71392
|
71394
|
71500
|
71501
|
71502
|
71503
|
71504
|
71505
|
71506
|
71507
|
71508
|
71509
|
71510
|
71511
|
71512
|
71513
|
71514
|
71515
|
71516
|
71517
|
71518
|
71519
|
71520
|
71521
|
71522
|
71523
|
71524
|
71525
|
71526
|
71527
|
71528
|
71529
|
71530
|
71767