+#
+# actions: database administration
+#
+
+sub action_create_dataset_login {
+ my ($self) = @_;
+
+ $self->database_administration_login_form(
+ title => t8('Create Dataset'),
+ next_action => 'create_dataset',
+ );
+}
+
+sub action_create_dataset {
+ my ($self) = @_;
+
+ my %superuser = $self->check_database_superuser_privileges(no_credentials_not_an_error => 1);
+ $self->create_dataset_form(superuser => \%superuser);
+}
+
+sub action_do_create_dataset {
+ my ($self) = @_;
+
+ my %superuser = $self->check_database_superuser_privileges;
+
+ my @errors;
+ push @errors, t8("Dataset missing!") if !$::form->{db};
+ push @errors, t8("Default currency missing!") if !$::form->{defaultcurrency};
+ push @errors, $superuser{error} if !$superuser{have_privileges} && $superuser{error};
+
+ if (@errors) {
+ flash('error', @errors);
+ return $self->create_dataset_form(superuser => \%superuser);
+ }
+
+ $::form->{encoding} = 'UNICODE';
+ User->new->dbcreate($::form);
+
+ flash_later('info', t8("The dataset #1 has been created.", $::form->{db}));
+ $self->redirect_to(action => 'show');
+}
+
+sub action_delete_dataset_login {
+ my ($self) = @_;
+
+ $self->database_administration_login_form(
+ title => t8('Delete Dataset'),
+ next_action => 'delete_dataset',
+ );
+}
+
+sub action_delete_dataset {
+ my ($self) = @_;
+ $self->delete_dataset_form;
+}
+
+sub action_do_delete_dataset {
+ my ($self) = @_;
+
+ my @errors;
+ push @errors, t8("Dataset missing!") if !$::form->{db};
+
+ if (@errors) {
+ flash('error', @errors);
+ return $self->delete_dataset_form;
+ }
+
+ User->new->dbdelete($::form);
+
+ flash_later('info', t8("The dataset #1 has been deleted.", $::form->{db}));
+ $self->redirect_to(action => 'show');
+}
+