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
        my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib");
115
        my $authorised_values_sth = $dbh->prepare("SELECT authorised_value,lib FROM authorised_values WHERE category=? ORDER BY lib");
Lines 155-160 sub generate_subfield_form { Link Here
155
	    $value = $input->param('barcode');
159
	    $value = $input->param('barcode');
156
	}
160
	}
157
        my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="$subfield_data{maxlength}" );
161
        my $attributes_no_value = qq(tabindex="1" id="$subfield_data{id}" name="field_value" class="input_marceditor" size="67" maxlength="$subfield_data{maxlength}" );
162
        $attributes_no_value .= 'readonly="readonly" '
163
            if (
164
                $limitededition
165
                and $subfieldtag ne $barcodesubfield
166
                and $subfieldtag ne $notessubfield
167
                and $subfieldtag ne $notforloansubfield
168
            );
169
158
        my $attributes          = qq($attributes_no_value value="$value" );
170
        my $attributes          = qq($attributes_no_value value="$value" );
159
        
171
        
160
        if ( $subfieldlib->{authorised_value} ) {
172
        if ( $subfieldlib->{authorised_value} ) {
Lines 215-221 sub generate_subfield_form { Link Here
215
                $subfield_data{marc_value} = qq(<input type="hidden" $attributes /> $authorised_lib{$value});
227
                $subfield_data{marc_value} = qq(<input type="hidden" $attributes /> $authorised_lib{$value});
216
            }
228
            }
217
            else {
229
            else {
218
                $subfield_data{marc_value} =CGI::scrolling_list(      # FIXME: factor out scrolling_list
230
                my @scrparam = (
219
                    -name     => "field_value",
231
                    -name     => "field_value",
220
                    -values   => \@authorised_values,
232
                    -values   => \@authorised_values,
221
                    -default  => $value,
233
                    -default  => $value,
Lines 227-232 sub generate_subfield_form { Link Here
227
                    -id       => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield,
239
                    -id       => "tag_".$tag."_subfield_".$subfieldtag."_".$index_subfield,
228
                    -class    => "input_marceditor",
240
                    -class    => "input_marceditor",
229
                );
241
                );
242
243
                push @scrparam, (-readonly => "readonly"), (-disabled => "disabled")
244
                    if (
245
                        $limitededition
246
                        and $subfieldtag ne $barcodesubfield
247
                        and $subfieldtag ne $notessubfield
248
                        and $subfieldtag ne $notforloansubfield
249
                    );
250
                $subfield_data{marc_value} =CGI::scrolling_list(@scrparam);
230
            }
251
            }
231
252
232
        }
253
        }
Lines 338-343 my ($template, $loggedinuser, $cookie) Link Here
338
                 });
359
                 });
339
360
340
361
362
# Does the user have a limited item edition permission?
363
my $uid = GetMember( borrowernumber => $loggedinuser )->{userid} if ($loggedinuser) ;
364
my $limitededition = haspermission($uid,  {'editcatalogue' => 'limited_item_edition'}) if ($uid);
365
# In case user is a superlibrarian, edition is not limited
366
$limitededition = 0 if ($limitededition != 0 && $limitededition->{'superlibrarian'} eq 1);
367
341
my $today_iso = C4::Dates->today('iso');
368
my $today_iso = C4::Dates->today('iso');
342
my $tagslib = &GetMarcStructure(1,$frameworkcode);
369
my $tagslib = &GetMarcStructure(1,$frameworkcode);
343
my $record = GetMarcBiblio($biblionumber);
370
my $record = GetMarcBiblio($biblionumber);
Lines 762-769 if($itemrecord){ Link Here
762
            next if subfield_is_koha_internal_p($subfieldtag);
789
            next if subfield_is_koha_internal_p($subfieldtag);
763
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
790
            next if ($tagslib->{$tag}->{$subfieldtag}->{'tab'} ne "10");
764
791
765
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i);        
792
            my $subfield_data = generate_subfield_form($tag, $subfieldtag, $value, $tagslib, $subfieldlib, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $limitededition);
766
767
            push @fields, "$tag$subfieldtag";
793
            push @fields, "$tag$subfieldtag";
768
            push (@loop_data, $subfield_data);
794
            push (@loop_data, $subfield_data);
769
            $i++;
795
            $i++;
