From f0134777c913c67460f769ef606ea97c2a05aba8 Mon Sep 17 00:00:00 2001 From: "seth%cs.brandeis.edu" <> Date: Sun, 13 Feb 2000 10:16:11 +0000 Subject: 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. --- contrib/bug_email.pl | 50 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 9 deletions(-) (limited to 'contrib/bug_email.pl') 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); } ############################################################### -- cgit v1.2.3-24-g4f1b