X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDBUpgrade2.pm;h=a583af8a55d49c8ca76a7208f56eb44016624af9;hb=7f1f5efedc0b738f8e8faaeca52f649150448e32;hp=389e7975b739d3524563ab428532da5a14e5ba96;hpb=626ec4b4e4f6dbb6d018fa71819098c73fb59c53;p=kivitendo-erp.git diff --git a/SL/DBUpgrade2.pm b/SL/DBUpgrade2.pm index 389e7975b..a583af8a5 100644 --- a/SL/DBUpgrade2.pm +++ b/SL/DBUpgrade2.pm @@ -4,6 +4,7 @@ use IO::File; use List::MoreUtils qw(any); use SL::Common; +use SL::DBUtils; use SL::Iconv; use strict; @@ -244,7 +245,7 @@ sub process_perl_script { $db_charset ||= Common::DEFAULT_CHARSET; - my $iconv = SL::Iconv::get_converter($file_charset, $db_charset); + my $iconv = SL::Iconv->new($file_charset, $db_charset); $dbh->begin_work(); @@ -342,6 +343,40 @@ sub unapplied_upgrade_scripts { return grep { !$_->{applied} } @all_scripts; } +sub apply_admin_dbupgrade_scripts { + my ($self, $called_from_admin) = @_; + + return 0 if !$self->{auth}; + + my $dbh = $::auth->dbconnect; + my @unapplied_scripts = $self->unapplied_upgrade_scripts($dbh); + + return 0 if !@unapplied_scripts; + + my $db_charset = $::lx_office_conf{system}->{dbcharset} || Common::DEFAULT_CHARSET; + $self->{form}->{login} ||= 'admin'; + + map { $_->{description} = SL::Iconv::convert($_->{charset}, $db_charset, $_->{description}) } values %{ $self->{all_controls} }; + + if ($called_from_admin) { + $self->{form}->{title} = $::locale->text('Dataset upgrade'); + $self->{form}->header; + } + + print $self->{form}->parse_html_template("dbupgrade/header", { dbname => $::auth->{DB_config}->{db} }); + + foreach my $control (@unapplied_scripts) { + $::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}"); + print $self->{form}->parse_html_template("dbupgrade/upgrade_message2", $control); + + $self->process_file($dbh, "sql/$self->{dbdriver}-upgrade2-auth/$control->{file}", $control, $db_charset); + } + + print $self->{form}->parse_html_template("dbupgrade/footer", { is_admin => 1 }) if $called_from_admin; + + return 1; +} + sub _check_for_loops { my ($form, $file_name, $controls, $tag, @path) = @_; @@ -395,6 +430,8 @@ sub _dbupdate2_calculate_depth { sub sort_dbupdate_controls { my $self = shift; + $self->parse_dbupdate_controls unless $self->{all_controls}; + return sort { ($a->{depth} <=> $b->{depth}) || ($a->{priority} <=> $b->{priority}) || ($a->{tag} cmp $b->{tag}) } values %{ $self->{all_controls} }; }