Bug 24872: Set languages prefererences after install

This patch set 'languages' and 'opaclanguages' system
preferences with the language used during install.

To test:
1. Apply the patch
2. Do a clean install in a language other than english
3. Verify that 'languages' and 'opaclanguages' system
preferences show the language code used during install,
besides english.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Joy Nelson <joy@bywatersolutions.com>
This commit is contained in:
Bernardo Gonzalez Kriegel 2020-03-15 11:39:42 -03:00 committed by Joy Nelson
parent 86799ff8ce
commit 6705ca9d4e
2 changed files with 31 additions and 0 deletions

View File

@ -435,6 +435,32 @@ sub set_version_syspref {
C4::Context->clear_syspref_cache();
}
=head2 set_languages_syspref
$installer->set_languages_syspref();
Add the installation language to 'language' and 'opaclanguages' system preferences
if different from 'en'
=cut
sub set_languages_syspref {
my $self = shift;
my $language = shift;
return if ( not $language or $language eq 'en' );
warn "UPDATE Languages";
# intranet
my $pref = $self->{'dbh'}->prepare("UPDATE systempreferences SET value=? WHERE variable='language'");
$pref->execute("en,$language");
# opac
$pref = $self->{'dbh'}->prepare("UPDATE systempreferences SET value=? WHERE variable='opaclanguages'");
$pref->execute("en,$language");
C4::Context->clear_syspref_cache();
}
=head2 load_sql
my $error = $installer->load_sql($filename);

View File

@ -212,6 +212,11 @@ elsif ( $step && $step == 3 ) {
elsif ( $op && $op eq 'finish' ) {
$installer->set_version_syspref();
my $langchoice = $query->param('fwklanguage');
$langchoice = $query->cookie('KohaOpacLanguage') unless ($langchoice);
$langchoice =~ s/[^a-zA-Z_-]*//g;
$installer->set_languages_syspref($langchoice);
# Installation is finished.
# We just deny anybody access to install
# And we redirect people to mainpage.