diff --git a/installer/data/mysql/atomicupdate/bug_41253_add_items_modification_by_age_permission.pl b/installer/data/mysql/atomicupdate/bug_41253_add_items_modification_by_age_permission.pl new file mode 100755 index 0000000000..b78b67062d --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_41253_add_items_modification_by_age_permission.pl @@ -0,0 +1,51 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_success say_info); + +return { + bug_number => "41253", + description => "Add items_modification_by_age permission", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( + q{ + INSERT IGNORE INTO permissions (module_bit, code, description) + VALUES (13, 'items_modification_by_age', 'Define rules for automatic item aging') + } + ); + + say $out "Added new permission 'items_modification_by_age'"; + + my $sth = $dbh->prepare( + q{ + SELECT borrowernumber + FROM user_permissions + WHERE code = 'items_batchmod' + } + ); + + $sth->execute(); + + my @borrowernumbers; + while ( my ($borrowernumber) = $sth->fetchrow_array ) { + push @borrowernumbers, $borrowernumber; + } + + if (@borrowernumbers) { + + my $insert_sth = $dbh->prepare( + q{ + INSERT IGNORE INTO user_permissions (borrowernumber, module_bit, code) + VALUES (?, 13, 'items_modification_by_age') + } + ); + + foreach my $borrowernumber (@borrowernumbers) { + $insert_sth->execute($borrowernumber); + } + + say_success( $out, "Granted items_modification_by_age to users with items_batchmod" ); + } + }, +}; diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index dbd907f6dd..3d32c18f64 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -126,6 +126,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES (13, 'items_batchmod', 'Perform batch modification of items'), (13, 'items_batchmod_restricted', 'Limit batch item modification to subfields defined in the SubfieldsToAllowForRestrictedBatchmod preference (please note that items_batchmod is still required)'), (13, 'items_batchdel', 'Perform batch deletion of items'), + (13, 'items_modification_by_age', 'Define rules for automatic item aging'), (13, 'manage_csv_profiles', 'Manage CSV export profiles'), (13, 'moderate_tags', 'Moderate patron tags'), (13, 'rotating_collections', 'Manage rotating collections'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index b12e828a91..119f6dcd5c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -436,6 +436,9 @@ Limit batch item modification to subfields defined in the SubfieldsToAllowForRestrictedBatchmod preference (please note that items_batchmod is still required) ([% name | html %]) + [%- CASE 'items_modification_by_age' -%] + Define rules for automatic item aging + ([% name | html %]) [%- CASE 'label_creator' -%] Create printable labels and barcodes from catalog and patron data ([% name | html %]) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/cataloging-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/cataloging-home.tt index da7cc85691..cbb5288820 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/cataloging-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/cataloging-home.tt @@ -165,10 +165,10 @@ [% END %] - [% IF ( CAN_user_tools_items_batchmod || ( CAN_user_stockrotation_manage_rotas && Koha.Preference('StockRotation') ) ) %] + [% IF ( CAN_user_tools_items_modification_by_age || ( CAN_user_stockrotation_manage_rotas && Koha.Preference('StockRotation') ) ) %]

Automation