diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Element.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Element.pm
index 3ae5e4482be..7424ef2fc80 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Element.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Element.pm
@@ -420,7 +420,9 @@ sub obliterate {
my $self = shift;
my $dbh = Bugzilla->dbh;
- $p->obliterate foreach my $p (@{$self->get_properties});
+ foreach my $p (@{$self->get_properties}){
+ $p->obliterate;
+ }
$dbh->do("DELETE FROM test_environment_map
WHERE element_id = ?", undef, $self->id);
diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Search.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Search.pm
index fa7d9fe2772..4ebc7053e50 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/Search.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Search.pm
@@ -489,9 +489,14 @@ sub init {
$f = 'case_status.name';
},
"^priority," => sub {
+ if ($obj eq 'case_run'){
+ push(@supptables,
+ "INNER JOIN test_cases
+ ON test_cases.case_id = test_case_runs.case_id");
+ }
push(@supptables,
"INNER JOIN priority ".
- "ON test_". $obj ."s.priority_id = priority.id");
+ "ON test_cases.priority_id = priority.id");
$f = 'priority.value';
},
"^environment," => sub {
diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm
index aa42e141404..c205b5a418b 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm
@@ -1297,6 +1297,8 @@ sub get_user_rights {
my $plan_ids = $dbh->selectcol_arrayref(
"SELECT plan_id FROM test_case_plans WHERE case_id = ?",
undef, $self->id);
+
+ return 0 unless $plan_ids;
$plan_ids = join(',',@$plan_ids);
my ($perms) = $dbh->selectrow_array(
@@ -1305,7 +1307,7 @@ sub get_user_rights {
INNER JOIN test_cases ON test_case_plans.case_id = test_cases.case_id
WHERE userid = ? AND test_plan_permissions.plan_id IN ($plan_ids)",
undef, $userid);
- print STDERR $perms;
+
return $perms;
}
###############################
diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCaseRun.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCaseRun.pm
index 6904e9c82f4..313dbdc1a83 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCaseRun.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCaseRun.pm
@@ -695,11 +695,11 @@ Removes this caserun, its history, and all things that reference it.
sub obliterate {
my $self = shift;
my $dbh = Bugzilla->dbh;
-
- $dbh->do("DELETE FROM test_case_bugs WHERE case_run_id IN (" .
- join(",", @{$self->get_case_run_list}) . ")", undef, $self->id)
- if $self->get_case_run_list;
-
+ my $sth = $dbh->prepare_cached("DELETE FROM test_case_bugs WHERE case_run_id = ?");
+ foreach my $id (@{$self->get_case_run_list}){
+ $sth->execute($id);
+ }
+
$dbh->do("DELETE FROM test_case_runs WHERE case_id = ? AND run_id = ?",
undef, ($self->case_id, $self->run_id));
return 1;
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 c28d50b8cc1..6de0281ca4d 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
@@ -38,11 +38,15 @@
Search |
Reports |
+ [% IF UserInGroup('Testers') %]
New Plan |
+ [% END %]
New Case |
New Run |
+ [% IF UserInGroup('Testers') %]
New Environment |
Environment Variables |
+ [% END %]
[% IF UserInGroup('admin') %]
Admin |
[% END %]
diff --git a/mozilla/webtools/testopia/template/en/default/hook/global/user-error.html.tmpl/errors/tr-user-error.html.tmpl b/mozilla/webtools/testopia/template/en/default/hook/global/user-error.html.tmpl/errors/tr-user-error.html.tmpl
index 61352c7ee3b..44121213091 100644
--- a/mozilla/webtools/testopia/template/en/default/hook/global/user-error.html.tmpl/errors/tr-user-error.html.tmpl
+++ b/mozilla/webtools/testopia/template/en/default/hook/global/user-error.html.tmpl/errors/tr-user-error.html.tmpl
@@ -32,7 +32,8 @@
paramaters .
[% ELSIF error == "testopia-create-denied" %]
[% title = "Cannot Create Object" %]
- You do not have sufficient rights to create new [% object FILTER html %]s.
+ You do not have sufficient rights to create new [% object FILTER html %]s
+ [% IF plan %] for plan [% plan.id %][% END %].
[% ELSIF error == "testopia-missing-parameter" %]
[% title = "Missing Parameter" %]
Missing required parameter [% param FILTER html %]
diff --git a/mozilla/webtools/testopia/template/en/default/testopia/case/filter.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/case/filter.html.tmpl
index a3ec4b74971..436e335f8f7 100644
--- a/mozilla/webtools/testopia/template/en/default/testopia/case/filter.html.tmpl
+++ b/mozilla/webtools/testopia/template/en/default/testopia/case/filter.html.tmpl
@@ -32,7 +32,7 @@
- [% PROCESS select sel = { name => 'category',
+ [% PROCESS select sel = { name => 'category_id',
accesskey => 't',
list => plan.product.categories,
elements => 5,
@@ -46,7 +46,7 @@
mult => 1 } %]
- [% PROCESS select sel = { name => 'component',
+ [% PROCESS select sel = { name => 'component_id',
accesskey => 'm',
list => plan.product.components
elements => 5,
diff --git a/mozilla/webtools/testopia/template/en/default/testopia/case/form.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/case/form.html.tmpl
index 4713e973d09..0e703bd5448 100644
--- a/mozilla/webtools/testopia/template/en/default/testopia/case/form.html.tmpl
+++ b/mozilla/webtools/testopia/template/en/default/testopia/case/form.html.tmpl
@@ -24,7 +24,6 @@
# ...
#%]
-[% IF case.canedit %]
-[% 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 4afad6ac34a..4ee0a244f94 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
@@ -89,7 +89,7 @@ No test cases
[% END %]
found.
-[% IF table.list_count > 0 && Param('allow-test-deletion') %]
+[% IF candelete %]
[% END %]
[% IF dotweak AND table.list_count %]
diff --git a/mozilla/webtools/testopia/tr_list_caseruns.cgi b/mozilla/webtools/testopia/tr_list_caseruns.cgi
index d69f0105190..c250c9077c1 100755
--- a/mozilla/webtools/testopia/tr_list_caseruns.cgi
+++ b/mozilla/webtools/testopia/tr_list_caseruns.cgi
@@ -304,7 +304,8 @@ if ($vars->{'run'}) {
}
else {
$vars->{'dotweak'} = Bugzilla->user->in_group('Testers');
- $vars->{'candelete'} = Param('testopia-allow-group-member-deletes');
+ $vars->{'candelete'} = Bugzilla->user->in_group('admin')
+ || (Bugzilla->user->in_group('Testers') && Param('testopia-allow-group-member-deletes'));
}
if ($serverpush && !$cgi->param('debug')) {
print $cgi->multipart_end;
diff --git a/mozilla/webtools/testopia/tr_list_cases.cgi b/mozilla/webtools/testopia/tr_list_cases.cgi
index 4de7c52276d..f8ceb4c667a 100755
--- a/mozilla/webtools/testopia/tr_list_cases.cgi
+++ b/mozilla/webtools/testopia/tr_list_cases.cgi
@@ -387,10 +387,19 @@ $vars->{'fullwidth'} = 1; #novellonly
$vars->{'case'} = $c;
$vars->{'status_list'} = $status_list;
$vars->{'priority_list'} = $priority_list;
-$vars->{'dotweak'} = Bugzilla->user->in_group('Testers');
$vars->{'table'} = $table;
$vars->{'urlquerypart'} = $cgi->canonicalise_query('cmdtype');
-
+if ($cgi->param('plan_id')){
+ my $plan_id = $cgi->param('plan_id');
+ my $plan = Bugzilla::Testopia::TestRun->new($plan_id);
+ $vars->{'dotweak'} = $plan->canedit;
+ $vars->{'candelete'} = $plan->candelete;
+}
+else{
+ $vars->{'dotweak'} = Bugzilla->user->in_group('Testers');
+ $vars->{'candelete'} = Bugzilla->user->in_group('admin')
+ || (Bugzilla->user->in_group('Testers') && Param('testopia-allow-group-member-deletes'));
+}
my $contenttype;
if ($format->{'extension'} eq "html") {
diff --git a/mozilla/webtools/testopia/tr_new_case.cgi b/mozilla/webtools/testopia/tr_new_case.cgi
index 13b882701d6..555c2d078e0 100755
--- a/mozilla/webtools/testopia/tr_new_case.cgi
+++ b/mozilla/webtools/testopia/tr_new_case.cgi
@@ -68,7 +68,7 @@ foreach my $entry (@plan_id){
}
foreach my $id (keys %seen){
my $plan = Bugzilla::Testopia::TestPlan->new($id);
- ThrowUserError("testopia-create-denied", {'object' => 'Test Case', 'plan' => $plan->id}) unless $plan->canedit;
+ ThrowUserError("testopia-create-denied", {'object' => 'Test Case', 'plan' => $plan}) unless $plan->canedit;
push @plan_ids, $id;
push @plans, $plan;
push @categories, @{$plan->product->categories};
diff --git a/mozilla/webtools/testopia/tr_new_environment.cgi b/mozilla/webtools/testopia/tr_new_environment.cgi
index cd9c7c7eeef..d27d6f4966e 100755
--- a/mozilla/webtools/testopia/tr_new_environment.cgi
+++ b/mozilla/webtools/testopia/tr_new_environment.cgi
@@ -27,6 +27,7 @@ use lib ".";
use Bugzilla;
use Bugzilla::Util;
use Bugzilla::Config;
+use Bugzilla::Error;
use Bugzilla::Constants;
use Bugzilla::Testopia::Util;
use Bugzilla::Testopia::Environment;
@@ -43,6 +44,8 @@ my $template = Bugzilla->template;
print $cgi->header;
+ThrowUserError("testopia-create-denied", {'object' => 'Test Environment'}) unless Bugzilla->user->in_group('Testers');
+
my $action = $cgi->param('action') || '';
if ($action eq 'Add'){
diff --git a/mozilla/webtools/testopia/tr_new_run.cgi b/mozilla/webtools/testopia/tr_new_run.cgi
index 6c6648580bc..d3d55c097c6 100755
--- a/mozilla/webtools/testopia/tr_new_run.cgi
+++ b/mozilla/webtools/testopia/tr_new_run.cgi
@@ -62,7 +62,7 @@ my $plan = Bugzilla::Testopia::TestPlan->new($plan_id);
unless ($plan->canedit){
print $cgi->header;
- ThrowUserError("testopia-create-denied", {'object' => 'Test Run'});
+ ThrowUserError("testopia-create-denied", {'object' => 'Test Run', 'plan' => $plan});
}
unless (scalar @{$plan->product->builds(1)} > 0){