[Bps-public-commit] RT-Extension-LDAPImport branch, master, updated. 0.33-3-g22b0995

Ruslan Zakirov ruz at bestpractical.com
Sat Oct 20 12:40:26 EDT 2012


The branch, master has been updated
       via  22b0995c834a6954c030eaee794277132a36c7b6 (commit)
      from  c61f9a84378fdf2b91feae4899411289614e81fa (commit)

Summary of changes:
 lib/RT/Extension/LDAPImport.pm | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

- Log -----------------------------------------------------------------
commit 22b0995c834a6954c030eaee794277132a36c7b6
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Sat Oct 20 20:35:44 2012 +0400

    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.

diff --git a/lib/RT/Extension/LDAPImport.pm b/lib/RT/Extension/LDAPImport.pm
index d90b807..45920de 100644
--- a/lib/RT/Extension/LDAPImport.pm
+++ b/lib/RT/Extension/LDAPImport.pm
@@ -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", at 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 = @_;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list