Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #343 from ctfliblime/PT26875895-patroncats_4.10

[#26875895] Fixes related to ConstrainPatronsDeeply
  • Loading branch information...
commit 6c1610f84ab058200aed9b895028ac4fb5f6346d 2 parents 10dd9f9 + df3c979
@ctfliblime ctfliblime authored
View
1  cgi/admin/systempreferences.pl
@@ -274,6 +274,7 @@ =head1 systempreferences.pl
$tabsysprefs{MaxShelfHoldsPerDay} = "Patrons";
$tabsysprefs{EnableOwedNotification} = "Patrons";
$tabsysprefs{UsePatronBranchForPatronInfo} = "Patrons";
+$tabsysprefs{ConstrainPatronsDeeply} = "Patrons";
# I18N/L10N
$tabsysprefs{dateformat} = "I18N/L10N";
View
17 cgi/circ/circulation.pl
@@ -339,10 +339,25 @@ sub FormatFinesSummary {
}
$borrower = GetMemberDetails( $borrowernumber, 0, $circ_session );
+
+ if ( $borrower
+ && C4::Branch::CategoryTypeIsUsed('patrons')
+ && C4::Members::ConstrainPatronSearch())
+ {
+ my $agent = C4::Members::GetMember($loggedinuser);
+ $borrower = undef
+ unless C4::Branch::BranchesAreSiblings(
+ $borrower->{branchcode}, $agent->{branchcode}, 'patrons');
+ }
+ unless (defined $borrower) {
+ output_html_with_http_headers $query, $cookie, $template->output;
+ exit;
+ }
+
if ( $circ_session->{'override_user'} ) {
$template->param( flagged => 1 );
}
-
+
## Store data for last scanned borrower in cookies for future use.
my $lbb = $query->cookie(-name=>'last_borrower_borrowernumber', -value=>"$borrowernumber", -expires=>'+1y');
my $lbc = $query->cookie(-name=>'last_borrower_cardnumber', -value=>"$borrower->{'cardnumber'}", -expires=>'+1y');
View
14 cgi/members/holdhistory.pl
@@ -47,6 +47,20 @@
#get borrower details
my $data=GetMember($borrowernumber,'borrowernumber');
+if ( $data
+ && C4::Branch::CategoryTypeIsUsed('patrons')
+ && C4::Members::ConstrainPatronSearch())
+{
+ my $agent = C4::Members::GetMember($loggedinuser);
+ $data = undef
+ unless C4::Branch::BranchesAreSiblings(
+ $data->{branchcode}, $agent->{branchcode}, 'patrons');
+}
+unless (defined $data) {
+ output_html_with_http_headers $input, $cookie, $template->output;
+ exit;
+}
+
$template->param(
borrowernumber => $data->{'borrowernumber'},
firstname => $data->{'firstname'},
View
22 cgi/members/moremember.pl
@@ -89,17 +89,25 @@ BEGIN
);
my $borrowernumber = $input->param('borrowernumber');
-#start the page and read in includes
-my $data = GetMember( $borrowernumber ,'borrowernumber');
-my $roaddetails = GetRoadTypeDetails( $data->{'streettype'} );
-my $reregistration = $input->param('reregistration');
-
-if ( not defined $data ) {
+my $data = GetMember( $borrowernumber ,'borrowernumber');
+if ( $data
+ && C4::Branch::CategoryTypeIsUsed('patrons')
+ && C4::Members::ConstrainPatronSearch())
+{
+ my $agent = C4::Members::GetMember($loggedinuser);
+ $data = undef
+ unless C4::Branch::BranchesAreSiblings(
+ $data->{branchcode}, $agent->{branchcode}, 'patrons');
+}
+unless (defined $data) {
$template->param (unknowuser => 1);
- output_html_with_http_headers $input, $cookie, $template->output;
+ output_html_with_http_headers $input, $cookie, $template->output;
exit;
}
+my $roaddetails = GetRoadTypeDetails( $data->{'streettype'} );
+my $reregistration = $input->param('reregistration');
+
# re-reregistration function to automatic calcul of date expiry
if ( $reregistration && $reregistration eq 'y' ) {
$data->{'dateexpiry'} = ExtendMemberSubscriptionTo( $borrowernumber );
View
14 cgi/members/readingrec.pl
@@ -43,6 +43,20 @@
my $borrowernumber=$input->param('borrowernumber');
#get borrower details
my $data=GetMember($borrowernumber,'borrowernumber');
+if ( $data
+ && C4::Branch::CategoryTypeIsUsed('patrons')
+ && C4::Members::ConstrainPatronSearch())
+{
+ my $agent = C4::Members::GetMember($loggedinuser);
+ $data = undef
+ unless C4::Branch::BranchesAreSiblings(
+ $data->{branchcode}, $agent->{branchcode}, 'patrons');
+}
+unless (defined $data) {
+ output_html_with_http_headers $input, $cookie, $template->output;
+ exit;
+}
+
my $order=$input->param('order') || '';
my $order2=$order;
if ($order2 eq ''){
View
6 installer/data/syspref_defaults.json
@@ -1,4 +1,10 @@
{
+ "ConstrainPatronsDeeply" : {
+ "explanation" : "When using patron categories, hide non-local patrons not only from search but from access within Koha modules. Has no effect unless patron groups are enabled.",
+ "options" : null,
+ "value" : "1",
+ "type" : "YesNo"
+ },
"KeepPreviousBorrowerInterval" : {
"explanation" : "Number of days that must pass before the previous borrower is expunged from old issues if that item has not since been checked out.",
"options" : null,
View
6 lib/C4/Branch.pm
@@ -428,6 +428,12 @@ sub GetSiblingBranchesOfType {
return @branchcodes;
}
+sub BranchesAreSiblings {
+ my ($b1code, $b2code, $categorytype) = @_;
+ my @b1_group = GetSiblingBranchesOfType($b1code, $categorytype);
+ return $b2code ~~ @b1_group;
+}
+
=head2 GetBranch
$branch = GetBranch( $query, $branches );
View
19 lib/C4/Members.pm
@@ -175,13 +175,16 @@ C<$count> is the number of elements in C<$borrowers>.
=cut
+sub ConstrainPatronSearch {
+ return (C4::Branch::CategoryTypeIsUsed('patrons')
+ && $ENV{REQUEST_METHOD} # need a nicer way to do this, but check if we're command line vs. CGI
+ && !C4::Auth::haspermission(undef, {superlibrarian => 1})) ? 1 : 0;
+}
+
sub _constrain_sql_by_branchcategory {
my ($query, @bind) = @_;
- if ( C4::Branch::CategoryTypeIsUsed('patrons')
- && $ENV{REQUEST_METHOD} # need a nicer way to do this, but check if we're command line vs. CGI
- && !C4::Auth::haspermission(undef, {superlibrarian => 1})
- )
+ if (ConstrainPatronSearch())
{
my $mybranch = (C4::Context->userenv) ? C4::Context->userenv->{branch} : undef;
confess 'Unable to determine selected branch' if not $mybranch;
@@ -377,8 +380,9 @@ sub GetMemberDetails {
else {
return;
}
- ($sql, @params) = _constrain_sql_by_branchcategory($sql, @params);
-
+ ($sql, @params) = _constrain_sql_by_branchcategory($sql, @params)
+ if C4::Context->preference('ConstrainPatronsDeeply');
+
my $borrower = $dbh->selectrow_hashref($sql, undef, @params);
return if !$borrower;
@@ -581,7 +585,8 @@ sub GetMember {
WHERE $type = ?
};
my @params = ($information);
- ($select, @params) = _constrain_sql_by_branchcategory($select, @params);
+ ($select, @params) = _constrain_sql_by_branchcategory($select, @params)
+ if C4::Context->preference('ConstrainPatronsDeeply');
my $borrower = C4::Context->dbh->selectrow_hashref($select, undef, @params);
return undef if !$borrower;
Please sign in to comment.
Something went wrong with that request. Please try again.