summaryrefslogtreecommitdiffstats
path: root/contrib/BugzillaEmail.pm
diff options
context:
space:
mode:
authorseth%cs.brandeis.edu <>2000-03-16 07:29:44 +0100
committerseth%cs.brandeis.edu <>2000-03-16 07:29:44 +0100
commit63c4dd9e1c068c1496b56ab0386bde61120663d8 (patch)
tree7e874df72fdfc97d9749b0b3e567a5dbf08ad477 /contrib/BugzillaEmail.pm
parent36feed94ac903b60c7baa9c8b9daf96dfceb5078 (diff)
downloadbugzilla-63c4dd9e1c068c1496b56ab0386bde61120663d8.tar.gz
bugzilla-63c4dd9e1c068c1496b56ab0386bde61120663d8.tar.xz
A few changes ...
1. BugzillaEmail.pm is a (kinda, sorta) module which is going to hold the various code which is common between all the scripts which access bugzilla via email. 2. bug_email.pl uses this module 3. bugzilla_email_append.pl is a mostly ready script which will append messages to existing bugs.
Diffstat (limited to 'contrib/BugzillaEmail.pm')
-rw-r--r--contrib/BugzillaEmail.pm79
1 files changed, 79 insertions, 0 deletions
diff --git a/contrib/BugzillaEmail.pm b/contrib/BugzillaEmail.pm
new file mode 100644
index 000000000..aaba0f4e0
--- /dev/null
+++ b/contrib/BugzillaEmail.pm
@@ -0,0 +1,79 @@
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+
+# The contents of this file are subject to the Mozilla Public
+# License Version 1.1 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS
+# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# rights and limitations under the License.
+#
+# This code is based on code found in bug_email.pl from the bugzilla
+# email tracker. Initial contributors are ::
+# Terry Weissman <terry@mozilla.org>
+# Gregor Fischer <fischer@suse.de>
+# Klaas Freitag <freitag@suse.de>
+# Seth Landsman <seth@dworkin.net>
+
+# The purpose of this module is to abstract out a bunch of the code
+# that is central to email interfaces to bugzilla and its database
+
+# Contributor : Seth Landsman <seth@dworkin.net>
+
+# Initial checkin : 03/15/00 (SML)
+# findUser() function moved from bug_email.pl to here
+
+push @INC, "../."; # this script now lives in contrib
+
+require "globals.pl";
+
+use diagnostics;
+use strict;
+
+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";
+
+# change to do incoming email address fuzzy matching
+my $email_transform = $EMAIL_TRANSFORM_NAME_ONLY;
+
+# findUser()
+# This function takes an email address and returns the user email.
+# matching is sloppy based 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) {
+ my ($username) = ($address =~ /(.+)@/);
+ my $stmt = "SELECT login_name FROM profiles WHERE profiles.login_name RLIKE \'$username\';";
+ SendSQL($stmt);
+
+ my $domain;
+ my $found = undef;
+ my $found_address;
+ my $new_address = undef;
+ while ((!$found) && ($found_address = FetchOneColumn())) {
+ ($domain) = ($found_address =~ /.+@(.+)/);
+ if ($address =~ /$domain/) {
+ $found = 1;
+ $new_address = $found_address;
+ }
+ }
+ return $new_address;
+ } 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;
+ }
+}
+
+1;