]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 308228: Whine-related saved search can be forgotten through buglist.cgi - Patch...
authorlpsolit%gmail.com <>
Mon, 26 Sep 2005 04:10:55 +0000 (04:10 +0000)
committerlpsolit%gmail.com <>
Mon, 26 Sep 2005 04:10:55 +0000 (04:10 +0000)
buglist.cgi
template/en/default/global/user-error.html.tmpl

index 2e59006697a127b1543968bca3950a1686fec101..d579d8086d4a7c4dd1855cc2ca764d68b8717179 100755 (executable)
@@ -382,6 +382,27 @@ if ($cgi->param('cmdtype') eq "dorem") {
         # the SQL, and the SQL is only a DELETE.
         my $qname = $cgi->param('namedcmd');
         trick_taint($qname);
+
+        # Do not forget the saved search if it is being used in a whine
+        my $whines_in_use = 
+            $dbh->selectcol_arrayref('SELECT DISTINCT whine_events.subject
+                                                 FROM whine_events
+                                           INNER JOIN whine_queries
+                                                   ON whine_queries.eventid
+                                                      = whine_events.id
+                                                WHERE whine_events.owner_userid
+                                                      = ?
+                                                  AND whine_queries.query_name
+                                                      = ?
+                                      ', undef, Bugzilla->user->id, $qname);
+        if (scalar(@$whines_in_use)) {
+            ThrowUserError('saved_search_used_by_whines', 
+                           { subjects    => join(',', @$whines_in_use),
+                             search_name => $qname                      }
+            );
+        }
+
+        # If we are here, then we can safely remove the saved search
         $dbh->do("DELETE FROM namedqueries"
             . " WHERE userid = ? AND name = ?"
             , undef, ($userid, $qname));
index 8fb3139d299f1edfa8921eae40fb6256f9230961..15c4df00af75c510778c6add5f9e0615f19af836 100644 (file)
     [% title = "Summary Needed" %]
     You must enter a summary for this [% terms.bug %].
 
+  [% ELSIF error == "saved_search_used_by_whines" %]
+    [% title = "Saved Search In Use" %]
+    The saved search <em>[% search_name FILTER html %]</em> is being used 
+    by <a href="editwhines.cgi">Whining events</a> with the following subjects:
+    [%+ subjects FILTER html %]
+
   [% ELSIF error == "search_content_without_matches" %]
     [% title = "Illegal Search" %]
     The "content" field can only be used with "matches" search 
   
 [% USE Bugzilla %]
 [% namedcmd = Bugzilla.cgi.param("namedcmd") %]
-[% IF namedcmd AND error != "missing_query" %]
+[% IF namedcmd AND error != "missing_query" 
+               AND error != "saved_search_used_by_whines" %]
   <p>  
     Alternatively, you can    
     <a href="buglist.cgi?cmdtype=dorem&amp;remaction=forget&amp;namedcmd=