diff options
author | seth%cs.brandeis.edu <> | 2000-02-13 11:16:11 +0100 |
---|---|---|
committer | seth%cs.brandeis.edu <> | 2000-02-13 11:16:11 +0100 |
commit | f0134777c913c67460f769ef606ea97c2a05aba8 (patch) | |
tree | ae84dac384dce578e556cf0cd1dbfadce55047dc | |
parent | 9250f5772012a8f40de17278056add62fcbb733b (diff) | |
download | bugzilla-f0134777c913c67460f769ef606ea97c2a05aba8.tar.gz bugzilla-f0134777c913c67460f769ef606ea97c2a05aba8.tar.xz |
o this is a minor step towards getting canonical email addresses to work, and not via a gross hack (the script with a gross hack is in use in a production environment, so ...)
Anyways, this address the findUser() sub and email transforms of none, base domain, and name only. base_domain is not properly implemented yet. an email transform of none does an exact match on email addresses in the profiles table. A name only transform does a regular expression match (via mysql's RLIKE operator) on the name portion of the address (i.e., seth from seth@job.cs.brandeis.edu). This is sloppy, but useful in an environment where there are only a few users.
the base_domain is next, probably tomorrow. I need to figure out how to implement it first.
-rwxr-xr-x | contrib/bug_email.pl | 50 |
1 files changed, 41 insertions, 9 deletions
diff --git a/contrib/bug_email.pl b/contrib/bug_email.pl index 37e5055dd..10dd233ad 100755 --- a/contrib/bug_email.pl +++ b/contrib/bug_email.pl @@ -37,7 +37,7 @@ # # You need to work with bug_email.pl the MIME::Parser installed. # -# $Id: bug_email.pl,v 1.1 2000/02/12 16:13:01 seth%cs.brandeis.edu Exp $ +# $Id: bug_email.pl,v 1.2 2000/02/13 02:16:11 seth%cs.brandeis.edu Exp $ ############################################################### # 02/12/2000 (SML) @@ -80,6 +80,37 @@ my $restricted = 0; my $SenderShort; my $Message_ID; +my $EMAIL_TRANSFORM_NONE = "email_transform_none"; +my $EMAIL_TRANSFORM_BASE_DOMAIN = "email_transform_base_domain"; +my $EMAIL_TRANSFORM_NAME_ONLY = "email_transform_name_only"; + +my $email_transform = $EMAIL_TRANSFORM_NONE; + +############################################################### +# findUser +# +# this sub will find a user from the profiles table which is reasonably +# the same as the passed in email address, depending on the $email_transform +# parameter +sub findUser($) { + my ($address) = @_; + # if $email_transform is $EMAIL_TRANSFORM_NONE, return the address, otherwise, return undef + if ($email_transform eq $EMAIL_TRANSFORM_NONE) { + my $stmt = "SELECT login_name FROM profiles WHERE profiles.login_name = \'$address\';"; + SendSQL($stmt); + my $found_address = FetchOneColumn(); + return $found_address; + } elsif ($email_transform eq $EMAIL_TRANSFORM_BASE_DOMAIN) { + + } elsif ($email_transform eq $EMAIL_TRANSFORM_NAME_ONLY) { + my ($username) = ($address =~ /(.+)@/); + my $stmt = "SELECT login_name FROM profiles WHERE profiles.login_name RLIKE \'$username\';"; + SendSQL($stmt); + my $found_address = FetchOneColumn(); + return $found_address; + } +} + ############################################################### # storeAttachments # @@ -163,14 +194,15 @@ sub CheckPermissions { # } else { # return; # } - my $query = "SELECT login_name FROM profiles WHERE profiles.login_name=\'$Name\'"; - SendSQL($query); - my $check_name = FetchOneColumn(); - if ($check_name eq $Name) { - return $Name; - } else { - return; - } +# my $query = "SELECT login_name FROM profiles WHERE profiles.login_name=\'$Name\'"; +# SendSQL($query); +# my $check_name = FetchOneColumn(); +# if ($check_name eq $Name) { +# return $Name; +# } else { +# return; +# } + return findUser($Name); } ############################################################### |