From 84c503892397b64020047cffe4fc32bae6bd8a85 Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" <> Date: Tue, 18 Mar 2008 02:38:27 +0000 Subject: =?UTF-8?q?Bug=20180259:=20"Requests"=20(logged=20out)=20and=20"My?= =?UTF-8?q?=20Requests"=20(logged=20in)=20links=20appear=20in=20footer=20e?= =?UTF-8?q?ven=20if=20the=20site=20doesn't=20use=20requests=20-=20Patch=20?= =?UTF-8?q?by=20Fr=C3=83=C2=A9d=C3=83=C2=A9ric=20Buclin=20=20r=3Dwurblzap=20a=3DLpSolit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bugzilla.pm | 10 ++++++++++ Bugzilla/Flag.pm | 20 ++++++++++++++++++++ template/en/default/global/common-links.html.tmpl | 14 ++++++++------ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Bugzilla.pm b/Bugzilla.pm index e35c75934..a20aa0f6b 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 00e40e33f..f8c43b508 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 94fed709f..db913d9a1 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 %]
  • -- cgit v1.2.1