View | Details | Raw Unified | Return to bug 7673
Collapse All | Expand All

(-)a/cataloguing/additem.pl (-7 / +35 lines)
Lines 36-42 use List::MoreUtils qw/any/; Link Here
36
use C4::Search;
36
use C4::Search;
37
use Storable qw(thaw freeze);
37
use Storable qw(thaw freeze);
38
use URI::Escape;
38
use URI::Escape;
39
39
use C4::Members;
40
40
41
use MARC::File::XML;
41
use MARC::File::XML;
42
use URI::Escape;
42
use URI::Escape;
Lines 104-112 sub _increment_barcode { Link Here
104
104
105
105
106
sub generate_subfield_form {
106
sub generate_subfield_form {
107
        my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i) = @_;
107
        my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i, $limitededition) = @_;
108
  
108
  
109
  my $frameworkcode = &GetFrameworkCode($biblionumber);
109
        my $frameworkcode = &GetFrameworkCode($biblionumber);
110
110
        my %subfield_data;
111
        my %subfield_data;
111
        my $dbh = C4::Context->dbh;
112
        my $dbh = C4::Context->dbh;
112
        
113
        
Lines 156-161 sub generate_subfield_form { Link Here
156
	}
157
	}
157
        my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="$subfield_data{maxlength}" );
158
        my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="$subfield_data{maxlength}" );
158
        my $attributes_no_value_textarea = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" rows="5" cols="64" );
159
        my $attributes_no_value_textarea = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" rows="5" cols="64" );
160
161
        # Getting list of subfields to keep when limited edition is enabled
162
        my $subfieldsToAllowForLimitedEdition = C4::Context->preference('SubfieldsToAllowForLimitedEdition');
163
        my @subfieldsToAllow = split(/ /, $subfieldsToAllowForLimitedEdition);
164
165
        # If we're on limited edition, and our field is not in the list of subfields to allow,
166
        # then it is read-only
167
        $attributes_no_value .= 'readonly="readonly" '
168
            if (
169
                $limitededition
170
                and !grep { $tag . '$' . $subfieldtag  eq $_ } @subfieldsToAllow
171
            );
172
159
        my $attributes          = qq($attributes_no_value value="$value" );
173
        my $attributes          = qq($attributes_no_value value="$value" );
160
        
174
        
161
        if ( $subfieldlib->{authorised_value} ) {
175
        if ( $subfieldlib->{authorised_value} ) {
Lines 216-222 sub generate_subfield_form { Link Here
216
                $subfield_data{marc_value} = qq(<input type="hidden" $attributes /> $authorised_lib{$value});
230
                $subfield_data{marc_value} = qq(<input type="hidden" $attributes /> $authorised_lib{$value});
217
            }
231
            }
218
            else {
232
            else {
219
                $subfield_data{marc_value} =CGI::scrolling_list(      # FIXME: factor out scrolling_list
233
                my @scrparam = (
220
                    -name     => "field_value",
234
                    -name     => "field_value",
221
                    -values   => \@authorised_values,
235
                    -values   => \@authorised_values,
222
                    -default  => $value,
236
                    -default  => $value,
Lines 228-233 sub generate_subfield_form { Link Here
228
                    -id       => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield,
242
                    -id       => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield,
229
                    -class    => "input_marceditor",
243
                    -class    => "input_marceditor",
230
                );
244
                );
245
246
                # If we're on limited edition, and our field is not in the list of subfields to allow,
247
                # then it is read-only
248
                push @scrparam, (-readonly => "readonly"), (-disabled => "disabled")
249
                    if (
250
                        $limitededition
251
                        and !grep { $tag . '$' . $subfieldtag  eq $_ } @subfieldsToAllow
252
                    );
253
                $subfield_data{marc_value} =CGI::scrolling_list(@scrparam);
231
            }
254
            }
232
255
233
        }
256
        }
Lines 346-351 my ($template, $loggedinuser, $cookie) Link Here
346
                 });
369
                 });
