Bugzilla – Attachment 16239 Details for
Bug 7673
New patron permissions to manage items (edit, batchmod, delete all)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7673 : New patron permissions
Bug-7673--New-patron-permissions.patch (text/plain), 15.87 KB, created by
Matthias Meusburger
on 2013-03-18 13:32:26 UTC
(
hide
)
Description:
Bug 7673 : New patron permissions
Filename:
MIME Type:
Creator:
Matthias Meusburger
Created:
2013-03-18 13:32:26 UTC
Size:
15.87 KB
patch
obsolete
>From fd89fd29970fb09bfc6495b7800ac12ceed2292b Mon Sep 17 00:00:00 2001 >From: Matthias Meusburger <matthias.meusburger@biblibre.com> >Date: Fri, 30 Mar 2012 13:52:38 +0200 >Subject: [PATCH] Bug 7673 : New patron permissions > > This patch adds the following permissions: > > - editcatalogue.limited_item_edition: Limit item modification to barcode, status and note > - editcatalogue.delete_all_items: Delete all items at once > - tools.items_limited_batchmod: Limit batch item modification to item status > > The SubfieldsToAllowForLimitedEdition syspref is used to define which subfields can be edited > when the editcatalogue.limited_item_edition permission is enabled. > > In the same way, the SubfieldsToAllowForLimitedBatchmod is used to define which subfields > can be edited when the tools.items_limited_batchmod permission is enabled. >--- > cataloguing/additem.pl | 42 ++++++++++++++++---- > .../data/mysql/en/mandatory/userpermissions.sql | 3 ++ > installer/data/mysql/sysprefs.sql | 3 ++ > installer/data/mysql/updatedatabase.pl | 27 +++++++++++++ > .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 1 - > .../en/modules/admin/preferences/cataloguing.pref | 6 +++ > .../prog/en/modules/cataloguing/additem.tt | 9 ++++- > tools/batchMod.pl | 10 +++++ > 8 files changed, 92 insertions(+), 9 deletions(-) > >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index a8a8649..57e039e 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -35,7 +35,7 @@ use List::MoreUtils qw/any/; > use C4::Search; > use Storable qw(thaw freeze); > use URI::Escape; >- >+use C4::Members; > > use MARC::File::XML; > use URI::Escape; >@@ -103,9 +103,10 @@ sub _increment_barcode { > > > sub generate_subfield_form { >- my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i) = @_; >+ my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i, $limitededition) = @_; > >- my $frameworkcode = &GetFrameworkCode($biblionumber); >+ my $frameworkcode = &GetFrameworkCode($biblionumber); >+ > my %subfield_data; > my $dbh = C4::Context->dbh; > >@@ -154,6 +155,19 @@ sub generate_subfield_form { > $value = $input->param('barcode'); > } > my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="$subfield_data{maxlength}" ); >+ >+ # Getting list of subfields to keep when limited edition is enabled >+ my $subfieldsToAllowForLimitedEdition = C4::Context->preference('SubfieldsToAllowForLimitedEdition'); >+ my @subfieldsToAllow = split(/ /, $subfieldsToAllowForLimitedEdition); >+ >+ # If we're on limited edition, and our field is not in the list of subfields to allow, >+ # then it is read-only >+ $attributes_no_value .= 'readonly="readonly" ' >+ if ( >+ $limitededition >+ and !grep { $tag . '$' . $subfieldtag eq $_ } @subfieldsToAllow >+ ); >+ > my $attributes = qq($attributes_no_value value="$value" ); > > if ( $subfieldlib->{authorised_value} ) { >@@ -214,7 +228,7 @@ sub generate_subfield_form { > $subfield_data{marc_value} = qq(<input type="hidden" $attributes /> $authorised_lib{$value}); > } > else { >- $subfield_data{marc_value} =CGI::scrolling_list( # FIXME: factor out scrolling_list >+ my @scrparam = ( > -name => "field_value", > -values => \@authorised_values, > -default => $value, >@@ -226,6 +240,15 @@ sub generate_subfield_form { > -id => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield, > -class => "input_marceditor", > ); >+ >+ # If we're on limited edition, and our field is not in the list of subfields to allow, >+ # then it is read-only >+ push @scrparam, (-readonly => "readonly"), (-disabled => "disabled") >+ if ( >+ $limitededition >+ and !grep { $tag . '$' . $subfieldtag eq $_ } @subfieldsToAllow >+ ); >+ $subfield_data{marc_value} =CGI::scrolling_list(@scrparam); > } > > } >@@ -343,6 +366,12 @@ my ($template, $loggedinuser, $cookie) > }); > > >+# Does the user have a limited item edition permission? >+my $uid = GetMember( borrowernumber => $loggedinuser )->{userid} if ($loggedinuser) ; >+my $limitededition = haspermission($uid, {'editcatalogue' => 'limited_item_edition'}) if ($uid); >+# In case user is a superlibrarian, edition is not limited >+$limitededition = 0 if ($limitededition != 0 && $limitededition->{'superlibrarian'} eq 1); >+ > my $today_iso = C4::Dates->today('iso'); > my $tagslib = &GetMarcStructure(1,$frameworkcode); > my $record = GetMarcBiblio($biblionumber); >@@ -770,8 +799,7 @@ if($itemrecord){ > next if subfield_is_koha_internal_p($subfieldtag); > next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10"); > >- my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i); >- >+ my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $limitededition); > push @fields, "$tag$subfieldtag"; > push (@loop_data, $subfield_data); > $i++; >@@ -795,7 +823,7 @@ foreach my $tag ( keys %{$tagslib}){ > my @values = (undef); > @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)->subfield($subtag))); > for my $value (@values){ >- my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i); >+ my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $limitededition); > push (@loop_data, $subfield_data); > $i++; > } >diff --git a/installer/data/mysql/en/mandatory/userpermissions.sql b/installer/data/mysql/en/mandatory/userpermissions.sql >index 8577ef2..583e094 100644 >--- a/installer/data/mysql/en/mandatory/userpermissions.sql >+++ b/installer/data/mysql/en/mandatory/userpermissions.sql >@@ -9,6 +9,8 @@ INSERT INTO permissions (module_bit, code, description) VALUES > ( 9, 'edit_catalogue', 'Edit catalog (Modify bibliographic/holdings data)'), > ( 9, 'fast_cataloging', 'Fast cataloging'), > ( 9, 'edit_items', 'Edit Items'), >+ ( 9, 'limited_item_edition', 'Limit item modification to barcode, status and note (please note that edit_item is still required)'), >+ ( 9, 'delete_all_items', 'Delete all items'), > (11, 'vendors_manage', 'Manage vendors'), > (11, 'contracts_manage', 'Manage contracts'), > (11, 'period_manage', 'Manage periods'), >@@ -38,6 +40,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES > (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'), > (13, 'schedule_tasks', 'Schedule tasks to run'), > (13, 'items_batchmod', 'Perform batch modification of items'), >+ (13, 'items_limited_batchmod', 'Limit batch item modification to item status (please note that items_batchmod is still required)'), > (13, 'items_batchdel', 'Perform batch deletion of items'), > (13, 'manage_csv_profiles', 'Manage CSV export profiles'), > (13, 'moderate_tags', 'Moderate patron tags'), >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index e3966ce..ecb4ca8 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -421,3 +421,6 @@ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES( > INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES('PatronSelfRegistrationAdditionalInstructions','','A free text field to display additional instructions to newly self registered patrons.','','free'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseQueryParser', '0', 'If enabled, try to use QueryParser for queries.', NULL, 'YesNo'); > INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('FinesIncludeGracePeriod','1','If enabled, fines calculations will include the grace period.',NULL,'YesNo'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToAllowForLimitedEdition','','Define a list of subfields for which edition is authorized when limited_item_edtion permission is enabled (separated by space)','','Free'); >+INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToAllowForLimitedBatchmod','','Define a list of subfields for which edition is authorized when items_limited_batchmod permission is enabled (separated by space)','','Free'); >+ >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index f0a9269..72a2fda 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -6532,6 +6532,33 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { > SetVersion ($DBversion); > } > >+$DBversion = "3.09.00.XXX"; >+if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { >+ $dbh->do(qq{ >+ INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'limited_item_edition', 'Limit item modification to barcode, status and note (please note that edit_item is still required)'); >+ }); >+ >+ $dbh->do(qq{ >+ INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'delete_all_items', 'Delete all items at once'); >+ }); >+ >+ $dbh->do(qq{ >+ INSERT INTO permissions (module_bit, code, description) VALUES ('13', 'items_limited_batchmod', 'Limit batch item modification to item status (please note that items_batchmod is still required)'); >+ }); >+ >+ $dbh->do(qq{ >+ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToAllowForLimitedEdition','','Define a list of subfields for which edition is authorized when limited_item_edtion permission is enabled (separated by space)','','Free'); >+ }); >+ >+ $dbh->do(qq{ >+ INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('SubfieldsToAllowForLimitedBatchmod','','Define a list of subfields for which edition is authorized when items_limited_batchmod permission is enabled (separated by space)','','Free'); >+ }); >+ >+ print "Upgrade to $DBversion done (Adds new permissions for cataloguing and batch item modification)\n"; >+ >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >index 2dde5ad..5c03dd6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc >@@ -133,7 +133,6 @@ CAN_user_serials_create_subscription ) %] > </ul> > </div> > [% END %] >- > <div class="btn-group"> > <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-pencil"></i> Edit <span class="caret"></span></button> > <ul class="dropdown-menu"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >index 96f3603..302ab8b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref >@@ -105,6 +105,12 @@ Cataloging: > - Define a list of subfields to use when prefilling items (separated by space) > - pref: SubfieldsToUseWhenPrefill > - >+ - Define a list of subfields for which edition is authorized when limited_item_edtion permission is enabled (separated by space) >+ - pref: SubfieldsToAllowForLimitedEdition >+ - >+ - Define a list of subfields for which edition is authorized when items_limited_batchmod permission is enabled (separated by space) >+ - pref: SubfieldsToAllowForLimitedBatchmod >+ - > - Use the languague (ISO 690-2) > - pref: UNIMARCField100Language > class: short >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index f01c682..bcb3cee 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -53,6 +53,13 @@ function Check(f) { > > var alertString2; > if (total_errors==0) { >+ // Explanation about this line: >+ // In case of limited edition permission, we have to prevent user from modifying some fields. >+ // But there is no such thing as readonly attribute for select elements. >+ // So we use disabled instead. But disabled prevent values from being passed through the form at submit. >+ // So we "un-disable" the elements just before submitting. >+ // That's a bit clumsy, and if someone comes up with a better solution, feel free to improve that. >+ $("select[name=field_value]").removeAttr("disabled"); > return true; > } else { > alertString2 = _("Form not submitted because of the following problem(s)"); >@@ -155,7 +162,7 @@ $(document).ready(function() { > </div> > <div class="yui-u"> > <div id="cataloguing_additem_newitem"> >- <form method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f"> >+ <form id="f" method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f"> > <input type="hidden" name="op" value="[% op %]" /> > [% IF (popup) %] > <input type="hidden" name="popup" value="1" /> >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index e416d44..090942a 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -33,6 +33,7 @@ use C4::BackgroundJob; > use C4::ClassSource; > use C4::Dates; > use C4::Debug; >+use C4::Members; > use MARC::File::XML; > use List::MoreUtils qw/uniq/; > >@@ -69,6 +70,11 @@ my ($template, $loggedinuser, $cookie) > flagsrequired => $template_flag, > }); > >+# Does the user have a limited item edition permission? >+my $uid = GetMember( borrowernumber => $loggedinuser )->{userid} if ($loggedinuser) ; >+my $limitededition = haspermission($uid, {'tools' => 'items_limited_batchmod'}) if ($uid); >+# In case user is a superlibrarian, edition is not limited >+$limitededition = 0 if ($limitededition != 0 && $limitededition->{'superlibrarian'} eq 1); > > my $today_iso = C4::Dates->today('iso'); > $template->param(today_iso => $today_iso); >@@ -283,11 +289,15 @@ unshift (@$branches, $nochange_branch); > > my $pref_itemcallnumber = C4::Context->preference('itemcallnumber'); > >+# Getting list of subfields to keep when limited batchmod edit is enabled >+my $subfieldsToAllowForBatchmod = C4::Context->preference('SubfieldsToAllowForLimitedBatchmod'); >+my @subfieldsToAllow = split(/ /, $subfieldsToAllowForBatchmod); > > foreach my $tag (sort keys %{$tagslib}) { > # loop through each subfield > foreach my $subfield (sort keys %{$tagslib->{$tag}}) { > next if subfield_is_koha_internal_p($subfield); >+ next if ($limitededition && !grep { $tag . '$' . $subfield eq $_ } @subfieldsToAllow ); > next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10"); > # barcode and stocknumber are not meant to be batch-modified > next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode'; >-- >1.7.10.4
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 7673
:
8714
|
9857
|
10360
|
12102
|
13004
|
16225
|
16239
|
16368
|
16371
|
23266
|
23267
|
23270
|
23271
|
26008
|
26009
|
26704
|
26705
|
26722
|
27631
|
27632
|
27633
|
27634
|
27635
|
27636
|
27637
|
27638
|
27640
|
27641
|
28007
|
28008
|
28009
|
28010
|
28011
|
28012
|
28013
|
28014
|
28015
|
29550
|
30910
|
30911
|
30912
|
30913
|
30914
|
30915
|
30916
|
30917
|
30918
|
30919
|
31010
|
31011
|
31012
|
31013
|
31015
|
31016
|
31017
|
31019
|
32200
|
32201
|
32215
|
32217
|
32219
|
32220
|
32222
|
32224
|
32225
|
32226
|
32227
|
32228
|
32928
|
32962
|
32993
|
33487