Lines 787-793 foreach my $tag ( keys %{$tagslib}){ Link Here
787
        my @values = (undef);
813
        my @values = (undef);
788
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)->subfield($subtag)));
814
        @values = $itemrecord->field($tag)->subfield($subtag) if ($itemrecord && defined($itemrecord->field($tag)->subfield($subtag)));
789
        for my $value (@values){
815
        for my $value (@values){
790
            my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i); 
816
            my $subfield_data = generate_subfield_form($tag, $subtag, $value, $tagslib, $tagslib->{$tag}->{$subtag}, $branches, $today_iso, $biblionumber, $temp, \@loop_data, $i, $limitededition); 
791
            push (@loop_data, $subfield_data);
817
            push (@loop_data, $subfield_data);
792
            $i++;
818
            $i++;
793
        } 
819
        } 
(-)a/installer/data/mysql/en/mandatory/userpermissions.sql (+3 lines)
Lines 8-13 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
8
   ( 9, 'edit_catalogue', 'Edit catalog (Modify bibliographic/holdings data)'),
8
   ( 9, 'edit_catalogue', 'Edit catalog (Modify bibliographic/holdings data)'),
9
   ( 9, 'fast_cataloging', 'Fast cataloging'),
9
   ( 9, 'fast_cataloging', 'Fast cataloging'),
10
   ( 9, 'edit_items', 'Edit Items'),
10
   ( 9, 'edit_items', 'Edit Items'),
11
   ( 9, 'limited_item_edition', 'Limit item modification to barcode, status and note (please note that edit_item is still required)'),
12
   ( 9, 'delete_all_items', 'Delete all items'),
11
   (11, 'vendors_manage', 'Manage vendors'),
13
   (11, 'vendors_manage', 'Manage vendors'),
12
   (11, 'contracts_manage', 'Manage contracts'),
14
   (11, 'contracts_manage', 'Manage contracts'),
13
   (11, 'period_manage', 'Manage periods'),
15
   (11, 'period_manage', 'Manage periods'),
Lines 37-42 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
37
   (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
39
   (13, 'batch_upload_patron_images', 'Upload patron images in batch or one at a time'),
38
   (13, 'schedule_tasks', 'Schedule tasks to run'),
40
   (13, 'schedule_tasks', 'Schedule tasks to run'),
39
   (13, 'items_batchmod', 'Perform batch modification of items'),
41
   (13, 'items_batchmod', 'Perform batch modification of items'),
42
   (13, 'items_limited_batchmod', 'Limit batch item modification to item status (please note that items_batchmod is still required)'),
40
   (13, 'items_batchdel', 'Perform batch deletion of items'),
43
   (13, 'items_batchdel', 'Perform batch deletion of items'),
41
   (13, 'manage_csv_profiles', 'Manage CSV export profiles'),
44
   (13, 'manage_csv_profiles', 'Manage CSV export profiles'),
42
   (13, 'moderate_tags', 'Moderate patron tags'),
45
   (13, 'moderate_tags', 'Moderate patron tags'),
(-)a/installer/data/mysql/updatedatabase.pl (+19 lines)
Lines 6019-6024 if (C4::Context->preference("Version") < TransformToNum($DBversion)) { Link Here
6019
   SetVersion ($DBversion);
6019
   SetVersion ($DBversion);
6020
}
6020
}
6021
6021
6022
$DBversion = "3.09.00.XXX";
6023
if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) {
6024
    $dbh->do(qq{
6025
       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)');
6026
   });
6027
6028
   $dbh->do(qq{
6029
       INSERT INTO permissions (module_bit, code, description) VALUES ('9', 'delete_all_items', 'Delete all items at once');
6030
   });
6031
6032
   $dbh->do(qq{
6033
       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)');
6034
   });
6035
6036
    print "Upgrade to $DBversion done (Adds new permissions for cataloguing and batch item modification)\n";
6037
6038
    SetVersion($DBversion);
6039
}
6040
6022
=head1 FUNCTIONS
6041
=head1 FUNCTIONS
6023
6042
6024
=head2 TableExists($table)
6043
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc (-1 / +1 lines)
Lines 118-124 function confirm_items_deletion() { Link Here
118
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Edit as new (duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]&amp;frameworkcode=&amp;op=duplicate" },[% END %]
118
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Edit as new (duplicate)"), url: "/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber %]&amp;frameworkcode=&amp;op=duplicate" },[% END %]
119
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Replace record via Z39.50"), onclick: {fn: PopupZ3950 } },[% END %]
119
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Replace record via Z39.50"), onclick: {fn: PopupZ3950 } },[% END %]
120
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Delete record"), onclick: {fn: confirm_deletion }[% IF ( count ) %],id:'disabled'[% END %] },[% END %]
120
            [% IF ( CAN_user_editcatalogue_edit_catalogue ) %]{ text: _("Delete record"), onclick: {fn: confirm_deletion }[% IF ( count ) %],id:'disabled'[% END %] },[% END %]
