Bugzilla – Attachment 148648 Details for
Bug 30418
Add permission and setting for public lists to allow staff with permission to edit contents
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30418: Add ability for permitted staff to edit list contents
Bug-30418-Add-ability-for-permitted-staff-to-edit-.patch (text/plain), 14.84 KB, created by
Kyle M Hall (khall)
on 2023-03-24 10:52:54 UTC
(
hide
)
Description:
Bug 30418: Add ability for permitted staff to edit list contents
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-03-24 10:52:54 UTC
Size:
14.84 KB
patch
obsolete
>From 2ca801bba6a3b453b198c6e3fedc01cc38af04e1 Mon Sep 17 00:00:00 2001 >From: Alex Buckley <alexbuckley@catalyst.net.nz> >Date: Fri, 19 Aug 2022 03:17:47 +0000 >Subject: [PATCH] Bug 30418: Add ability for permitted staff to edit list > contents > >Public lists with 'Allow changes to contents from' = 'Permitted staff only' >can have their contents managed by Koha patrons with either of the >permissions below: > >- superlibrarian permission >- catalogue permission + 'edit_public_list_contents' sub-permission > >Test plan: >1. Apply patches, update database, restart services >2. In the staff client go to: Lists > New List >3. Create a list, choose 'Allow changes to contents from' => 'Permitted >staff only' > >4. Log into the OPAC as a patron with no permissions. >5. Confirm you CANNOT add a biblio to the list from the OPAC search result page and >OPAC biblio detail pages > >6. Log into the OPAC as a patron with only the 'catalogue' permissions >enabled >7. Confirm you CANNOT add a biblio to the list from OPAC search result >or biblio detail pages > >8. Log into the OPAC as a patron with the 'catalogue' and >'edit_public_list_contents' permissions enabled >9. Confirm you CAN add/remove biblios from the OPAC search result and >biblio detail pages > >10. Log into the OPAC as a patron with superlibrarian permissions >11. Confirm you CAN add a biblio to the list from the OPAC search result >page and OPAC biblio detail pages > >12. Log into the staff client as a patron with only the >'catalogue' permission and confirm you CANNOT add/remove records from the >list > >13. Log into the staff client as a patron with the 'catalogue' and >'edit_public_list_contents' sub-permission (found under 'Lists' parent >permission) >14. Confirm you CAN add/remove records from the list > >15. Login into thestaff client as a patron with 'superlibrarian' >permissions and confirm you CAN add/remove records from the list > >Sponsored-by: Catalyst IT, New Zealand > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> >--- > Koha/Patron.pm | 15 ++++++++++ > Koha/Virtualshelf.pm | 7 +++-- > Koha/Virtualshelves.pm | 21 +++++++++++-- > .../bootstrap/en/modules/opac-shelves.tt | 2 +- > opac/opac-addbybiblionumber.pl | 21 +++++++++++-- > opac/opac-shelves.pl | 30 +++++++++++-------- > virtualshelves/shelves.pl | 13 ++++---- > 7 files changed, 83 insertions(+), 26 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index d3ec9154d8c..bfe4a5e3e0a 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -2359,6 +2359,21 @@ sub can_patron_change_staff_only_lists { > return 0; > } > >+=head3 can_patron_change_permitted_staff_lists >+ >+$patron->can_patron_change_permitted_staff_lists; >+ >+Return 1 if a patron has 'Superlibrarian' or 'Catalogue' and 'edit_public_list_contents' permissions. >+Otherwise, return 0. >+ >+=cut >+ >+sub can_patron_change_permitted_staff_lists { >+ my ( $self, $params ) = @_; >+ return 1 if C4::Auth::haspermission( $self->userid, { 'catalogue' => 1, lists => 'edit_public_list_contents' } ); >+ return 0; >+} >+ > =head3 encode_secret > > $patron->encode_secret($secret32); >diff --git a/Koha/Virtualshelf.pm b/Koha/Virtualshelf.pm >index 605916ef45a..ec39715a547 100644 >--- a/Koha/Virtualshelf.pm >+++ b/Koha/Virtualshelf.pm >@@ -59,6 +59,8 @@ sub store { > unless defined $self->allow_change_from_others; > $self->allow_change_from_staff( 0 ) > unless defined $self->allow_change_from_staff; >+ $self->allow_change_from_permitted_staff( 0 ) >+ unless defined $self->allow_change_from_permitted_staff; > > $self->created_on( dt_from_string ) > unless defined $self->created_on; >@@ -181,7 +183,7 @@ sub add_biblio { > > # Check permissions > my $patron = Koha::Patrons->find( $borrowernumber ) or return 0; >- return 0 unless ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) || ( $self->allow_change_from_staff && $patron->can_patron_change_staff_only_lists ) || $self->allow_change_from_others; >+ return 0 unless ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) || ( $self->allow_change_from_staff && $patron->can_patron_change_staff_only_lists ) || ( $self->allow_change_from_permitted_staff && $patron->can_patron_change_permitted_staff_lists ) || $self->allow_change_from_others; > > my $content = Koha::Virtualshelfcontent->new( > { >@@ -206,6 +208,7 @@ sub remove_biblios { > my $patron = Koha::Patrons->find( $borrowernumber ) or return 0; > if( ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) > || ( $self->allow_change_from_staff && $patron->can_patron_change_staff_only_lists ) >+ || ( $self->allow_change_from_permitted_staff && $patron->can_patron_change_permitted_staff_lists ) > || $self->allow_change_from_others ) { > $number_removed += $self->get_contents->search({ > biblionumber => $biblionumbers, >@@ -256,7 +259,7 @@ sub can_biblios_be_added { > my $patron = Koha::Patrons->find( $borrowernumber ) or return 0; > return 1 > if $borrowernumber >- and ( ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) or ( $self->allow_change_from_staff && $patron->can_patron_change_staff_only_lists ) or $self->allow_change_from_others ); >+ and ( ( $self->owner == $borrowernumber && $self->allow_change_from_owner ) or ( $self->allow_change_from_staff && $patron->can_patron_change_staff_only_lists ) or ( $self->allow_change_from_permitted_staff && $patron->can_patron_change_permitted_staff_lists ) or $self->allow_change_from_others ); > return 0; > } > >diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm >index 2b82dfc7324..9b71a016bb8 100644 >--- a/Koha/Virtualshelves.pm >+++ b/Koha/Virtualshelves.pm >@@ -136,12 +136,14 @@ sub get_some_shelves { > my @conditions; > my $patron; > my $staffuser = 0; >+ my $permitteduser = 0; > if ( $borrowernumber != 0 ) { > $patron = Koha::Patrons->find( $borrowernumber ); > $staffuser = $patron->can_patron_change_staff_only_lists; >+ $permitteduser = $patron->can_patron_change_permitted_staff_lists; > } > if ( $add_allowed ) { >- if ( $staffuser ) { >+ if ( $permitteduser ) { > push @conditions, { > -or => > [ >@@ -149,8 +151,21 @@ sub get_some_shelves { > "me.owner" => $borrowernumber, > "me.allow_change_from_owner" => 1, > }, >- "me.allow_change_from_others" => 1, >- "me.allow_change_from_staff" => 1 >+ "me.allow_change_from_others" => 1, >+ "me.allow_change_from_staff" => 1, >+ "me.allow_change_from_permitted_staff" => 1 >+ ] >+ }; >+ } elsif ( $staffuser ) { >+ push @conditions, { >+ -or => >+ [ >+ { >+ "me.owner" => $borrowernumber, >+ "me.allow_change_from_owner" => 1, >+ }, >+ "me.allow_change_from_others" => 1, >+ "me.allow_change_from_staff" => 1 > ] > }; > } else { >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >index 354ba34c360..5da2a6d427c 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt >@@ -51,7 +51,7 @@ > [% IF shelf.allow_change_from_others %]<option value="2" selected="selected">Anyone seeing this list</option>[% ELSE %]<option value="2">Anyone seeing this list</option>[% END %] > > [% IF staffuser == 1 %][% IF shelf.allow_change_from_staff %]<option value="3" selected="selected">Staff only</option>[% ELSE %]<option value="3">Staff only</option>[% END %][% END %] >- [% IF permitteduser == 1 %][% shelf.allow_change_from_permitted_staff %]<option value="4" selected="selected">Permitted staff only</option>[% ELSE %]<option value="4">Permitted staff only</option>[% END %'[% END %] >+ [% IF permitteduser == 1 %][% IF shelf.allow_change_from_permitted_staff %]<option value="4" selected="selected">Permitted staff only</option>[% ELSE %]<option value="4">Permitted staff only</option>[% END %][% END %] > > </select> >   <span id="anyone_remark" style="display:none;color:red;">The "Anyone" permission has no actual effect while this list is strictly private.</span> >diff --git a/opac/opac-addbybiblionumber.pl b/opac/opac-addbybiblionumber.pl >index 4edbd133e71..fc31627882f 100755 >--- a/opac/opac-addbybiblionumber.pl >+++ b/opac/opac-addbybiblionumber.pl >@@ -119,7 +119,7 @@ if ($newvirtualshelf) { > ); > my $public_shelves; > if ( $loggedinuser ) { >- if ( Koha::Patrons->find( $loggedinuser )->can_patron_change_staff_only_lists ) { >+ if ( Koha::Patrons->find( $loggedinuser )->can_patron_change_permitted_staff_lists ) { > $public_shelves = Koha::Virtualshelves->search( > { public => 1, > -or => [ >@@ -127,8 +127,23 @@ if ($newvirtualshelf) { > allow_change_from_owner => 1, > owner => $loggedinuser, > }, >- allow_change_from_others => 1, >- allow_change_from_staff => 1 >+ allow_change_from_others => 1, >+ allow_change_from_staff => 1, >+ allow_change_from_permitted_staff => 1 >+ ], >+ }, >+ { order_by => 'shelfname' } >+ ); >+ } elsif ( Koha::Patrons->find( $loggedinuser )->can_patron_change_staff_only_lists ) { >+ $public_shelves = Koha::Virtualshelves->search( >+ { public => 1, >+ -or => [ >+ -and => { >+ allow_change_from_owner => 1, >+ owner => $loggedinuser, >+ }, >+ allow_change_from_others => 1, >+ allow_change_from_staff => 1 > ], > }, > { order_by => 'shelfname' } >diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl >index a7be90ba58b..5cecfc7b969 100755 >--- a/opac/opac-shelves.pl >+++ b/opac/opac-shelves.pl >@@ -48,6 +48,7 @@ use Koha::RecordProcessor; > > use constant ANYONE => 2; > use constant STAFF => 3; >+use constant PERMITTED => 4; > > my $query = CGI->new; > >@@ -118,9 +119,10 @@ if ( $op eq 'add_form' ) { > { shelfname => scalar $query->param('shelfname'), > sortfield => scalar $query->param('sortfield'), > public => $public, >- allow_change_from_owner => $allow_changes_from > 0, >- allow_change_from_others => $allow_changes_from == ANYONE, >- allow_change_from_staff => $allow_changes_from == STAFF, >+ allow_change_from_owner => $allow_changes_from > 0, >+ allow_change_from_others => $allow_changes_from == ANYONE, >+ allow_change_from_staff => $allow_changes_from == STAFF, >+ allow_change_from_permitted_staff => $allow_changes_from == PERMITTED, > owner => scalar $loggedinuser, > } > ); >@@ -153,6 +155,7 @@ if ( $op eq 'add_form' ) { > $shelf->allow_change_from_owner( $allow_changes_from > 0 ); > $shelf->allow_change_from_others( $allow_changes_from == ANYONE ); > $shelf->allow_change_from_staff( $allow_changes_from == STAFF ); >+ $shelf->allow_change_from_permitted_staff( $allow_changes_from == PERMITTED ); > $shelf->public( $public ); > eval { $shelf->store }; > >@@ -487,17 +490,20 @@ if ( $op eq 'view' ) { > ); > } > >-my $staffuser; >+my ($staffuser, $permitteduser); > $staffuser = Koha::Patrons->find( $loggedinuser )->can_patron_change_staff_only_lists if $loggedinuser; >+$permitteduser = Koha::Patrons->find( $loggedinuser )->can_patron_change_permitted_staff_lists if $loggedinuser; >+ > $template->param( >- op => $op, >- referer => $referer, >- shelf => $shelf, >- messages => \@messages, >- public => $public, >- print => scalar $query->param('print') || 0, >- listsview => 1, >- staffuser => $staffuser, >+ op => $op, >+ referer => $referer, >+ shelf => $shelf, >+ messages => \@messages, >+ public => $public, >+ print => scalar $query->param('print') || 0, >+ listsview => 1, >+ staffuser => $staffuser, >+ permitteduser => $permitteduser > ); > > my $content_type = $query->param('rss')? 'rss' : 'html'; >diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl >index fa92cfcd6eb..a7c5fcf7f02 100755 >--- a/virtualshelves/shelves.pl >+++ b/virtualshelves/shelves.pl >@@ -40,8 +40,9 @@ use Koha::CsvProfiles; > use Koha::Patrons; > use Koha::Virtualshelves; > >-use constant ANYONE => 2; >-use constant STAFF => 3; >+use constant ANYONE => 2; >+use constant STAFF => 3; >+use constant PERMITTED => 4; > > my $query = CGI->new; > >@@ -84,9 +85,10 @@ if ( $op eq 'add_form' ) { > { shelfname => scalar $query->param('shelfname'), > sortfield => scalar $query->param('sortfield'), > public => $public, >- allow_change_from_owner => $allow_changes_from > 0, >- allow_change_from_others => $allow_changes_from == ANYONE, >- allow_change_from_staff => $allow_changes_from == STAFF, >+ allow_change_from_owner => $allow_changes_from > 0, >+ allow_change_from_others => $allow_changes_from == ANYONE, >+ allow_change_from_staff => $allow_changes_from == STAFF, >+ allow_change_from_permitted_staff => $allow_changes_from == PERMITTED, > owner => scalar $query->param('owner'), > } > ); >@@ -117,6 +119,7 @@ if ( $op eq 'add_form' ) { > $shelf->allow_change_from_owner( $allow_changes_from > 0 ); > $shelf->allow_change_from_others( $allow_changes_from == ANYONE ); > $shelf->allow_change_from_staff( $allow_changes_from == STAFF ); >+ $shelf->allow_change_from_permitted_staff( $allow_changes_from == PERMITTED ); > $shelf->public( scalar $query->param('public') ); > eval { $shelf->store }; > >-- >2.30.2
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 30418
:
139696
|
139697
|
139698
|
139699
|
139700
|
139701
|
146363
|
146364
|
146365
|
146366
|
146367
|
146368
|
146374
|
146375
|
146376
|
146377
|
146378
|
146379
|
146609
|
148645
|
148646
|
148647
| 148648 |
148649
|
148650
|
148651
|
148652
|
151249