From 91cfe2e35d7ea95515728f8a5d4e50149b41111e Mon Sep 17 00:00:00 2001 From: "ghendricks%novell.com" Date: Tue, 9 Jan 2007 00:41:23 +0000 Subject: [PATCH] Added rudimentary saved search support. NEEDS TESTING! git-svn-id: svn://10.0.0.236/trunk@218038 18797224-902f-48f8-a5cc-f745e15eee43 --- .../useful-links.html.tmpl/end/tr.html.tmpl | 14 ++++- .../en/default/testopia/case/list.html.tmpl | 3 +- .../en/default/testopia/plan/list.html.tmpl | 2 +- .../en/default/testopia/run/list.html.tmpl | 1 + .../default/testopia/saved-search.html.tmpl | 32 ++++++++++++ mozilla/webtools/testopia/testopia/patch-2.22 | 23 +++++++++ .../webtools/testopia/testopia/patch-2.22.1 | 24 +++++++++ .../webtools/testopia/tr_list_caseruns.cgi | 2 + mozilla/webtools/testopia/tr_list_cases.cgi | 3 ++ .../testopia/tr_list_environments.cgi | 2 + mozilla/webtools/testopia/tr_list_plans.cgi | 1 + mozilla/webtools/testopia/tr_list_runs.cgi | 1 + mozilla/webtools/testopia/tr_query.cgi | 51 +++++++++++++++++++ 13 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 mozilla/webtools/testopia/template/en/default/testopia/saved-search.html.tmpl diff --git a/mozilla/webtools/testopia/template/en/default/hook/global/useful-links.html.tmpl/end/tr.html.tmpl b/mozilla/webtools/testopia/template/en/default/hook/global/useful-links.html.tmpl/end/tr.html.tmpl index ad7e21a8b51..019f0f94e11 100644 --- a/mozilla/webtools/testopia/template/en/default/hook/global/useful-links.html.tmpl/end/tr.html.tmpl +++ b/mozilla/webtools/testopia/template/en/default/hook/global/useful-links.html.tmpl/end/tr.html.tmpl @@ -36,6 +36,7 @@ + [% IF user.login %] + + [% END %] diff --git a/mozilla/webtools/testopia/template/en/default/testopia/case/list.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/case/list.html.tmpl index fdd889dd0f1..5f0431aafd3 100644 --- a/mozilla/webtools/testopia/template/en/default/testopia/case/list.html.tmpl +++ b/mozilla/webtools/testopia/template/en/default/testopia/case/list.html.tmpl @@ -207,8 +207,9 @@ found. -[% END %] +[% END %] +[% PROCESS "testopia/saved-search.html.tmpl" %] [%############################################################################%] [%# Page Footer #%] [%############################################################################%] diff --git a/mozilla/webtools/testopia/template/en/default/testopia/plan/list.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/plan/list.html.tmpl index 5d21be9b51d..67ce2c754ab 100644 --- a/mozilla/webtools/testopia/template/en/default/testopia/plan/list.html.tmpl +++ b/mozilla/webtools/testopia/template/en/default/testopia/plan/list.html.tmpl @@ -108,9 +108,9 @@ found.