121
            [% IF ( CAN_user_editcatalogue_edit_items ) %]{ text: _("Delete all items"), onclick: {fn: confirm_items_deletion }[% UNLESS ( count ) %],id:'disabled'[% END %] }[% END %]
121
            [% IF ( CAN_user_editcatalogue_delete_all_items ) %]{ text: _("Delete all items"), onclick: {fn: confirm_items_deletion }[% UNLESS ( count ) %],id:'disabled'[% END %] }[% END %]
122
	    ];
122
	    ];
123
		if(editmenu.length){
123
		if(editmenu.length){
124
			new YAHOO.widget.Button({
124
			new YAHOO.widget.Button({
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt (-1 / +8 lines)
Lines 52-57 function Check(f) { Link Here
52
52
53
    var alertString2;
53
    var alertString2;
54
    if (total_errors==0) {
54
    if (total_errors==0) {
55
        // Explanation about this line: 
56
        // In case of limited edition permission, we have to prevent user from modifying some fields.
57
        // But there is no such thing as readonly attribute for select elements.
58
        // So we use disabled instead. But disabled prevent values from being passed through the form at submit.
59
        // So we "un-disable" the elements just before submitting.
60
        // That's a bit clumsy, and if someone comes up with a better solution, feel free to improve that.
61
        $("select[name=field_value]").removeAttr("disabled");
55
        return true;
62
        return true;
56
    } else {
63
    } else {
57
        alertString2  = _("Form not submitted because of the following problem(s)");
64
        alertString2  = _("Form not submitted because of the following problem(s)");
Lines 222-228 $(document).ready(function() { Link Here
222
</div>
229
</div>
223
<div class="yui-u">
230
<div class="yui-u">
224
<div id="cataloguing_additem_newitem">
231
<div id="cataloguing_additem_newitem">
225
    <form method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
232
    <form id="f" method="post" action="/cgi-bin/koha/cataloguing/additem.pl" name="f">
226
    <input type="hidden" name="op" value="[% op %]" />
233
    <input type="hidden" name="op" value="[% op %]" />
227
    [% IF (popup) %]
234
    [% IF (popup) %]
228
        <input type="hidden" name="popup" value="1" />
235
        <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
38
38
my $input = new CGI;
39
my $input = new CGI;
Lines 68-73 my ($template, $loggedinuser, $cookie) Link Here
68
                 flagsrequired => $template_flag,
69
                 flagsrequired => $template_flag,
69
                 });
70
                 });
70
71
72
# Does the user have a limited item edition permission?
73
my $uid = GetMember( borrowernumber => $loggedinuser )->{userid} if ($loggedinuser) ;
74
my $limitededition = haspermission($uid,  {'tools' => 'items_limited_batchmod'}) if ($uid);
75
# In case user is a superlibrarian, edition is not limited
76
$limitededition = 0 if ($limitededition != 0 && $limitededition->{'superlibrarian'} eq 1);
71
77
72
my $today_iso = C4::Dates->today('iso');
78
my $today_iso = C4::Dates->today('iso');
73
$template->param(today_iso => $today_iso);
79
$template->param(today_iso => $today_iso);
Lines 281-286 foreach my $tag (sort keys %{$tagslib}) { Link Here
281
    # loop through each subfield
287
    # loop through each subfield
282
    foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
288
    foreach my $subfield (sort keys %{$tagslib->{$tag}}) {
283
     	next if subfield_is_koha_internal_p($subfield);
289
     	next if subfield_is_koha_internal_p($subfield);
290
        next if ($limitededition && $tagslib->{$tag}->{$subfield}->{'kohafield'} ne 'items.notforloan');
284
    	next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
291
    	next if ($tagslib->{$tag}->{$subfield}->{'tab'} ne "10");
285
        # barcode and stocknumber are not meant to be batch-modified
292
        # barcode and stocknumber are not meant to be batch-modified
286
    	next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode';
293
    	next if $tagslib->{$tag}->{$subfield}->{'kohafield'} eq 'items.barcode';
287
- 

Return to bug 7673