]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
o this is a minor step towards getting canonical email addresses to work, and not...
authorseth%cs.brandeis.edu <>
Sun, 13 Feb 2000 10:16:11 +0000 (10:16 +0000)
committerseth%cs.brandeis.edu <>
Sun, 13 Feb 2000 10:16:11 +0000 (10:16 +0000)
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

index 37e5055dd86927b891eda8f9c7e81fbf6974d78f..10dd233addf639378bbb939c3065e2bdcdb598a2 100755 (executable)
@@ -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);
 }
 
 ###############################################################