From acff8fd6fdeb69c1c950df1e510bfde00383012a Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 13 Jun 2022 22:06:50 +0000 Subject: [PATCH] Bug 30624: Add select_loggedin_library permission To test: 1. Apply patch, updatedatabase, restart_all 2. Have a user with superlibrarian privileges ( User1 ) 3. Have a user who has staff access and circulate privileges but is not a super librarian. ( User2 ) Make note of this users home library 4. Turn on the system preference 'CircSidebar'. -MAIN log in ( auth.tt ) 5. As User1, go to the main login screen and try logging in. You should be able to log in AND you should be able to properly chnage your branch BEFORE logging in. 6. As User2, to to the main login screnn amd try logging in. You should be able to but if you try and switch your libraray to anything beside the user's home branch it will not work. You will be logged in at your home branch. 7. For User2, set the new permission 'select_loggedin_library' on. 8. Now you should be able to successfully switch libraries before log in. 9. Turn the 'select_loggedin_library' back off for User2. -AFTER log in- 10. With User1, click on your name/branch in the top right, you should see the the link 'Set library' at the top. If you turn on 'UseCirculationDesks' the link will be 'Set library and desk'. 11. With User2, click on your name/branch in the top right. If you have 'UseCirculationDesks' on, you should see 'Set desk', otherwise you should see nothing. 12. Repeat step 7. 13. NOw if you click on your name/branch in the top right, you should see the the link 'Set library' at the top. If you turn on 'UseCirculationDesks' the link will be 'Set library and desk'. 14. Repeat Step 9. -CircSideBar- 15. With 'CircSideBar' turned on, go to any ciculation page (Holds queue, Holds to pull, Holds awaiting pickup) with User1. You will see the 'Set library' link. If 'UseCirculationDesks' is on you will see a 'Set library and desk'. 16. Try with User2 and you will not see a 'Set library' link. If 'UseCirculationDesks' is on you will see a 'Set desk' link. 17. Repeat step 7. 18. For with User2 you go to any ciculation page (Holds queue, Holds to pull, Holds awaiting pickup). You will see the 'Set library' link. If 'UseCirculationDesks' is on you will see a 'Set library and desk'. 19. Repeat step 9. -Set library page- 20. Go to the set library page (http://localhost:8081/cgi-bin/koha/circ/set-library.pl) with User1. You will see a dropdown for 'Set library'. Make sure you can change your library successfully. 21. Go to the set library page (http://localhost:8081/cgi-bin/koha/circ/set-library.pl) with User2. You should NOT see see a dropdown for 'Set library'. 22. Repeat step 7. 23. Go to the set library page (http://localhost:8081/cgi-bin/koha/circ/set-library.pl) with User2. Now you should see a dropdown for 'Set library'. Signed-off-by: Andrew --- C4/Auth.pm | 4 ++-- .../data/mysql/mandatory/userpermissions.sql | 1 + .../prog/en/includes/circ-nav.inc | 2 +- .../intranet-tmpl/prog/en/includes/header.inc | 2 +- .../prog/en/includes/permissions.inc | 5 ++++ .../prog/en/modules/circ/circulation-home.tt | 8 ++++++- .../prog/en/modules/circ/set-library.tt | 24 ++++++++++++++----- 7 files changed, 35 insertions(+), 11 deletions(-) diff --git a/C4/Auth.pm b/C4/Auth.pm index a2b1b84aea..91f8d2e6c8 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -1190,10 +1190,10 @@ sub checkauth { my $ip = $ENV{'REMOTE_ADDR'}; # if they specify at login, use that - if ( $query->param('branch') ) { + if ( $query->param('branch') && ( haspermission($userid, { parameters => 'select_loggedin_library' }) || $flags->{superlibrarian}) ) { $branchcode = $query->param('branch'); my $library = Koha::Libraries->find($branchcode); - $branchname = $library? $library->branchname: ''; + $branchname = $library ? $library->branchname: ''; } if ( $query->param('desk_id') ) { $desk_id = $query->param('desk_id'); diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index 612d17233f..5cff05aa80 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -39,6 +39,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES ( 3, 'manage_smtp_servers', 'Manage SMTP servers configuration'), ( 3, 'manage_background_jobs', 'Manage background jobs'), ( 3, 'manage_curbside_pickups', 'Manage curbside pickups'), + ( 3, 'select_loggedin_library' , 'Allow user to change logged in library'), ( 4, 'delete_borrowers', 'Delete patrons'), ( 4, 'edit_borrowers', 'Add, modify and view patron information'), ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc index 3e2aaa81ae..943ad70186 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc @@ -15,7 +15,7 @@ [% IF !Koha.Preference('IndependentBranchesTransfers') || CAN_user_superlibrarian %]
  • Transfer
  • [% END %] - [% IF !( Koha.Preference('IndependentBranches') && !CAN_user_superlibrarian && !CAN_user_editcatalogue_edit_catalogue ) %] + [% IF ( CAN_user_parameters_select_loggedin_library ) %] [% IF Koha.Preference('UseCirculationDesks') %]
  • Set library and desk
  • [% ELSE %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc index 754ac0d294..2c83be701e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc @@ -149,7 +149,7 @@ [% END %] - [% IF !( Koha.Preference('IndependentBranches') && !CAN_user_superlibrarian && !CAN_user_editcatalogue_edit_catalogue ) %] + [% IF ( CAN_user_parameters_select_loggedin_library ) %]
  • [% IF Koha.Preference('UseCirculationDesks') && Koha.Preference('UseCashRegisters') %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index bb635165d1..8edb3c0c96 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -118,6 +118,11 @@ Manage account debit and credit types ([% name | html %]) + [%- CASE 'select_loggedin_library' -%] + + Allow user to change logged in library + + ([% name | html %]) [%- CASE 'manage_circ_rules' -%] Manage circulation rules diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt index 9cc2b96708..b70786bc3e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt @@ -41,7 +41,7 @@
  • Renew
  • - [% UNLESS IndependentBranches %] + [% IF ( CAN_user_parameters_select_loggedin_library ) %]
  • [% IF Koha.Preference('UseCirculationDesks') %] Set library and desk @@ -49,6 +49,12 @@ Set library [% END %]
  • + [% ELSE %] +
  • + [% IF Koha.Preference('UseCirculationDesks') %] + Set desk + [% END %] +
  • [% END %] [% IF ( fast_cataloging ) %] [% IF ( CAN_user_editcatalogue_fast_cataloging ) %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt index d89de8b7a3..d8552b05f0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/set-library.tt @@ -20,6 +20,19 @@ [% INCLUDE 'header.inc' %] [% INCLUDE 'circ-search.inc' %] +[% SET page_title = "" %] +[% IF ( CAN_user_parameters_select_loggedin_library ) %] + [% IF Koha.Preference('UseCirculationDesks') %] + [% page_title = "Set library and desk" %] + [% ELSE %] + [% page_title = "Set library" %] + [% END %] +[% ELSE %] + [% IF Koha.Preference('UseCirculationDesks') %] + [% page_title = "Set desk"%] + [% END %] +[% END %] + @@ -39,13 +52,12 @@
    - [% IF Koha.Preference('CircSidebar') %]
    -

    Set library

    +

    [% page_title | html%]

    [% ELSE %]
    -

    Set library

    +

    [% page_title | html %]

    [% END %] @@ -81,13 +93,13 @@ Updated:
      [% ELSE %]
      -[% IF !( Koha.Preference('IndependentBranches') && !CAN_user_superlibrarian && !CAN_user_editcatalogue_edit_catalogue ) %] +[% IF ( CAN_user_parameters_select_loggedin_library ) %]
      Set library
      -- 2.30.2