Bug 16168: Eliminate unneeded C4::Context->dbh calls in C4/Biblio.pm
[koha.git] / C4 / Installer.pm
index 2add0e8..f110477 100644 (file)
@@ -4,25 +4,27 @@ package C4::Installer;
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use strict;
 #use warnings; FIXME - Bug 2505
 
-our $VERSION = 3.07.00.049;
+use Encode qw( encode is_utf8 );
 use C4::Context;
 use C4::Installer::PerlModules;
+use DBI;
+use Koha;
 
 =head1 NAME
 
@@ -136,8 +138,7 @@ sub marc_framework_sql_list {
             open my $fh, "<:encoding(UTF-8)", "$dir/$requirelevel/$name.txt";
             my $lines = <$fh>;
             $lines =~ s/\n|\r/<br \/>/g;
-            use utf8;
-            utf8::encode($lines) unless ( utf8::is_utf8($lines) );
+            $lines = Encode::encode('UTF-8', $lines) unless ( Encode::is_utf8($lines) );
             my $mandatory = ($requirelevel =~ /(mandatory|requi|oblig|necess)/i);
             push @frameworklist,
               {
@@ -214,8 +215,7 @@ sub sample_data_sql_list {
             open my $fh , "<:encoding(UTF-8)", "$dir/$requirelevel/$name.txt";
             my $lines = <$fh>;
             $lines =~ s/\n|\r/<br \/>/g;
-            use utf8;
-            utf8::encode($lines) unless ( utf8::is_utf8($lines) );
+            $lines = Encode::encode('UTF-8', $lines) unless ( Encode::is_utf8($lines) );
             my $mandatory = ($requirelevel =~ /(mandatory|requi|oblig|necess)/i);
             push @frameworklist,
               {
@@ -298,9 +298,15 @@ sub load_sql_in_order {
     $request->execute;
     my ($systempreference) = $request->fetchrow;
     $systempreference = '' unless defined $systempreference; # avoid warning
+    # Make sure subtag_registry.sql is loaded second
+    my $subtag_registry = C4::Context->config('intranetdir') . "/installer/data/$self->{dbms}/mandatory/subtag_registry.sql";
+    unshift(@fnames, $subtag_registry);
     # Make sure the global sysprefs.sql file is loaded first
     my $globalsysprefs = C4::Context->config('intranetdir') . "/installer/data/$self->{dbms}/sysprefs.sql";
     unshift(@fnames, $globalsysprefs);
+    push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/userflags.sql";
+    push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/userpermissions.sql";
+    push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/audio_alerts.sql";
     foreach my $file (@fnames) {
         #      warn $file;
         undef $/;
@@ -387,7 +393,7 @@ Koha software version.
 sub set_version_syspref {
     my $self = shift;
 
-    my $kohaversion=C4::Context::KOHAVERSION;
+    my $kohaversion = Koha::version();
     # remove the 3 last . to have a Perl number
     $kohaversion =~ s/(.*\..*)\.(.*)\.(.*)/$1$2$3/;
     if (C4::Context->preference('Version')) {
@@ -455,7 +461,7 @@ sub load_sql {
         $error = qx($strcmd -f $filename 2>&1 1>/dev/null);
         # Be sure to set 'client_min_messages = error' in postgresql.conf
         # so that only true errors are returned to stderr or else the installer will
-        # report the import a failure although it really succeded -fbcit
+        # report the import as a failure although it really succeeded -fbcit
     }
 #   errors thrown while loading installer data should be logged
     if($error) {