347
370
348
371
372
# Does the user have a limited item edition permission?
373
my $uid = GetMember( borrowernumber => $loggedinuser )->{userid} if ($loggedinuser) ;
374
my $limitededition = haspermission($uid,  {'editcatalogue' => 'limited_item_edition'}) if ($uid);
375
# In case user is a superlibrarian, edition is not limited
376
$limitededition = 0 if ($limitededition != 0 && $limitededition->{'superlibrarian'} eq 1);
377
349
my $today_iso = C4::Dates->today('iso');
378
my $today_iso = C4::Dates->today('iso');
350
my $tagslib = &GetMarcStructure(1,$frameworkcode);
379
my $tagslib = &GetMarcStructure(1,$frameworkcode);
351
my $record = GetMarcBiblio($biblionumber);
380
my $record = GetMarcBiblio($biblionumber);
Lines 777-784 if($itemrecord){ Link Here
777
            next if subfield_is_koha_internal_p($subfieldtag);
806
            next if subfield_is_koha_internal_p($subfieldtag);
778
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
807
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
779
808
780
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i);        
809
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $limitededition);
781
782
            push @fields, "$tag$subfieldtag";
810
            push @fields, "$tag$subfieldtag";
783
            push (@loop_data, $subfield_data);
811
            push (@loop_data, $subfield_data);
784
            $i++;
812
            $i++;
Lines 802-808 foreach my $tag ( keys %{$tagslib}){ Link Here
802
        my @values = (undef);
830
        my @values = (undef);
803
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)) && defined($itemrecord->field($tag)->subfield($subtag)));
831
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)) && defined($itemrecord->field($tag)->subfield($subtag)));
804
        for my $value (@values){
832
        for my $value (@values){
805
            my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i); 
833
            my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $limitededition); 
806
            push (@loop_data, $subfield_data);
834
            push (@loop_data, $subfield_data);
807
            $i++;
835
            $i++;
808
        } 
836
        } 
(-)a/installer/data/mysql/en/mandatory/userpermissions.sql (+3 lines)
Lines 9-14 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
9
   ( 9, 'edit_catalogue', 'Edit catalog (Modify bibliographic/holdings data)'),
9
   ( 9, 'edit_catalogue', 'Edit catalog (Modify bibliographic/holdings data)'),
10
   ( 9, 'fast_cataloging', 'Fast cataloging'),
10
   ( 9, 'fast_cataloging', 'Fast cataloging'),
11
   ( 9, 'edit_items', 'Edit Items'),
11
   ( 9, 'edit_items', 'Edit Items'),
12
   ( 9, 'limited_item_edition', 'Limit item modification to barcode, status and note (please note that edit_item is still required)'),
13
   ( 9, 'delete_all_items', 'Delete all items'),
12
   (11, 'vendors_manage', 'Manage vendors'),
14
   (11, 'vendors_manage', 'Manage vendors'),
13
   (11, 'contracts_manage', 'Manage contracts'),
15
   (11, 'contracts_manage', 'Manage contracts'),
14
   (11, 'period_manage', 'Manage periods'),
16
   (11, 'period_manage', 'Manage periods'),
Lines 39-44 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
39
   (13, 'batch_upload_patron_images', 'Upload patron images in a batch or one at a time'),
41
   (13, 'batch_upload_patron_images', 'Upload patron images in a batch or one at a time'),
40
   (13, 'schedule_tasks', 'Schedule tasks to run'),
42
   (13, 'schedule_tasks', 'Schedule tasks to run'),
41
   (13, 'items_batchmod', 'Perform batch modification of items'),
43
   (13, 'items_batchmod', 'Perform batch modification of items'),
44
   (13, 'items_limited_batchmod', 'Limit batch item modification to item status (please note that items_batchmod is still required)'),
42
   (13, 'items_batchdel', 'Perform batch deletion of items'),
45
   (13, 'items_batchdel', 'Perform batch deletion of items'),
43
   (13, 'manage_csv_profiles', 'Manage CSV export profiles'),
46
   (13, 'manage_csv_profiles', 'Manage CSV export profiles'),
44
   (13, 'moderate_tags', 'Moderate patron tags'),
