Bugzilla – Attachment 131681 Details for
Bug 20256
Add ability to limit editing of items to home library or library group
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20256: Use new methods
Bug-20256-Use-new-methods.patch (text/plain), 7.14 KB, created by
Katrin Fischer
on 2022-03-14 22:07:01 UTC
(
hide
)
Description:
Bug 20256: Use new methods
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2022-03-14 22:07:01 UTC
Size:
7.14 KB
patch
obsolete
>From b8e26615dcef63722bca4a776a00ecd91bfbf08e Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Thu, 28 Mar 2019 11:07:02 -0400 >Subject: [PATCH] Bug 20256: Use new methods > >Signed-off-by: Bob Bennhoff - CLiC <bbennhoff@clicweb.org> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > Koha/Item.pm | 4 +--- > Koha/UI/Table/Builder/Items.pm | 3 +++ > catalogue/detail.pl | 8 +------- > catalogue/moredetail.pl | 3 +++ > cataloguing/additem.pl | 5 ++++- > koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc | 2 +- > .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 4 +++- > tools/batchMod.pl | 5 +++-- > 8 files changed, 19 insertions(+), 15 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 26321babfe..198621452e 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -281,9 +281,7 @@ sub safe_to_delete { > > $error = "not_same_branch" > if defined C4::Context->userenv >- and !C4::Context->IsSuperLibrarian() >- and C4::Context->preference("IndependentBranches") >- and ( C4::Context->userenv->{branch} ne $self->homebranch ); >+ and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $self ) ) > > # check it doesn't have a waiting reserve > $error = "book_reserved" >diff --git a/Koha/UI/Table/Builder/Items.pm b/Koha/UI/Table/Builder/Items.pm >index b573f2a3b3..2df4c164ba 100644 >--- a/Koha/UI/Table/Builder/Items.pm >+++ b/Koha/UI/Table/Builder/Items.pm >@@ -72,6 +72,8 @@ Use it with: > sub build_table { > my ( $self, $params ) = @_; > >+ my $patron = $self->params; >+ > my $items = Koha::Items->search( { itemnumber => $self->{itemnumbers} } ); > > my @items; >@@ -84,6 +86,7 @@ sub build_table { > holds => $item->biblio->holds->count, > item_holds => $item->holds->count, > is_checked_out => $item->checkout || 0, >+ nomod => $patron ? 0 : $patron->can_edit_item($item), > }; > push @items, $item_info; > } >diff --git a/catalogue/detail.pl b/catalogue/detail.pl >index 75aeed0e96..dea5048844 100755 >--- a/catalogue/detail.pl >+++ b/catalogue/detail.pl >@@ -389,13 +389,7 @@ foreach my $item (@items) { > $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} ); > } > >- if ( C4::Context->preference('IndependentBranches') ) { >- my $userenv = C4::Context->userenv(); >- if ( not C4::Context->IsSuperLibrarian() >- and $userenv->{branch} ne $item->{homebranch} ) { >- $item->{cannot_be_edited} = 1; >- } >- } >+ $item->{cannot_be_edited} = !$patron->can_edit_item( $item_object ); > > if ( C4::Context->preference("LocalCoverImages") == 1 ) { > $item->{cover_images} = $item_object->cover_images; >diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl >index cff2460a27..f9eb3a4fbe 100755 >--- a/catalogue/moredetail.pl >+++ b/catalogue/moredetail.pl >@@ -232,6 +232,9 @@ foreach my $item (@items){ > $item->{'nomod'}=1; > } > } >+ >+ $item->{nomod} = !$patron->can_edit_item( $item ); >+ > if ($item->{'datedue'}) { > $item->{'issue'}= 1; > } else { >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 4588b13fb5..2ccecad4e8 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -124,7 +124,8 @@ my ($template, $loggedinuser, $cookie) > > > # Does the user have a restricted item editing permission? >-my $uid = Koha::Patrons->find( $loggedinuser )->userid; >+my $patron = Koha::Patrons->find( $loggedinuser ); >+my $uid = $patron->userid; > my $restrictededition = $uid ? haspermission($uid, {'editcatalogue' => 'edit_items_restricted'}) : undef; > # In case user is a superlibrarian, editing is not restricted > $restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian()); >@@ -506,6 +507,8 @@ if ($op) { > > my @items; > for my $item ( $biblio->items->as_list, $biblio->host_items->as_list ) { >+ my $i = $item->columns_to_str; >+ $item->{nomod} = 1 unless $patron->can_edit_item($item); > push @items, $item->columns_to_str; > } > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >index 4f4f461e0e..f13093903e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >@@ -246,7 +246,7 @@ > </thead> > <tbody> > [% FOREACH item IN items %] >- [% SET can_be_edited = ! ( Koha.Preference('IndependentBranches') && ! logged_in_user.is_superlibrarian && item.homebranch != Branches.GetLoggedInBranchname() ) %] >+ [% SET can_be_edited = !item.nomod && !( Koha.Preference('IndependentBranches') && ! logged_in_user && item.homebranch != Branches.GetLoggedInBranchname() ) %] > > <tr> > [% IF checkboxes_edit %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 70a22e7262..7327029807 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -344,7 +344,9 @@ > <tr> > [% IF (StaffDetailItemSelection) %] > <td style="text-align:center;vertical-align:middle"> >- <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" /> >+ [% UNLESS item.cannot_be_edited %] >+ <input type="checkbox" value="[% item.itemnumber | html %]" name="itemnumber" /> >+ [% END %] > </td> > [% END %] > [% IF Koha.Preference('LocalCoverImages') && ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %] >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index ef6dec19b8..16288a9ff1 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -75,7 +75,8 @@ my ($template, $loggedinuser, $cookie) > $template->param( searchid => scalar $input->param('searchid'), ); > > # Does the user have a restricted item edition permission? >-my $uid = $loggedinuser ? Koha::Patrons->find( $loggedinuser )->userid : undef; >+my $patron = Koha::Patrons->find( $loggedinuser ); >+my $uid = $loggedinuser ? $patron->userid : undef; > my $restrictededition = $uid ? haspermission($uid, {'tools' => 'items_batchmod_restricted'}) : undef; > # In case user is a superlibrarian, edition is not restricted > $restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian()); >@@ -296,7 +297,7 @@ if ($op eq "show"){ > if ( $display_items ) { > my $items_table = > Koha::UI::Table::Builder::Items->new( { itemnumbers => \@itemnumbers } ) >- ->build_table; >+ ->build_table( { patron => $patron } );; > $template->param( > items => $items_table->{items}, > item_header_loop => $items_table->{headers}, >-- >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 20256
:
87226
|
87227
|
87228
|
87229
|
87230
|
87231
|
87232
|
87233
|
87262
|
87263
|
87264
|
87265
|
87266
|
87267
|
87268
|
87269
|
87270
|
88537
|
88539
|
88541
|
88542
|
88543
|
88544
|
88545
|
88546
|
88547
|
88632
|
88702
|
88703
|
88704
|
88705
|
88935
|
88936
|
96015
|
96016
|
96017
|
96018
|
96019
|
96020
|
96021
|
96022
|
96023
|
96024
|
96025
|
96026
|
96027
|
96028
|
96029
|
96030
|
96031
|
96032
|
96033
|
102622
|
102623
|
102624
|
102625
|
102626
|
102627
|
102628
|
102629
|
102630
|
102631
|
102632
|
102633
|
102634
|
102635
|
102636
|
102637
|
102638
|
102639
|
102640
|
102641
|
102642
|
102703
|
102704
|
102705
|
102706
|
102707
|
102708
|
102709
|
102710
|
102711
|
102712
|
102713
|
102714
|
102715
|
102716
|
102717
|
102718
|
102719
|
102720
|
102721
|
102722
|
102732
|
102733
|
102734
|
102735
|
102736
|
102737
|
102738
|
102739
|
102740
|
102741
|
102742
|
102743
|
102744
|
102745
|
102746
|
102747
|
102748
|
102749
|
102750
|
102751
|
107312
|
107313
|
107314
|
107315
|
107316
|
107317
|
107318
|
107319
|
107320
|
107321
|
107322
|
107323
|
107324
|
107325
|
107326
|
107327
|
107328
|
107329
|
107330
|
108851
|
108852
|
108853
|
108854
|
108855
|
108856
|
108857
|
108858
|
108859
|
108860
|
108861
|
108862
|
108863
|
108864
|
108865
|
108866
|
108867
|
108868
|
108869
|
108870
|
109939
|
110005
|
113706
|
113707
|
113708
|
113709
|
113710
|
113711
|
113712
|
113713
|
113714
|
113715
|
113716
|
113717
|
113718
|
113719
|
113720
|
113721
|
113722
|
113723
|
113724
|
113725
|
113726
|
113727
|
113728
|
116042
|
116043
|
116044
|
116045
|
116046
|
116047
|
116048
|
116049
|
116050
|
116051
|
116052
|
116053
|
116054
|
116055
|
116056
|
116057
|
116058
|
116059
|
116060
|
116061
|
116062
|
116063
|
116064
|
120055
|
120056
|
120057
|
120058
|
120059
|
120060
|
120061
|
120062
|
120063
|
120064
|
120065
|
120066
|
120067
|
120068
|
120069
|
120070
|
120071
|
120072
|
120073
|
120074
|
120075
|
120076
|
121771
|
121772
|
121773
|
121774
|
121775
|
121776
|
121777
|
121778
|
121779
|
121780
|
121781
|
121782
|
121783
|
121785
|
121786
|
121787
|
121788
|
121789
|
121790
|
121791
|
121792
|
124286
|
124287
|
124288
|
124289
|
124290
|
124291
|
124292
|
124293
|
124294
|
124295
|
124296
|
124297
|
124298
|
124299
|
124300
|
124301
|
124302
|
124303
|
124304
|
124305
|
124306
|
124307
|
124321
|
128734
|
128735
|
128736
|
128737
|
128738
|
128739
|
128740
|
128741
|
128742
|
128743
|
128744
|
128745
|
128746
|
128747
|
128748
|
128749
|
128750
|
128751
|
128752
|
128753
|
131676
|
131677
|
131678
|
131679
|
131680
|
131681
|
131682
|
131683
|
131684
|
131685
|
131686
|
131687
|
131688
|
131689
|
131690
|
131691
|
131692
|
131693
|
131694
|
131695
|
131696
|
131697
|
132483
|
132484
|
132486
|
132917
|
134375
|
134376
|
134377
|
139135
|
139136
|
139137
|
139138
|
139139
|
139140
|
139141
|
139142
|
139143
|
139144
|
139145
|
139146
|
139147
|
139148
|
139149
|
139150
|
139151
|
139152
|
139153
|
139154
|
139155
|
139156
|
139157
|
139158
|
139159
|
139160
|
139161
|
139162
|
139163
|
143527
|
143529
|
143530
|
143531
|
143532
|
143533
|
143534
|
143535
|
143536
|
143537
|
143538
|
143539
|
143540
|
143541
|
143542
|
143543
|
143544
|
143545
|
143546
|
143547
|
143548
|
143549
|
143550
|
143551
|
143552
|
143553
|
143554
|
143555
|
143556
|
145286
|
145287
|
145288
|
145289
|
145290
|
145291
|
145292
|
145293
|
145482
|
145483
|
145484
|
145485
|
145486
|
145487
|
145488
|
145489
|
145809
|
145810
|
145811
|
145812
|
145813
|
145814
|
145815
|
145816
|
145887
|
145888
|
145889
|
145890
|
145891
|
145892
|
145893
|
145894
|
145895
|
145896
|
145951
|
145952
|
145953
|
145954
|
145955