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

(-)a/cataloguing/additem.pl (-7 / +33 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
        my ($barcodefield,    $barcodesubfield)      = GetMarcFromKohaField("items.barcode", $frameworkcode);
110
        my ($notesfield,      $notessubfield)        = GetMarcFromKohaField("items.itemnotes", $frameworkcode);
111
        my ($notforloanfield, $notforloansubfield)   = GetMarcFromKohaField("items.notforloan", $frameworkcode);
112
109
        my %subfield_data;
113
        my %subfield_data;
110
        my $dbh = C4::Context->dbh;
114
        my $dbh = C4::Context->dbh;
111
        
115
        
Lines 154-159 sub generate_subfield_form { Link Here
154
	    $value = $input->param('barcode');
158
	    $value = $input->param('barcode');
155
	}
159
	}
156
        my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="$subfield_data{maxlength}" );
160
        my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="$subfield_data{maxlength}" );
161
        $attributes_no_value .= 'readonly="readonly" '
162
            if (
163
                $limitededition
164
                and $subfieldtag ne $barcodesubfield
165
                and $subfieldtag ne $notessubfield
166
                and $subfieldtag ne $notforloansubfield
167
            );
168
157
        my $attributes          = qq($attributes_no_value value="$value" );
169
        my $attributes          = qq($attributes_no_value value="$value" );
158
        
170
        
159
        if ( $subfieldlib->{authorised_value} ) {
171
        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});
226
                $subfield_data{marc_value} = qq(<input type="hidden" $attributes /> $authorised_lib{$value});
215
            }
227
            }
216
            else {
228
            else {
217
                $subfield_data{marc_value} =CGI::scrolling_list(      # FIXME: factor out scrolling_list
229
                my @scrparam = (
218
                    -name     => "field_value",
230
                    -name     => "field_value",
219
                    -values   => \@authorised_values,
231
                    -values   => \@authorised_values,
220
                    -default  => $value,
232
                    -default  => $value,
Lines 226-231 sub generate_subfield_form { Link Here
226
                    -id       => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield,
238
                    -id       => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield,
227
                    -class    => "input_marceditor",
239
                    -class    => "input_marceditor",
228
                );
240
                );
241
242
                push @scrparam, (-readonly => "readonly"), (-disabled => "disabled")
243
                    if (
244
                        $limitededition
245
                        and $subfieldtag ne $barcodesubfield
246
                        and $subfieldtag ne $notessubfield
247
                        and $subfieldtag ne $notforloansubfield
248
                    );
249
                $subfield_data{marc_value} =CGI::scrolling_list(@scrparam);
229
            }
250
            }
230
251
231
        }
252
        }
Lines 343-348 my ($template, $loggedinuser, $cookie) Link Here
343
                 });
364
                 });
344
365
345
366
367
# Does the user have a limited item edition permission?
368
my $uid = GetMember( borrowernumber => $loggedinuser )->{userid} if ($loggedinuser) ;
369
my $limitededition = haspermission($uid,  {'editcatalogue' => 'limited_item_edition'}) if ($uid);
370
# In case user is a superlibrarian, edition is not limited
371
$limitededition = 0 if ($limitededition != 0 && $limitededition->{'superlibrarian'} eq 1);
372
346
my $today_iso = C4::Dates->today('iso');
373
my $today_iso = C4::Dates->today('iso');
347
my $tagslib = &GetMarcStructure(1,$frameworkcode);
374
my $tagslib = &GetMarcStructure(1,$frameworkcode);
348
my $record = GetMarcBiblio($biblionumber);
375
my $record = GetMarcBiblio($biblionumber);
Lines 770-777 if($itemrecord){ Link Here
770
            next if subfield_is_koha_internal_p($subfieldtag);
797
            next if subfield_is_koha_internal_p($subfieldtag);
771
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
798
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
772
799
773
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i);        
800
            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";
801
            push @fields, "$tag$subfieldtag";
776
            push (@loop_data, $subfield_data);
802
            push (@loop_data, $subfield_data);
777
            $i++;
803
            $i++;
Lines 795-801 foreach my $tag ( keys %{$tagslib}){ Link Here
795
        my @values = (undef);
821
        my @values = (undef);
796
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)->subfield($subtag)));
822
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)->subfield($subtag)));
797
        for my $value (@values){
823
        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); 
824
            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);
825
            push (@loop_data, $subfield_data);
800
            $i++;
826
            $i++;
801
        } 
827
        } 
(-)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/updatedatabase.pl (+19 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
    print "Upgrade to $DBversion done (Adds new permissions for cataloguing and batch item modification)\n";
6550
6551
    SetVersion($DBversion);
6552
}
6553
6535
=head1 FUNCTIONS
6554
=head1 FUNCTIONS
6536
6555
6537
=head2 TableExists($table)
6556
=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/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 / +7 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 288-293 foreach my $tag (sort keys %{$tagslib}) { Link Here
288
    # loop through each subfield
294
    # loop through each subfield
289
    foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
295
    foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
290
     	next if subfield_is_koha_internal_p($subfield);
296
     	next if subfield_is_koha_internal_p($subfield);
297
        next if ($limitededition && $tagslib->{$tag}->{$subfield}->{'kohafield'} ne 'items.notforloan');
291
    	next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
298
    	next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
292
        # barcode and stocknumber are not meant to be batch-modified
299
        # barcode and stocknumber are not meant to be batch-modified
293
    	next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode';
300
    	next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode';
294
- 

Return to bug 7673