diff --git a/admin/smart-rules.pl b/admin/smart-rules.pl index d7161ff7e9..74a067453f 100755 --- a/admin/smart-rules.pl +++ b/admin/smart-rules.pl @@ -35,6 +35,7 @@ use Koha::Libraries; use Koha::CirculationRules; use Koha::Patron::Categories; use Koha::Caches; +use Koha::Patrons; my $input = CGI->new; my $dbh = C4::Context->dbh; @@ -61,6 +62,12 @@ unless ( $branch ) { $branch = C4::Context::only_my_library() ? ( C4::Context::mybranch() || '*' ) : '*'; } } + +my $uid = Koha::Patrons->find( $loggedinuser )->userid; +my $restricted_to_own_library = $uid && haspermission( $uid, { parameters => 'manage_circ_rules_restricted' }, { no_inherit => 1 } ); +$template->param( restricted_to_own_library => $restricted_to_own_library ); +$branch = C4::Context::mybranch() if $restricted_to_own_library; + $branch = '*' if $branch eq 'NO_LIBRARY_SET'; my $op = $input->param('op') || q{}; diff --git a/installer/data/mysql/atomicupdate/bug_15520-add_manage_circ_rules_restricted.sql b/installer/data/mysql/atomicupdate/bug_15520-add_manage_circ_rules_restricted.sql new file mode 100644 index 0000000000..830f4fb0aa --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_15520-add_manage_circ_rules_restricted.sql @@ -0,0 +1 @@ +INSERT IGNORE INTO `permissions` (module_bit, code, description) VALUES(3, 'manage_circ_rules_restricted', 'Only manage circ rules for own library'); diff --git a/installer/data/mysql/userpermissions.sql b/installer/data/mysql/userpermissions.sql index 67b76e6871..18fe3f8080 100644 --- a/installer/data/mysql/userpermissions.sql +++ b/installer/data/mysql/userpermissions.sql @@ -7,6 +7,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'manage_checkout_notes', 'Mark checkout notes as seen/not seen'), ( 3, 'parameters_remaining_permissions', 'Remaining system parameters permissions'), ( 3, 'manage_circ_rules', 'Manage circulation rules'), + ( 3, 'manage_circ_rules_restricted', 'Only manage circ rules for own library'), ( 4, 'edit_borrowers', 'Add, modify and view patron information'), ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'), ( 6, 'place_holds', 'Place holds for patrons'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index 6193de3ed4..baf966a0e1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -33,6 +33,7 @@ [%- CASE 'override_renewals' -%]Override blocked renewals [%- CASE 'manage_checkout_notes' %]Mark checkout notes as seen/not seen [%- CASE 'manage_circ_rules' -%]manage circulation rules + [%- CASE 'manage_circ_rules_restricted' -%]Limit circulation rules editing to the user's own library (please note that manage_circ_rules is still required) [%- CASE 'parameters_remaining_permissions' -%]Remaining system parameters permissions [%- CASE 'edit_borrowers' -%]Add, modify and view patron information [%- CASE 'view_borrower_infos_from_any_libraries' -%]View patron infos from any libraries. If not set the logged in user could only access patron infos from its own library or group of libraries. diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt index fa3c75c8eb..849ad7315a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt @@ -41,22 +41,24 @@
To modify a rule, create a new one with the same patron category and item type.