Admin: Anlegen, Bearbeiten und Löschen von Mandanten implementiert
[kivitendo-erp.git] / SL / DB / AuthClient.pm
1 package SL::DB::AuthClient;
2
3 use strict;
4
5 use SL::DB::MetaSetup::AuthClient;
6 use SL::DB::Manager::AuthClient;
7 use SL::DB::Helper::Util;
8
9 __PACKAGE__->meta->add_relationship(
10   users => {
11     type      => 'many to many',
12     map_class => 'SL::DB::AuthClientUser',
13     map_from  => 'client',
14     map_to    => 'user',
15   },
16   groups => {
17     type      => 'many to many',
18     map_class => 'SL::DB::AuthClientGroup',
19     map_from  => 'client',
20     map_to    => 'group',
21   },
22 );
23
24 __PACKAGE__->meta->initialize;
25
26 sub validate {
27   my ($self) = @_;
28
29   my @errors;
30   push @errors, $::locale->text('The name is missing.')                                           if !$self->name;
31   push @errors, $::locale->text('The database name is missing.')                                  if !$self->dbname;
32   push @errors, $::locale->text('The database host is missing.')                                  if !$self->dbhost;
33   push @errors, $::locale->text('The database port is missing.')                                  if !$self->dbport;
34   push @errors, $::locale->text('The database user is missing.')                                  if !$self->dbuser;
35   push @errors, $::locale->text('The name is not unique.')                                        if !SL::DB::Helper::Util::is_unique($self, 'name');
36   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');
37
38   return @errors;
39 }
40
41 1;