X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/6b935d522a38e1a20802c25ed51a15e0cd292c1d..9f9f93b3f869be5b187a7fe00327ed85f9a43b6c:/SL/DB/AuthUser.pm diff --git a/SL/DB/AuthUser.pm b/SL/DB/AuthUser.pm index 2a15449d6..a11248ec6 100644 --- a/SL/DB/AuthUser.pm +++ b/SL/DB/AuthUser.pm @@ -1,6 +1,3 @@ -# 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::AuthUser; use strict; @@ -8,12 +5,10 @@ use strict; use List::Util qw(first); use SL::DB::MetaSetup::AuthUser; +use SL::DB::Manager::AuthUser; +use SL::DB::AuthClient; use SL::DB::AuthUserGroup; - -# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. -__PACKAGE__->meta->make_manager_class; - -__PACKAGE__->meta->schema('auth'); +use SL::DB::Helper::Util; __PACKAGE__->meta->add_relationship( groups => { @@ -27,10 +22,27 @@ __PACKAGE__->meta->add_relationship( class => 'SL::DB::AuthUserConfig', column_map => { id => 'user_id' }, }, + clients => { + type => 'many to many', + map_class => 'SL::DB::AuthUserClient', + map_from => 'user', + map_to => 'client', + }, ); __PACKAGE__->meta->initialize; +sub validate { + my ($self) = @_; + + my @errors; + push @errors, $::locale->text('The login is missing.') if !$self->login; + push @errors, $::locale->text('The login is not unique.') if !SL::DB::Helper::Util::is_unique($self, 'login'); + push @errors, "chunky bacon"; + + return @errors; +} + sub get_config_value { my ($self, $key) = @_; @@ -38,4 +50,15 @@ sub get_config_value { return $cfg ? $cfg->cfg_value : undef; } +sub config_values { + my $self = shift; + + if (0 != scalar(@_)) { + my %settings = (ref($_[0]) || '') eq 'HASH' ? %{ $_[0] } : @_; + $self->configs([ map { SL::DB::AuthUserConfig->new(cfg_key => $_, cfg_value => $settings{$_}) } keys %settings ]); + } + + return { map { ($_->cfg_key => $_->cfg_value) } @{ $self->configs } }; +} + 1;