Bug 66740 - correct_urlbase in request/email, move our hacks into hooks

git-svn-id: svn://svn.office.custis.ru/3rdparty/bugzilla.org/trunk@886 6955db30-a419-402b-8a0d-67ecbb4d7f56
master
vfilippov 2010-07-19 10:53:49 +00:00
parent 8bcb97b0e8
commit 35d554a425
10 changed files with 64 additions and 31 deletions

View File

@ -38,7 +38,6 @@ use Bugzilla::User::Setting ();
use Bugzilla::Auth::Login::Stack;
use Bugzilla::Auth::Verify::Stack;
use Bugzilla::Auth::Persist::Cookie;
use Bugzilla::CustisLocalBugzillas;
sub new {
my ($class, $params) = @_;
@ -95,27 +94,7 @@ sub login {
}
$user->set_authorizer($self);
if ($user->settings->{redirect_me_to_my_bugzilla} &&
lc($user->settings->{redirect_me_to_my_bugzilla}->{value}) eq "on")
{
my $loc = \%Bugzilla::CustisLocalBugzillas::local_urlbase;
my $fullurl = Bugzilla->cgi->url();
foreach my $regemail (keys %$loc)
{
if ($user->login =~ /$regemail/s &&
$fullurl !~ /\Q$loc->{$regemail}->{urlbase}\E/s)
{
my $relativeurl = Bugzilla->cgi->url(
-path_info => 1,
-query => 1,
-relative => 1
);
my $url = $loc->{$regemail}->{urlbase} . $relativeurl;
print Bugzilla->cgi->redirect(-location => $url);
exit;
}
}
}
Bugzilla::Hook::process('auth-post-login', { user => $user });
return $self->_handle_login_result($login_info, $type);
}

View File

@ -43,7 +43,6 @@ use Bugzilla::Product;
use Bugzilla::Component;
use Bugzilla::Status;
use Bugzilla::Mailer;
use Bugzilla::CustisLocalBugzillas;
use Date::Parse;
use Date::Format;
@ -599,9 +598,6 @@ sub sendMail
three_columns => \&three_columns,
};
# Hack into urlbase and set it to be correct for current user
Bugzilla::CustisLocalBugzillas::HackIntoUrlbase($user->email);
my $msg;
my $tmpl = '';
@ -613,8 +609,7 @@ sub sendMail
MessageToMTA($msg);
# Unhack urlbase :-)
Bugzilla::CustisLocalBugzillas::HackIntoUrlbase(undef);
Bugzilla::Hook::process('bugmail-post_send', { tmpl => \$tmpl, vars => $vars });
return 1;
}

View File

@ -1024,6 +1024,8 @@ sub notify {
my $lang = $recipients{$to} ?
$recipients{$to}->settings->{'lang'}->{'value'} : $default_lang;
Bugzilla::Hook::process('flag-notify-pre-template', { vars => $vars });
my $template = Bugzilla->template_inner($lang);
my $message;
$template->process("request/email.txt.tmpl", $vars, \$message)
@ -1031,6 +1033,8 @@ sub notify {
Bugzilla->template_inner("");
MessageToMTA($message);
Bugzilla::Hook::process('flag-notify-post-send', { vars => $vars });
}
}

View File

@ -286,10 +286,10 @@ sub do_ssl_redirect_if_required {
}
sub correct_urlbase {
if ($Bugzilla::CustisLocalBugzillas::HackIntoCorrectUrlbase)
if ($CustisLocalBugzillas::HackIntoCorrectUrlbase)
{
# Отправка почты заказчикам со ссылками на свои багзиллы
return $Bugzilla::CustisLocalBugzillas::HackIntoCorrectUrlbase;
return $CustisLocalBugzillas::HackIntoCorrectUrlbase;
}
my $ssl = Bugzilla->params->{'ssl_redirect'};
my $urlbase = Bugzilla->params->{'urlbase'};

View File

@ -0,0 +1,28 @@
#!/usr/bin/perl
use strict;
use Bugzilla::Util qw(trim);
use CustisLocalBugzillas;
my $user = Bugzilla->hook_args->{user};
if ($user->settings->{redirect_me_to_my_bugzilla} &&
lc($user->settings->{redirect_me_to_my_bugzilla}->{value}) eq "on")
{
my $loc = \%CustisLocalBugzillas::local_urlbase;
my $fullurl = Bugzilla->cgi->url();
foreach my $regemail (keys %$loc)
{
if ($user->login =~ /$regemail/s &&
$fullurl !~ /\Q$loc->{$regemail}->{urlbase}\E/s)
{
my $relativeurl = Bugzilla->cgi->url(
-path_info => 1,
-query => 1,
-relative => 1
);
my $url = $loc->{$regemail}->{urlbase} . $relativeurl;
print Bugzilla->cgi->redirect(-location => $url);
exit;
}
}
}

View File

@ -0,0 +1,7 @@
#!/usr/bin/perl
use strict;
use CustisLocalBugzillas;
# Unhack urlbase :-)
CustisLocalBugzillas::HackIntoUrlbase(undef);

View File

@ -2,6 +2,7 @@
use strict;
use Bugzilla::Constants;
use CustisLocalBugzillas;
use Bugzilla::Util;
use POSIX qw(strftime);
@ -25,3 +26,6 @@ if (-w "$datadir/maillog" && open $fd, ">>$datadir/maillog")
print $fd $s, "\n";
close $fd;
}
# Hack into urlbase and set it to be correct for email recipient
CustisLocalBugzillas::HackIntoUrlbase($vars->{to});

View File

@ -0,0 +1,7 @@
#!/usr/bin/perl
use strict;
use CustisLocalBugzillas;
# Unhack urlbase :-)
CustisLocalBugzillas::HackIntoUrlbase(undef);

View File

@ -0,0 +1,9 @@
#!/usr/bin/perl
use strict;
use CustisLocalBugzillas;
my $vars = Bugzilla->hook_args->{vars};
# Hack into urlbase and set it to be correct for email recipient
CustisLocalBugzillas::HackIntoUrlbase($vars->{to});

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl
# Для перенаправления в свою багзиллу
package Bugzilla::CustisLocalBugzillas;
package CustisLocalBugzillas;
use strict;