Bugzilla – Attachment 145048 Details for
Bug 30624
Add a permission to control the ability to change the logged in library
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30624: Add loggedinlibrary permission and DB update
Bug-30624-Add-loggedinlibrary-permission-and-DB-up.patch (text/plain), 11.57 KB, created by
Lucas Gass (lukeg)
on 2023-01-04 22:21:08 UTC
(
hide
)
Description:
Bug 30624: Add loggedinlibrary permission and DB update
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2023-01-04 22:21:08 UTC
Size:
11.57 KB
patch
obsolete
>From 29482b4a572b605aee1dc1f7d8cd7575f329ac70 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Tue, 13 Dec 2022 20:59:50 +0000 >Subject: [PATCH] Bug 30624: Add loggedinlibrary permission and DB update > >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 top level permission 'Allow staff to change logged in library (loggedinlibrary). >8. Now you should be able to successfully switch libraries before log in. >9. Turn the 'loggedinlibrary' permission 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: Bob Bennhoff/AspenCat Team >--- > C4/Auth.pm | 3 ++- > circ/set-library.pl | 4 ++-- > .../atomicupdate/bug_30624_add_userflag.pl | 20 +++++++++++++++++++ > installer/data/mysql/mandatory/userflags.sql | 3 ++- > .../prog/en/includes/circ-nav.inc | 7 +++++-- > .../intranet-tmpl/prog/en/includes/header.inc | 2 +- > .../prog/en/includes/permissions.inc | 3 +++ > .../prog/en/modules/circ/circulation-home.tt | 6 +++++- > .../prog/en/modules/circ/set-library.tt | 2 +- > 9 files changed, 41 insertions(+), 9 deletions(-) > create mode 100755 installer/data/mysql/atomicupdate/bug_30624_add_userflag.pl > >diff --git a/C4/Auth.pm b/C4/Auth.pm >index d8ddb170985..f6127fe8e38 100644 >--- a/C4/Auth.pm >+++ b/C4/Auth.pm >@@ -1154,7 +1154,8 @@ sub checkauth { > my $ip = $ENV{'REMOTE_ADDR'}; > > # if they specify at login, use that >- if ( $query->param('branch') ) { >+ my $patron = Koha::Patrons->find({userid => $userid}); >+ if ( $query->param('branch') && ( haspermission($userid, { 'loggedinlibrary'=> 1 }) || $patron->is_superlibrarian ) ) { > $branchcode = $query->param('branch'); > my $library = Koha::Libraries->find($branchcode); > $branchname = $library? $library->branchname: ''; >diff --git a/circ/set-library.pl b/circ/set-library.pl >index 9d2823d9c6d..35261a5006b 100755 >--- a/circ/set-library.pl >+++ b/circ/set-library.pl >@@ -49,8 +49,8 @@ my $userenv_register_id = C4::Context->userenv->{'register_id'} || ''; > my @updated; > > # $session lines here are doing the updating >-if ( $branch and my $library = Koha::Libraries->find($branch) ) { >- if (! $userenv_branch or $userenv_branch ne $branch ) { >+if ( $branch and my $library = Koha::Libraries->find($branch) and ( $flags->{loggedinlibrary} == 1 or $flags->{superlibrarian} == 1 ) ) { >+ if ( !$userenv_branch or $userenv_branch ne $branch ) { > my $branchname = $library->branchname; > $session->param('branchname', $branchname); # update sesssion in DB > $session->param('branch', $branch); # update sesssion in DB >diff --git a/installer/data/mysql/atomicupdate/bug_30624_add_userflag.pl b/installer/data/mysql/atomicupdate/bug_30624_add_userflag.pl >new file mode 100755 >index 00000000000..c4b1d5c8458 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_30624_add_userflag.pl >@@ -0,0 +1,20 @@ >+use Modern::Perl; >+ >+return { >+ bug_number => "30624", >+ description => "Add loggedinlibrary permission", >+ up => sub { >+ my ($args) = @_; >+ my ($dbh, $out) = @$args{qw(dbh out)}; >+ $dbh->do(q{ >+ INSERT IGNORE INTO userflags (bit, flag, flagdesc, defaulton) VALUES (29, 'loggedinlibrary', 'Allow staff to change logged in library', 0) >+ }); >+ >+ my $IndependentBranches = C4::Context->preference('IndependentBranches'); >+ unless ( $IndependentBranches ) { >+ $dbh->do(q{ >+ UPDATE borrowers SET flags = flags + (1<<29) WHERE flags & 4; >+ }); >+ } >+ }, >+}; >diff --git a/installer/data/mysql/mandatory/userflags.sql b/installer/data/mysql/mandatory/userflags.sql >index 137612f14cd..b9905e2f5e7 100644 >--- a/installer/data/mysql/mandatory/userflags.sql >+++ b/installer/data/mysql/mandatory/userflags.sql >@@ -25,5 +25,6 @@ INSERT INTO userflags (bit, flag, flagdesc, defaulton) VALUES > (25, 'cash_management', 'Cash management', 0), > (26, 'problem_reports', 'Manage problem reports', 0), > (27, 'recalls', 'Recalls', 0), >-(28, 'erm', 'Manage electronic resources', 0) >+(28, 'erm', 'Manage electronic resources', 0), >+(29, 'loggedinlibrary', 'Change logged in library', 0) > ; >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 61d82953b47..e10a4805897 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc >@@ -2,7 +2,6 @@ > [% USE Branches %] > <div id="navmenu"> > <div id="navmenulist"> >- > <h5>Circulation</h5> > <ul> > <li> >@@ -14,7 +13,7 @@ > <li> > <a href="/cgi-bin/koha/circ/renew.pl">Renew</a> > </li> >- [% UNLESS IndependentBranches %] >+ [% IF ( CAN_user_superlibrarian || CAN_user_loggedinlibrary ) %] > <li> > [% IF Koha.Preference('UseCirculationDesks') %] > <a href="/cgi-bin/koha/circ/set-library.pl">Set library and desk</a> >@@ -22,6 +21,10 @@ > <a href="/cgi-bin/koha/circ/set-library.pl">Set library</a> > [% END %] > </li> >+ [% ELSIF Koha.Preference('UseCirculationDesks') %] >+ <li> >+ <a href="/cgi-bin/koha/circ/set-library.pl">Set desk</a> >+ </li> > [% END %] > [% IF ( fast_cataloging && CAN_user_editcatalogue_fast_cataloging ) %] > <li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >index 9925b7aba49..33b19402abe 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/header.inc >@@ -157,7 +157,7 @@ > </li> > [% END %] > >- [% IF !( Koha.Preference('IndependentBranches') && !CAN_user_superlibrarian && !CAN_user_editcatalogue_edit_catalogue ) %] >+ [% IF ( CAN_user_superlibrarian || CAN_user_loggedinlibrary ) %] > <li role="separator" class="loggedin-menu-label divider"></li> > <li> > [% 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 336021f5001..c7adf23aa89 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc >@@ -81,6 +81,9 @@ > [%- CASE 'erm' -%] > <span class="main_permission erm_permission">Manage the electronic resources module</span> > <span class="permissioncode">([% name | html %])</span> >+ [%- CASE 'loggedinlibrary' -%] >+ <span class="main_permission loggedinlibrary_permission">Allow staff to change logged in library</span> >+ <span class="permissioncode">([% name | html %])</span> > [%- END -%] > [%- END -%] > >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 ca2d955a57d..2e7849c630d 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 >@@ -44,7 +44,7 @@ > <li> > <a class="circ-button" href="/cgi-bin/koha/circ/renew.pl"><i class="fa fa-retweet"></i> Renew</a> > </li> >- [% UNLESS IndependentBranches %] >+ [% IF ( CAN_user_superlibrarian || CAN_user_loggedinlibrary ) %] > <li> > [% IF Koha.Preference('UseCirculationDesks') %] > <a class="circ-button" href="/cgi-bin/koha/circ/set-library.pl"><i class="fa fa-home"></i> Set library and desk</a> >@@ -52,6 +52,10 @@ > <a class="circ-button" href="/cgi-bin/koha/circ/set-library.pl"><i class="fa fa-home"></i> Set library</a> > [% END %] > </li> >+ [% ELSIF Koha.Preference('UseCirculationDesks') %] >+ <li> >+ <a class="circ-button" href="/cgi-bin/koha/circ/set-library.pl"><i class="fa fa-home"></i> Set desk</a> >+ </li> > [% 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 07b6dd50469..08f7397df00 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 >@@ -84,7 +84,7 @@ Updated:<ul> > [% ELSE %] > > <form method="post" action="set-library.pl"> >-[% IF !( Koha.Preference('IndependentBranches') && !CAN_user_superlibrarian && !CAN_user_editcatalogue_edit_catalogue ) %] >+[% IF ( CAN_user_superlibrarian || CAN_user_loggedinlibrary ) %] > <fieldset class="rows"> > <legend>Set library</legend> > <ol> >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 30624
:
136055
|
136076
|
137733
|
138377
|
138378
|
139961
|
139962
|
139963
|
141069
|
141070
|
141071
|
142269
|
142270
|
142271
|
144557
|
144559
|
144584
|
144594
|
144595
|
144596
|
145048
|
145049
|
145631
|
147509
|
147753
|
147754
|
147755
|
147756
|
148116