X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/90bb521a25eeb37c5bbae1ff68c38e6c142b6e6b..a3ae31cd5221738f7d0cc6bc2f4df316e7b83daa:/SL/Controller/Admin.pm diff --git a/SL/Controller/Admin.pm b/SL/Controller/Admin.pm index 8ba249034..e1d26fd8c 100644 --- a/SL/Controller/Admin.pm +++ b/SL/Controller/Admin.pm @@ -12,11 +12,12 @@ use SL::DB::AuthGroup; use SL::DB::Printer; use SL::Helper::Flash; use SL::Locale::String qw(t8); +use SL::System::InstallationLock; use SL::User; use Rose::Object::MakeMethods::Generic ( - 'scalar --get_set_init' => [ qw(client user group printer nologin_file_name db_cfg is_locked + 'scalar --get_set_init' => [ qw(client user group printer db_cfg is_locked all_dateformats all_numberformats all_countrycodes all_stylesheets all_menustyles all_clients all_groups all_users all_rights all_printers) ], ); @@ -36,6 +37,7 @@ sub keep_auth_vars { sub action_login { my ($self) = @_; + return $self->redirect_to(action => 'show') if $::auth->authenticate_root == SL::Auth::OK(); return $self->login_form if !$::form->{do_login}; return if !$self->authenticate_root; return if !$self->check_auth_db_and_tables; @@ -57,7 +59,7 @@ sub action_apply_dbupgrade_scripts { my ($self) = @_; return if $self->apply_dbupgrade_scripts; - $self->action_show; + $self->redirect_to(action => 'show'); } sub action_create_auth_db { @@ -156,12 +158,21 @@ sub action_save_user { sub action_delete_user { my ($self) = @_; + my @clients = @{ $self->user->clients || [] }; + if (!$self->user->delete) { flash('error', t8('The user could not be deleted.')); $self->edit_user_form(title => t8('Edit User')); return; } + # Flag corresponding entries in 'employee' as deleted. + foreach my $client (@clients) { + my $dbh = $client->dbconnect(AutoCommit => 1) || next; + $dbh->do(qq|UPDATE employee SET deleted = TRUE WHERE login = ?|, undef, $self->user->login); + $dbh->disconnect; + } + flash_later('info', t8('The user has been deleted.')); $self->redirect_to(action => 'show'); } @@ -355,7 +366,8 @@ sub action_delete_printer { sub action_unlock_system { my ($self) = @_; - unlink $self->nologin_file_name; + + SL::System::InstallationLock->unlock; flash_later('info', t8('Lockfile removed!')); $self->redirect_to(action => 'show'); } @@ -363,15 +375,9 @@ sub action_unlock_system { sub action_lock_system { my ($self) = @_; - my $fh = IO::File->new($self->nologin_file_name, "w"); - if (!$fh) { - $::form->error(t8('Cannot create Lock!')); - - } else { - $fh->close; - flash_later('info', t8('Lockfile created!')); - $self->redirect_to(action => 'show'); - } + SL::System::InstallationLock->unlock; + flash_later('info', t8('Lockfile created!')); + $self->redirect_to(action => 'show'); } # @@ -379,8 +385,7 @@ sub action_lock_system { # sub init_db_cfg { $::lx_office_conf{'authentication/database'} } -sub init_nologin_file_name { $::lx_office_conf{paths}->{userspath} . '/nologin'; } -sub init_is_locked { -e $_[0]->nologin_file_name } +sub init_is_locked { SL::System::InstallationLock->is_locked } sub init_client { SL::DB::Manager::AuthClient->find_by(id => ($::form->{id} || ($::form->{client} || {})->{id})) } sub init_user { SL::DB::AuthUser ->new(id => ($::form->{id} || ($::form->{user} || {})->{id}))->load } sub init_group { SL::DB::AuthGroup ->new(id => ($::form->{id} || ($::form->{group} || {})->{id}))->load } @@ -460,7 +465,7 @@ sub use_multiselect_js { sub login_form { my ($self, %params) = @_; $::request->layout->focus('#admin_password'); - $self->render('admin/adminlogin', title => t8('kivitendo v#1 administration', $::form->{version}), %params); + $self->render('admin/adminlogin', title => t8('kivitendo v#1 administration', $::form->read_version), %params); } sub edit_user_form {