X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FDB%2FAuthUser.pm;h=a8d8ab5139aa316186b6aab4100f17ca40722b24;hb=5d244100bb104bb9319cd806fdf072fa37253d1c;hp=0d22be94f8c7024f133b0a2155347bc1bb87a39c;hpb=a5ba22d29e683629d731fc0bfdfb72719e59a0b9;p=kivitendo-erp.git diff --git a/SL/DB/AuthUser.pm b/SL/DB/AuthUser.pm index 0d22be94f..a8d8ab513 100644 --- a/SL/DB/AuthUser.pm +++ b/SL/DB/AuthUser.pm @@ -1,17 +1,17 @@ -# 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; -use SL::DB::MetaSetup::AuthUser; -use SL::DB::AuthUserGroup; +use List::Util qw(first); -# Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. -__PACKAGE__->meta->make_manager_class; +use SL::DB::MetaSetup::AuthUser; +use SL::DB::Manager::AuthUser; +use SL::DB::Helper::Util; -__PACKAGE__->meta->schema('auth'); +use constant CONFIG_VARS => qw(copies countrycode dateformat timeformat default_media default_printer_id + email favorites fax hide_cvar_search_options mandatory_departments menustyle name + numberformat show_form_details signature stylesheet taxincluded_checked tel + template_format vclimit focus_position form_cvars_nr_cols item_multiselect); __PACKAGE__->meta->add_relationship( groups => { @@ -25,8 +25,42 @@ __PACKAGE__->meta->add_relationship( class => 'SL::DB::AuthUserConfig', column_map => { id => 'user_id' }, }, + clients => { + type => 'many to many', + map_class => 'SL::DB::AuthClientUser', + 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'); + + return @errors; +} + +sub get_config_value { + my ($self, $key) = @_; + + my $cfg = first { $_->cfg_key eq $key } @{ $self->configs || [] }; + 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;