Bug 14004

Summary: Add ability to temporarily disable added CSS and Javascript in OPAC and interface
Product: Koha Reporter: Barton Chittenden <barton>
Component: Staff interfaceAssignee: Fridolin Somers <fridolin.somers>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: andrew, fridolin.somers, gmcharlt, jonathan.druart, lucas, victor
Version: unspecifiedKeywords: Manual
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This allows to temporarily disable any of OPACUserCSS, OPACUserJS, OpacAdditionalStylesheet, opaclayoutstylesheet, IntranetUserCSS, IntranetUserJS, intranetcolorstylesheet, and intranetstylesheet system preference via an URL parameter. Alter the URL in OPAC or staff interface by adding an additional parameter DISABLE_SYSPREF_<system preference name>=1. Example: /cgi-bin/koha/mainpage.pl?DISABLE_SYSPREF_IntranetUserCSS=1
Version(s) released in:
21.05.00,20.11.03,20.05.09
Circulation function:
Bug Depends on:    
Bug Blocks: 28583    
Attachments: Bug 14004: Add ability to temporarily disable JS/CSS sysprefs
Bug 14004: Add ability to temporarily disable JS/CSS sysprefs
Bug 14004: Add OpacAdditionalStylesheet and opaclayoutstylesheet
Bug 14004: Add ability to temporarily disable JS/CSS sysprefs
Bug 14004: Add OpacAdditionalStylesheet and opaclayoutstylesheet
Bug 14004: Add ability to temporarily disable JS/CSS sysprefs
Bug 14004: Add OpacAdditionalStylesheet and opaclayoutstylesheet
Bug 14004: Set the syspref's value to an empty string
Bug 14004: Set the syspref's value to an empty string
Bug 14004: Set the syspref's value to an empty string
Bug 14004: Set the syspref's value to an empty string

Description Barton Chittenden 2015-04-16 14:31:28 UTC
It would be *super* handy if intranetuserjs and/or opacuserjs could be temporarily disabled via a check-box or syspref. Right now, debugging issues in intranetuserjs usuaally starts with copying the contents into a text file, blanking the syspref and re-testing.
Comment 1 Barton Chittenden 2017-03-15 21:03:36 UTC
Actually, it would be even nicer if this could be handled via an option in the URL, eg.

   .../cgi-bin/koha/catalogue/itemsearch.pl?disbable_intranetuserjs=true
Comment 2 Fridolin Somers 2021-01-12 10:52:23 UTC
Created attachment 115064 [details] [review]
Bug 14004: Add ability to temporarily disable JS/CSS sysprefs

It would be *super* handy if intranetuserjs and/or opacuserjs could be temporarily disabled via a check-box or syspref.
Right now, debugging issues in intranetuserjs usuaally starts with copying the contents into a text file, blanking the syspref and re-testing.

This patch adds this feature by setting syspref via ENV OVERRIDE_SYSPREF
like override via Apache config.
Note that this only works for

Implemented only for preferences :
OPACUserCSS OPACUserJS IntranetUserCSS IntranetUserJS
=> replaced with ' '
intranetcolorstylesheet intranetstylesheet
=> replaced with 0

Test plan :
1) Set some CSS in IntranetUserCSS like : #breadcrumbs{color:red}
2) Go to staff interface home page like : /cgi-bin/koha/mainpage.pl
3) See CSS impact is visible
4) Edit URL : /cgi-bin/koha/mainpage.pl?DISABLE_SYSPREF_IntranetUserCSS=1
5) See CSS impact is not visible
6) Check with the other preferences
Comment 3 Lucas Gass (lukeg) 2021-01-13 23:58:53 UTC
Nice! This works well and its a great way to troubleshoot potential problems.
Comment 4 Lucas Gass (lukeg) 2021-01-14 00:00:54 UTC Comment hidden (obsolete)
Comment 5 Katrin Fischer 2021-01-17 17:30:37 UTC
Hi Frido,
could we please add OpacAdditionalStylesheet and  opaclayoutstylesheet to this to make the same options available for staff and intranet?
Comment 6 Fridolin Somers 2021-01-21 16:09:58 UTC Comment hidden (obsolete)
Comment 7 Owen Leonard 2021-01-21 18:04:21 UTC
Created attachment 115583 [details] [review]
Bug 14004: Add ability to temporarily disable JS/CSS sysprefs

It would be *super* handy if intranetuserjs and/or opacuserjs could be
temporarily disabled via a check-box or syspref.
Right now, debugging issues in intranetuserjs usuaally starts with
copying the contents into a text file, blanking the syspref and re-testing.

This patch adds this feature by setting syspref via ENV
OVERRIDE_SYSPREF like override via Apache config.

Implemented only for preferences :
OPACUserCSS OPACUserJS IntranetUserCSS IntranetUserJS
=> replaced with ' '
intranetcolorstylesheet intranetstylesheet
=> replaced with 0

