[Bps-public-commit] r12995 - RT-Extension-MergeUsers/lib/RT

ruz at bestpractical.com ruz at bestpractical.com
Fri Jun 6 16:40:02 EDT 2008


Author: ruz
Date: Fri Jun  6 16:40:02 2008
New Revision: 12995

Modified:
   RT-Extension-MergeUsers/lib/RT/User_Vendor.pm

Log:
* override SetEmailAddress to pass new tests

Modified: RT-Extension-MergeUsers/lib/RT/User_Vendor.pm
==============================================================================
--- RT-Extension-MergeUsers/lib/RT/User_Vendor.pm	(original)
+++ RT-Extension-MergeUsers/lib/RT/User_Vendor.pm	Fri Jun  6 16:40:02 2008
@@ -178,4 +178,23 @@
     return ($merge->id, "Unmerged from @{[$merge->EmailAddress]}");
 }
 
+sub SetEmailAddress {
+    my $self = shift;
+    my $value = shift;
+
+    return ( 0, $self->loc('Email address in use') )
+        unless $self->ValidateEmailAddress( $value );
+
+    # if value is valid then either there is no user or
+    # user is merged into this one
+    my $tmp = RT::User->new($RT::SystemUser);
+    $tmp->LoadOriginal( EmailAddress => $value );
+    if ( $tmp->id && $tmp->id != $self->id ) {
+        # there is a different user record
+        $tmp->_Set( Field => 'EmailAddress', Value => undef );
+    }
+
+    return $self->_Set( Field => 'EmailAddress', Value => $value );
+}
+
 1;



More information about the Bps-public-commit mailing list