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

(-)a/cataloguing/additem.pl (-7 / +35 lines)
Lines 35-41 use List::MoreUtils qw/any/; Link Here
35
use C4::Search;
35
use C4::Search;
36
use Storable qw(thaw freeze);
36
use Storable qw(thaw freeze);
37
use URI::Escape;
37
use URI::Escape;
38
38
use C4::Members;
39
39
40
use MARC::File::XML;
40
use MARC::File::XML;
41
use URI::Escape;
41
use URI::Escape;
Lines 103-111 sub _increment_barcode { Link Here
103
103
104
104
105
sub generate_subfield_form {
105
sub generate_subfield_form {
106
        my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i) = @_;
106
        my ($tag, $subfieldtag, $value, $tagslib,$subfieldlib, $branches, $today_iso, $biblionumber, $temp, $loop_data, $i, $limitededition) = @_;
107
  
107
  
108
  my $frameworkcode = &GetFrameworkCode($biblionumber);
108
        my $frameworkcode = &GetFrameworkCode($biblionumber);
109
109
        my %subfield_data;
110
        my %subfield_data;
110
        my $dbh = C4::Context->dbh;
111
        my $dbh = C4::Context->dbh;
111
        
112
        
Lines 154-159 sub generate_subfield_form { Link Here
154
	    $value = $input->param('barcode');
155
	    $value = $input->param('barcode');
155
	}
156
	}
156
        my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="$subfield_data{maxlength}" );
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
159
    # Getting list of subfields to keep when limited edition is enabled
160
    my $subfieldsToAllowForLimitedEdition = C4::Context->preference('SubfieldsToAllowForLimitedEdition');
161
    my @subfieldsToAllow = split(/ /, $subfieldsToAllowForLimitedEdition);
162
163
        # If we're on limited edition, and our field is not in the list of subfields to allow,
164
        # then it is read-only
165
        $attributes_no_value .= 'readonly="readonly" '
166
            if (
167
                $limitededition
168
                and !grep { $tag . '$' . $subfieldtag  eq $_ } @subfieldsToAllow
169
            );
170
157
        my $attributes          = qq($attributes_no_value value="$value" );
171
        my $attributes          = qq($attributes_no_value value="$value" );
158
        
172
        
159
        if ( $subfieldlib->{authorised_value} ) {
173
        if ( $subfieldlib->{authorised_value} ) {
Lines 214-220 sub generate_subfield_form { Link Here
214
                $subfield_data{marc_value} = qq(<input type="hidden" $attributes /> $authorised_lib{$value});
228
                $subfield_data{marc_value} = qq(<input type="hidden" $attributes /> $authorised_lib{$value});
215
            }
229
            }
216
            else {
230
            else {
217
                $subfield_data{marc_value} =CGI::scrolling_list(      # FIXME: factor out scrolling_list
231
                my @scrparam = (
218
                    -name     => "field_value",
232
                    -name     => "field_value",
219
                    -values   => \@authorised_values,
233
                    -values   => \@authorised_values,
220
                    -default  => $value,
234
                    -default  => $value,
Lines 226-231 sub generate_subfield_form { Link Here
226
                    -id       => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield,
240
                    -id       => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield,
227
                    -class    => "input_marceditor",
241
                    -class    => "input_marceditor",
228
                );
242
                );
243
244
                # If we're on limited edition, and our field is not in the list of subfields to allow,
245
                # then it is read-only
246
                push @scrparam, (-readonly => "readonly"), (-disabled => "disabled")
247
                    if (
248
                        $limitededition
249
                        and !grep { $tag . '$' . $subfieldtag  eq $_ } @subfieldsToAllow
250
                    );
251
                $subfield_data{marc_value} =CGI::scrolling_list(@scrparam);
229
            }
252
            }
230
253
231
        }
254
        }
Lines 343-348 my ($template, $loggedinuser, $cookie) Link Here
343
                 });
366
                 });
