diff options
author | terry%netscape.com <> | 1999-03-12 01:30:51 +0100 |
---|---|---|
committer | terry%netscape.com <> | 1999-03-12 01:30:51 +0100 |
commit | 6f3e5c8018709ef5a43427c5259e24372eefe7c3 (patch) | |
tree | b2cbd1c250a035299e5bde3402aa1a0aa26b6492 /globals.pl | |
parent | 5b2ed378cc135b0f3b94d960824c65e43365e247 (diff) | |
download | bugzilla-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.pl | 29 |
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}) { |