Commit 84c50389 authored by lpsolit%gmail.com's avatar lpsolit%gmail.com

Bug 180259: "Requests" (logged out) and "My Requests" (logged in) links appear…

Bug 180259: "Requests" (logged out) and "My Requests" (logged in) links appear in footer even if the site doesn't use requests - Patch by Fré©ric Buclin <LpSolit@gmail.com> r=wurblzap a=LpSolit
parent 141674b7
...@@ -47,6 +47,7 @@ use Bugzilla::User; ...@@ -47,6 +47,7 @@ use Bugzilla::User;
use Bugzilla::Error; use Bugzilla::Error;
use Bugzilla::Util; use Bugzilla::Util;
use Bugzilla::Field; use Bugzilla::Field;
use Bugzilla::Flag;
use File::Basename; use File::Basename;
use File::Spec::Functions; use File::Spec::Functions;
...@@ -439,6 +440,15 @@ sub active_custom_fields { ...@@ -439,6 +440,15 @@ sub active_custom_fields {
return @{$class->request_cache->{active_custom_fields}}; return @{$class->request_cache->{active_custom_fields}};
} }
sub has_flags {
my $class = shift;
if (!defined $class->request_cache->{has_flags}) {
$class->request_cache->{has_flags} = Bugzilla::Flag::has_flags();
}
return $class->request_cache->{has_flags};
}
sub hook_args { sub hook_args {
my ($class, $args) = @_; my ($class, $args) = @_;
$class->request_cache->{hook_args} = $args if $args; $class->request_cache->{hook_args} = $args if $args;
......
...@@ -191,6 +191,26 @@ sub attachment { ...@@ -191,6 +191,26 @@ sub attachment {
=over =over
=item C<has_flags>
Returns 1 if at least one flag exists in the DB, else 0. This subroutine
is mainly used to decide to display the "(My )Requests" link in the footer.
=back
=cut
sub has_flags {
my $dbh = Bugzilla->dbh;
my $has_flags = $dbh->selectrow_array('SELECT 1 FROM flags ' . $dbh->sql_limit(1));
return $has_flags || 0;
}
=pod
=over
=item C<match($criteria)> =item C<match($criteria)>
Queries the database for flags matching the given criteria Queries the database for flags matching the given criteria
......
...@@ -39,12 +39,14 @@ ...@@ -39,12 +39,14 @@
<li><span class="separator">| </span><a href="report.cgi">Reports</a></li> <li><span class="separator">| </span><a href="report.cgi">Reports</a></li>
<li> <li>
<span class="separator">| </span> [% IF Bugzilla.has_flags %]
[% IF user.id %] <span class="separator">| </span>
<a href="request.cgi?requester=[% user.login FILTER url_quote %]&amp;requestee= [% IF user.id %]
[% user.login FILTER url_quote %]&amp;do_union=1&amp;group=type&amp;action=queue">My Requests</a> <a href="request.cgi?requester=[% user.login FILTER url_quote %]&amp;requestee=
[% ELSE %] [% user.login FILTER url_quote %]&amp;do_union=1&amp;group=type&amp;action=queue">My Requests</a>
<a href="request.cgi">Requests</a> [% ELSE %]
<a href="request.cgi">Requests</a>
[% END %]
[% END %] [% END %]
[%-# Work around FF bug: keep this on one line %]</li> [%-# Work around FF bug: keep this on one line %]</li>
......
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