Bugzilla – Attachment 75119 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-ava.patch (text/plain), 8.83 KB, created by
Kyle M Hall (khall)
on 2018-05-07 12:29:35 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:
2018-05-07 12:29:35 UTC
Size:
8.83 KB
patch
obsolete
>From c04c12f23f9dfc0ed03df88bfede6a091d332fe2 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 | 16 ++++++++- > Koha/Virtualshelf.pm | 15 ++++++++- > Koha/Virtualshelves.pm | 38 +++++++++++++++++++--- > .../prog/en/modules/virtualshelves/shelves.tt | 28 ++++++++++++++-- > virtualshelves/shelves.pl | 4 +++ > 5 files changed, 92 insertions(+), 9 deletions(-) > >diff --git a/C4/Utils/DataTables/VirtualShelves.pm b/C4/Utils/DataTables/VirtualShelves.pm >index 5a349326b1..942044cd43 100644 >--- a/C4/Utils/DataTables/VirtualShelves.pm >+++ b/C4/Utils/DataTables/VirtualShelves.pm >@@ -15,11 +15,24 @@ 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->{lists} == 1) { >+ return { >+ iTotalRecords => 0, >+ iTotalDisplayRecords => 0, >+ shelves => [], >+ }; >+ } >+ } > > my ($iTotalRecords, $iTotalDisplayRecords); > >@@ -125,6 +138,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 3992830d59..a04ec7914e 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 ) = @_; >@@ -81,6 +82,11 @@ sub is_private { > return $self->category == $PRIVATE; > } > >+sub is_staff { >+ my ( $self ) = @_; >+ return $self->category == $STAFF; >+} >+ > sub is_shelfname_valid { > my ( $self ) = @_; > >@@ -243,8 +249,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 bb7db67789..cd3645fca4 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/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >index 35a70ff8d3..f0815c34cc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt >@@ -2,7 +2,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 %]">Public lists</a> >@@ -297,6 +304,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 %] >@@ -332,6 +346,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"> >@@ -439,6 +456,8 @@ > $(document).ready(function(){ > [% IF category == PUBLIC %] > var type = [% PUBLIC %]; >+ [% ELSIF category == STAFF %] >+ var type = [% STAFF %]; > [% ELSE %] > var type = [% PRIVATE %]; > [% END %] >@@ -498,7 +517,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, >@@ -511,6 +532,9 @@ > } else if ( active == 1 ) { > type = [% PUBLIC %]; > dtListResults.fnDraw(); >+ } else if ( active == 2 ) { >+ type = [% STAFF %]; >+ dtListResults.fnDraw(); > } > } > }); >diff --git a/virtualshelves/shelves.pl b/virtualshelves/shelves.pl >index 192580f857..889942187b 100755 >--- a/virtualshelves/shelves.pl >+++ b/virtualshelves/shelves.pl >@@ -343,6 +343,9 @@ if ( $op eq 'view' ) { > } > } > >+my $permissions = C4::Auth::haspermission( $loggedinuser, { lists => '*' } ); >+my $can_manage_lists = $permissions && $permissions->{lists} == 1; >+ > $template->param( > op => $op, > referer => $referer, >@@ -351,6 +354,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.15.1 (Apple Git-101)
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