diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Attachment.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Attachment.pm
index 231116c285f..22595bd74ba 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/Attachment.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Attachment.pm
@@ -570,6 +570,18 @@ sub plans {
return $self->{'plans'};
}
+=head2 type
+
+Returns 'attachment'
+
+=cut
+
+sub type {
+ my $self = shift;
+ $self->{'type'} = 'attachment';
+ return $self->{'type'};
+}
+
=head1 SEE ALSO
Bugzilla::Attachment
diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Environment.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Environment.pm
index b1c9406f8d3..8931b73bcde 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/Environment.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Environment.pm
@@ -203,7 +203,9 @@ sub elements_to_json {
$json .= '{title:"'. $element->{'name'} .'",';
$json .= 'objectId:"'. $element->{'element_id'}. '",';
$json .= 'widgetId:"element'. $element->{'element_id'} .'",';
- $json .= 'actionsDisabled:["addCategory","addValue","addChild"],';
+ $json .= 'actionsDisabled:["addCategory","addValue","addChild"';
+ $json .= ',"remove"' unless $self->canedit;
+ $json .= '],';
$json .= 'isFolder:true,' if($element->check_for_children || $element->check_for_properties);
$json .= 'childIconSrc:"testopia/img/circle.gif"},';
}
diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Category.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Category.pm
index 15e27128cf4..5b29d592948 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Category.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Category.pm
@@ -487,6 +487,13 @@ sub obliterate {
}
+sub canview {
+ my $self = shift;
+ return 1 if ($self->product_id == 0);
+ return 1 if Bugzilla->user->can_see_product($self->product->name);
+ return 0;
+}
+
sub canedit {
my $self = shift;
if ($self->product_id == 0){
diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Element.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Element.pm
index bdfbc71bff4..8a7db50bfbc 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Element.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Element.pm
@@ -432,6 +432,12 @@ sub obliterate {
return 1;
}
+sub canview {
+ my $self = shift;
+ return 1 if $self->get_parent->canview;
+ return 0;
+}
+
sub canedit {
my $self = shift;
return 1 if $self->get_parent->canedit;
diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Property.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Property.pm
index 611e6633cb8..f4cc404d555 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Property.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Environment/Property.pm
@@ -330,6 +330,13 @@ sub obliterate {
}
+sub canview {
+ my $self = shift;
+ my $element = Bugzilla::Testopia::Environment::Element->new($self->element_id);
+ return 1 if $element->canview;
+ return 0;
+}
+
sub canedit {
my $self = shift;
my $element = Bugzilla::Testopia::Environment::Element->new($self->element_id);
diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Search.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Search.pm
index 4ebc7053e50..50d1f70e627 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/Search.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Search.pm
@@ -329,7 +329,7 @@ sub init {
# TODO: is there a better way to do this?
if ($obj eq 'environment'){
my @prod_ids;
- foreach my $p (Bugzilla->user->get_selectable_products){
+ foreach my $p (@{Bugzilla->user->get_selectable_products}){
push @prod_ids, $p->id;
}
my $prod_ids = join(',',@prod_ids);
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 523cde3f4ab..aa8a2183a57 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
@@ -20,13 +20,13 @@
[% IF error == "testopia-permission-denied" %]
[% title = "Insufficient Permissions" %]
- You are not authorized to view this [% object FILTER html %]
+ You are not authorized to view [% object.type FILTER html %] [% object.id FILTER html %]
[% ELSIF error == "testopia-read-only" %]
[% title = "Insufficient Permissions" %]
- You are not authorized to edit [% object FILTER html %] [% id FILTER html %]
+ You are not authorized to edit [% object.type FILTER html %] [% object.id FILTER html %]
[% ELSIF error == "testopia-no-delete" %]
[% title = "Insufficient Permissions" %]
- You are not authorized to delete [% object.type FILTER html %] [% object.id FILTER html %]
+ You are not authorized to delete [% object.type FILTER html %] [% object.id FILTER html %]
[% IF UserInGroup('admin') %]
If you are the administrator, you can check that your installation
allows deletion of Testopia objects in the
diff --git a/mozilla/webtools/testopia/template/en/default/testopia/environment/form.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/environment/form.html.tmpl
index 7ce862a680d..7a1a0beba0b 100644
--- a/mozilla/webtools/testopia/template/en/default/testopia/environment/form.html.tmpl
+++ b/mozilla/webtools/testopia/template/en/default/testopia/environment/form.html.tmpl
@@ -59,25 +59,38 @@ values for each of the properties.
Name
- Create a New Environment
+
+ [% IF user.in_group('Testers') %]
+ Create a New Environment
+ [% END %]
Product
- [% PROCESS select sel = {
+
+ [% IF environment.canedit %]
+ [% PROCESS select sel = {
name => 'product_id',
list => user.get_selectable_products,
default => environment.product_id,
accesskey => 'p'} %]
+ [% ELSE %]
+ [% environment.product.name FILTER html %]
+ [% END %]
- Edit Environment Variables
+
+ [% IF user.in_group('Testers') %]
+ Edit Environment Variables
+ [% END %]
Archive
[% IF environment.candelete %]
- Delete his Environment
+ Delete this Environment
[% END %]
+[% IF environment.canedit %]
+[% END %]
\ No newline at end of file
diff --git a/mozilla/webtools/testopia/template/en/default/testopia/environment/show.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/environment/show.html.tmpl
index edae4c821f3..f8832abef50 100644
--- a/mozilla/webtools/testopia/template/en/default/testopia/environment/show.html.tmpl
+++ b/mozilla/webtools/testopia/template/en/default/testopia/environment/show.html.tmpl
@@ -189,13 +189,13 @@ dojo.addOnLoad(function() {
widgetId="environment[% environment.id %]"
objectId="[% environment.id %]"
isFolder="[% environment.element_count ? 'true' : 'false' %]"
- actionsDisabled="edit;move">
+ actionsDisabled="[% 'remove;' UNLESS environment.canedit %]edit;move">
-
+[% IF environment.canedit %]
@@ -236,6 +236,7 @@ dojo.addOnLoad(function() {
+[% END %]
diff --git a/mozilla/webtools/testopia/template/en/default/testopia/environment/table.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/environment/table.html.tmpl
index e7e86e4cd15..621fbe4c68c 100644
--- a/mozilla/webtools/testopia/template/en/default/testopia/environment/table.html.tmpl
+++ b/mozilla/webtools/testopia/template/en/default/testopia/environment/table.html.tmpl
@@ -37,7 +37,10 @@
[% env.id FILTER none %]
[% env.name FILTER none %]
[% env.product.name FILTER none %]
- [% env.isactive ? 'Archive' : 'Unarchive' %]
+
+ [% IF env.edit %]
+ [% env.isactive ? 'Archive' : 'Unarchive' %]
+ [% END %]
[% IF env.candelete %]
|
Delete
diff --git a/mozilla/webtools/testopia/tr_admin.cgi b/mozilla/webtools/testopia/tr_admin.cgi
index 2b26a41527d..0867f4309b1 100755
--- a/mozilla/webtools/testopia/tr_admin.cgi
+++ b/mozilla/webtools/testopia/tr_admin.cgi
@@ -38,7 +38,7 @@ use vars qw($vars);
Bugzilla->login(LOGIN_REQUIRED);
print $cgi->header;
-ThrowUserError("testopia-read-only", {'object' => 'admin pages'}) unless Bugzilla->user->in_group('admin');
+ThrowUserError("testopia-read-only") unless Bugzilla->user->in_group('admin');
my $plan = Bugzilla::Testopia::TestPlan->new({});
my $action = $cgi->param('action') || '';
diff --git a/mozilla/webtools/testopia/tr_admin_environment.cgi b/mozilla/webtools/testopia/tr_admin_environment.cgi
index 2e3005b8f4e..7460b7a119b 100755
--- a/mozilla/webtools/testopia/tr_admin_environment.cgi
+++ b/mozilla/webtools/testopia/tr_admin_environment.cgi
@@ -52,7 +52,7 @@ use vars qw($vars);
print $cgi->header;
-ThrowUserError('testopia-permission-denied', {'object' => 'environments'}) unless Bugzilla->user->in_group('Testers');
+ThrowUserError('testopia-permission-denied') unless Bugzilla->user->in_group('Testers');
my $action = $cgi->param('action') || '';
my $env_id = $cgi->param('env_id') || 0;
diff --git a/mozilla/webtools/testopia/tr_attachment.cgi b/mozilla/webtools/testopia/tr_attachment.cgi
index 356fd95905b..3e0923326c6 100755
--- a/mozilla/webtools/testopia/tr_attachment.cgi
+++ b/mozilla/webtools/testopia/tr_attachment.cgi
@@ -77,7 +77,7 @@ elsif ($caserun_id){
##################
if ($action eq 'edit'){
print $cgi->header;
- ThrowUserError('testopia-permission-denied', {'object' => 'Attachment'}) unless $attachment->canedit;
+ ThrowUserError('testopia-permission-denied', {'object' => $attachment}) unless $attachment->canedit;
$vars->{'attachment'} = $attachment;
$vars->{'isviewable'} = $attachment->isViewable($cgi);
@@ -87,7 +87,7 @@ if ($action eq 'edit'){
}
elsif ($action eq 'do_edit') {
print $cgi->header;
- ThrowUserError('testopia-permission-denied', {'object' => 'Attachment'}) unless $attachment->canedit;
+ ThrowUserError('testopia-permission-denied', {'object' => $attachment}) unless $attachment->canedit;
my %newvalues = (
'description' => $cgi->param('description') || '',
@@ -113,7 +113,7 @@ elsif ($action eq 'do_edit') {
elsif ($action eq 'remove') {
print $cgi->header;
ThrowUserError('testopia-missing-parameter', {'param' => 'case_id or plan_id'}) unless $obj;
- ThrowUserError('testopia-no-delete', {'object' => 'Attachment'}) unless $obj->canedit;
+ ThrowUserError('testopia-no-delete', {'object' => $attachment}) unless $obj->canedit;
$vars->{'attachment'} = $attachment;
$vars->{'action'} = 'do_remove';
$vars->{'obj'} = $obj;
@@ -126,7 +126,7 @@ elsif ($action eq 'do_remove') {
print $cgi->header;
$vars->{'tr_message'} = "Attachment ". $attachment->description ." deleted";
ThrowUserError('testopia-missing-parameter', {'param' => 'case_id or plan_id'}) unless $obj;
- ThrowUserError('testopia-no-delete', {'object' => 'Attachment'}) unless $obj->canedit;
+ ThrowUserError('testopia-no-delete', {'object' => $attachment}) unless $obj->canedit;
if ($plan_id){
$attachment->unlink_plan($plan_id);
}
@@ -148,7 +148,7 @@ elsif ($action eq 'do_remove') {
elsif ($action eq 'delete') {
print $cgi->header;
- ThrowUserError('testopia-no-delete', {'object' => 'Attachment'}) unless $attachment->candelete;
+ ThrowUserError('testopia-no-delete', {'object' => $attachment}) unless $attachment->candelete;
$vars->{'attachment'} = $attachment;
$vars->{'action'} = 'do_delete';
@@ -159,7 +159,7 @@ elsif ($action eq 'delete') {
elsif ($action eq 'do_delete') {
print $cgi->header;
$vars->{'tr_message'} = "Attachment ". $attachment->description ." deleted";
- ThrowUserError('testopia-no-delete', {'object' => 'Attachment'}) unless $attachment->candelete;
+ ThrowUserError('testopia-no-delete', {'object' => $attachment}) unless $attachment->candelete;
$attachment->obliterate;
$vars->{'tr_message'} = "Attachment deleted";
diff --git a/mozilla/webtools/testopia/tr_builds.cgi b/mozilla/webtools/testopia/tr_builds.cgi
index ba017ea71fd..b9b4b9080fa 100755
--- a/mozilla/webtools/testopia/tr_builds.cgi
+++ b/mozilla/webtools/testopia/tr_builds.cgi
@@ -48,7 +48,7 @@ my $product_id = $cgi->param('product_id');
ThrowUserError("testopia-missing-parameter", {param => "product_id"}) unless $product_id;
my $product = Bugzilla::Testopia::Product->new($product_id);
-ThrowUserError('testopia-read-only', {'object' => 'Build'}) unless $product->canedit;
+ThrowUserError('testopia-read-only', {'object' => $product}) unless $product->canedit;
$vars->{'plan_id'} = $cgi->param('plan_id');
$vars->{'product'} = $product;
diff --git a/mozilla/webtools/testopia/tr_categories.cgi b/mozilla/webtools/testopia/tr_categories.cgi
index f90c178931f..db43eb704a8 100755
--- a/mozilla/webtools/testopia/tr_categories.cgi
+++ b/mozilla/webtools/testopia/tr_categories.cgi
@@ -48,7 +48,7 @@ my $product_id = $cgi->param('product_id');
ThrowUserError("testopia-missing-parameter", {param => "product_id"}) unless $product_id;
my $product = Bugzilla::Testopia::Product->new($product_id);
-ThrowUserError('testopia-read-only', {'object' => 'Category'}) unless $product->canedit;
+ThrowUserError('testopia-read-only', {'object' => $product}) unless $product->canedit;
$vars->{'plan_id'} = $cgi->param('plan_id');
$vars->{'product'} = $product;
diff --git a/mozilla/webtools/testopia/tr_export_environment.cgi b/mozilla/webtools/testopia/tr_export_environment.cgi
index 046ff90b3fa..6002ef6b0b4 100755
--- a/mozilla/webtools/testopia/tr_export_environment.cgi
+++ b/mozilla/webtools/testopia/tr_export_environment.cgi
@@ -58,7 +58,8 @@ my $env_id = $cgi->param('env_id');
#********************************************* UI Logic ************************************************#
print $cgi->header;
-
+my $env = Bugzilla::Testopia::Environment->new($env_id);
+ThrowUserError("testopia-read-only", {'object' => $env}) unless $env->canview;
my $xml = Bugzilla::Testopia::Environment::Xml->export($env_id);
if (!defined($xml)) {
$vars->{'tr_error'} .= "Exporting XML Environment Failed. Please try again. ";
diff --git a/mozilla/webtools/testopia/tr_list_caseruns.cgi b/mozilla/webtools/testopia/tr_list_caseruns.cgi
index c250c9077c1..0b1e2a86b28 100755
--- a/mozilla/webtools/testopia/tr_list_caseruns.cgi
+++ b/mozilla/webtools/testopia/tr_list_caseruns.cgi
@@ -196,7 +196,7 @@ elsif ($action eq 'Delete Selected'){
my $caserun = Bugzilla::Testopia::TestCaseRun->new($1) if $p =~ $reg;
if (($caserun && !$caserun->candelete)){
print $cgi->multipart_end if $serverpush;
- ThrowUserError("testopia-read-only", {'object' => 'case run'});
+ ThrowUserError("testopia-no-delete", {'object' => $caserun});
}
push @caseruns, $caserun if $caserun;
}
diff --git a/mozilla/webtools/testopia/tr_plan_reports.cgi b/mozilla/webtools/testopia/tr_plan_reports.cgi
index 274712db351..3385d9d3081 100755
--- a/mozilla/webtools/testopia/tr_plan_reports.cgi
+++ b/mozilla/webtools/testopia/tr_plan_reports.cgi
@@ -55,7 +55,7 @@ if ($type eq 'build_coverage'){
my $action = $cgi->param('action') || '';
my $plan = Bugzilla::Testopia::TestPlan->new($plan_id);
- ThrowUserError("testopia-permission-denied", {'object' => 'plan'}) unless $plan->canview;
+ ThrowUserError("testopia-permission-denied", {'object' => $plan}) unless $plan->canview;
my $report = {};
my %buildseen;
foreach my $case (@{$plan->test_cases}){
@@ -104,7 +104,7 @@ elsif ($type eq 'bugcounts'){
}
validate_test_id($plan_id, 'plan');
my $plan = Bugzilla::Testopia::TestPlan->new($plan_id);
- ThrowUserError("testopia-permission-denied", {'object' => 'plan'}) unless $plan->canview;
+ ThrowUserError("testopia-permission-denied", {'object' => $plan}) unless $plan->canview;
my $dbh = Bugzilla->dbh;
my $ref = $dbh->selectall_arrayref(
diff --git a/mozilla/webtools/testopia/tr_show_case.cgi b/mozilla/webtools/testopia/tr_show_case.cgi
index bbbc0e47bc7..a91d1430675 100755
--- a/mozilla/webtools/testopia/tr_show_case.cgi
+++ b/mozilla/webtools/testopia/tr_show_case.cgi
@@ -171,7 +171,7 @@ elsif ($action eq 'do_clone'){
elsif ($action eq 'Attach'){
my $case = Bugzilla::Testopia::TestCase->new($case_id);
- ThrowUserError("testopia-read-only", {'object' => 'case'}) unless $case->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $case}) unless $case->canedit;
defined $cgi->upload('data')
|| ThrowUserError("file_not_specified");
@@ -206,7 +206,7 @@ elsif ($action eq 'Attach'){
elsif ($action eq 'Commit'){
my $case = Bugzilla::Testopia::TestCase->new($case_id);
- ThrowUserError("testopia-read-only", {'object' => 'case'}) unless $case->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $case}) unless $case->canedit;
do_update($case);
$vars->{'tr_message'} = "Test case updated";
$vars->{'backlink'} = $case;
@@ -215,7 +215,7 @@ elsif ($action eq 'Commit'){
elsif ($action eq 'History'){
my $case = Bugzilla::Testopia::TestCase->new($case_id);
- ThrowUserError("testopia-permission-denied", {'object' => 'case'}) unless $case->canview;
+ ThrowUserError("testopia-permission-denied", {'object' => $case}) unless $case->canview;
$vars->{'case'} = $case;
$vars->{'diff'} = $case->compare_doc_versions($cgi->param('new'),$cgi->param('old'));
$vars->{'new'} = $cgi->param('new');
@@ -229,7 +229,7 @@ elsif ($action eq 'unlink'){
my $plan_id = $cgi->param('plan_id');
validate_test_id($plan_id, 'plan');
my $case = Bugzilla::Testopia::TestCase->new($case_id);
- ThrowUserError("testopia-read-only", {'object' => 'case'})
+ ThrowUserError("testopia-read-only", {'object' => $case})
unless ($case->can_unlink_plan($plan_id));
if (scalar @{$case->plans} == 1){
@@ -265,7 +265,7 @@ elsif ($action eq 'do_unlink'){
elsif ($action eq 'detach_bug'){
my $case = Bugzilla::Testopia::TestCase->new($case_id);
- ThrowUserError("testopia-read-only", {'object' => 'case'}) unless $case->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $case}) unless $case->canedit;
my @buglist;
foreach my $bug (split(/[\s,]+/, $cgi->param('bug_id'))){
ValidateBugID($bug);
@@ -300,7 +300,7 @@ elsif ($action eq 'do_delete'){
####################
elsif ($action eq 'addcomponent' || $action eq 'removecomponent'){
my $case = Bugzilla::Testopia::TestCase->new($case_id);
- ThrowUserError("testopia-read-only", {'object' => 'case'}) unless $case->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $case}) unless $case->canedit;
my $comp = $cgi->param('component_id');
detaint_natural($comp);
validate_selection($comp, 'id', 'components');
@@ -328,7 +328,7 @@ elsif ($action eq 'addcomponent' || $action eq 'removecomponent'){
#TODO: Clean up styles and put them in skins
else{
my $case = Bugzilla::Testopia::TestCase->new($case_id);
- ThrowUserError("testopia-permission-denied", {'object' => 'case'}) unless $case->canview;
+ ThrowUserError("testopia-permission-denied", {'object' => $case}) unless $case->canview;
display($case);
}
diff --git a/mozilla/webtools/testopia/tr_show_caserun.cgi b/mozilla/webtools/testopia/tr_show_caserun.cgi
index d42d9930b38..79144a22710 100755
--- a/mozilla/webtools/testopia/tr_show_caserun.cgi
+++ b/mozilla/webtools/testopia/tr_show_caserun.cgi
@@ -59,7 +59,6 @@ my $action = $cgi->param('action') || '';
# For use on the classic form
if ($action eq 'Commit'){
- ;
my $caserun = Bugzilla::Testopia::TestCaseRun->new($caserun_id);
display(do_update($caserun));
}
@@ -99,7 +98,7 @@ elsif ($action eq 'Attach'){
elsif ($action eq 'delete'){
my $caserun = Bugzilla::Testopia::TestCaseRun->new($caserun_id);
- ThrowUserError("testopia-no-delete", {'object' => $caserun}) if !$caserun->candelete;
+ ThrowUserError("testopia-no-delete", {'object' => $caserun}) unless $caserun->candelete;
$vars->{'title'} = 'Remove Test Case '. $caserun->case->id .' from Run: ' . $caserun->run->summary;
$vars->{'bugcount'} = scalar @{$caserun->bugs};
$vars->{'form_action'} = 'tr_show_caserun.cgi';
@@ -109,7 +108,7 @@ elsif ($action eq 'delete'){
}
elsif ($action eq 'do_delete'){
my $caserun = Bugzilla::Testopia::TestCaseRun->new($caserun_id);
- ThrowUserError("testopia-no-delete", {'object' => $caserun}) if !$caserun->candelete;
+ ThrowUserError("testopia-no-delete", {'object' => $caserun}) unless $caserun->candelete;
$caserun->obliterate;
# See if there is a saved filter
@@ -334,7 +333,7 @@ else {
sub do_update {
my $caserun = shift;
- ThrowUserError("testopia-read-only", {'object' => 'case run'}) unless $caserun->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $caserun}) unless $caserun->canedit;
my $status = $cgi->param('status');
my $notes = $cgi->param('notes');
diff --git a/mozilla/webtools/testopia/tr_show_environment.cgi b/mozilla/webtools/testopia/tr_show_environment.cgi
index ebddd2b6c69..6060b7eb803 100755
--- a/mozilla/webtools/testopia/tr_show_environment.cgi
+++ b/mozilla/webtools/testopia/tr_show_environment.cgi
@@ -139,7 +139,7 @@ elsif ($action eq 'getChildren'){
detaint_natural($id);
trick_taint($type);
-
+ print STDERR $type;
for ($type){
/classification/ && do { get_products($id); };
/product/ && do { get_categories($id); };
@@ -166,6 +166,10 @@ elsif($action eq 'removeNode'){
trick_taint($type);
my $env = Bugzilla::Testopia::Environment->new($env_id);
+ unless ($env->canedit){
+ print 'false';
+ exit;
+ }
$env->delete_element($id);
print "true";
@@ -188,6 +192,7 @@ elsif($action eq 'set_selected'){
trick_taint($value);
my $env = Bugzilla::Testopia::Environment->new($env_id);
+ exit unless $env->canedit;
my $property = Bugzilla::Testopia::Environment::Property->new($prop_id);
my $elmnt_id = $property->element_id();
@@ -216,6 +221,10 @@ elsif($action eq 'move'){
trick_taint($environment_id);
my $env = Bugzilla::Testopia::Environment->new($environment_id);
+ unless ($env->canedit){
+ print "false";
+ exit;
+ }
$element = Bugzilla::Testopia::Environment::Element->new($element_id);
my $properties = $element->get_properties;
if (scalar @$properties == 0){
@@ -226,11 +235,9 @@ elsif($action eq 'move'){
if ($success == 0){print "{error:\"error\"";exit;}
}
- print "true";exit;
+ print "true";
+ exit;
- print "{error:\"";
- print "element_id: ".$element_id." ";
- print "environment_id: ".$environment_id."\"}";
}
else {
@@ -245,14 +252,13 @@ sub display {
if(!defined($env)){
my $env = Bugzilla::Testopia::Environment->new({'environment_id' => 0});
- ThrowUserError("testopia-read-only", {'object' => 'Environment'}) unless $env->canedit;
$vars->{'environment'} = $env;
$vars->{'action'} = 'do_add';
$template->process("testopia/environment/add.html.tmpl", $vars)
|| print $template->error();
exit;
}
- ThrowUserError('testopia-permission-denied', {object => 'Environment'}) unless $env->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $env}) unless $env->canview;
my $category = Bugzilla::Testopia::Environment::Category->new({'id' => 0});
if (Param('useclassification')){
$vars->{'allhaschild'} = $category->get_all_child_count;
@@ -294,7 +300,7 @@ sub get_categories{
sub get_category_element_json {
my ($id) = (@_);
my $category = Bugzilla::Testopia::Environment::Category->new($id);
- return unless $category->canedit;
+ return unless $category->canview;
my $fish = $category->elements_to_json("TRUE");
print $fish;
}
@@ -302,20 +308,21 @@ sub get_category_element_json {
sub get_element_children {
my ($id) = (@_);
my $element = Bugzilla::Testopia::Environment::Element->new($id);
- return unless $element->canedit;
+ print STDERR $element->canview;
+ return unless $element->canview;
print $element->children_to_json(1);
}
sub get_env_elements {
my ($id) = (@_);
my $env = Bugzilla::Testopia::Environment->new($id);
- return unless $env->canedit;
+ return unless $env->canview;
print $env->elements_to_json(1);
}
sub get_validexp_json {
my ($id,$env_id) = (@_);
my $property = Bugzilla::Testopia::Environment::Property->new($id);
- return unless $property->canedit;
+ return unless $property->canview;
print $property->valid_exp_to_json(1,$env_id);
}
diff --git a/mozilla/webtools/testopia/tr_show_plan.cgi b/mozilla/webtools/testopia/tr_show_plan.cgi
index 060ecbb4448..081d0374636 100755
--- a/mozilla/webtools/testopia/tr_show_plan.cgi
+++ b/mozilla/webtools/testopia/tr_show_plan.cgi
@@ -78,7 +78,7 @@ $vars->{'form_action'} = "tr_show_plan.cgi";
if ($action eq 'Archive' || $action eq 'Unarchive'){
print $cgi->header;
my $plan = Bugzilla::Testopia::TestPlan->new($plan_id);
- ThrowUserError("testopia-read-only", {'object' => 'plan'}) unless $plan->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $plan}) unless $plan->canedit;
do_update($plan);
$vars->{'plan'} = $plan;
$plan->toggle_archive(Bugzilla->user->id);
@@ -93,7 +93,7 @@ if ($action eq 'Archive' || $action eq 'Unarchive'){
#############
elsif ($action eq 'Clone'){
print $cgi->header;
- ThrowUserError("testopia-permission-denied", {'object' => 'plan'}) unless Bugzilla->user->in_group('Testers');
+ ThrowUserError("testopia-create-denied", {'object' => 'plans'}) unless Bugzilla->user->in_group('Testers');
my $plan = Bugzilla::Testopia::TestPlan->new($plan_id);
do_update($plan);
$vars->{'plan'} = $plan;
@@ -104,7 +104,7 @@ elsif ($action eq 'Clone'){
elsif ($action eq 'do_clone'){
unless (Bugzilla->user->in_group('Testers')){
print $cgi->header;
- ThrowUserError("testopia-permission-denied", {'object' => 'plan'});
+ ThrowUserError("testopia-create-denied", {'object' => 'plans'});
}
if ($serverpush) {
@@ -224,7 +224,7 @@ elsif ($action eq 'do_clone'){
elsif ($action eq 'Commit'){
print $cgi->header;
my $plan = Bugzilla::Testopia::TestPlan->new($plan_id);
- ThrowUserError("testopia-read-only", {'object' => 'plan'}) unless $plan->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $plan}) unless $plan->canedit;
do_update($plan);
$vars->{'tr_message'} = "Test plan updated";
$vars->{'backlink'} = $plan;
@@ -245,7 +245,7 @@ elsif ($action eq 'Print'){
elsif ($action eq 'History'){
print $cgi->header;
my $plan = Bugzilla::Testopia::TestPlan->new($plan_id);
- ThrowUserError("testopia-permission-denied", {'object' => 'plan'}) unless $plan->canview;
+ ThrowUserError("testopia-permission-denied", {'object' => $plan}) unless $plan->canview;
$vars->{'plan'} = $plan;
$vars->{'diff'} = $plan->diff_plan_doc($cgi->param('new'),$cgi->param('old'));
$vars->{'new'} = $cgi->param('new');
@@ -260,7 +260,7 @@ elsif ($action eq 'History'){
elsif ($action eq 'Attach'){
print $cgi->header;
my $plan = Bugzilla::Testopia::TestPlan->new($plan_id);
- ThrowUserError("testopia-read-only", {'object' => 'plan'}) unless $plan->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $plan}) unless $plan->canedit;
defined $cgi->upload('data')
|| ThrowUserError("file_not_specified");
my $filename = $cgi->upload('data');
@@ -338,7 +338,7 @@ elsif ($action eq 'do_delete'){
####################
else{
my $plan = Bugzilla::Testopia::TestPlan->new($plan_id);
- ThrowUserError("testopia-permission-denied", {'object' => 'plan'}) unless $plan->canview;
+ ThrowUserError("testopia-permission-denied", {'object' => $plan}) unless $plan->canview;
display($plan);
}
###################
diff --git a/mozilla/webtools/testopia/tr_show_run.cgi b/mozilla/webtools/testopia/tr_show_run.cgi
index 0c551255685..9472708aa3e 100755
--- a/mozilla/webtools/testopia/tr_show_run.cgi
+++ b/mozilla/webtools/testopia/tr_show_run.cgi
@@ -69,7 +69,7 @@ my $action = $cgi->param('action') || '';
if ($action eq 'Commit'){
print $cgi->header;
my $run = Bugzilla::Testopia::TestRun->new($run_id);
- ThrowUserError("testopia-read-only", {'object' => 'run'}) unless $run->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $run}) unless $run->canedit;
do_update($run);
$vars->{'tr_message'} = "Test run updated";
$vars->{'backlink'} = $run;
@@ -79,7 +79,7 @@ if ($action eq 'Commit'){
elsif ($action eq 'History'){
print $cgi->header;
my $run = Bugzilla::Testopia::TestRun->new($run_id);
- ThrowUserError("testopia-permission-denied", {'object' => 'run'}) unless $run->canview;
+ ThrowUserError("testopia-permission-denied", {'object' => $run}) unless $run->canview;
$vars->{'run'} = $run;
$template->process("testopia/run/history.html.tmpl", $vars)
|| ThrowTemplateError($template->error());
@@ -92,7 +92,7 @@ elsif ($action eq 'History'){
elsif ($action =~ /^Clone/){
print $cgi->header;
my $run = Bugzilla::Testopia::TestRun->new($run_id);
- ThrowUserError("testopia-read-only", {'object' => 'run'}) unless $run->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $run->plan}) unless $run->plan->canedit;
my $case_list = $cgi->param('case_list');
do_update($run);
my @ids;
@@ -129,7 +129,7 @@ elsif ($action eq 'do_clone'){
}
- ThrowUserError("testopia-read-only", {'object' => 'run'}) unless $run->plan->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $run->plan}) unless $run->plan->canedit;
my $summary = $cgi->param('summary');
my $build = $cgi->param('build');
my $plan_id = $cgi->param('plan_id');
@@ -160,7 +160,7 @@ elsif ($action eq 'do_clone'){
my $case = Bugzilla::Testopia::TestCase->new($id);
unless ($case->canview){
print $cgi->multipart_end if $serverpush;
- ThrowUserError('testopia-permission-denied', {'object' => 'Test Case'});
+ ThrowUserError('testopia-permission-denied', {'object' => $case});
}
push @case_ids, $id
}
@@ -268,7 +268,7 @@ elsif ($action eq 'clear_filter'){
####################
elsif ($action eq 'addcc'){
my $run = Bugzilla::Testopia::TestRun->new($run_id);
- ThrowUserError("testopia-read-only", {'object' => 'run'}) unless $run->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $run}) unless $run->canedit;
my @cclist = split(/[\s,]+/, $cgi->param('cc'));
my %ccids;
foreach my $email (@cclist){
@@ -298,7 +298,7 @@ elsif ($action eq 'removecc'){
elsif ($action eq 'Delete'){
print $cgi->header;
my $run = Bugzilla::Testopia::TestRun->new($run_id);
- ThrowUserError("testopia-no-delete", {'object' => 'run'}) unless $run->candelete;
+ ThrowUserError("testopia-no-delete", {'object' => $run}) unless $run->candelete;
$vars->{'run'} = $run;
$template->process("testopia/run/delete.html.tmpl", $vars) ||
@@ -309,7 +309,7 @@ elsif ($action eq 'do_delete'){
my $run = Bugzilla::Testopia::TestRun->new($run_id);
unless ($run->candelete){
print $cgi->header;
- ThrowUserError("testopia-no-delete", {'object' => 'run'});
+ ThrowUserError("testopia-no-delete", {'object' => $run});
}
if ($serverpush) {
print $cgi->multipart_init();
@@ -420,7 +420,7 @@ sub do_update {
sub display {
my $run = shift;
- ThrowUserError("testopia-permission-denied", {'object' => 'run'}) unless $run->canview;
+ ThrowUserError("testopia-permission-denied", {'object' => $run}) unless $run->canview;
# See if there is a saved filter
if ($cgi->cookie('TESTOPIA-FILTER-RUN-' . $run_id) && $action ne 'Filter' && $action ne 'clear_filter'){
$cgi = Bugzilla::CGI->new($cgi->cookie('TESTOPIA-FILTER-RUN-' . $run_id));
diff --git a/mozilla/webtools/testopia/tr_tags.cgi b/mozilla/webtools/testopia/tr_tags.cgi
index ab0caa3bf9b..311b56a58dc 100755
--- a/mozilla/webtools/testopia/tr_tags.cgi
+++ b/mozilla/webtools/testopia/tr_tags.cgi
@@ -55,7 +55,7 @@ if ($action eq 'delete'){
my $tag_id = $cgi->param('tagid');
validate_test_id($tag_id, 'tag');
my $tag = Bugzilla::Testopia::TestTag->new($tag_id);
- ThrowUserError("testopia-no-delete", {'object' => 'Tag'}) unless $tag->candelete;
+ ThrowUserError("testopia-no-delete", {'object' => $tag}) unless $tag->candelete;
$tag->obliterate;
$vars->{'tr_message'} = "Tag " . $tag->name . " deleted";
display();
@@ -126,7 +126,7 @@ elsif ($action eq 'removetag'){
$obj = Bugzilla::Testopia::TestRun->new($id);
}
ThrowUserError('testopia-unkown-object') unless $obj;
- ThrowUserError("testopia-read-only", {'object' => $type}) unless $obj->canedit;
+ ThrowUserError("testopia-read-only", {'object' => $obj}) unless $obj->canedit;
$obj->remove_tag($tag_id);
if ($cgi->param('method')){
$vars->{'tr_message'} = "Removed tag From $type " . $obj->id;
@@ -204,7 +204,8 @@ sub display {
my @products;
foreach my $id (split(",", $cgi->param('product'))){
- push @products, Bugzilla::Testopia::Product->new($id) if detaint_natural($id);;
+ my $product = Bugzilla::Testopia::Product->new($id);
+ push @products, $product if Bugzilla->user->can_see_product($product->name);
}
$vars->{'products'} = \@products;
@@ -214,10 +215,12 @@ sub display {
detaint_natural($id);
push @tags, Bugzilla::Testopia::TestTag->new($id);
}
-
- my $name = trim($cgi->param('tag'));
- trick_taint($name);
- push @tags, Bugzilla::Testopia::TestTag->new($name);
+
+ if ($cgi->param('tag')){
+ my $name = trim($cgi->param('tag'));
+ trick_taint($name);
+ push @tags, Bugzilla::Testopia::TestTag->new($name);
+ }
$vars->{'tags'} = \@tags;
$template->process("testopia/tag/show.html.tmpl", $vars)