Commit 1d5410c7 authored by mkanat%bugzilla.org's avatar mkanat%bugzilla.org

Bug 350921: [email_in] Create an email interface that can create a bug in Bugzilla

Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=colin, r=ghendricks, a=myk
parent fcd10254
......@@ -175,6 +175,11 @@ sub user {
return request_cache()->{user};
}
sub set_user {
my ($class, $user) = @_;
$class->request_cache->{user} = $user;
}
sub sudoer {
my $class = shift;
return request_cache()->{sudoer};
......@@ -196,6 +201,8 @@ sub sudo_request {
sub login {
my ($class, $type) = @_;
return Bugzilla->user if Bugzilla->usage_mode == USAGE_MODE_EMAIL;
my $authorizer = new Bugzilla::Auth();
$type = LOGIN_REQUIRED if Bugzilla->cgi->param('GoAheadAndLogIn');
if (!defined $type || $type == LOGIN_NORMAL) {
......@@ -222,7 +229,7 @@ sub login {
!($sudo_target->in_group('bz_sudo_protect'))
)
{
request_cache()->{user} = $sudo_target;
Bugzilla->set_user($sudo_target);
request_cache()->{sudoer} = $authenticated_user;
# And make sure that both users have the same Auth object,
# since we never call Auth::login for the sudo target.
......@@ -231,10 +238,10 @@ sub login {
# NOTE: If you want to do any special logging, do it here.
}
else {
request_cache()->{user} = $authenticated_user;
Bugzilla->set_user($authenticated_user);
}
return request_cache()->{user};
return Bugzilla->user;
}
sub logout {
......@@ -303,6 +310,9 @@ sub usage_mode {
elsif ($newval == USAGE_MODE_WEBSERVICE) {
$class->error_mode(ERROR_MODE_DIE_SOAP_FAULT);
}
elsif ($newval == USAGE_MODE_EMAIL) {
$class->error_mode(ERROR_MODE_DIE);
}
else {
ThrowCodeError('usage_mode_invalid',
{'invalid_usage_mode', $newval});
......@@ -476,6 +486,12 @@ yet been run. If an sudo session is in progress, the C<Bugzilla::User>
corresponding to the person who is being impersonated. If no session is in
progress, the current C<Bugzilla::User>.
=item C<set_user>
Allows you to directly set what L</user> will return. You can use this
if you want to bypass L</login> for some reason and directly "log in"
a specific L<Bugzilla::User>. Be careful with it, though!
=item C<sudoer>
C<undef> if there is no currently logged in user, the currently logged in user
......
......@@ -113,6 +113,7 @@ use File::Basename;
USAGE_MODE_BROWSER
USAGE_MODE_CMDLINE
USAGE_MODE_WEBSERVICE
USAGE_MODE_EMAIL
ERROR_MODE_WEBPAGE
ERROR_MODE_DIE
......@@ -317,6 +318,7 @@ use constant BUG_STATE_OPEN => ('NEW', 'REOPENED', 'ASSIGNED',
use constant USAGE_MODE_BROWSER => 0;
use constant USAGE_MODE_CMDLINE => 1;
use constant USAGE_MODE_WEBSERVICE => 2;
use constant USAGE_MODE_EMAIL => 3;
# Error modes. Default set by Bugzilla->usage_mode (so ERROR_MODE_WEBPAGE
# usually). Use with Bugzilla->error_mode.
......
......@@ -108,6 +108,7 @@ sub FILESYSTEM {
'testserver.pl' => { perms => $ws_executable },
'whine.pl' => { perms => $ws_executable },
'customfield.pl' => { perms => $owner_executable },
'email_in.pl' => { perms => $owner_executable },
'docs/makedocs.pl' => { perms => $owner_executable },
'docs/rel_notes.txt' => { perms => $ws_readable },
......
......@@ -184,6 +184,39 @@ sub OPTIONAL_MODULES {
version => 0,
feature => 'More HTML in Product/Group Descriptions'
},
# Inbound Email
{
# Attachment::Stripper requires this, but doesn't pull it in
# when you install it from CPAN.
package => 'MIME-Types',
module => 'MIME::Types',
version => 0,
feature => 'Inbound Email',
},
{
# Email::MIME::Attachment::Stripper can throw an error with
# earlier versions.
# This also pulls in Email::MIME and Email::Address for us.
package => 'Email-MIME-Modifier',
module => 'Email::MIME::Modifier',
version => '1.43',
feature => 'Inbound Email'
},
{
package => 'Email-MIME-Attachment-Stripper',
module => 'Email::MIME::Attachment::Stripper',
version => 0,
feature => 'Inbound Email'
},
{
package => 'Email-Reply',
module => 'Email::Reply',
version => 0,
feature => 'Inbound Email'
},
# mod_perl
{
package => 'mod_perl',
module => 'mod_perl2',
......
This diff is collapsed. Click to expand it.
......@@ -29,6 +29,7 @@ use lib qw(.);
use Bugzilla;
use Bugzilla::Attachment;
use Bugzilla::BugMail;
use Bugzilla::Constants;
use Bugzilla::Util;
use Bugzilla::Error;
......@@ -243,8 +244,13 @@ if ($token) {
("createbug:$id", $token));
}
print $cgi->header();
$template->process("bug/create/created.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
if (Bugzilla->usage_mode == USAGE_MODE_EMAIL) {
Bugzilla::BugMail::Send($id, $vars->{'mailrecipients'});
}
else {
print $cgi->header();
$template->process("bug/create/created.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
}
1;
......@@ -380,6 +380,10 @@
[% title = "Email Address Confirmation Failed" %]
Email address confirmation failed.
[% ELSIF error == "email_no_text_plain" %]
Your message did not contain any text.[% terms.Bugzilla %] does not
accept HTML-only email, or HTML email with attachments.
[% ELSIF error == "empty_group_description" %]
[% title = "The group description can not be empty" %]
You must enter a description for the group.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment