Bugzilla – Attachment 62302 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: Deal with the DB user
Bug-18403-Deal-with-the-DB-user.patch (text/plain), 7.74 KB, created by
Jonathan Druart
on 2017-04-18 16:15:02 UTC
(
hide
)
Description:
Bug 18403: Deal with the DB user
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-04-18 16:15:02 UTC
Size:
7.74 KB
patch
obsolete
>From 9d5c7909408274b33db7ac3ffde3b24561633675 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 12 Apr 2017 09:56:22 -0300 >Subject: [PATCH] Bug 18403: Deal with the DB user > >On first login, Koha explodes before the logged in user does not exist >in DB. >This patch deals with that by adding several checks when it's needed. > >Test plan: >Use the DB user to create a superlibrarian user. >The DB user should no be allowed to do anything else. >--- > C4/Auth.pm | 2 +- > Koha/ArticleRequests.pm | 2 +- > Koha/Libraries.pm | 3 ++- > Koha/Patron/Discharge.pm | 2 +- > Koha/Patron/Modifications.pm | 2 +- > Koha/Patrons.pm | 2 +- > Koha/Reviews.pm | 2 +- > members/member-flags.pl | 7 +++++-- > members/memberentry.pl | 9 +++++---- > members/moremember.pl | 8 +++++--- > 10 files changed, 23 insertions(+), 16 deletions(-) > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index 61b7cfc..99a6dee 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -256,7 +256,7 @@ sub get_template_and_user { > ); > } > >- $template->param( "USER_INFO" => $patron->unblessed ); >+ $template->param( "USER_INFO" => $patron->unblessed ) if $borrowernumber != 0; > > my $all_perms = get_all_subpermissions(); > >diff --git a/Koha/ArticleRequests.pm b/Koha/ArticleRequests.pm >index 27be468..c43c23e 100644 >--- a/Koha/ArticleRequests.pm >+++ b/Koha/ArticleRequests.pm >@@ -51,7 +51,7 @@ sub search_limited { > > my $userenv = C4::Context->userenv; > my @restricted_branchcodes; >- if ( $userenv ) { >+ if ( $userenv and $userenv->{number} ) { > my $logged_in_user = Koha::Patrons->find( $userenv->{number} ); > @restricted_branchcodes = $logged_in_user->libraries_where_can_see_patrons; > } >diff --git a/Koha/Libraries.pm b/Koha/Libraries.pm >index 5d88c6b..38a61a4 100644 >--- a/Koha/Libraries.pm >+++ b/Koha/Libraries.pm >@@ -46,7 +46,8 @@ sub search_filtered { > my ( $self, $params, $attributes ) = @_; > > my @branchcodes; >- if ( my $userenv = C4::Context->userenv ) { >+ my $userenv = C4::Context->userenv; >+ if ( $userenv and $userenv->{number} ) { > my $only_from_group = $params->{only_from_group}; > if ( $only_from_group ) { > my $logged_in_user = Koha::Patrons->find( $userenv->{number} ); >diff --git a/Koha/Patron/Discharge.pm b/Koha/Patron/Discharge.pm >index 52d3abf..81d73a6 100644 >--- a/Koha/Patron/Discharge.pm >+++ b/Koha/Patron/Discharge.pm >@@ -183,7 +183,7 @@ sub search_limited { > my ( $params, $attributes ) = @_; > my $userenv = C4::Context->userenv; > my @restricted_branchcodes; >- if ( $userenv ) { >+ if ( $userenv and $userenv->{number} ) { > my $logged_in_user = Koha::Patrons->find( $userenv->{number} ); > @restricted_branchcodes = $logged_in_user->libraries_where_can_see_patrons; > } >diff --git a/Koha/Patron/Modifications.pm b/Koha/Patron/Modifications.pm >index 1a35894..6419796 100644 >--- a/Koha/Patron/Modifications.pm >+++ b/Koha/Patron/Modifications.pm >@@ -54,7 +54,7 @@ sub pending_count { > > my $userenv = C4::Context->userenv; > my @branchcodes; >- if ( $userenv ) { >+ if ( $userenv and $userenv->{number} ) { > my $logged_in_user = Koha::Patrons->find( $userenv->{number} ); > if ($branchcode) { > return 0 unless $logged_in_user->can_see_patrons_from($branchcode); >diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm >index 9ae5efd..22ba83a 100644 >--- a/Koha/Patrons.pm >+++ b/Koha/Patrons.pm >@@ -54,7 +54,7 @@ sub search_limited { > > my $userenv = C4::Context->userenv; > my @restricted_branchcodes; >- if ( $userenv ) { >+ if ( $userenv and $userenv->{number} ) { > my $logged_in_user = Koha::Patrons->find( $userenv->{number} ); > @restricted_branchcodes = $logged_in_user->libraries_where_can_see_patrons; > } >diff --git a/Koha/Reviews.pm b/Koha/Reviews.pm >index a5fcae3..1e980a9 100644 >--- a/Koha/Reviews.pm >+++ b/Koha/Reviews.pm >@@ -48,7 +48,7 @@ sub search_limited { > > my $userenv = C4::Context->userenv; > my @restricted_branchcodes; >- if ( $userenv ) { >+ if ( $userenv and $userenv->{number} ) { > my $logged_in_user = Koha::Patrons->find( $userenv->{number} ); > @restricted_branchcodes = $logged_in_user->libraries_where_can_see_patrons; > } >diff --git a/members/member-flags.pl b/members/member-flags.pl >index 95723d1..857f2ad 100755 >--- a/members/member-flags.pl >+++ b/members/member-flags.pl >@@ -41,8 +41,11 @@ my ($template, $loggedinuser, $cookie) = get_template_and_user({ > debug => 1, > }); > >-my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"; >-output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); >+my $userenv = C4::Context->userenv; >+if ( $userenv and $userenv->{number} ) { # Allow DB user to create a superlibrarian patron >+ my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"; >+ output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); >+} > > my %member2; > $member2{'borrowernumber'}=$member; >diff --git a/members/memberentry.pl b/members/memberentry.pl >index 755c4f2..bda4f96 100755 >--- a/members/memberentry.pl >+++ b/members/memberentry.pl >@@ -76,9 +76,12 @@ my ($template, $loggedinuser, $cookie) > }); > > my $borrowernumber = $input->param('borrowernumber'); >-my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"; > my $patron = Koha::Patrons->find($borrowernumber); >-output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); >+my $userenv = C4::Context->userenv; >+if ( $userenv and $userenv->{number} ) { # Allow DB user to create a superlibrarian patron >+ my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"; >+ output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); >+} > > if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) { > my @providers = Koha::SMS::Providers->search(); >@@ -106,8 +109,6 @@ my $step = $input->param('step') || 0; > my @errors; > my $borrower_data; > my $NoUpdateLogin; >-my $userenv = C4::Context->userenv; >- > > ## Deal with debarments > $template->param( >diff --git a/members/moremember.pl b/members/moremember.pl >index 6b08ef6..5e1dcd0 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -119,9 +119,12 @@ my $borrowernumber = $input->param('borrowernumber'); > my $error = $input->param('error'); > $template->param( error => $error ) if ( $error ); > >-my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"; > my $patron = Koha::Patrons->find( $borrowernumber ); >-output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); >+my $userenv = C4::Context->userenv; >+if ( $userenv and $userenv->{number} ) { # Allow DB user to create a superlibrarian patron >+ my $logged_in_user = Koha::Patrons->find( $loggedinuser ) or die "Not logged in"; >+ output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); >+} > > my $issues = $patron->checkouts; > my $balance = $patron->account->balance; >@@ -196,7 +199,6 @@ $bor{'borrowernumber'} = $borrowernumber; > # Converts the branchcode to the branch name > my $samebranch; > if ( C4::Context->preference("IndependentBranches") ) { >- my $userenv = C4::Context->userenv; > if ( C4::Context->IsSuperLibrarian() ) { > $samebranch = 1; > } >-- >2.9.3
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