Commit 22b0995c authored by Ruslan Zakirov's avatar Ruslan Zakirov
Browse files

use custom function instead of RT::Record->Update

Update method does s/\r\n/\n/g on values. This change
of values is not visible, but if combined with ExternalAuth
can result in regular change of a field back and forth.
parent c61f9a84
......@@ -664,7 +664,7 @@ sub create_rt_user {
if ($RT::LDAPUpdateUsers || $RT::LDAPUpdateOnly) {
$self->_debug("$message, updating their data");
if ($args{import}) {
my @results = $user_obj->Update( ARGSRef => $user, AttributesRef => [keys %$user] );
my @results = $self->update_rt_user( user => $user_obj, info => $user );
$self->_debug(join("\n",@results)||'no change');
} else {
$self->_debug("Found existing user $user->{Name} to update");
......@@ -701,6 +701,25 @@ sub create_rt_user {
}
sub update_rt_user {
my $self = shift;
my %args = @_;
my @results;
my $user = $args{'user'};
while ( my ($field, $new) = each %{ $args{'info'} } ) {
next unless defined $new;
my $old = $user->$field();
next if defined $old && $old eq $new;
my $method = "Set$field";
my ($status, $msg) = $user->$method( $new );
push @results, $user->loc('User [_1]: [_2]', $user->Name, $msg);
}
return @results;
}
sub _load_rt_user {
my $self = shift;
my %args = @_;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment