Bugzilla – Attachment 144557 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), 6.94 KB, created by
Lucas Gass
on 2022-12-13 21:00:39 UTC
(
hide
)
Description:
Bug 30624: Add loggedinlibrary permission and DB update
Filename:
MIME Type:
Creator:
Lucas Gass
Created:
2022-12-13 21:00:39 UTC
Size:
6.94 KB
patch
obsolete
>From 04f8b047b3413e0e053b0662d6c0d4307f47e19f 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 > >--- > C4/Auth.pm | 3 ++- > .../atomicupdate/bug_30624_add_userflag.pl | 20 +++++++++++++++++++ > installer/data/mysql/mandatory/userflags.sql | 3 ++- > .../prog/en/includes/circ-nav.inc | 3 +-- > .../intranet-tmpl/prog/en/includes/header.inc | 2 +- > .../prog/en/includes/permissions.inc | 3 +++ > .../prog/en/modules/circ/circulation-home.tt | 2 +- > .../prog/en/modules/circ/set-library.tt | 2 +- > 8 files changed, 31 insertions(+), 7 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/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..38735f1f997 >--- /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 + (2<<28) 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..122741c569d 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> >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..f2a386d4182 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> >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