+sub action_new_user {
+ my ($self) = @_;
+
+ $self->user(SL::DB::AuthUser->new(
+ config_values => {
+ vclimit => 200,
+ countrycode => "de",
+ numberformat => "1.000,00",
+ dateformat => "dd.mm.yy",
+ stylesheet => "kivitendo.css",
+ menustyle => "neu",
+ },
+ ));
+
+ $self->edit_user_form(title => t8('Create a new user'));
+}
+
+sub action_edit_user {
+ my ($self) = @_;
+ $self->edit_user_form(title => t8('Edit User'));
+}
+
+sub action_save_user {
+ my ($self) = @_;
+ my $params = delete($::form->{user}) || { };
+ my $props = delete($params->{config_values}) || { };
+ my $is_new = !$params->{id};
+
+ $self->user($is_new ? SL::DB::AuthUser->new : SL::DB::AuthUser->new(id => $params->{id})->load)
+ ->assign_attributes(%{ $params })
+ ->config_values({ %{ $self->user->config_values }, %{ $props } });
+
+ my @errors = $self->user->validate;
+
+ if (@errors) {
+ flash('error', @errors);
+ $self->edit_user_form(title => $is_new ? t8('Create a new user') : t8('Edit User'));
+ return;
+ }
+
+ $self->user->save;
+
+ if ($::auth->can_change_password && $::form->{new_password}) {
+ $::auth->change_password($self->user->login, $::form->{new_password});
+ }
+
+ flash_later('info', $is_new ? t8('The user has been created.') : t8('The user has been saved.'));
+ $self->redirect_to(action => 'show');
+}
+
+sub action_delete_user {
+ my ($self) = @_;
+
+ if (!$self->user->delete) {
+ flash('error', t8('The user could not be deleted.'));
+ $self->edit_user_form(title => t8('Edit User'));
+ return;
+ }
+
+ flash_later('info', t8('The user has been deleted.'));
+ $self->redirect_to(action => 'show');
+}
+
+#
+# actions: locking, unlocking
+#
+