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) ],
);
my ($self) = @_;
return if $self->apply_dbupgrade_scripts;
- $self->action_show;
+ $self->redirect_to(action => 'show');
}
sub action_create_auth_db {
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');
}
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');
}
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');
}
#
#
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 }
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 {
}
sub apply_dbupgrade_scripts {
- return SL::DBUpgrade2->new(form => $::form, dbdriver => 'Pg', auth => 1)->apply_admin_dbupgrade_scripts(1);
+ return SL::DBUpgrade2->new(form => $::form, auth => 1)->apply_admin_dbupgrade_scripts(1);
}
sub authenticate_root {