Bugzilla – Attachment 115823 Details for
Bug 20718
Add ability to have lists that are available to all list editors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20718: Add ability to have lists that are available to all list editors
Bug-20718-Add-ability-to-have-lists-that-are-avail.patch (text/plain), 10.49 KB, created by
Kyle M Hall (khall)
on 2021-01-26 14:14:45 UTC
(
hide
)
Description:
Bug 20718: Add ability to have lists that are available to all list editors
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-01-26 14:14:45 UTC
Size:
10.49 KB
patch
obsolete
>From 8962409d1fe3f04b8489af51ace71b74fe90de55 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatetsolutions.com> >Date: Mon, 7 May 2018 07:10:28 -0400 >Subject: [PATCH] Bug 20718: Add ability to have lists that are available to > all list editors > >Some librarians would like to have lists that can be shared among staff that have the lists permission. > >Test Plan: >1) Apply this patch >2) Create some private, public and 'staff' lists >3) Note only staff that can edit lists have access to the 'staff' lists >--- > C4/Utils/DataTables/VirtualShelves.pm | 21 +++++++++- > Koha/Virtualshelf.pm | 40 ++++++++++++++++++- > Koha/Virtualshelves.pm | 38 +++++++++++++++--- > .../virtualshelves/addbybiblionumber.tt | 1 + > .../prog/en/modules/virtualshelves/shelves.tt | 28 ++++++++++++- > virtualshelves/shelves.pl | 4 ++ > 6 files changed, 123 insertions(+), 9 deletions(-) > >diff --git a/C4/Utils/DataTables/VirtualShelves.pm b/C4/Utils/DataTables/VirtualShelves.pm >index 5a349326b1..a6c1798c2e 100644 >--- a/C4/Utils/DataTables/VirtualShelves.pm >+++ b/C4/Utils/DataTables/VirtualShelves.pm >@@ -15,12 +15,30 @@ sub search { > my $dt_params = $params->{dt_params}; > > # public is default >- $type = 2 if not $type or $type != 1; >+ $type = 2 unless $type && ( $type == 1 || $type == 3 ); > > # If not logged in user, be carreful and set the borrowernumber to 0 > # to prevent private lists lack > my $loggedinuser = C4::Context->userenv->{'number'} || 0; > >+ if ( $type == 3 ) { >+ my $permissions = >+ C4::Auth::haspermission( C4::Context->userenv->{id}, { lists => '*' } ); >+ >+ unless ( >+ $permissions >+ && ( $permissions->{superlibrarian} == 1 >+ || $permissions->{lists} == 1 ) >+ ) >+ { >+ return { >+ iTotalRecords => 0, >+ iTotalDisplayRecords => 0, >+ shelves => [], >+ }; >+ } >+ } >+ > my ($iTotalRecords, $iTotalDisplayRecords); > > my $dbh = C4::Context->dbh; >@@ -125,6 +143,7 @@ sub search { > $shelf->{can_delete_shelf} = $s->can_be_deleted( $loggedinuser ); > $shelf->{is_shared} = $s->is_shared; > } >+ > return { > iTotalRecords => $iTotalRecords, > iTotalDisplayRecords => $iTotalDisplayRecords, >diff --git a/Koha/Virtualshelf.pm b/Koha/Virtualshelf.pm >index c27c695ada..185e2b6608 100644 >--- a/Koha/Virtualshelf.pm >+++ b/Koha/Virtualshelf.pm >@@ -47,7 +47,8 @@ Koha::Virtualshelf - Koha Virtualshelf Object class > =cut > > our $PRIVATE = 1; >-our $PUBLIC = 2; >+our $PUBLIC = 2; >+our $STAFF = 3; > > sub store { > my ( $self ) = @_; >@@ -71,16 +72,45 @@ sub store { > return $self->SUPER::store( $self ); > } > >+=head3 is_public >+ >+ my $bool = $shelf->is_public; >+ >+ Returns true if shelf has been made public. >+ >+=cut >+ > sub is_public { > my ( $self ) = @_; > return $self->category == $PUBLIC; > } > >+=head3 is_private >+ >+ my $bool = $shelf->is_private; >+ >+ Returns true if shelf is a private shelf. >+ >+=cut >+ > sub is_private { > my ( $self ) = @_; > return $self->category == $PRIVATE; > } > >+=head3 is_staff >+ >+ my $bool = $shelf->is_staff; >+ >+ Returns true if shelf is available to staff only. >+ >+=cut >+ >+sub is_staff { >+ my ( $self ) = @_; >+ return $self->category == $STAFF; >+} >+ > sub is_shelfname_valid { > my ( $self ) = @_; > >@@ -221,6 +251,7 @@ sub can_be_viewed { > return 1 if $self->is_public; > return 0 unless $borrowernumber; > return 1 if $self->owner == $borrowernumber; >+ return 1 if $self->category == 3; > return $self->get_shares->search( > { > borrowernumber => $borrowernumber, >@@ -243,8 +274,15 @@ sub can_be_deleted { > > sub can_be_managed { > my ( $self, $borrowernumber ) = @_; >+ > return 1 > if $borrowernumber and $self->owner == $borrowernumber; >+ >+ my $patron = Koha::Patrons->find( $borrowernumber ); >+ my $permissions = C4::Auth::haspermission( $patron->userid, { lists => '*' } ); >+ return 1 >+ if $borrowernumber and $self->category == 3 and $permissions and $permissions->{lists} == 1; >+ > return 0; > } > >diff --git a/Koha/Virtualshelves.pm b/Koha/Virtualshelves.pm >index 3dde3c35da..7678cc0de9 100644 >--- a/Koha/Virtualshelves.pm >+++ b/Koha/Virtualshelves.pm >@@ -35,10 +35,6 @@ Koha::Virtualshelf - Koha Virtualshelf Object class > > =cut > >-=head3 type >- >-=cut >- > sub get_private_shelves { > my ( $self, $params ) = @_; > my $page = $params->{page}; >@@ -62,7 +58,6 @@ sub get_private_shelves { > ); > } > >- > sub get_public_shelves { > my ( $self, $params ) = @_; > my $page = $params->{page}; >@@ -80,6 +75,31 @@ sub get_public_shelves { > ); > } > >+=head3 get_staff_shelves >+ >+ my $shelves = $virtual_shelves->get_staff_shelves( { page => $page, rows => $rowss ); >+ >+ Returns item lists that are visible to all staff that can manage patron lists >+ >+=cut >+ >+sub get_staff_shelves { >+ my ( $self, $params ) = @_; >+ my $page = $params->{page}; >+ my $rows = $params->{rows}; >+ >+ $self->search( >+ { >+ category => 3, >+ }, >+ { >+ group_by => 'shelfnumber', >+ order_by => 'shelfname', >+ ( ( $page and $rows ) ? ( page => $page, rows => $rows ) : () ), >+ } >+ ); >+} >+ > sub get_some_shelves { > my ( $self, $params ) = @_; > my $borrowernumber = $params->{borrowernumber} || 0; >@@ -160,10 +180,18 @@ sub get_shelves_containing_record { > ); > } > >+=head3 _type >+ >+=cut >+ > sub _type { > return 'Virtualshelve'; > } > >+=head3 object_class >+ >+=cut >+ > sub object_class { > return 'Koha::Virtualshelf'; > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/addbybiblionumber.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/addbybiblionumber.tt >index e43c50ed1f..35a14d7727 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/addbybiblionumber.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/addbybiblionumber.tt >@@ -97,6 +97,7 @@ > <select name="category" id="category"> > <option value="1">Private</option> > <option value="2">Public</option> >+ <option value="3">Staff only</option> > </select> > </li></ol> > </fieldset> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >index 3c55406ab2..51684a8287 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >@@ -3,7 +3,8 @@ > [% USE Koha %] > [% USE KohaDates %] > [% SET PRIVATE = 1 %] >-[% SET PUBLIC = 2 %] >+[% SET PUBLIC = 2 %] >+[% SET STAFF = 3 %] > [% SET footerjs = 1 %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › [% IF op == 'view' %]Lists › Contents of [% shelf.shelfname | html %][% ELSE %]Lists[% END %][% IF op == 'add_form' %] › Create new list[% END %][% IF op == 'edit_form' %] › Edit list [% shelf.shelfname | html %][% END %]</title> >@@ -48,6 +49,12 @@ > [% ELSE %] > Your lists > [% END %] >+ [% ELSIF shelf AND shelf.is_staff %] › >+ [% IF op == 'view' %] >+ <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&category=[% STAFF %]">Staff lists</a> >+ [% ELSE %] >+ Public lists >+ [% END %] > [% ELSIF shelf AND shelf.is_public %] › > [% IF op == 'view' %] > <a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=list&category=[% PUBLIC | uri %]">Public lists</a> >@@ -301,6 +308,13 @@ > [% ELSE %] > <option value="1">Private</option> > [% END %] >+ >+ [% IF shelf.is_staff %] >+ <option value="3" selected="selected">Staff only</option> >+ [% ELSE %] >+ <option value="3">Staff only</option> >+ [% END %] >+ > [% IF shelf.is_public %] > <option value="2" selected="selected">Public</option> > [% ELSE %] >@@ -335,6 +349,9 @@ > <ul> > <li id="privateshelves_tab" class="active"><a href="#tab_content">Your lists</a></li> > <li id="publicshelves_tab" class="active"><a href="#tab_content">Public lists</a></li> >+ [% IF can_manage_lists %] >+ <li id="staffshelves_tab" class="active"><a href="#tab_content">[% CAN_user_lists %] Staff lists</a></li> >+ [% END %] > </ul> > > <div id="tab_content"> >@@ -451,6 +468,8 @@ > $(document).ready(function(){ > [% IF category == PUBLIC %] > var type = [% PUBLIC | html %]; >+ [% ELSIF category == STAFF %] >+ var type = [% STAFF %]; > [% ELSE %] > var type = [% PRIVATE | html %]; > [% END %] >@@ -510,7 +529,9 @@ > dtListResults.fnAddFilters("filter", 750); > > var tabs = $("#tabs").tabs({ >- [% IF category == PUBLIC %] >+ [% IF category == STAFF %] >+ active: 2, >+ [% ELSIF category == PUBLIC %] > active: 1, > [% ELSE %] > active: 0, >@@ -523,6 +544,9 @@ > } else if ( active == 1 ) { > type = [% PUBLIC | html %]; > dtListResults.fnDraw(); >+ } else if ( active == 2 ) { >+ type = [% STAFF %]; >+ dtListResults.fnDraw(); > } > } > }); >diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl >index d233eb1355..6d4c89f09b 100755 >--- a/virtualshelves/shelves.pl >+++ b/virtualshelves/shelves.pl >@@ -346,6 +346,9 @@ if ( $op eq 'view' ) { > } > } > >+my $permissions = C4::Auth::haspermission( C4::Context->userenv->{id}, { lists => '*' } ); >+my $can_manage_lists = $permissions && ( $permissions->{superlibrarian} == 1 || $permissions->{lists} == 1 ); >+ > $template->param( > op => $op, > referer => $referer, >@@ -354,6 +357,7 @@ $template->param( > category => $category, > print => scalar $query->param('print') || 0, > csv_profiles => [ Koha::CsvProfiles->search({ type => 'marc', used_for => 'export_records' }) ], >+ can_manage_lists => $can_manage_lists, > ); > > output_html_with_http_headers $query, $cookie, $template->output; >-- >2.24.1 (Apple Git-126)
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 20718
:
75119
|
75201
|
76944
|
81135
|
81136
|
115823
|
116716
|
118185