47
   (13, 'moderate_tags', 'Moderate patron tags'),
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 355-360 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
355
('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'),
355
('StaffDetailItemSelection', '1', NULL, 'Enable item selection in record detail page', 'YesNo'),
356
('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the Staff client','Integer'),
356
('StaffSerialIssueDisplayCount','3','','Number of serial issues to display per subscription in the Staff client','Integer'),
357
('StaticHoldsQueueWeight','0',NULL,'Specify a list of library location codes separated by commas -- the list of codes will be traversed and weighted with first values given higher weight for holds fulfillment -- alternatively, if RandomizeHoldsQueueWeight is set, the list will be randomly selective','Integer'),
357
('StaticHoldsQueueWeight','0',NULL,'Specify a list of library location codes separated by commas -- the list of codes will be traversed and weighted with first values given higher weight for holds fulfillment -- alternatively, if RandomizeHoldsQueueWeight is set, the list will be randomly selective','Integer'),
358
('SubfieldsToAllowForLimitedEdition','','','Define a list of subfields for which edition is authorized when limited_item_edtion permission is enabled, separated by spaces. Example: 995$f 995$h 995$j','Free'),
359
('SubfieldsToAllowForLimitedBatchmod','','','Define a list of subfields for which edition is authorized when items_limited_batchmod permission is enabled, separated by spaces. Example: 995$f 995$h 995$j','Free'),
358
('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'),
360
('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'),
359
('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'),
361
('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'),
360
('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'),
362
('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'),
(-)a/installer/data/mysql/updatedatabase.pl (+28 lines)
Lines 7778-7783 if(CheckVersion($DBversion)) { Link Here
7778
    SetVersion($DBversion);
7778
    SetVersion($DBversion);
7779
}
7779
}
7780
7780
7781
$DBversion = "3.15.00.XXX";
7782
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
7783
    $dbh->do(q{
7784
       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)');
7785
   });
7786
7787
   $dbh->do(q{
7788
       INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'delete_all_items', 'Delete all items at once');
7789
   });
7790
7791
   $dbh->do(q{
7792
       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)');
7793
   });
7794
7795
   $dbh->do(q{
7796
       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 spaces. Example: 995\$f 995\$h 995\$j','','Free');
7797
   });
7798
7799
   $dbh->do(q{
7800
       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 spaces. Example: 995\$f 995\$h 995\$j','','Free');
7801
   });
7802
7803
    print "Upgrade to $DBversion done (Bug 7673: Adds new permissions for cataloguing and batch item modification)\n";
7804
7805
    SetVersion($DBversion);
7806
}
7807
7808
7781
=head1 FUNCTIONS
7809
=head1 FUNCTIONS
7782
7810
7783
=head2 TableExists($table)
7811
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (-1 lines)
Lines 148-154 CAN_user_serials_create_subscription ) %] Link Here
148
    </ul>
148
    </ul>
149
    </div>
149
    </div>
150
[% END %]
150
[% END %]
151
152
    <div class="btn-group">
151
    <div class="btn-group">
153
    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-pencil"></i> Edit <span class="caret"></span></button>
152
    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-pencil"></i> Edit <span class="caret"></span></button>
154
        <ul class="dropdown-menu">
153
        <ul class="dropdown-menu">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref (+6 lines)
Lines 105-110 Cataloging: Link Here
105
            - Define a list of subfields to use when prefilling items (separated by space)
105
            - Define a list of subfields to use when prefilling items (separated by space)
106
            - pref: SubfieldsToUseWhenPrefill
106
            - pref: SubfieldsToUseWhenPrefill
107
        -
107
        -
108
            - 'Define a list of subfields for which edition is authorized when limited_item_edtion permission is enabled, separated by spaces. Example: 995$f 995$h 995$j'
109
            - pref: SubfieldsToAllowForLimitedEdition
110
        -
111
            - 'Define a list of subfields for which edition is authorized when items_limited_batchmod permission is enabled, separated by spaces. Example: 995$f 995$h 995$j'
112
            - pref: SubfieldsToAllowForLimitedBatchmod
113
        -
108
            - Use the languague (ISO 690-2)
114
            - Use the languague (ISO 690-2)
109
            - pref: UNIMARCField100Language
115
            - pref: UNIMARCField100Language
110
              class: short
