]> wagnertech.de Git - mfinanz.git/blobdiff - SL/DB/AuthClient.pm
Admin: Anlegen, Bearbeiten und Löschen von Mandanten implementiert
[mfinanz.git] / SL / DB / AuthClient.pm
index 5291da20928c2e543a3cd196abc94a5a23c3a9b3..9e3d3e8ef50e0fdc7e43b343c6c56eccefdd3cf6 100644 (file)
@@ -1,27 +1,21 @@
-# This file has been auto-generated only because it didn't exist.
-# Feel free to modify it at will; it will not be overwritten automatically.
-
 package SL::DB::AuthClient;
 
 use strict;
 
 use SL::DB::MetaSetup::AuthClient;
-
-# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all.
-__PACKAGE__->meta->schema('auth');
-
-__PACKAGE__->meta->make_manager_class;
+use SL::DB::Manager::AuthClient;
+use SL::DB::Helper::Util;
 
 __PACKAGE__->meta->add_relationship(
   users => {
     type      => 'many to many',
-    map_class => 'SL::DB::AuthUserGroup',
+    map_class => 'SL::DB::AuthClientUser',
     map_from  => 'client',
     map_to    => 'user',
   },
   groups => {
     type      => 'many to many',
-    map_class => 'SL::DB::AuthUserGroup',
+    map_class => 'SL::DB::AuthClientGroup',
     map_from  => 'client',
     map_to    => 'group',
   },
@@ -29,4 +23,19 @@ __PACKAGE__->meta->add_relationship(
 
 __PACKAGE__->meta->initialize;
 
+sub validate {
+  my ($self) = @_;
+
+  my @errors;
+  push @errors, $::locale->text('The name is missing.')                                           if !$self->name;
+  push @errors, $::locale->text('The database name is missing.')                                  if !$self->dbname;
+  push @errors, $::locale->text('The database host is missing.')                                  if !$self->dbhost;
+  push @errors, $::locale->text('The database port is missing.')                                  if !$self->dbport;
+  push @errors, $::locale->text('The database user is missing.')                                  if !$self->dbuser;
+  push @errors, $::locale->text('The name is not unique.')                                        if !SL::DB::Helper::Util::is_unique($self, 'name');
+  push @errors, $::locale->text('The combination of database host, port and name is not unique.') if !SL::DB::Helper::Util::is_unique($self, 'dbhost', 'dbport', 'dbname');
+
+  return @errors;
+}
+
 1;