From 62e2b5c5b522d44c2a161512d874526dec926636 Mon Sep 17 00:00:00 2001 From: Oli Williams Date: Wed, 28 Jan 2026 11:57:31 +1300 Subject: [PATCH] Bug 41522: Make sysprefs clickable in warnings This patch makes the system preferences warnings/errors in system information clickable, linking to the system preferences page. Links are only shown to users with permissions to manage system preferences. Test plan: 1. Log in as a user with the superlibrarian or manage_sysprefs permission 2. Go to More -> About Koha -> System information 3. Verify warnings containing system preferences names are clickable and lead to the correct preference (to check all messages, you must manually trigger the warnings via incorrect settings or direct database modification) 4. Log in as a user without the superlibrarian and manage_sysprefs permission 5. Verify preference names are not links --- about.pl | 15 + .../intranet-tmpl/prog/en/modules/about.tt | 302 +++++++++++++++--- 2 files changed, 274 insertions(+), 43 deletions(-) diff --git a/about.pl b/about.pl index 86080fa..9bc828c 100755 --- a/about.pl +++ b/about.pl @@ -397,6 +397,7 @@ if ( $tab eq 'sysinfo' ) { my $userid = C4::Context->preference('AutoSelfCheckID'); my $all_permissions = C4::Auth::get_user_subpermissions($userid); my ( $has_self_checkout_perm, $has_other_permissions ); + while ( my ( $module, $permissions ) = each %$all_permissions ) { if ( $module eq 'self_check' ) { while ( my ( $permission, $flag ) = each %$permissions ) { @@ -416,6 +417,20 @@ if ( $tab eq 'sysinfo' ) { ); } + my $patron = Koha::Patrons->find( { borrowernumber => $loggedinuser } ); + + my ($has_sysprefs_perm); + + if ( C4::Auth::haspermission( $patron->userid, { superlibrarian => '1' } ) ) { + $has_sysprefs_perm = 1; + } elsif ( C4::Auth::haspermission( $patron->userid, { parameters => 'manage_sysprefs' } ) ) { + $has_sysprefs_perm = 1; + } + + $template->param( + UserHasSysPrefsPerm => $has_sysprefs_perm, + ); + if ( C4::Context->preference('PatronSelfRegistration') ) { $template->param( warnPrefPatronSelfRegistrationDefaultCategory => 1 ) unless Koha::Patron::Categories->find( C4::Context->preference('PatronSelfRegistrationDefaultCategory') ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index 326eae4..2cc95bc 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -545,59 +545,164 @@ [% IF (warnPrefRequireChoosingExistingAuthority) %] Warning - System preference 'RequireChoosingExistingAuthority' is disabled, but needs 'AutoCreateAuthorities' enabled. Otherwise catalogers can add headings that will not be linked to authorities. + + System preference + [% IF (UserHasSysPrefsPerm) %] + 'RequireChoosingExistingAuthority' + [% ELSE %] + 'RequireChoosingExistingAuthority' + [% END %] + is disabled, but needs + [% IF (UserHasSysPrefsPerm) %] + AutoCreateAuthorities + [% ELSE %] + AutoCreateAuthorities + [% END %] + enabled. Otherwise catalogers can add headings that will not be linked to authorities. + [% END %] [% IF (warnPrefEasyAnalyticalRecords) %] Warning - System preference 'EasyAnalyticalRecords' set, but UseControlNumber preference is set to 'Use'. Set it to 'Don't use' or else the 'Show analytics' links in the staff interface and the OPAC will be - broken. + + System preference + [% IF (UserHasSysPrefsPerm) %] + 'EasyAnalyticalRecords' + [% ELSE %] + 'EasyAnalyticalRecords' + [% END %] + set, but + [% IF (UserHasSysPrefsPerm) %] + UseControlNumber + [% ELSE %] + UseControlNumber + [% END %] + preference is set to 'Use'. Set it to 'Don't use' or else the 'Show analytics' links in the staff interface and the OPAC will be broken. + [% END %] [% IF warnPrefAnonymousPatronOPACPrivacy %] Error - System preference 'OPACPrivacy' set, but AnonymousPatron preference is set to '0'. Set it to a valid borrower number or checkins for these patrons will fail. + + System preference + [% IF (UserHasSysPrefsPerm) %] + 'OPACPrivacy' + [% ELSE %] + 'OPACPrivacy' + [% END %] + set, but + [% IF (UserHasSysPrefsPerm) %] + AnonymousPatron + [% ELSE %] + AnonymousPatron + [% END %] + preference is set to '0'. Set it to a valid borrower number or checkins for these patrons will fail. + [% END %] [% IF warnPrefAnonymousPatronAnonSuggestions %] Warning - System preference 'AnonSuggestions' set, but AnonymousPatron preference is set to '0'. Set it to a valid borrower number if you want that this feature works correctly. + + System preference + [% IF (UserHasSysPrefsPerm) %] + 'AnonSuggestions' + [% ELSE %] + 'AnonSuggestions' + [% END %] + set, but + [% IF (UserHasSysPrefsPerm) %] + AnonymousPatron + [% ELSE %] + AnonymousPatron + [% END %] + preference is set to '0'. Set it to a valid borrower number if you want that this feature works correctly. + [% END %] - [% IF warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist %] + [% IF warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || 1 %] Error - Some patrons have requested privacy after their items are checked in, but the AnonymousPatron preference is not set correctly. Set it to a valid borrower number or checkins for these patrons will fail. + + Some patrons have requested privacy after their items are checked in, but the + [% IF (UserHasSysPrefsPerm) %] + AnonymousPatron + [% ELSE %] + AnonymousPatron + [% END %] + preference is not set correctly. Set it to a valid borrower number or checkins for these patrons will fail. + [% END %] - [% IF warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist %] + [% IF warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || 1 %] Warning - System preference 'AnonSuggestions' set, but AnonymousPatron preference is not set correctly. Set it to a valid borrower number if you want that this feature works correctly. + + System preference + [% IF (UserHasSysPrefsPerm) %] + 'AnonSuggestions' + [% ELSE %] + 'AnonSuggestions' + [% END %] + set, but + [% IF (UserHasSysPrefsPerm) %] + AnonymousPatron + [% ELSE %] + AnonymousPatron + [% END %] + preference is not set correctly. Set it to a valid borrower number if you want that this feature works correctly. [% END %] [% IF warnPrefKohaAdminEmailAddress %] Warning - System preference 'KohaAdminEmailAddress' does not contain a valid email address. Emails will not be sent. + + System preference + [% IF (UserHasSysPrefsPerm) %] + 'KohaAdminEmailAddress' + [% ELSE %] + 'KohaAdminEmailAddress' + [% END %] + does not contain a valid email address. Emails will not be sent. + [% END %] - [% IF warnPrefOpacHiddenItems %] + [% IF warnPrefOpacHiddenItems || 1 %] Warning - System preference 'OpacHiddenItems' generates a warning and will produce unexpected behaviors: [% warnPrefOpacHiddenItems | html %] + + System preference + [% IF (UserHasSysPrefsPerm) %] + 'OpacHiddenItems' + [% ELSE %] + 'OpacHiddenItems' + [% END %] + generates a warning and will produce unexpected behaviors: [% warnPrefOpacHiddenItems | html %] + [% END %] [% IF warnPrefPatronSelfRegistrationDefaultCategory %] - Warning System preference 'PatronSelfRegistration' is set, but 'PatronSelfRegistrationDefaultCategory' does not contain a valid patron category code. Patron self-registration is disabled. + + Warning + + System preference + [% IF (UserHasSysPrefsPerm) %] + 'PatronSelfRegistration' + [% ELSE %] + 'PatronSelfRegistration' + [% END %] + is set, but + [% IF (UserHasSysPrefsPerm) %] + 'PatronSelfRegistrationDefaultCategory' + [% ELSE %] + 'PatronSelfRegistrationDefaultCategory' + [% END %] + does not contain a valid patron category code. Patron self-registration is disabled. + + [% END %] [% IF warnXSLT %] [% FOR p IN warnXSLT %] @@ -611,7 +716,15 @@ [% FOR p IN invalid_yesno %] Warning - System preference '[% p.variable | html %]' must be '0' or '1', but is [% IF p.value.defined %]'[% p.value | html %]'[% ELSE %]NULL[% END %]. + + System preference + [% IF (UserHasSysPrefsPerm) %] + '[% p.variable | html %]' + [% ELSE %] + '[% p.variable | html %]' + [% END %] + must be '0' or '1', but is [% IF p.value.defined %]'[% p.value | html %]'[% ELSE %]NULL[% END %]. + [% END %] [% END %] @@ -621,10 +734,18 @@ No active currency is defined. Please go to Administration > Currencies and exchange rates and mark one currency as active. [% END %] - [% IF warnStatisticsFieldsError %] + [% IF warnStatisticsFieldsError || 1 %] Warning - System preference 'StatisticsFields' contains field names not belonging to the items database table: [% warnStatisticsFieldsError | html %] + + System preference + [% IF (UserHasSysPrefsPerm) %] + 'StatisticsFields' + [% ELSE %] + 'StatisticsFields' + [% END %] + contains field names not belonging to the items database table: [% warnStatisticsFieldsError | html %] + [% END %] [% IF AutoSelfCheckPatronDoesNotHaveSelfCheckPerm %] @@ -651,54 +772,133 @@ The PO directory has not been found. See the dedicated wiki page for more information. [% END %] - [% IF warnPassChangeNoticeMissing %] + [% IF warnPassChangeNoticeMissing || 1 %] Warning - System preference 'NotifyPasswordChange' is enabled, but the PASSWORD_CHANGE notice template is missing. Patrons will not be notified about password changes. Please create the PASSWORD_CHANGE notice template - in Tools > Notices and slips. + + System preference + [% IF (UserHasSysPrefsPerm) %] + 'NotifyPasswordChange' + [% ELSE %] + 'NotifyPasswordChange' + [% END %] + is enabled, but the PASSWORD_CHANGE notice template is missing. Patrons will not be notified about password changes. Please create the PASSWORD_CHANGE notice template in + Tools > Notices and slips. + [% END %] - [% IF warnILLConfiguration %] - [% IF no_ill_backends %] + [% IF warnILLConfiguration || 1 %] + [% IF no_ill_backends || 1 %] Warning - The ILL module is enabled, but there are no backends available. + + The + [% IF (UserHasSysPrefsPerm) %] + ILL module + [% ELSE %] + ILL module + [% END %] + is enabled, but there are no backends available. + [% END %] [% IF ill_partner_code_not_defined %] Warning - The ILL module is enabled, but ILLPartnerCode system preference is empty. Falling back to the hardcoded 'IL'. + + The + [% IF (UserHasSysPrefsPerm) %] + ILL module + [% ELSE %] + ILL module + [% END %] + is enabled, but + [% IF (UserHasSysPrefsPerm) %] + ILLPartnerCode + [% ELSE %] + ILLPartnerCode + [% END %] + system preference is empty. Falling back to the hardcoded 'IL'. + [% END %] - [% IF ill_partner_code_no_patrons %] + [% IF ill_partner_code_no_patrons || 1 %] Warning - The ILL module is enabled and ILLPartnerCode system preference configured, but there are no patrons in [% ill_partner_code_no_patrons | html %] category. + + The + [% IF (UserHasSysPrefsPerm) %] + ILL module + [% ELSE %] + ILL module + [% END %] + is enabled and + [% IF (UserHasSysPrefsPerm) %] + ILLPartnerCode + [% ELSE %] + ILLPartnerCode + [% END %] + system preference configured, but there are no patrons in [% ill_partner_code_no_patrons | html %] category. + [% END %] - [% IF ill_branch_not_defined %] + [% IF ill_branch_not_defined || 1 %] Warning - The ILL module is enabled, but no 'branch' block is defined in koha-conf.xml. You must define this block before use. + + The + [% IF (UserHasSysPrefsPerm) %] + ILL module + [% ELSE %] + ILL module + [% END %] + is enabled, but no 'branch' block is defined in koha-conf.xml. You must define this block before use. + [% END %] - [% IF ill_partner_code_doesnt_exist %] + [% IF ill_partner_code_doesnt_exist || 1 %] Warning - The ILL module is enabled, but the configured ILLPartnerCode ([% ill_partner_code_doesnt_exist | html %]) is not defined on the system. + + The + [% IF (UserHasSysPrefsPerm) %] + ILL module + [% ELSE %] + ILL module + [% END %] + is enabled, but the configured + [% IF (UserHasSysPrefsPerm) %] + ILLPartnerCode + [% ELSE %] + ILLPartnerCode + [% END %] + ([% ill_partner_code_doesnt_exist | html %]) is not defined on the system. + [% END %] - [% IF ill_deprecated_backend_freeform_is_installed %] + [% IF ill_deprecated_backend_freeform_is_installed || 1 %] Warning -

The ILL module is enabled, but the deprecated 'FreeForm' backend is installed.

+

The + [% IF (UserHasSysPrefsPerm) %] + ILL module + [% ELSE %] + ILL module + [% END %] + is enabled, but the deprecated 'FreeForm' backend is installed.

'FreeForm' has since become part of core Koha as 'Standard'.

All 'FreeForm' ILL content should've been migrated to 'Standard' upon upgrading Koha to 24.11.

-

To avoid confusion or redundancy, please uninstall the 'FreeForm' backend before using the ILL module.

+

To avoid confusion or redundancy, please uninstall the 'FreeForm' backend before using the + [% IF (UserHasSysPrefsPerm) %] + ILL module. + [% ELSE %] + ILL module. + [% END %] +

[% END %] @@ -710,10 +910,18 @@ > [% END %] - [% IF oauth2_missing_deps %] + [% IF oauth2_missing_deps || 1 %] Warning - System preference 'RESTOAuth2ClientCredentials' is set, but the required Net::OAuth2::AuthorizationServer dependency is missing. The feature is disabled. + + System preference + [% IF (UserHasSysPrefsPerm) %] + 'RESTOAuth2ClientCredentials' + [% ELSE %] + 'RESTOAuth2ClientCredentials' + [% END %] + is set, but the required Net::OAuth2::AuthorizationServer dependency is missing. The feature is disabled. + [% END %] [% IF bad_yaml_prefs %] @@ -722,10 +930,18 @@ Some system preferences have badly formatted YAML content: [% bad_yaml_prefs.join(', ') | html %] [% END %] - [% IF config_bcrypt_settings_no_set %] + [% IF config_bcrypt_settings_no_set || 1 %] Warning - System preference 'Pseudonymization' is set, but there is not 'bcrypt_settings' entry defined in the $KOHA_CONF file. + + System preference + [% IF (UserHasSysPrefsPerm) %] + 'Pseudonymization' + [% ELSE %] + 'Pseudonymization' + [% END %] + is set, but there is not 'bcrypt_settings' entry defined in the $KOHA_CONF file. + [% END %] [% IF warnHiddenBiblionumbers.size %] -- 2.39.5