1 package SL::DB::Manager::Employee;
5 use SL::DB::Helper::Manager;
6 use SL::DB::Helper::Sorted;
7 use base qw(SL::DB::Helper::Manager);
9 sub object_class { 'SL::DB::Employee' }
11 __PACKAGE__->make_manager_methods;
15 default => [ 'name', 1 ],
18 map { +($_ => "lower(employee.$_)") } qw(deleted_email deleted_fax deleted_signature deleted_tel login name)
24 return undef unless $::form && $::form->{login};
25 return shift->find_by(login => $::form->{login});
28 sub update_entries_for_authorized_users {
31 my %employees_by_login = map { ($_->login => $_) } @{ $class->get_all };
33 require SL::DB::AuthClient;
34 foreach my $user (@{ SL::DB::AuthClient->new(id => $::auth->client->{id})->load->users || [] }) {
35 my $user_config = $user->config_values;
36 my $employee = $employees_by_login{$user->login} || SL::DB::Employee->new(login => $user->login);
38 $employee->update_attributes(
39 name => $user_config->{name},
54 SL::DB::Manager::Employee - RDBO manager for the C<employee> table
58 my $logged_in_employee = SL::DB::Manager::Employee->current;
66 Returns an RDBO instance corresponding to the currently logged-in user.
68 =item C<update_entries_for_authorized_users>
70 For each user created by the administrator in the admin section an
71 entry only exists in the authentication table, but not in the employee
72 table. This is where this function comes in: It iterates over all
73 authentication users that have access to the current client and ensure
74 than an entry for them exists in the table C<employee>. The matching
75 is done via the login name which must be the same in both tables.
77 The only other properties that will be copied from the authentication
78 table into the C<employee> row are C<name> and C<workphone>. In
79 addition C<deleted> is always set to 0.
81 The intention is that this function is called automatically during the
92 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>