Revision 74477782
Von Moritz Bunkus vor etwa 11 Jahren hinzugefügt
SL/DB/Manager/Employee.pm | ||
---|---|---|
14 | 14 |
return shift->find_by(login => $::form->{login}); |
15 | 15 |
} |
16 | 16 |
|
17 |
sub update_entries_for_authorized_users { |
|
18 |
my ($class) = @_; |
|
19 |
|
|
20 |
my %employees_by_login = map { ($_->login => $_) } @{ $class->get_all }; |
|
21 |
|
|
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); |
|
26 |
|
|
27 |
$employee->update_attributes( |
|
28 |
name => $user_config->{name}, |
|
29 |
workphone => $user_config->{tel}, |
|
30 |
deleted => 0, |
|
31 |
); |
|
32 |
} |
|
33 |
} |
|
34 |
|
|
17 | 35 |
1; |
36 |
__END__ |
|
37 |
|
|
38 |
=pod |
|
39 |
|
|
40 |
=encoding utf8 |
|
41 |
|
|
42 |
=head1 NAME |
|
43 |
|
|
44 |
SL::DB::Manager::Employee - RDBO manager for the C<employee> table |
|
45 |
|
|
46 |
=head1 SYNOPSIS |
|
47 |
|
|
48 |
my $logged_in_employee = SL::DB::Manager::Employee->current; |
|
49 |
|
|
50 |
=head1 FUNCTIONS |
|
51 |
|
|
52 |
=over 4 |
|
53 |
|
|
54 |
=item C<current> |
|
55 |
|
|
56 |
Returns an RDBO instance corresponding to the currently logged-in user. |
|
57 |
|
|
58 |
=item C<update_entries_for_authorized_users> |
|
59 |
|
|
60 |
For each user created by the administrator in the admin section an |
|
61 |
entry only exists in the authentication table, but not in the employee |
|
62 |
table. This is where this function comes in: It iterates over all |
|
63 |
authentication users that have access to the current client and ensure |
|
64 |
than an entry for them exists in the table C<employee>. The matching |
|
65 |
is done via the login name which must be the same in both tables. |
|
66 |
|
|
67 |
The only other properties that will be copied from the authentication |
|
68 |
table into the C<employee> row are C<name> and C<workphone>. In |
|
69 |
addition C<deleted> is always set to 0. |
|
70 |
|
|
71 |
The intention is that this function is called automatically during the |
|
72 |
login process. |
|
73 |
|
|
74 |
=back |
|
75 |
|
|
76 |
=head1 BUGS |
|
77 |
|
|
78 |
Nothing here yet. |
|
79 |
|
|
80 |
=head1 AUTHOR |
|
81 |
|
|
82 |
Moritz Bunkus E<lt>m.bunkus@linet-services.deE<gt> |
|
83 |
|
|
84 |
=cut |
Auch abrufbar als: Unified diff
Einträge in employee aus User->login heraus aktualisieren
Vor der Mandanteneinführung war User->login bereits hierfür
verantwortlich. Dann wurde diese Funktionalität in den
Login-Controller verschoben. Allerdings kehrt die Ausführung in exakt
einem Fall nicht zum Logincontroller zurück: wenn noch
Datenbankupgrades eingespielt werden müssen.
In dem Fall werden die Updates eingespielt, dem User wird die
"Weiter"-Seite angezeigt, und von hier aus geht es direkt zum
company_logo.
User->login weiß daher als einzige Instanz, wann alle DB-Upgrades
User->installiert sind, und damit, wann RDBO-Instanzen sicher genutzt
User->werden können.
Daher die Funktionalität in die Employee-Manager-Klasse verschoben und
das Triggern der Funktion aus dem Login-Controller wieder zurück nach
User->login verschoben.
Fixt #2361.