From 2da6fbfbbb3c708bd7a33057026e369b1be61bc3 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 30 Nov 2010 10:53:47 +0100 Subject: [PATCH] Auth-DB auch bei Benutzerlogins aktualisieren, sofern notwendig --- SL/DBUpgrade2.pm | 16 ++++++++++------ SL/User.pm | 2 +- bin/mozilla/admin.pl | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/SL/DBUpgrade2.pm b/SL/DBUpgrade2.pm index cbb8b9fb9..f30859963 100644 --- a/SL/DBUpgrade2.pm +++ b/SL/DBUpgrade2.pm @@ -347,20 +347,23 @@ sub unapplied_upgrade_scripts { sub apply_admin_dbupgrade_scripts { my ($self, $called_from_admin) = @_; - return if !$self->{auth}; + return 0 if !$self->{auth}; my $dbh = $::auth->dbconnect; my @unapplied_scripts = $self->unapplied_upgrade_scripts($dbh); - return if !@unapplied_scripts; + return 0 if !@unapplied_scripts; my $db_charset = $main::dbcharset || Common::DEFAULT_CHARSET; $self->{form}->{login} ||= 'admin'; map { $_->{description} = SL::Iconv::convert($_->{charset}, $db_charset, $_->{description}) } values %{ $self->{all_controls} }; - $self->{form}->{title} = $::locale->text('Dataset upgrade'); - $self->{form}->header; + 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) { @@ -370,8 +373,9 @@ sub apply_admin_dbupgrade_scripts { $self->process_file($dbh, "sql/$self->{dbdriver}-upgrade2-auth/$control->{file}", $control, $db_charset); } - print $self->{form}->parse_html_template("dbupgrade/footer", { is_admin => $called_from_admin }); - ::end_of_request(); + print $self->{form}->parse_html_template("dbupgrade/footer", { is_admin => 1 }) if $called_from_admin; + + return 1; } sub _check_for_loops { diff --git a/SL/User.pm b/SL/User.pm index 6edcbc603..024a683db 100644 --- a/SL/User.pm +++ b/SL/User.pm @@ -161,6 +161,7 @@ sub login { $self->dbupdate($form); $self->dbupdate2($form, $dbupdater); + SL::DBUpgrade2->new(form => $::form, dbdriver => 'Pg', auth => 1)->apply_admin_dbupgrade_scripts(0); close(FH); @@ -177,7 +178,6 @@ sub login { print $form->parse_html_template("dbupgrade/footer", { "menufile" => $menufile }); $rc = -2; - } } diff --git a/bin/mozilla/admin.pl b/bin/mozilla/admin.pl index 11d61e8a4..2819da00e 100755 --- a/bin/mozilla/admin.pl +++ b/bin/mozilla/admin.pl @@ -1167,7 +1167,7 @@ sub dispatcher { } sub _apply_dbupgrade_scripts { - SL::DBUpgrade2->new(form => $::form, dbdriver => 'Pg', auth => 1)->parse_dbupdate_controls->apply_admin_dbupgrade_scripts(1); + ::end_of_request() if SL::DBUpgrade2->new(form => $::form, dbdriver => 'Pg', auth => 1)->apply_admin_dbupgrade_scripts(1); } 1; -- 2.20.1