[rt-commit] [svn] r512 - in rt/branches/rt-3.1: etc html/Admin/Users lib/RT

jesse at fsck.com jesse at fsck.com
Mon Mar 8 23:52:11 EST 2004


Author: jesse
Date: Mon Mar  8 23:52:10 2004
New Revision: 512

Modified:
   rt/branches/rt-3.1/etc/RT_Config.pm.in
   rt/branches/rt-3.1/html/Admin/Users/Modify.html
   rt/branches/rt-3.1/lib/RT/User_Overlay.pm
Log:
A new hook for canonicalization of user information on initial create



Modified: rt/branches/rt-3.1/etc/RT_Config.pm.in
==============================================================================
--- rt/branches/rt-3.1/etc/RT_Config.pm.in	(original)
+++ rt/branches/rt-3.1/etc/RT_Config.pm.in	Mon Mar  8 23:52:10 2004
@@ -138,6 +138,10 @@
 Set($CanonicalizeEmailAddressMatch   , 'subdomain.example.com$');
 Set($CanonicalizeEmailAddressReplace , 'example.com');
 
+# set this to true and the create new user page will use the values that you
+# enter in the form but use the function CanonicalizeUserInfo in User_Local.pm
+Set($CanonicalizeOnCreate , 0);
+
 # If $SenderMustExistInExternalDatabase is true, RT will refuse to
 # create non-privileged accounts for unknown users if you are using
 # the "LookupSenderInExternalDatabase" option.

Modified: rt/branches/rt-3.1/html/Admin/Users/Modify.html
==============================================================================
--- rt/branches/rt-3.1/html/Admin/Users/Modify.html	(original)
+++ rt/branches/rt-3.1/html/Admin/Users/Modify.html	Mon Mar  8 23:52:10 2004
@@ -216,8 +216,37 @@
 
     $current_tab = 'Admin/Users/Modify.html?id='.$id;
     if ($id eq 'new') {
-	($val, $msg) = $UserObj->Create( Name => $Name,
-					 EmailAddress => $ARGS{'EmailAddress'}
+    ( $val, $msg ) = $UserObj->Create(
+        Name                  => $Name,
+        EmailAddress          => $ARGS{'EmailAddress'},
+        Name                  => $ARGS{'Name'},
+        Comments              => $ARGS{'Comments'},
+        Signature             => $ARGS{'Signature'},
+        EmailAddress          => $ARGS{'EmailAddress'},
+        FreeformContactInfo   => $ARGS{'FreeformContactInfo'},
+        Organization          => $ARGS{'Organization'},
+        RealName              => $ARGS{'RealName'},
+        NickName              => $ARGS{'NickName'},
+        Lang                  => $ARGS{'Lang'},
+        EmailEncoding         => $ARGS{'EmailEncoding'},
+        WebEncoding           => $ARGS{'WebEncoding'},
+        ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
+        ContactInfoSystem     => $ARGS{'ContactInfoSystem'},
+        Gecos                 => $ARGS{'Gecos'},
+        ExternalAuthId        => $ARGS{'ExternalAuthId'},
+        AuthSystem            => $ARGS{'AuthSystem'},
+        HomePhone             => $ARGS{'HomePhone'},
+        WorkPhone             => $ARGS{'WorkPhone'},
+        MobilePhone           => $ARGS{'MobilePhone'},
+        PagerPhone            => $ARGS{'PagerPhone'},
+        Address1              => $ARGS{'Address1'},
+        Address2              => $ARGS{'Address2'},
+        City                  => $ARGS{'City'},
+        State                 => $ARGS{'State'},
+        Zip                   => $ARGS{'Zip'},
+        Country               => $ARGS{'Country'},
+        Privileged           => $ARGS{'Privileged'},
+        Disabled            => ($ARGS{'Enabled'} ? 0 : 1) 
 				       );
 	if ($val) {
 		push @results, $msg;
@@ -227,7 +256,6 @@
 
 	# set the id, so the the menu will have the right info
 	$id = $UserObj->Id;	
-
     } else {
 	$UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
 	$val = $UserObj->Id();
@@ -251,7 +279,7 @@
 
 
 # If we have a user to modify, lets try. 
-if ($UserObj->Id) {
+if ($UserObj->Id && $id ne 'new') {
     
     my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo 
 		    Organization RealName NickName Lang EmailEncoding WebEncoding 

Modified: rt/branches/rt-3.1/lib/RT/User_Overlay.pm
==============================================================================
--- rt/branches/rt-3.1/lib/RT/User_Overlay.pm	(original)
+++ rt/branches/rt-3.1/lib/RT/User_Overlay.pm	Mon Mar  8 23:52:10 2004
@@ -156,7 +156,13 @@
         return ( 0, $self->loc('No permission to create users') );
     }
 
+
+    unless ($self->CanonicalizeUserInfo(\%args)) {
+        return ( 0, $self->loc("Could not set user info") );
+    }
+
     $args{'EmailAddress'} = $self->CanonicalizeEmailAddress($args{'EmailAddress'});
+
     # if the user doesn't have a name defined, set it to the email address
     $args{'Name'} = $args{'EmailAddress'} unless ($args{'Name'});
 
@@ -615,6 +621,32 @@
         $email =~ s/$RT::CanonicalizeEmailAddressMatch/$RT::CanonicalizeEmailAddressReplace/gi;
     }
     return ($email);
+}
+
+
+# }}}
+
+# {{{ sub CanonicalizeUserInfo
+
+
+
+=item CanonicalizeUserInfo HASH of ARGS
+
+# CanonicalizeUserInfo can convert all User->Create options.
+# it takes a hashref of all the params sent to User->Create and
+# returns that same hash, by default nothing is done.
+
+# This function is intended to allow users to have their info looked up via
+# an outside source and modified upon creation.
+
+=cut
+
+sub CanonicalizeUserInfo {
+    my $self = shift;
+    my $args = shift;
+    my $success = 1;
+
+    return ($success);
 }
 
 



More information about the Rt-commit mailing list