]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 180259: "Requests" (logged out) and "My Requests" (logged in) links appear in...
authorlpsolit%gmail.com <>
Tue, 18 Mar 2008 02:38:27 +0000 (02:38 +0000)
committerlpsolit%gmail.com <>
Tue, 18 Mar 2008 02:38:27 +0000 (02:38 +0000)
Bugzilla.pm
Bugzilla/Flag.pm
template/en/default/global/common-links.html.tmpl

index e35c75934c2676fd424a74ea55b1c0745d2328a6..a20aa0f6b1a911d7214391ba8147ef3c7c5432e8 100644 (file)
@@ -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;
index 00e40e33f9eec63d59ab87c24c4f69cacd0eee69..f8c43b5085e279e13ae22912d12411e47182f3ce 100644 (file)
@@ -191,6 +191,26 @@ sub attachment {
 
 =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)>
 
 Queries the database for flags matching the given criteria
index 94fed709fd0511ed981ebddaa56dfc9bb0f35b57..db913d9a19abcd79129f44b70e803816b4355197 100644 (file)
   <li><span class="separator">| </span><a href="report.cgi">Reports</a></li>
 
   <li>
-    <span class="separator">| </span>
-    [% IF user.id %]
-      <a href="request.cgi?requester=[% user.login FILTER url_quote %]&amp;requestee=
-               [% user.login FILTER url_quote %]&amp;do_union=1&amp;group=type&amp;action=queue">My Requests</a>
-    [% ELSE %]
-      <a href="request.cgi">Requests</a>
+    [% IF Bugzilla.has_flags %]
+      <span class="separator">| </span>
+      [% IF user.id %]
+        <a href="request.cgi?requester=[% user.login FILTER url_quote %]&amp;requestee=
+                 [% user.login FILTER url_quote %]&amp;do_union=1&amp;group=type&amp;action=queue">My Requests</a>
+      [% ELSE %]
+        <a href="request.cgi">Requests</a>
+      [% END %]
     [% END %]
   [%-# Work around FF bug: keep this on one line %]</li>