1 package SL::DB::Manager::Employee;
5 use SL::DB::Helper::Manager;
6 use base qw(SL::DB::Helper::Manager);
8 sub object_class { 'SL::DB::Employee' }
10 __PACKAGE__->make_manager_methods;
13 return undef unless $::form && $::form->{login};
14 return shift->find_by(login => $::form->{login});
17 sub update_entries_for_authorized_users {
20 my %employees_by_login = map { ($_->login => $_) } @{ $class->get_all };
22 require SL::DB::AuthClient;
23 foreach my $user (@{ SL::DB::AuthClient->new(id => $::auth->client->{id})->load->users || [] }) {
24 my $user_config = $user->config_values;
25 my $employee = $employees_by_login{$user->login} || SL::DB::Employee->new(login => $user->login);
27 $employee->update_attributes(
28 name => $user_config->{name},
43 SL::DB::Manager::Employee - RDBO manager for the C<employee> table
47 my $logged_in_employee = SL::DB::Manager::Employee->current;
55 Returns an RDBO instance corresponding to the currently logged-in user.
57 =item C<update_entries_for_authorized_users>
59 For each user created by the administrator in the admin section an
60 entry only exists in the authentication table, but not in the employee
61 table. This is where this function comes in: It iterates over all
62 authentication users that have access to the current client and ensure
63 than an entry for them exists in the table C<employee>. The matching
64 is done via the login name which must be the same in both tables.
66 The only other properties that will be copied from the authentication
67 table into the C<employee> row are C<name> and C<workphone>. In
68 addition C<deleted> is always set to 0.
70 The intention is that this function is called automatically during the
81 Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt>