From 98b11e485f73993ac26aa2b94d3ca7989ad8704e Mon Sep 17 00:00:00 2001
From: "ghendricks%novell.com"
Date: Thu, 22 Feb 2007 00:23:48 +0000
Subject: [PATCH] Updated constants and fixed some syntax errors.
git-svn-id: svn://10.0.0.236/trunk@220679 18797224-902f-48f8-a5cc-f745e15eee43
---
.../testopia/Bugzilla/Testopia/Constants.pm | 8 ++++----
.../testopia/Bugzilla/Testopia/TestCase.pm | 2 +-
.../testopia/Bugzilla/Testopia/TestPlan.pm | 18 +++++++++---------
.../testopia/Bugzilla/Testopia/TestRun.pm | 2 +-
.../testopia/admin/access-list.html.tmpl | 4 +++-
mozilla/webtools/testopia/tr_plan_access.cgi | 6 +++++-
6 files changed, 23 insertions(+), 17 deletions(-)
diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Constants.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Constants.pm
index 9c943e0273d..b1cb58c1a85 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/Constants.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Constants.pm
@@ -95,10 +95,10 @@ use constant PAUSED => 5;
use constant BLOCKED => 6;
# Test Plan Permissions (bit flags)
-use constant READ => 1;
-use constant WRITE => 2;
-use constant DELETE => 4;
-use constant ADMIN => 8;
+use constant TR_READ => 1;
+use constant TR_WRITE => 2;
+use constant TR_DELETE => 4;
+use constant TR_ADMIN => 8;
use constant REL_AUTHOR => 0;
use constant REL_EDITOR => 1;
diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm
index 44fe3fa8aea..e2915cb4843 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/TestCase.pm
@@ -1280,7 +1280,7 @@ sub can_unlink_plan {
my $plan = Bugzilla::Testopia::TestPlan->new($plan_id);
return 1 if Bugzilla->user->in_group('admin');
return 1 if Bugzilla->user->in_group('Testers') && Param("testopia-allow-group-member-deletes");
- return 1 if $plan->get_user_rights(Bugzilla->user->id) & DELETE;
+ return 1 if $plan->get_user_rights(Bugzilla->user->id) & TR_DELETE;
return 0;
}
diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/TestPlan.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/TestPlan.pm
index 07639d01cd2..04839f036dc 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/TestPlan.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/TestPlan.pm
@@ -798,7 +798,7 @@ sub update_tester {
my $self = shift;
my ($userid, $perms) = @_;
my $dbh = Bugzilla->dbh;
-
+
$dbh->do("UPDATE test_plan_permissions SET permissions = ?
WHERE userid = ? AND plan_id = ? AND grant_type = ?",
undef, ($perms, $userid, $self->id, GRANT_DIRECT));
@@ -994,10 +994,10 @@ sub tester_regexp_permissions {
WHERE plan_id = ?", undef, $self->id);
my $p;
- $p->{'read'} = 1 & $perms;
- $p->{'write'} = 2 & $perms;
- $p->{'delete'} = 4 & $perms;
- $p->{'admin'} = 8 & $perms;
+ $p->{'read'} = $perms >= TR_READ;
+ $p->{'write'} = $perms >= TR_WRITE;
+ $p->{'delete'} = $perms >= TR_DELETE;
+ $p->{'admin'} = $perms >= TR_ADMIN;
return $p;
}
@@ -1015,10 +1015,10 @@ sub access_list {
my @rows;
foreach my $row (@$ref){
push @rows, {'user' => Bugzilla::User->new($row->{'userid'}),
- 'read' => 1 & $row->{'permissions'},
- 'write' => 2 & $row->{'permissions'},
- 'delete' => 4 & $row->{'permissions'},
- 'admin' => 8 & $row->{'permissions'},
+ 'read' => $row->{'permissions'} >= TR_READ,
+ 'write' => $row->{'permissions'} >= TR_WRITE,
+ 'delete' => $row->{'permissions'} >= TR_DELETE,
+ 'admin' => $row->{'permissions'} >= TR_ADMIN,
};
}
$self->{'access_list'} = \@rows;
diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/TestRun.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/TestRun.pm
index 903a5123170..0a8fcea32b3 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/TestRun.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/TestRun.pm
@@ -46,7 +46,7 @@ use strict;
use Bugzilla::Util;
use Bugzilla::User;
use Bugzilla::Constants;
-use Bugzilla::Testopia::Constants
+use Bugzilla::Testopia::Constants;
use Bugzilla::Config;
use Bugzilla::Testopia::Environment;
use Bugzilla::Bug;
diff --git a/mozilla/webtools/testopia/template/en/default/testopia/admin/access-list.html.tmpl b/mozilla/webtools/testopia/template/en/default/testopia/admin/access-list.html.tmpl
index 367bbfd969d..dfdeeec2413 100644
--- a/mozilla/webtools/testopia/template/en/default/testopia/admin/access-list.html.tmpl
+++ b/mozilla/webtools/testopia/template/en/default/testopia/admin/access-list.html.tmpl
@@ -27,7 +27,9 @@ This page allows plan managers to permit access to a test plan. By default, memb
Testers group in Bugzilla will have read and write access. Beyond this, users login names
(email addresses) that match a given regular expression will be granted the level of permissions
specified. Lastly, individuals can be granted additional permissions by adding them
-explicitly.
+explicitly. In other words, you cannot remove permissions from a user explicitily that has those rights
+by virtue of membership in the Testers group or that matches the regular expression, although you can add
+additional rights.
Delete and Admin rights are always handled by the access control list, unless the
diff --git a/mozilla/webtools/testopia/tr_plan_access.cgi b/mozilla/webtools/testopia/tr_plan_access.cgi
index d55fb006397..e116fe147b0 100644
--- a/mozilla/webtools/testopia/tr_plan_access.cgi
+++ b/mozilla/webtools/testopia/tr_plan_access.cgi
@@ -24,6 +24,7 @@ use lib ".";
use Bugzilla;
use Bugzilla::Constants;
+use Bugzilla::Testopia::Constants;
use Bugzilla::Error;
use Bugzilla::Util;
use Bugzilla::Testopia::Util;
@@ -74,7 +75,8 @@ elsif ($action eq 'Add User'){
$perms |= TR_WRITE if $cgi->param("nw");
$perms |= TR_DELETE if $cgi->param("nd");
$perms |= TR_ADMIN if $cgi->param("na");
-
+
+ detaint_natural($perms);
$plan->add_tester($userid, $perms);
display();
@@ -109,6 +111,7 @@ sub do_update {
$regexp_perms |= TR_DELETE if $cgi->param('pd');
$regexp_perms |= TR_ADMIN if $cgi->param('pa');
+ detaint_natural($regexp_perms);
$plan->set_tester_regexp($tester_regexp, $regexp_perms);
foreach my $row (@{$plan->access_list}){
@@ -121,6 +124,7 @@ sub do_update {
$perms |= TR_DELETE if $cgi->param('d'.$row->{'user'}->id);
$perms |= TR_ADMIN if $cgi->param('a'.$row->{'user'}->id);
+ detaint_natural($perms);
$plan->update_tester($row->{'user'}->id, $perms);
}
}