Koha/members/member.pl
Thibaud Guillot 483a11ff54 Bug 30230: Add new 'list_borrowers' permission
When a patron search is performed only a user with edit_borrowers
permission can search by name. Search can works only with cardnumber but
it makes searching less intuitive I think.

So, as mentioned in the discussion, I've added a new 'list_borrowers' permission,
completely independent of 'edit_borrowers', so that I can search for a member via the interface
and get the results. In addition to the permission to perform check in and checkouts, this no longer poses an obstacle to simple use.

Test plan:

1) Check with a user without 'edit_borrowers' permission that the patron search can only be performed with cardnumber
2) Apply this patch
3) Make the updatedatabase to add new 'list_borrowers' permissions
4) Set 'list_borrowers' permission on one user and see the difference

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>
Signed-off-by: Emmi Takkinen <emmi.takkinen@koha-suomi.fi>
Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit fc75a344b8)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
2024-02-01 16:22:55 +01:00

86 lines
2.9 KiB
Perl
Executable file

#!/usr/bin/perl
#script to do a borrower enquiry/bring up borrower details etc
#written 20/12/99 by chris@katipo.co.nz
# Copyright 2000-2002 Katipo Communications
# Copyright 2013 BibLibre
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use C4::Auth qw( get_template_and_user );
use C4::Output qw( output_html_with_http_headers );
use CGI qw( -utf8 );
use Koha::List::Patron qw( GetPatronLists );
use Koha::Patrons;
use Koha::Patron::Attribute::Types;
my $input = CGI->new;
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "members/member.tt",
query => $input,
type => "intranet",
flagsrequired => { borrowers => ['edit_borrowers', 'list_borrowers'] },
});
my $theme = $input->param('theme') || "default";
my $searchmember = $input->param('searchmember');
my $quicksearch = $input->param('quicksearch') // 0;
my $circsearch = $input->param('circsearch') // 0;
if ( $quicksearch and $searchmember && !$circsearch ) {
my $branchcode;
if ( C4::Context::only_my_library ) {
my $userenv = C4::Context->userenv;
$branchcode = $userenv->{'branch'};
}
my $patron = Koha::Patrons->find( { cardnumber => $searchmember } );
if (
$patron
and ( ( $branchcode and $patron->branchcode eq $branchcode )
or ( not $branchcode ) )
)
{
print $input->redirect( "/cgi-bin/koha/members/moremember.pl?borrowernumber=" . $patron->borrowernumber );
exit;
}
}
my $searchfieldstype = $input->param('searchfieldstype') || 'standard';
my $searchtype = $input->param('searchtype');
$template->param( 'alphabet' => C4::Context->preference('alphabet') || join ' ', 'A' .. 'Z' );
my $defer_loading = $input->request_method() eq "GET" && !$circsearch ? 1 : 0;
$template->param(
patron_lists => [ GetPatronLists() ],
searchmember => $searchmember,
branchcode_filter => scalar $input->param('branchcode_filter'),
categorycode_filter => scalar $input->param('categorycode_filter'),
searchtype => $searchtype,
searchfieldstype => $searchfieldstype,
PatronsPerPage => C4::Context->preference("PatronsPerPage") || 20,
do_not_defer_loading => !$defer_loading,
circsearch => $circsearch,
);
output_html_with_http_headers $input, $cookie, $template->output;