- [% END %] +[% PROCESS "testopia/saved-search.html.tmpl" %] [%############################################################################%] [%# Page Footer #%] [%############################################################################%] diff --git a/mozilla/webtools/testopia/template/en/default/testopia/run/list.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/run/list.html.tmpl index fa4b8926020..a0ea50a1333 100644 --- a/mozilla/webtools/testopia/template/en/default/testopia/run/list.html.tmpl +++ b/mozilla/webtools/testopia/template/en/default/testopia/run/list.html.tmpl @@ -116,6 +116,7 @@ found. [% END %] +[% PROCESS "testopia/saved-search.html.tmpl" %] [%############################################################################%] [%# Page Footer #%] [%############################################################################%] diff --git a/mozilla/webtools/testopia/template/en/default/testopia/saved-search.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/saved-search.html.tmpl new file mode 100644 index 00000000000..2f8b8d52584 --- /dev/null +++ b/mozilla/webtools/testopia/template/en/default/testopia/saved-search.html.tmpl @@ -0,0 +1,32 @@ +[%# 1.0@bugzilla.org %] +[%# The contents of this file are subject to the Mozilla Public + # License Version 1.1 (the "License"); you may not use this file + # except in compliance with the License. You may obtain a copy of + # the License at http://www.mozilla.org/MPL/ + # + # Software distributed under the License is distributed on an "AS + # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + # implied. See the License for the specific language governing + # rights and limitations under the License. + # + # The Original Code is the Bugzilla Testopia System. + # + # The Initial Developer of the Original Code is Greg Hendricks. + # Portions created by Greg Hendricks are Copyright (C) 2001 + # Greg Hendricks. All Rights Reserved. + # + # Contributor(s): Greg Hendricks + #%] + + \ No newline at end of file diff --git a/mozilla/webtools/testopia/testopia/patch-2.22 b/mozilla/webtools/testopia/testopia/patch-2.22 index 442d36294dd..48f766eb46a 100644 --- a/mozilla/webtools/testopia/testopia/patch-2.22 +++ b/mozilla/webtools/testopia/testopia/patch-2.22 @@ -88,6 +88,29 @@ Index: /bmo-2.22/Bugzilla.pm ]; # Non-cgi scripts that should silently exit. +Index: /bmo-2.22/Bugzilla/User.pm +=================================================================== +RCS file: /cvsroot/mozilla/webtools/bugzilla/Bugzilla/User.pm,v +retrieving revision 1.101.2.3 +diff -u -r1.101.2.3 User.pm +--- /bmo-2.22/Bugzilla/User.pm 14 Mar 2006 07:45:54 -0000 1.101.2.3 ++++ /bmo-2.22-testopia/Bugzilla/User.pm 9 Jan 2007 00:35:14 -0000 +@@ -236,6 +236,16 @@ + return $self->{queries}; + } + ++sub testopia_queries { ++ my $self = shift; ++ my $dbh = Bugzilla->dbh; ++ my $ref = $dbh->selectall_arrayref( ++ "SELECT name, query FROM test_named_queries ++ WHERE userid = ? AND isvisible = 1", ++ {'Slice' =>{}}, $self->id); ++ return $ref; ++} ++ + sub settings { + my ($self) = @_; Index: /bmo-2.22/Bugzilla/DB/Schema.pm =================================================================== --- /bmo-2.22/Bugzilla/DB/Schema.pm 2006-01-06 07:38:42.000000000 -0700 diff --git a/mozilla/webtools/testopia/testopia/patch-2.22.1 b/mozilla/webtools/testopia/testopia/patch-2.22.1 index 2b17aa4e82f..ebe08c587a5 100644 --- a/mozilla/webtools/testopia/testopia/patch-2.22.1 +++ b/mozilla/webtools/testopia/testopia/patch-2.22.1 @@ -88,6 +88,30 @@ Index: /bmo-2.22/Bugzilla.pm ]; # Non-cgi scripts that should silently exit. +Index: /bmo-2.22/Bugzilla/User.pm +=================================================================== +RCS file: /cvsroot/mozilla/webtools/bugzilla/Bugzilla/User.pm,v +retrieving revision 1.101.2.5 +diff -u -r1.101.2.5 User.pm +--- /bmo-2.22/Bugzilla/User.pm 14 Oct 2006 21:07:19 -0000 1.101.2.5 ++++ /bmo-2.22-testopia/Bugzilla/User.pm 9 Jan 2007 00:38:05 -0000 +@@ -236,6 +236,16 @@ + return $self->{queries}; + } + ++sub testopia_queries { ++ my $self = shift; ++ my $dbh = Bugzilla->dbh; ++ my $ref = $dbh->selectall_arrayref( ++ "SELECT name, query FROM test_named_queries ++ WHERE userid = ? AND isvisible = 1", ++ {'Slice' =>{}}, $self->id); ++ return $ref; ++} ++ + sub settings { + my ($self) = @_; + Index: /bmo-2.22/Bugzilla/DB/Schema.pm =================================================================== --- /bmo-2.22/Bugzilla/DB/Schema.pm 2006-01-06 07:38:42.000000000 -0700 diff --git a/mozilla/webtools/testopia/tr_list_caseruns.cgi b/mozilla/webtools/testopia/tr_list_caseruns.cgi index 0fb39d82f7a..5f3c68e2b5e 100755 --- a/mozilla/webtools/testopia/tr_list_caseruns.cgi +++ b/mozilla/webtools/testopia/tr_list_caseruns.cgi @@ -237,6 +237,8 @@ elsif ($action eq 'do_delete'){ exit; } +$vars->{'qname'} = $cgi->param('qname') if $cgi->param('qname'); + # Take the search from the URL params and convert it to SQL $cgi->param('current_tab', 'case_run'); my $search = Bugzilla::Testopia::Search->new($cgi); diff --git a/mozilla/webtools/testopia/tr_list_cases.cgi b/mozilla/webtools/testopia/tr_list_cases.cgi index 18e8b1ca601..a35d8d05e21 100755 --- a/mozilla/webtools/testopia/tr_list_cases.cgi +++ b/mozilla/webtools/testopia/tr_list_cases.cgi @@ -245,6 +245,9 @@ if ($action eq 'Commit'){ ############### ### Display ### ############### + +$vars->{'qname'} = $cgi->param('qname') if $cgi->param('qname'); + # Take the search from the URL params and convert it to SQL $cgi->param('current_tab', 'case'); my $search = Bugzilla::Testopia::Search->new($cgi); diff --git a/mozilla/webtools/testopia/tr_list_environments.cgi b/mozilla/webtools/testopia/tr_list_environments.cgi index 2b21af70119..f71d11c4da4 100755 --- a/mozilla/webtools/testopia/tr_list_environments.cgi +++ b/mozilla/webtools/testopia/tr_list_environments.cgi @@ -46,6 +46,8 @@ print $cgi->header; my $action = $cgi->param('action') || ''; +$vars->{'qname'} = $cgi->param('qname') if $cgi->param('qname'); + $cgi->param('current_tab', 'environment'); my $search = Bugzilla::Testopia::Search->new($cgi); my $table = Bugzilla::Testopia::Table->new('environment', 'tr_list_environments.cgi', $cgi, undef, $search->query); diff --git a/mozilla/webtools/testopia/tr_list_plans.cgi b/mozilla/webtools/testopia/tr_list_plans.cgi index bdf0d140e63..82bed65b235 100755 --- a/mozilla/webtools/testopia/tr_list_plans.cgi +++ b/mozilla/webtools/testopia/tr_list_plans.cgi @@ -132,6 +132,7 @@ if ($action eq 'Commit'){ } else { + $vars->{'qname'} = $cgi->param('qname') if $cgi->param('qname'); $cgi->param('current_tab', 'plan'); my $search = Bugzilla::Testopia::Search->new($cgi); my $table = Bugzilla::Testopia::Table->new('plan', 'tr_list_plans.cgi', $cgi, undef, $search->query); diff --git a/mozilla/webtools/testopia/tr_list_runs.cgi b/mozilla/webtools/testopia/tr_list_runs.cgi index 3c8150af9d9..ed8a75bf0e9 100755 --- a/mozilla/webtools/testopia/tr_list_runs.cgi +++ b/mozilla/webtools/testopia/tr_list_runs.cgi @@ -144,6 +144,7 @@ if ($action eq 'Commit'){ } else { + $vars->{'qname'} = $cgi->param('qname') if $cgi->param('qname'); $cgi->param('current_tab', 'run'); my $search = Bugzilla::Testopia::Search->new($cgi); my $table = Bugzilla::Testopia::Table->new('run', 'tr_list_runs.cgi', $cgi, undef, $search->query); diff --git a/mozilla/webtools/testopia/tr_query.cgi b/mozilla/webtools/testopia/tr_query.cgi index 46c1006ca17..468e090ee5d 100755 --- a/mozilla/webtools/testopia/tr_query.cgi +++ b/mozilla/webtools/testopia/tr_query.cgi @@ -27,6 +27,7 @@ use lib "."; use Bugzilla; use Bugzilla::Util; use Bugzilla::Error; +use Bugzilla::Constants; use Bugzilla::Testopia::Util; use Bugzilla::Testopia::TestPlan; use Bugzilla::Testopia::TestRun; @@ -185,7 +186,57 @@ elsif ($action eq 'get_valid_exp'){ chop($ret); print $ret; } +elsif ($action eq 'save_query'){ + Bugzilla->login(LOGIN_REQUIRED); + my $query = $cgi->param('query_part'); + my $qname = $cgi->param('query_name'); + + ThrowUserError('query_name_missing') unless $qname; + + trick_taint($query); + trick_taint($qname); + + my ($name) = $dbh->selectrow_array( + "SELECT name + FROM test_named_queries + WHERE userid = ? + AND name = ?", + undef,(Bugzilla->user->id, $qname)); + + if ($name){ + $dbh->do( + "UPDATE test_named_queries + SET query = ? + WHERE userid = ? + AND name = ?", + undef,($query, Bugzilla->user->id, $qname)); + $vars->{'tr_message'} = "Updated saved search '$qname'"; + } + else{ + $query .= "&qname=$qname"; + $dbh->do("INSERT INTO test_named_queries + VALUES(?,?,?,?)", + undef, (Bugzilla->user->id, $qname, 1, $query)); + + $vars->{'tr_message'} = "Search saved as '$qname'"; + } + display(); +} +elsif ($action eq 'delete_query'){ + my $qname = $cgi->param('query_name'); + + trick_taint($qname); + + $dbh->do("DELETE FROM test_named_queries WHERE userid = ? AND name = ?", + undef, (Bugzilla->user->id, $qname)); + $vars->{'tr_message'} = "Testopia Saved Search '$qname' Deleted"; + display(); +} else{ + display(); +} + +sub display { my $plan = Bugzilla::Testopia::TestPlan->new({ 'plan_id' => 0 }); my @allversions; foreach my $p (@{$plan->get_available_products}){