diff --git a/mozilla/webtools/testopia/template/en/default/testopia/tag/show.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/tag/show.html.tmpl index 053b855e5cb..71db242be25 100644 --- a/mozilla/webtools/testopia/template/en/default/testopia/tag/show.html.tmpl +++ b/mozilla/webtools/testopia/template/en/default/testopia/tag/show.html.tmpl @@ -24,7 +24,7 @@ [% PROCESS testopia/messages.html.tmpl %] [% PROCESS testopia/blocks.html.tmpl %] -[% IF viewall %] +[% IF viewall OR tags %] [% PROCESS testopia/tag/list.html.tmpl %] [% ELSE %] diff --git a/mozilla/webtools/testopia/testopia/js/util.js b/mozilla/webtools/testopia/testopia/js/util.js index 2f2eef4ca33..876c2bfd7c2 100755 --- a/mozilla/webtools/testopia/testopia/js/util.js +++ b/mozilla/webtools/testopia/testopia/js/util.js @@ -131,7 +131,7 @@ var OK_TIMEOUT=3000; var MSG_WAIT='Please wait...'; var MSG_TIMEOUT='Request timed out. Please try again.'; -var MSG_REQUEST_FAILED='Error, request failed. Please, try again or use the classic interface.'; +var MSG_REQUEST_FAILED='Error, request failed. You either do not have permission to perform this action or an internal error occurred.'; var MSG_COMM_PROBLEM='Error, communication problem. Please try again.'; var MSG_BAD_BROWSER="Your browser doesn't support client HTTP requests (XMLHttp). Please, use the classic interface."; diff --git a/mozilla/webtools/testopia/tr_tags.cgi b/mozilla/webtools/testopia/tr_tags.cgi index c2337f426d1..54d9e74e46a 100755 --- a/mozilla/webtools/testopia/tr_tags.cgi +++ b/mozilla/webtools/testopia/tr_tags.cgi @@ -77,8 +77,16 @@ elsif ($action eq 'addtag'){ } elsif($type eq 'run'){ $obj = Bugzilla::Testopia::TestRun->new($id); } - ThrowUserError('testopia-unkown-object') unless $obj; - ThrowUserError("testopia-read-only", {'object' => $type}) unless $obj->canedit; + unless ($obj) { + $vars->{'tr_error'} = "Error - I don't know what you are trying to do."; + print $vars->{'tr_error'}; + exit; + } + unless ($obj->canedit) { + $vars->{'tr_error'} = "Error - You do not have permission to modify this ". $obj->type; + print $vars->{'tr_error'}; + exit; + } my $tagged = $obj->add_tag($tag_id); if ($tagged) { @@ -146,74 +154,79 @@ sub display { my $dbh = Bugzilla->dbh; my @tags; my $user = login_to_id($cgi->param('user')) if $cgi->param('user'); - - if ($cgi->param('action') eq 'show_all' && Bugzilla->user->in_group('admin')){ - my $tags = $dbh->selectcol_arrayref( - "SELECT tag_id FROM test_tags - ORDER BY tag_name"); - foreach my $t (@{$tags}){ - push @tags, Bugzilla::Testopia::TestTag->new($t); - } - $vars->{'viewall'} = 1; + if ($cgi->param('tag')){ + my $name = $cgi->param('tag'); + trick_taint($name); + push @tags, Bugzilla::Testopia::TestTag->new($name); } - else { - my $userid = $user ? $user : Bugzilla->user->id; - ThrowUserError("invalid_username", { name => $cgi->param('user') }) unless $userid; - my $user_tags = $dbh->selectcol_arrayref( - "(SELECT test_tags.tag_id, test_tags.tag_name AS name FROM test_case_tags - INNER JOIN test_tags ON test_case_tags.tag_id = test_tags.tag_id - WHERE userid = ?) - UNION (SELECT test_tags.tag_id, test_tags.tag_name AS name FROM test_plan_tags - INNER JOIN test_tags ON test_plan_tags.tag_id = test_tags.tag_id - WHERE userid = ?) - UNION (SELECT test_tags.tag_id, test_tags.tag_name AS name FROM test_run_tags - INNER JOIN test_tags ON test_run_tags.tag_id = test_tags.tag_id - WHERE userid = ?) - ORDER BY name", undef, ($userid, $userid, $userid)); - my @user_tags; - foreach my $id (@$user_tags){ - push @user_tags, Bugzilla::Testopia::TestTag->new($id); + else{ + if ($cgi->param('action') eq 'show_all' && Bugzilla->user->in_group('admin')){ + my $tags = $dbh->selectcol_arrayref( + "SELECT tag_id FROM test_tags + ORDER BY tag_name"); + foreach my $t (@{$tags}){ + push @tags, Bugzilla::Testopia::TestTag->new($t); + } + $vars->{'viewall'} = 1; } + else { + my $userid = $user ? $user : Bugzilla->user->id; + ThrowUserError("invalid_username", { name => $cgi->param('user') }) unless $userid; + my $user_tags = $dbh->selectcol_arrayref( + "(SELECT test_tags.tag_id, test_tags.tag_name AS name FROM test_case_tags + INNER JOIN test_tags ON test_case_tags.tag_id = test_tags.tag_id + WHERE userid = ?) + UNION (SELECT test_tags.tag_id, test_tags.tag_name AS name FROM test_plan_tags + INNER JOIN test_tags ON test_plan_tags.tag_id = test_tags.tag_id + WHERE userid = ?) + UNION (SELECT test_tags.tag_id, test_tags.tag_name AS name FROM test_run_tags + INNER JOIN test_tags ON test_run_tags.tag_id = test_tags.tag_id + WHERE userid = ?) + ORDER BY name", undef, ($userid, $userid, $userid)); + my @user_tags; + foreach my $id (@$user_tags){ + push @user_tags, Bugzilla::Testopia::TestTag->new($id); + } + + $vars->{'user_tags'} = \@user_tags; + $vars->{'user_name'} = $cgi->param('user') ? $cgi->param('user') : Bugzilla->user->login; - $vars->{'user_tags'} = \@user_tags; - $vars->{'user_name'} = $cgi->param('user') ? $cgi->param('user') : Bugzilla->user->login; - - if ($cgi->param('case_id')){ - my $case_id = $cgi->param('case_id'); - detaint_natural($case_id); - $vars->{'case'} = Bugzilla::Testopia::TestCase->new($case_id); + if ($cgi->param('case_id')){ + my $case_id = $cgi->param('case_id'); + detaint_natural($case_id); + $vars->{'case'} = Bugzilla::Testopia::TestCase->new($case_id); + } + if ($cgi->param('plan_id')){ + my $plan_id = $cgi->param('plan_id'); + detaint_natural($plan_id); + $vars->{'plan'} = Bugzilla::Testopia::TestPlan->new($plan_id); + } + if ($cgi->param('run_id')){ + my $run_id = $cgi->param('run_id'); + detaint_natural($run_id); + $vars->{'run'} = Bugzilla::Testopia::TestRun->new($run_id); + } + + my @products; + foreach my $id (split(",", $cgi->param('product'))){ + push @products, Bugzilla::Testopia::Product->new($id) if detaint_natural($id);; + } + $vars->{'products'} = \@products; + + my @tagids = split(/[\s,]/, $cgi->param('tag_id')); + + foreach my $id (@tagids){ + detaint_natural($id); + push @tags, Bugzilla::Testopia::TestTag->new($id); + } + my @tagnames = split(/[\s,]/, $cgi->param('tag')); + foreach my $name (@tagnames){ + $name = trim($name); + trick_taint($name); + push @tags, Bugzilla::Testopia::TestTag->new($name); + } } - if ($cgi->param('plan_id')){ - my $plan_id = $cgi->param('plan_id'); - detaint_natural($plan_id); - $vars->{'plan'} = Bugzilla::Testopia::TestPlan->new($plan_id); - } - if ($cgi->param('run_id')){ - my $run_id = $cgi->param('run_id'); - detaint_natural($run_id); - $vars->{'run'} = Bugzilla::Testopia::TestRun->new($run_id); - } - - my @products; - foreach my $id (split(",", $cgi->param('product'))){ - push @products, Bugzilla::Testopia::Product->new($id) if detaint_natural($id);; - } - $vars->{'products'} = \@products; - - my @tagids = split(/[\s,]/, $cgi->param('tag_id')); - - foreach my $id (@tagids){ - detaint_natural($id); - push @tags, Bugzilla::Testopia::TestTag->new($id); - } - my @tagnames = split(/[\s,]/, $cgi->param('tag')); - foreach my $name (@tagnames){ - $name = trim($name); - trick_taint($name); - push @tags, Bugzilla::Testopia::TestTag->new($name); - } - } - + } $vars->{'tags'} = \@tags; $template->process("testopia/tag/show.html.tmpl", $vars) || print $template->error();