344
367
345
368
369
# Does the user have a limited item edition permission?
370
my $uid = GetMember( borrowernumber => $loggedinuser )->{userid} if ($loggedinuser) ;
371
my $limitededition = haspermission($uid,  {'editcatalogue' => 'limited_item_edition'}) if ($uid);
372
# In case user is a superlibrarian, edition is not limited
373
$limitededition = 0 if ($limitededition != 0 && $limitededition->{'superlibrarian'} eq 1);
374
346
my $today_iso = C4::Dates->today('iso');
375
my $today_iso = C4::Dates->today('iso');
347
my $tagslib = &GetMarcStructure(1,$frameworkcode);
376
my $tagslib = &GetMarcStructure(1,$frameworkcode);
348
my $record = GetMarcBiblio($biblionumber);
377
my $record = GetMarcBiblio($biblionumber);
Lines 770-777 if($itemrecord){ Link Here
770
            next if subfield_is_koha_internal_p($subfieldtag);
799
            next if subfield_is_koha_internal_p($subfieldtag);
771
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
800
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
772
801
773
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i);        
802
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $limitededition);
774
775
            push @fields, "$tag$subfieldtag";
803
            push @fields, "$tag$subfieldtag";
776
            push (@loop_data, $subfield_data);
804
            push (@loop_data, $subfield_data);
777
            $i++;
805
            $i++;
Lines 795-801 foreach my $tag ( keys %{$tagslib}){ Link Here
795
        my @values = (undef);
823
        my @values = (undef);
796
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)->subfield($subtag)));
824
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)->subfield($subtag)));
797
        for my $value (@values){
825
        for my $value (@values){
798
            my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i); 
826
            my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $limitededition); 
799
            push (@loop_data, $subfield_data);
827
            push (@loop_data, $subfield_data);
800
            $i++;
828
            $i++;
801
        } 
829
        } 
(-)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 38-43 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
38
   (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
40
   (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
39
   (13, 'schedule_tasks', 'Schedule tasks to run'),
41
   (13, 'schedule_tasks', 'Schedule tasks to run'),
40
   (13, 'items_batchmod', 'Perform batch modification of items'),
42
   (13, 'items_batchmod', 'Perform batch modification of items'),
43
   (13, 'items_limited_batchmod', 'Limit batch item modification to item status (please note that items_batchmod is still required)'),
41
   (13, 'items_batchdel', 'Perform batch deletion of items'),
44
   (13, 'items_batchdel', 'Perform batch deletion of items'),
42
   (13, 'manage_csv_profiles', 'Manage CSV export profiles'),
45
   (13, 'manage_csv_profiles', 'Manage CSV export profiles'),
43
   (13, 'moderate_tags', 'Moderate patron tags'),
46
   (13, 'moderate_tags', 'Moderate patron tags'),
(-)a/installer/data/mysql/sysprefs.sql (+3 lines)
Lines 421-423 INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES( Link Here
421
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');
421
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');
422
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseQueryParser', '0', 'If enabled, try to use QueryParser for queries.', NULL, 'YesNo');
422
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('UseQueryParser', '0', 'If enabled, try to use QueryParser for queries.', NULL, 'YesNo');
423
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('FinesIncludeGracePeriod','1','If enabled, fines calculations will include the grace period.',NULL,'YesNo');
423
INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('FinesIncludeGracePeriod','1','If enabled, fines calculations will include the grace period.',NULL,'YesNo');
424
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');
425
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');
426
(-)a/installer/data/mysql/updatedatabase.pl (+27 lines)
Lines 6532-6537 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
6532
    SetVersion ($DBversion);
6532
    SetVersion ($DBversion);
6533
}
6533
}
6534
6534
6535
$DBversion = "3.09.00.XXX";
6536
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6537
    $dbh->do(qq{
6538
       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)');
6539
   });
6540
6541
   $dbh->do(qq{
6542
       INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'delete_all_items', 'Delete all items at once');
6543
   });
