Bugzilla – Attachment 120665 Details for
Bug 26346
Add option to make a public list editable by library staff only
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26346: Move checking if patron can change staff list to Koha/Patron.pm
Bug-26346-Move-checking-if-patron-can-change-staff.patch (text/plain), 5.01 KB, created by
Alex Buckley
on 2021-05-07 09:23:55 UTC
(
hide
)
Description:
Bug 26346: Move checking if patron can change staff list to Koha/Patron.pm
Filename:
MIME Type:
Creator:
Alex Buckley
Created:
2021-05-07 09:23:55 UTC
Size:
5.01 KB
patch
obsolete
>From 5daaeb933cafe21714cb9c551f5a2d3634300376 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Fri, 30 Apr 2021 08:13:21 +0000 >Subject: [PATCH] Bug 26346: Move checking if patron can change staff list to > Koha/Patron.pm > >Sponsored-by: Horowhenua Library Trust, New Zealand >--- > Koha/Patron.pm | 15 +++++++++++++++ > Koha/Virtualshelf.pm | 16 ++++------------ > Koha/Virtualshelves.pm | 4 +--- > opac/opac-addbybiblionumber.pl | 3 +-- > 4 files changed, 21 insertions(+), 17 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index d47b3f77d2..bd0e201f41 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -1909,6 +1909,21 @@ sub queue_notice { > return \%return; > } > >+=head3 can_patron_change_staff_only_lists >+ >+$patron->can_patron_change_staff_only_lists; >+ >+Return 1 if a patron has 'Superlibrarian' or 'Catalogue' permission. >+Otherwise, return 0. >+ >+=cut >+ >+sub can_patron_change_staff_only_lists { >+ my ( $self, $params ) = @_; >+ return 1 if C4::Auth->haspermission( $self->userid, { 'catalogue' => 1 }); >+ return 0; >+} >+ > =head2 Internal methods > > =head3 _type >diff --git a/Koha/Virtualshelf.pm b/Koha/Virtualshelf.pm >index 56ffe42d74..3a937bc9d3 100644 >--- a/Koha/Virtualshelf.pm >+++ b/Koha/Virtualshelf.pm >@@ -184,11 +184,8 @@ sub add_biblio { > )->count; > return if $already_exists; > >- my $patron = Koha::Patrons->find( $borrowernumber ); >- my $staffuser = 1 if ( C4::Auth::haspermission( $patron->userid, {'catalogue' => 1 }) ); >- > # Check permissions >- return unless ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) || ( $self->allow_change_from_staff && $staffuser ) || $self->allow_change_from_others; >+ return unless ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) || ( $self->allow_change_from_staff && Koha::Patrons->find( $borrowernumber )->can_patron_change_staff_only_lists ) || $self->allow_change_from_others; > > my $content = Koha::Virtualshelfcontent->new( > { >@@ -209,11 +206,9 @@ sub remove_biblios { > my $borrowernumber = $params->{borrowernumber}; > return unless @$biblionumbers; > >- my $patron = Koha::Patrons->find( $borrowernumber ); >- my $staffuser = 1 if ( haspermission( $patron->userid, {'catalogue' => 1 })); > my $number_removed = 0; > if( ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) >- || ( $staffuser && $self->allow_change_from_staff ) >+ || ( $self->allow_change_from_staff && Koha::Patrons->find( $borrowernumber )->can_patron_change_staff_only_lists ) > || $self->allow_change_from_others ) { > $number_removed += $self->get_contents->search({ > biblionumber => $biblionumbers, >@@ -242,7 +237,7 @@ sub can_be_deleted { > > my $patron = Koha::Patrons->find( $borrowernumber ); > >- return 1 if $self->is_public and C4::Auth::haspermission( $patron->userid, { lists => 'delete_public_lists' } ); >+ return 1 if $self->is_public and haspermission( $patron->userid, { lists => 'delete_public_lists' } ); > > return 0; > } >@@ -257,12 +252,9 @@ sub can_be_managed { > sub can_biblios_be_added { > my ( $self, $borrowernumber ) = @_; > >- my $patron = Koha::Patrons->find( $borrowernumber ); >- my $staffuser = 1 if ( C4::Auth::haspermission( $patron->userid, {'catalogue' => 1 } )); >- > return 1 > if $borrowernumber >- and ( ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) or ( $self->allow_change_from_staff && $staffuser ) or $self->allow_change_from_others ); >+ and ( ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) or ( $self->allow_change_from_staff && Koha::Patrons->find( $borrowernumber )->can_patron_change_staff_only_lists ) or $self->allow_change_from_others ); > return 0; > } > >diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm >index 2cd1f6f7b0..8162dfd815 100644 >--- a/Koha/Virtualshelves.pm >+++ b/Koha/Virtualshelves.pm >@@ -90,9 +90,7 @@ sub get_some_shelves { > > my @conditions; > if ( $add_allowed ) { >- my $patron = Koha::Patrons->find( $borrowernumber ); >- my $staffuser = haspermission( $patron->userid, {'catalogue' => 1}); >- if ( $staffuser ) { >+ if ( Koha::Patrons->find( $borrowernumber )->can_patron_change_staff_only_lists ) { > push @conditions, { > -or => > [ >diff --git a/opac/opac-addbybiblionumber.pl b/opac/opac-addbybiblionumber.pl >index c6a76b4715..fd654f34fa 100755 >--- a/opac/opac-addbybiblionumber.pl >+++ b/opac/opac-addbybiblionumber.pl >@@ -119,8 +119,7 @@ if ($newvirtualshelf) { > { join => 'virtualshelfshares', } > ); > my $public_shelves; >- my $logged_in_patron = Koha::Patrons->find( $loggedinuser ); >- if ( haspermission( $logged_in_patron->userid, {'catalogue' => 1})) { >+ if ( Koha::Patrons->find( $borrowernumber )->can_patron_change_staff_only_lists ) { > $public_shelves = Koha::Virtualshelves->search( > { category => 2, > -or => [ >-- >2.11.0
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 26346
:
119686
|
120663
|
120664
|
120665
|
120909
|
120910
|
120953
|
120954
|
121511
|
121512
|
122033
|
122034
|
122533
|
122535
|
122536
|
122537
|
122538
|
122539
|
122540
|
122685
|
122686
|
122687
|
122688
|
122689
|
122691
|
124010
|
124011
|
125436
|
125472
|
125914
|
125915
|
125916
|
125917
|
127556
|
127557
|
127558
|
127559
|
127560
|
128017
|
128018
|
128019
|
128020
|
128021
|
128022
|
128023
|
128383
|
128384
|
128385
|
131699
|
131700
|
131757
|
131764
|
132373
|
132475
|
132476
|
132477
|
132478
|
132479
|
132751
|
132752
|
132753
|
132754
|
132755