X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=C4%2FInstaller.pm;h=a1c47149f82375a2f0703a21b67208aed5f711c6;hb=2a58e32f7d506ee87a20d50a53f497e18fb7cf13;hp=416518364e045559c7163ded5508eab22e007aba;hpb=0b15c5e2cc5d5a84b062c5c5738fe54ab5df98ab;p=koha.git diff --git a/C4/Installer.pm b/C4/Installer.pm index 416518364e..a1c47149f8 100644 --- a/C4/Installer.pm +++ b/C4/Installer.pm @@ -30,7 +30,7 @@ use vars qw(@ISA @EXPORT); BEGIN { require Exporter; @ISA = qw( Exporter ); - push @EXPORT, qw( constraint_exists column_exists ); + push @EXPORT, qw( foreign_key_exists index_exists column_exists ); }; =head1 NAME @@ -75,8 +75,17 @@ sub new { $self->{'port'} = C4::Context->config("port"); $self->{'user'} = C4::Context->config("user"); $self->{'password'} = C4::Context->config("pass"); + $self->{'tls'} = C4::Context->config("tls"); + if( $self->{'tls'} && $self->{'tls'} eq 'yes' ) { + $self->{'ca'} = C4::Context->config('ca'); + $self->{'cert'} = C4::Context->config('cert'); + $self->{'key'} = C4::Context->config('key'); + $self->{'tlsoptions'} = ";mysql_ssl=1;mysql_ssl_client_key=".$self->{key}.";mysql_ssl_client_cert=".$self->{cert}.";mysql_ssl_ca_file=".$self->{ca}; + $self->{'tlscmdline'} = " --ssl-cert ". $self->{cert} . " --ssl-key " . $self->{key} . " --ssl-ca ".$self->{ca}." " + } $self->{'dbh'} = DBI->connect("DBI:$self->{dbms}:dbname=$self->{dbname};host=$self->{hostname}" . - ( $self->{port} ? ";port=$self->{port}" : "" ), + ( $self->{port} ? ";port=$self->{port}" : "" ). + ( $self->{tlsoptions} ? $self->{tlsoptions} : ""), $self->{'user'}, $self->{'password'}); $self->{'language'} = undef; $self->{'marcflavour'} = undef; @@ -143,15 +152,15 @@ sub marc_framework_sql_list { map { my $name = substr( $_, 0, -4 ); open my $fh, "<:encoding(UTF-8)", "$dir/$requirelevel/$name.txt"; - my $lines = <$fh>; - $lines =~ s/\n|\r/
/g; - $lines = Encode::encode('UTF-8', $lines) unless ( Encode::is_utf8($lines) ); + my $line = <$fh>; + $line = Encode::encode('UTF-8', $line) unless ( Encode::is_utf8($line) ); + my @lines = split /\n/, $line; my $mandatory = ($requirelevel =~ /(mandatory|requi|oblig|necess)/i); push @frameworklist, { 'fwkname' => $name, 'fwkfile' => "$dir/$requirelevel/$_", - 'fwkdescription' => $lines, + 'fwkdescription' => \@lines, 'checked' => ( ( $frameworksloaded{$_} || $mandatory ) ? 1 : 0 ), 'mandatory' => $mandatory, }; @@ -220,15 +229,15 @@ sub sample_data_sql_list { map { my $name = substr( $_, 0, -4 ); open my $fh , "<:encoding(UTF-8)", "$dir/$requirelevel/$name.txt"; - my $lines = <$fh>; - $lines =~ s/\n|\r/
/g; - $lines = Encode::encode('UTF-8', $lines) unless ( Encode::is_utf8($lines) ); + my $line = <$fh>; + $line = Encode::encode('UTF-8', $line) unless ( Encode::is_utf8($line) ); + my @lines = split /\n/, $line; my $mandatory = ($requirelevel =~ /(mandatory|requi|oblig|necess)/i); push @frameworklist, { 'fwkname' => $name, 'fwkfile' => "$dir/$requirelevel/$_", - 'fwkdescription' => $lines, + 'fwkdescription' => \@lines, 'checked' => ( ( $frameworksloaded{$_} || $mandatory ) ? 1 : 0 ), 'mandatory' => $mandatory, }; @@ -317,7 +326,7 @@ sub load_sql_in_order { 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"; - push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/mandatory/refund_lost_item_fee_rules.sql"; + push @fnames, C4::Context->config('intranetdir') . "/installer/data/mysql/account_offset_types.sql"; foreach my $file (@fnames) { # warn $file; undef $/; @@ -454,7 +463,6 @@ sub load_sql { if( $dup_stderr ) { warn "C4::Installer::load_sql returned the following errors while attempting to load $filename:\n"; $error = $dup_stderr; - } return $error; @@ -498,7 +506,14 @@ sub get_file_path_from_name { } -sub constraint_exists { +sub foreign_key_exists { + my ( $table_name, $constraint_name ) = @_; + my $dbh = C4::Context->dbh; + my (undef, $infos) = $dbh->selectrow_array(qq|SHOW CREATE TABLE $table_name|); + return $infos =~ m|CONSTRAINT `$constraint_name` FOREIGN KEY|; +} + +sub index_exists { my ( $table_name, $key_name ) = @_; my $dbh = C4::Context->dbh; my ($exists) = $dbh->selectrow_array(