X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/c377a2dac9813ef97651e747ece0def8acbad5d6..53593baa211863fbf66540cf1bcc36c8fb37257f:/SL/DB/Employee.pm diff --git a/SL/DB/Employee.pm b/SL/DB/Employee.pm index 1ef565ee6..0c321b62f 100644 --- a/SL/DB/Employee.pm +++ b/SL/DB/Employee.pm @@ -5,5 +5,36 @@ use strict; use SL::DB::MetaSetup::Employee; use SL::DB::Manager::Employee; +__PACKAGE__->meta->add_relationship( + project_invoice_permissions => { + type => 'many to many', + map_class => 'SL::DB::EmployeeProjectInvoices', + }, +); + +__PACKAGE__->meta->initialize; + +sub has_right { + my $self = shift; + my $right = shift; + + return $::auth->check_right($self->login, $right); +} + +sub safe_name { + my ($self) = @_; + + return $self->name || $self->login; +} + +sub auth_user { + my ($self) = @_; + + die 'not an accessor' if scalar(@_) > 1; + + require SL::DB::AuthUser; + + return SL::DB::Manager::AuthUser->find_by(login => $self->login); +} 1;