summaryrefslogtreecommitdiffstats
path: root/globals.pl
diff options
context:
space:
mode:
authorterry%netscape.com <>1999-03-12 01:30:51 +0100
committerterry%netscape.com <>1999-03-12 01:30:51 +0100
commit6f3e5c8018709ef5a43427c5259e24372eefe7c3 (patch)
treeb2cbd1c250a035299e5bde3402aa1a0aa26b6492 /globals.pl
parent5b2ed378cc135b0f3b94d960824c65e43365e247 (diff)
downloadbugzilla-6f3e5c8018709ef5a43427c5259e24372eefe7c3.tar.gz
bugzilla-6f3e5c8018709ef5a43427c5259e24372eefe7c3.tar.xz
Added 'groups' stuff, where we have different group bits that we can
put on a person or on a bug. Some of the group bits control access to bugzilla features. And a person can't access a bug unless he has every group bit set that is also set on the bug.
Diffstat (limited to 'globals.pl')
-rw-r--r--globals.pl29
1 files changed, 28 insertions, 1 deletions
diff --git a/globals.pl b/globals.pl
index f3288e8c8..409d12b63 100644
--- a/globals.pl
+++ b/globals.pl
@@ -356,7 +356,19 @@ sub InsertNewUser {
for (my $i=0 ; $i<8 ; $i++) {
$password .= substr("abcdefghijklmnopqrstuvwxyz", int(rand(26)), 1);
}
- SendSQL("insert into profiles (login_name, password, cryptpassword) values (@{[SqlQuote($username)]}, '$password', encrypt('$password'))");
+ SendSQL("select bit, userregexp from groups where userregexp != ''");
+ my $groupset = "0";
+ while (MoreSQLData()) {
+ my @row = FetchSQLData();
+ if ($username =~ m/$row[1]/) {
+ $groupset .= "+ $row[0]"; # Silly hack to let MySQL do the math,
+ # not Perl, since we're dealing with 64
+ # bit ints here, and I don't *think* Perl
+ # does that.
+ }
+ }
+
+ SendSQL("insert into profiles (login_name, password, cryptpassword, groupset) values (@{[SqlQuote($username)]}, '$password', encrypt('$password'), $groupset)");
return $password;
}
@@ -484,6 +496,21 @@ sub SqlQuote {
+sub UserInGroup {
+ my ($groupname) = (@_);
+ if ($::usergroupset eq "0") {
+ return 0;
+ }
+ ConnectToDatabase();
+ SendSQL("select (bit & $::usergroupset) != 0 from groups where name = " . SqlQuote($groupname));
+ my $bit = FetchOneColumn();
+ if ($bit) {
+ return 1;
+ }
+ return 0;
+}
+
+
sub Param {
my ($value) = (@_);
if (defined $::param{$value}) {