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) {
$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 {
$self->dbupdate($form);
$self->dbupdate2($form, $dbupdater);
+ SL::DBUpgrade2->new(form => $::form, dbdriver => 'Pg', auth => 1)->apply_admin_dbupgrade_scripts(0);
close(FH);
print $form->parse_html_template("dbupgrade/footer", { "menufile" => $menufile });
$rc = -2;
-
}
}
}
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;