Test plan :
1) Set some CSS in IntranetUserCSS like : #breadcrumbs{color:red}
2) Go to staff interface home page like : /cgi-bin/koha/mainpage.pl
3) See CSS impact is visible
4) Edit URL : /cgi-bin/koha/mainpage.pl?DISABLE_SYSPREF_IntranetUserCSS=1
5) See CSS impact is not visible
6) Check with the other preferences

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 8 Owen Leonard 2021-01-21 18:04:24 UTC
Created attachment 115584 [details] [review]
Bug 14004: Add OpacAdditionalStylesheet and opaclayoutstylesheet

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 9 Owen Leonard 2021-01-21 18:06:11 UTC
In case it helps, here are the links I tested:

/cgi-bin/koha/opac-main.pl?DISABLE_SYSPREF_OPACUserCSS=1
/cgi-bin/koha/opac-main.pl?DISABLE_SYSPREF_OPACUserJS=1
/cgi-bin/koha/mainpage.pl?DISABLE_SYSPREF_IntranetUserCSS=1
/cgi-bin/koha/mainpage.pl?DISABLE_SYSPREF_IntranetUserJS=1
/cgi-bin/koha/opac-main.pl?DISABLE_SYSPREF_OpacAdditionalStylesheet=1
/cgi-bin/koha/opac-main.pl?DISABLE_SYSPREF_opaclayoutstylesheet=1
/cgi-bin/koha/mainpage.pl?DISABLE_SYSPREF_intranetcolorstylesheet=1
/cgi-bin/koha/mainpage.pl?DISABLE_SYSPREF_intranetstylesheet=1


I also tested some doubling them up, e.g. 

/cgi-bin/koha/opac-main.pl?DISABLE_SYSPREF_opaclayoutstylesheet=1&DISABLE_SYSPREF_OPACUserJS=1
Comment 10 Katrin Fischer 2021-01-21 18:29:53 UTC
I am going to pass this. One idea for future improvement: make the syspref spelling case-insensitive!
Comment 11 Katrin Fischer 2021-01-21 18:30:19 UTC
Created attachment 115589 [details] [review]
Bug 14004: Add ability to temporarily disable JS/CSS sysprefs

It would be *super* handy if intranetuserjs and/or opacuserjs could be
temporarily disabled via a check-box or syspref.
Right now, debugging issues in intranetuserjs usuaally starts with
copying the contents into a text file, blanking the syspref and re-testing.

This patch adds this feature by setting syspref via ENV
OVERRIDE_SYSPREF like override via Apache config.

Implemented only for preferences :
OPACUserCSS OPACUserJS IntranetUserCSS IntranetUserJS
=> replaced with ' '
intranetcolorstylesheet intranetstylesheet
=> replaced with 0

Test plan :
1) Set some CSS in IntranetUserCSS like : #breadcrumbs{color:red}
2) Go to staff interface home page like : /cgi-bin/koha/mainpage.pl
3) See CSS impact is visible
4) Edit URL : /cgi-bin/koha/mainpage.pl?DISABLE_SYSPREF_IntranetUserCSS=1
5) See CSS impact is not visible
6) Check with the other preferences

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 12 Katrin Fischer 2021-01-21 18:30:23 UTC
Created attachment 115590 [details] [review]
Bug 14004: Add OpacAdditionalStylesheet and opaclayoutstylesheet

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 13 Jonathan Druart 2021-01-27 10:58:21 UTC
Why setting the env vars to 0 and " "?

I am expecting to have them set to an empty string.
Comment 14 Jonathan Druart 2021-01-27 11:04:36 UTC
Created attachment 115871 [details] [review]
Bug 14004: Set the syspref's value to an empty string

It's tested with "defined" in C4::Context->preference
Comment 15 Jonathan Druart 2021-01-27 11:21:19 UTC
Created attachment 115874 [details] [review]
Bug 14004: Set the syspref's value to an empty string

It's tested with "defined" in C4::Context->preference
Comment 16 Jonathan Druart 2021-01-27 12:03:39 UTC
Created attachment 115876 [details] [review]
Bug 14004: Set the syspref's value to an empty string

It's tested with "defined" in C4::Context->preference
Comment 17 Fridolin Somers 2021-01-27 13:12:50 UTC
Created attachment 115883 [details] [review]
Bug 14004: Set the syspref's value to an empty string

It's tested with "defined" in C4::Context->preference

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Comment 18 Jonathan Druart 2021-01-27 13:37:15 UTC
Pushed to master for 21.05, thanks to everybody involved!
Comment 19 Fridolin Somers 2021-02-01 13:40:52 UTC
Small but very usefull feature, I choose to backport.

Pushed to 20.11.x for 20.11.03
Comment 20 Andrew Fuerste-Henry 2021-02-05 12:42:51 UTC
Small and useful and really no way someone's going to bump into it on accident. Backporting to 20.05.x for 20.05.09.
Comment 21 Victor Grousset/tuxayo 2021-02-09 23:10:04 UTC
> Small and useful and really no way someone's going to bump into it on accident.
Indeed !

Backported: Pushed to 19.11.x branch for 19.11.15