116
              class: short
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-2 / +11 lines)
Lines 61-67 function active(numlayer) Link Here
61
}
61
}
62
function Check(f) {
62
function Check(f) {
63
    var total_errors = CheckMandatorySubfields(f);
63
    var total_errors = CheckMandatorySubfields(f);
64
    if (total_errors > 0) {
64
    if (total_errors==0) {
65
        // Explanation about this line:
66
        // In case of limited edition permission, we have to prevent user from modifying some fields.
67
        // But there is no such thing as readonly attribute for select elements.
68
        // So we use disabled instead. But disabled prevent values from being passed through the form at submit.
69
        // So we "un-disable" the elements just before submitting.
70
        // That's a bit clumsy, and if someone comes up with a better solution, feel free to improve that.
71
        $("select[name=field_value]").removeAttr("disabled");
72
        return true;
73
    } else {
65
        var alertString2 = _("Form not submitted because of the following problem(s)");
74
        var alertString2 = _("Form not submitted because of the following problem(s)");
66
        alertString2 += "\n------------------------------------------------------------------------------------\n";
75
        alertString2 += "\n------------------------------------------------------------------------------------\n";
67
        alertString2 += "\n- "+ total_errors + _(" mandatory fields empty (highlighted)");
76
        alertString2 += "\n- "+ total_errors + _(" mandatory fields empty (highlighted)");
Lines 192-198 $(document).ready(function() { Link Here
192
</div>
201
</div>
193
<div class="yui-u">
202
<div class="yui-u">
194
<div id="cataloguing_additem_newitem">
203
<div id="cataloguing_additem_newitem">
195
    <form method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
204
    <form id="f" method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
196
    <input type="hidden" name="op" value="[% op %]" />
205
    <input type="hidden" name="op" value="[% op %]" />
197
    [% IF (popup) %]
206
    [% IF (popup) %]
198
        <input type="hidden" name="popup" value="1" />
207
        <input type="hidden" name="popup" value="1" />
(-)a/tools/batchMod.pl (-1 / +10 lines)
Lines 33-38 use C4::BackgroundJob; Link Here
33
use C4::ClassSource;
33
use C4::ClassSource;
34
use C4::Dates;
34
use C4::Dates;
35
use C4::Debug;
35
use C4::Debug;
36
use C4::Members;
36
use MARC::File::XML;
37
use MARC::File::XML;
37
use List::MoreUtils qw/uniq/;
38
use List::MoreUtils qw/uniq/;
38
39
Lines 69-74 my ($template, $loggedinuser, $cookie) Link Here
69
                 flagsrequired => $template_flag,
70
                 flagsrequired => $template_flag,
70
                 });
71
                 });
71
72
73
# Does the user have a limited item edition permission?
74
my $uid = GetMember( borrowernumber => $loggedinuser )->{userid} if ($loggedinuser) ;
75
my $limitededition = haspermission($uid,  {'tools' => 'items_limited_batchmod'}) if ($uid);
76
# In case user is a superlibrarian, edition is not limited
77
$limitededition = 0 if ($limitededition != 0 && $limitededition->{'superlibrarian'} eq 1);
72
78
73
my $today_iso = C4::Dates->today('iso');
79
my $today_iso = C4::Dates->today('iso');
74
$template->param(today_iso => $today_iso);
80
$template->param(today_iso => $today_iso);
Lines 294-304 unshift (@$branches, $nochange_branch); Link Here
294
300
295
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
301
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
296
302
303
# Getting list of subfields to keep when limited batchmod edit is enabled
304
my $subfieldsToAllowForBatchmod = C4::Context->preference('SubfieldsToAllowForLimitedBatchmod');
305
my @subfieldsToAllow = split(/ /, $subfieldsToAllowForBatchmod);
297
306
298
foreach my $tag (sort keys %{$tagslib}) {
307
foreach my $tag (sort keys %{$tagslib}) {
299
    # loop through each subfield
308
    # loop through each subfield
300
    foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
309
    foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
301
     	next if subfield_is_koha_internal_p($subfield);
310
     	next if subfield_is_koha_internal_p($subfield);
311
        next if ($limitededition && !grep { $tag . '$' . $subfield eq $_ } @subfieldsToAllow );
302
    	next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
312
    	next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
303
        # barcode and stocknumber are not meant to be batch-modified
313
        # barcode and stocknumber are not meant to be batch-modified
304
    	next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode';
314
    	next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode';
305
- 

Return to bug 7673