Revision 07cd1c32
Von Cem Aydin vor mehr als 2 Jahren hinzugefügt
SL/Controller/Admin.pm | ||
---|---|---|
137 | 137 |
my $params = delete($::form->{user}) || { }; |
138 | 138 |
my $props = delete($params->{config_values}) || { }; |
139 | 139 |
my $is_new = !$params->{id}; |
140 |
my $check_previously_used = delete($::form->{check_previously_used}) || 0; |
|
141 |
my $assign_documents = delete($::form->{assign_documents}) || 0; |
|
140 | 142 |
|
141 | 143 |
# Assign empty arrays if the browser doesn't send those controls. |
142 | 144 |
$params->{clients} ||= []; |
... | ... | |
149 | 151 |
my @errors = $self->user->validate; |
150 | 152 |
|
151 | 153 |
if (@errors) { |
152 |
flash('error', @errors); |
|
153 |
$self->edit_user_form(title => $is_new ? t8('Create a new user') : t8('Edit User')); |
|
154 |
return; |
|
154 |
$self->js->flash('error', $_) foreach @errors; |
|
155 |
return $self->js->render(); |
|
156 |
} |
|
157 |
|
|
158 |
# check if given login name was previously used and show a dialog if so |
|
159 |
if ($is_new && $check_previously_used && $self->check_loginname_previously_used()) { |
|
160 |
$self->js->run('show_loginname_previously_used_dialog'); |
|
161 |
return $self->js->render(); |
|
162 |
} |
|
163 |
|
|
164 |
# rename previous usernames in employee table, if not set to assign |
|
165 |
if ($is_new && !$assign_documents) { |
|
166 |
my $clients = SL::DB::Manager::AuthClient->get_all_sorted; |
|
167 |
for my $client (@$clients) { |
|
168 |
my $now = DateTime->now_local; |
|
169 |
my $timestamp = $now->format_cldr('yyyyMMddHHmmss'); |
|
170 |
|
|
171 |
my $dbh = $client->dbconnect(AutoCommit => 1); |
|
172 |
$dbh->do(qq|UPDATE employee SET login = ? WHERE login = ?;|,undef, |
|
173 |
$params->{'login'} . $timestamp, $params->{'login'}); |
|
174 |
$dbh->disconnect; |
|
175 |
} |
|
155 | 176 |
} |
156 | 177 |
|
157 | 178 |
$self->user->save; |
... | ... | |
762 | 783 |
return (%result, error => $::locale->text('The database user \'#1\' does not have superuser privileges.', $result{username})); |
763 | 784 |
} |
764 | 785 |
|
786 |
sub check_loginname_previously_used() { |
|
787 |
my ($self) = @_; |
|
788 |
|
|
789 |
my $clients = SL::DB::Manager::AuthClient->get_all_sorted; |
|
790 |
for my $client (@$clients) { |
|
791 |
my $dbh = $client->dbconnect(); |
|
792 |
my ($result) = $dbh->selectrow_array(qq|SELECT login FROM employee WHERE login = ?;|,undef, |
|
793 |
$self->user->{'login'}); |
|
794 |
$dbh->disconnect; |
|
795 |
|
|
796 |
if ($result) { |
|
797 |
return 1; |
|
798 |
} |
|
799 |
} |
|
800 |
return 0; |
|
801 |
} |
|
802 |
|
|
765 | 803 |
1; |
Auch abrufbar als: Unified diff
Beim Erstellen neuer Benutzer Dialog anzeigen, wenn der Loginname schon einmal
verwendet wurde.
Auswahlmöglichkeit im Dialog ob Belege von gelöschten Benutzern mit demselben
Loginnamen, dem neuen Benutzer zugewiesen werden sollen
Falls nein wird derselbe Benutzername in der employee table eindeutig
umbenannt. Falls ja bleibt das Verhalten gleich wie bis anhin.
Fix zu #501.