From: lpsolit%gmail.com <> Date: Tue, 18 Mar 2008 02:38:27 +0000 (+0000) Subject: Bug 180259: "Requests" (logged out) and "My Requests" (logged in) links appear in... X-Git-Tag: bugzilla-3.1.3~278 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84c503892397b64020047cffe4fc32bae6bd8a85;p=thirdparty%2Fbugzilla.git 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édéric Buclin r=wurblzap a=LpSolit --- diff --git a/Bugzilla.pm b/Bugzilla.pm index e35c75934c..a20aa0f6b1 100644 --- a/Bugzilla.pm +++ b/Bugzilla.pm @@ -47,6 +47,7 @@ use Bugzilla::User; use Bugzilla::Error; use Bugzilla::Util; use Bugzilla::Field; +use Bugzilla::Flag; use File::Basename; use File::Spec::Functions; @@ -439,6 +440,15 @@ sub 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 { my ($class, $args) = @_; $class->request_cache->{hook_args} = $args if $args; diff --git a/Bugzilla/Flag.pm b/Bugzilla/Flag.pm index 00e40e33f9..f8c43b5085 100644 --- a/Bugzilla/Flag.pm +++ b/Bugzilla/Flag.pm @@ -191,6 +191,26 @@ sub attachment { =over +=item C + +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 Queries the database for flags matching the given criteria diff --git a/template/en/default/global/common-links.html.tmpl b/template/en/default/global/common-links.html.tmpl index 94fed709fd..db913d9a19 100644 --- a/template/en/default/global/common-links.html.tmpl +++ b/template/en/default/global/common-links.html.tmpl @@ -39,12 +39,14 @@
  • | Reports
  • - | - [% IF user.id %] - My Requests - [% ELSE %] - Requests + [% IF Bugzilla.has_flags %] + | + [% IF user.id %] + My Requests + [% ELSE %] + Requests + [% END %] [% END %] [%-# Work around FF bug: keep this on one line %]