From 2372ed13258620a6392c507fb7de477a0c5ea8d4 Mon Sep 17 00:00:00 2001 From: Imani Thomas Date: Tue, 18 Feb 2025 17:20:17 +0000 Subject: [PATCH] Bug 39142: Add debug permission to allow user to toggle JS and CSS customizations on/off to test: 1. apply the patch 2. use updatedatabase run to update your db 3. add custom JS and CSS in the IntranetUserJS and IntranetUserCSS fields 4. with as SuperLibrarian account confirm you have 3 buttons at the bottom of your screen, Disable User JS, Disable User CSS, and load only default stylesheets 5. clicking the buttons should reload the current page with a query to disable those things. 6. Log in as a user that is not a superlibrarian and does not have the debug UI permission enabled 7. confirm the buttons are no longer visible 8. Add the debug UI permission to the user 9. confirm the debug buttons are now visible for that user. Signed-off-by: Lari Strand --- Koha/Template/Plugin/Koha.pm | 20 +++++++++++++++++++ .../prog/en/includes/intranet-bottom.inc | 10 ++++++++++ .../prog/en/includes/permissions.inc | 3 +++ 3 files changed, 33 insertions(+) diff --git a/Koha/Template/Plugin/Koha.pm b/Koha/Template/Plugin/Koha.pm index de2363d2a3..75e527d988 100644 --- a/Koha/Template/Plugin/Koha.pm +++ b/Koha/Template/Plugin/Koha.pm @@ -87,6 +87,26 @@ sub MultivaluePreference { return C4::Context->multivalue_preference($pref); } +=head3 debug_flag + +This method checks if the currently logged in user is allowed +access to the new debug ui permission. It should return +0 if no one is logged in or context is unavailable for some other reason + or they do not have the permission +1 if they are a superlibrarian +1<<31 if they do have the permission + +=cut + +sub debug_flag { + return 0 unless C4::Context->userenv(); + return 1 if C4::Context->IsSuperLibrarian(); + my $flags = C4::Context->userenv()->{'flags'}; + my $mask = 1 << 31; + return $flags & $mask; + +} + =head3 CSVDelimiter The delimiter option 'tabs' is stored in the DB as 'tabulation' to avoid issues diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc index d267032d37..228edb66cc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc @@ -186,6 +186,16 @@ [% END %] [% END %] +[% IF Koha.debug_flag %] +
+ + + +
+[% END # IF %] + [% IF ( footerjs ) %] [% INCLUDE js_includes.inc %] [% jsinclude | $raw # Parse the page template's JavaScript block if necessary %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc index a0e17a2d41..a4e03591ce 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc @@ -87,6 +87,9 @@ [%- CASE 'preservation' -%] Manage the preservation module ([% name | html %]) + [%- CASE 'debug' -%] + Display the Debug UI + ([% name | html %]) [%- END -%] [%- END -%] -- 2.43.0