sub new {
   $main::lxdebug->enter_sub();
 
-  my ($type, $login) = @_;
+  my ($type, %params) = @_;
 
   my $self = {};
 
-  if ($login ne "") {
-    my %user_data = $main::auth->read_user($login);
+  if ($params{id} || $params{login}) {
+    my %user_data = $main::auth->read_user(%params);
     map { $self->{$_} = $user_data{$_} } keys %user_data;
   }
 
   my @dir = grep(!/(^\.\.?$|\..*)/, readdir(DIR));
 
   foreach my $dir (@dir) {
-    next unless open(FH, "locale/$dir/LANGUAGE");
-    @language = <FH>;
-    close FH;
+    next unless open(my $fh, '<:encoding(UTF-8)', "locale/$dir/LANGUAGE");
+    @language = <$fh>;
+    close $fh;
 
     $cc{$dir} = "@language";
   }
   my $rc = -3;
 
   if ($self->{login}) {
-    my %myconfig = $main::auth->read_user($self->{login});
+    my %myconfig = $main::auth->read_user(login => $self->{login});
 
     # check if database is down
     my $dbh = SL::DBConnect->connect($myconfig{dbconnect}, $myconfig{dbuser}, $myconfig{dbpasswd})
 
     $self->create_schema_info_table($form, $dbh);
 
+    my $dbupdater_auth = SL::DBUpgrade2->new(form => $form, dbdriver => 'Pg', auth => 1)->parse_dbupdate_controls;
+    if ($dbupdater_auth->unapplied_upgrade_scripts($::auth->dbconnect)) {
+      $::lxdebug->leave_sub;
+      return -3;
+    }
+
     $rc = 0;
 
     my $dbupdater = SL::DBUpgrade2->new(form => $form, dbdriver => $myconfig{dbdriver})->parse_dbupdate_controls;
       }
 
       # update the tables
-      if (!open(FH, ">" . $::lx_office_conf{paths}->{userspath} . "/nologin")) {
+      if (!open(FH, ">", $::lx_office_conf{paths}->{userspath} . "/nologin")) {
         $form->show_generic_error($main::locale->text('A temporary file could not be created. ' .
                                                       'Please verify that the directory "#1" is writeable by the webserver.',
                                                       $::lx_office_conf{paths}->{userspath}),
         $self->{"menustyle"} eq "v3" ? "menuv3.pl" :
         $self->{"menustyle"} eq "neu" ? "menunew.pl" :
         $self->{"menustyle"} eq "js" ? "menujs.pl" :
-        $self->{"menustyle"} eq "xml" ? "menuXML.pl" :
         "menu.pl";
 
       print $form->parse_html_template("dbupgrade/footer", { "menufile" => $menufile });
 
   $query = "UPDATE defaults SET coa = ?";
   do_query($form, $dbh, $query, $form->{chart});
+  $query = "UPDATE defaults SET accounting_method = ?";
+  do_query($form, $dbh, $query, $form->{accounting_method});
+  $query = "UPDATE defaults SET profit_determination = ?";
+  do_query($form, $dbh, $query, $form->{profit_determination});
+  $query = "UPDATE defaults SET inventory_system = ?";
+  do_query($form, $dbh, $query, $form->{inventory_system});
 
   $dbh->disconnect;
 
     do_query($form, $dbh, $query, ($self->{login}, $myconfig->{name}, $myconfig->{tel}, "user"));
 
   } elsif ($update_existing) {
-    my $query = qq|UPDATE employee SET name = ?, workphone = ?, role = 'user' WHERE id = ?|;
+    my $query = qq|UPDATE employee SET name = ?, workphone = ?, role = 'user', deleted = 'f' WHERE id = ?|;
     do_query($form, $dbh, $query, $myconfig->{name}, $myconfig->{tel}, $id);
   }
 
   my @conf = qw(address admin businessnumber company countrycode
     currency dateformat dbconnect dbdriver dbhost dbport dboptions
     dbname dbuser dbpasswd email fax name numberformat password
-    printer role sid signature stylesheet tel templates vclimit angebote
+    printer sid signature stylesheet tel templates vclimit angebote
     bestellungen rechnungen anfragen lieferantenbestellungen einkaufsrechnungen
     taxnumber co_ustid duns menustyle template_format default_media
     default_printer_id copies show_form_details favorites
   $main::lxdebug->leave_sub();
 }
 
+sub data {
+  +{ %{ $_[0] } }
+}
+
 1;