6544
6545
   $dbh->do(qq{
6546
       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)');
6547
   });
6548
6549
   $dbh->do(qq{
6550
       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');
6551
   });
6552
6553
   $dbh->do(qq{
6554
       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');
6555
   });
6556
6557
    print "Upgrade to $DBversion done (Adds new permissions for cataloguing and batch item modification)\n";
6558
6559
    SetVersion($DBversion);
6560
}
6561
6535
=head1 FUNCTIONS
6562
=head1 FUNCTIONS
6536
6563
6537
=head2 TableExists($table)
6564
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (-1 lines)
Lines 133-139 CAN_user_serials_create_subscription ) %] Link Here
133
    </ul>
133
    </ul>
134
    </div>
134
    </div>
135
[% END %]
135
[% END %]
136
137
    <div class="btn-group">
136
    <div class="btn-group">
138
    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-pencil"></i> Edit <span class="caret"></span></button>
137
    <button class="btn btn-small dropdown-toggle" data-toggle="dropdown"><i class="icon-pencil"></i> Edit <span class="caret"></span></button>
139
        <ul class="dropdown-menu">
138
        <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 space)
109
            - pref: SubfieldsToAllowForLimitedEdition
110
        -
111
            - Define a list of subfields for which edition is authorized when items_limited_batchmod permission is enabled (separated by space)
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 (-1 / +8 lines)
Lines 53-58 function Check(f) { Link Here
53
53
54
    var alertString2;
54
    var alertString2;
55
    if (total_errors==0) {
55
    if (total_errors==0) {
56
        // Explanation about this line: 
57
        // In case of limited edition permission, we have to prevent user from modifying some fields.
58
        // But there is no such thing as readonly attribute for select elements.
59
        // So we use disabled instead. But disabled prevent values from being passed through the form at submit.
60
        // So we "un-disable" the elements just before submitting.
61
        // That's a bit clumsy, and if someone comes up with a better solution, feel free to improve that.
62
        $("select[name=field_value]").removeAttr("disabled");
56
        return true;
63
        return true;
57
    } else {
64
    } else {
58
        alertString2  = _("Form not submitted because of the following problem(s)");
65
        alertString2  = _("Form not submitted because of the following problem(s)");
Lines 155-161 $(document).ready(function() { Link Here
155
</div>
162
</div>
156
<div class="yui-u">
163
<div class="yui-u">
157
<div id="cataloguing_additem_newitem">
164
<div id="cataloguing_additem_newitem">
158
    <form method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
165
    <form id="f" method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
159
    <input type="hidden" name="op" value="[% op %]" />
166
    <input type="hidden" name="op" value="[% op %]" />
160
    [% IF (popup) %]
167
    [% IF (popup) %]
161
        <input type="hidden" name="popup" value="1" />
168
        <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 283-293 unshift (@$branches, $nochange_branch); Link Here
283
289
284
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
290
my $pref_itemcallnumber = C4::Context->preference('itemcallnumber');
285
291
292
# Getting list of subfields to keep when limited batchmod edit is enabled
293
my $subfieldsToAllowForBatchmod = C4::Context->preference('SubfieldsToAllowForLimitedBatchmod');
294
my @subfieldsToAllow = split(/ /, $subfieldsToAllowForBatchmod);
286
295
287
foreach my $tag (sort keys %{$tagslib}) {
296
foreach my $tag (sort keys %{$tagslib}) {
288
    # loop through each subfield
297
    # loop through each subfield
289
    foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
298
    foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
290
     	next if subfield_is_koha_internal_p($subfield);
299
     	next if subfield_is_koha_internal_p($subfield);
300
        next if ($limitededition && !grep { $tag . '$' . $subfield eq $_ } @subfieldsToAllow );
291
    	next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
301
    	next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
292
        # barcode and stocknumber are not meant to be batch-modified
302
        # barcode and stocknumber are not meant to be batch-modified
293
    	next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode';
303
    	next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode';
294
- 

Return to bug 7673