Bugzilla – Attachment 186914 Details for
Bug 39142
Add debug permission to allow user to toggle JS and CSS customizations on/off
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39142: Add debug permission to allow user to toggle JS and CSS customizations on/off
Bug-39142-Add-debug-permission-to-allow-user-to-to.patch (text/plain), 4.05 KB, created by
Martin Renvoize (ashimema)
on 2025-09-25 10:53:46 UTC
(
hide
)
Description:
Bug 39142: Add debug permission to allow user to toggle JS and CSS customizations on/off
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-09-25 10:53:46 UTC
Size:
4.05 KB
patch
obsolete
>From 5e330d851086d16989a725d4af3c925a63c563e0 Mon Sep 17 00:00:00 2001 >From: Imani Thomas <imani.thomas@bywatersolutions.com> >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 a 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 <lari.strand@koha-suomi.fi> >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > 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 11ed0cecf37..b771253713d 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 d267032d37c..228edb66cc1 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 %] >+ <div style="position: fixed; bottom: 0;"> >+ <button onclick="window.location.search += '&DISABLE_SYSPREF_IntranetUserCSS=yes&DISABLE_SYSPREF_OPACUserCSS=yes'">Disable User CSS</button> >+ <button onclick="window.location.search += '&DISABLE_SYSPREF_IntranetUserJS=yes&DISABLE_SYSPREF_OPACUserJS=yes'">Disable User JS</button> >+ <button onclick="window.location.search += '&DISABLE_SYSPREF_OpacAdditionalStylesheet=yes&DISABLE_SYSPREF_opaclayoutstylesheet=yes&DISABLE_SYSPREF_intranetcolorstylesheet=yes&DISABLE_SYSPREF_intranetstylesheet=yes'" >+ >Load only default stylesheets</button >+ > >+ </div> >+[% 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 8cb47687a64..941fb6b8ce3 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' -%] > <span class="main_permission preservation_permission">Manage the preservation module</span> > <span class="permissioncode">([% name | html %])</span> >+ [%- CASE 'debug' -%] >+ <span class="main_permission debug_permission">Display the Debug UI</span> >+ <span class="permissioncode">([% name | html %])</span> > [%- END -%] > [%- END -%] > >-- >2.51.0
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 39142
:
178123
|
178294
|
178481
|
178482
|
183392
|
183393
|
186913
| 186914 |
186915
|
186916
|
187061