Clean up some of the MattyT items

git-svn-id: svn://10.0.0.236/branches/Groups_20020716_Branch@128977 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
bugreport%peshkin.net
2002-09-06 18:15:15 +00:00
parent b4223e1351
commit c170784d80
6 changed files with 64 additions and 70 deletions

View File

@@ -356,12 +356,11 @@ sub UserInGroup {
my $self = shift();
my ($groupname) = (@_);
PushGlobalSQLState();
&::ConnectToDatabase();
&::SendSQL("SELECT groups.id FROM groups, user_group_map
WHERE groups.id = user_group_map.group_id
AND user_group_map.user_id = " . $self->{'whoid'} .
" AND isbless = 0
AND groups.name = " . SqlQuote($groupname));
&::SendSQL("SELECT groups.id FROM groups, user_group_map" .
" WHERE groups.id = user_group_map.group_id " .
" AND user_group_map.user_id = " . $self->{'whoid'} .
" AND isbless = 0" .
" AND groups.name = " . SqlQuote($groupname));
my $rslt = FetchOneColumn();
PopGlobalSQLState();
if ($rslt) {

View File

@@ -437,20 +437,20 @@ sub quietly_check_login() {
my $userid = 0;
if (defined $::COOKIE{"Bugzilla_login"} &&
defined $::COOKIE{"Bugzilla_logincookie"}) {
SendSQL("SELECT profiles.userid, " .
"profiles.login_name, " .
"(profiles.login_name = " .
SqlQuote($::COOKIE{"Bugzilla_login"}) .
" AND logincookies.ipaddr = " .
SqlQuote($ENV{"REMOTE_ADDR"}) .
") AS isok, profiles.disabledtext " .
SendSQL("SELECT profiles.userid," .
" profiles.login_name, " .
" profiles.disabledtext " .
" FROM profiles, logincookies WHERE logincookies.cookie = " .
SqlQuote($::COOKIE{"Bugzilla_logincookie"}) .
" AND profiles.userid = logincookies.userid HAVING isok");
" AND profiles.userid = logincookies.userid AND" .
" profiles.login_name = " .
SqlQuote($::COOKIE{"Bugzilla_login"}) .
" AND logincookies.ipaddr = " .
SqlQuote($ENV{"REMOTE_ADDR"}));
my @row;
if (@row = FetchSQLData()) {
($userid, my $loginname, my $ok, my $disabledtext) = (@row);
if ($ok) {
($userid, my $loginname, my $disabledtext) = (@row);
if ($userid > 0) {
if ($disabledtext eq '') {
$::COOKIE{"Bugzilla_login"} = $loginname; # Makes sure case
# is in
@@ -461,8 +461,6 @@ sub quietly_check_login() {
$::disabledreason = $disabledtext;
$userid = 0;
}
} else {
$userid = 0;
}
}
}
@@ -516,7 +514,7 @@ sub GetUserInfo {
SendSQL("SELECT name FROM groups, user_group_map " .
"WHERE groups.id = user_group_map.group_id " .
"AND user_id = $userid " .
"AND isbless = 0");
"AND NOT isbless");
while (MoreSQLData()) {
my ($name) = FetchSQLData();
$groups{$name} = 1;

View File

@@ -228,19 +228,19 @@ sub show_bug {
# user_group_map record putting the user in that group.
# The LEFT JOINs are checking for record existence.
#
SendSQL("SELECT DISTINCT groups.id, name, description,
ISNULL(bug_group_map.group_id) = 0,
ISNULL(user_group_map.group_id) = 0,
isactive
FROM groups
LEFT JOIN bug_group_map
ON bug_group_map.group_id = groups.id
AND bug_id = $bug{'bug_id'}
LEFT JOIN user_group_map
ON user_group_map.group_id = groups.id
AND user_id = $::userid
AND isbless = 0
WHERE isbuggroup = 1");
SendSQL("SELECT DISTINCT groups.id, name, description," .
" bug_group_map.group_id IS NOT NULL," .
" user_group_map.group_id IS NOT NULL," .
" isactive" .
" FROM groups" .
" LEFT JOIN bug_group_map" .
" ON bug_group_map.group_id = groups.id" .
" AND bug_id = $bug{'bug_id'}" .
" LEFT JOIN user_group_map" .
" ON user_group_map.group_id = groups.id" .
" AND user_id = $::userid" .
" AND NOT isbless" .
" WHERE isbuggroup");
$user{'inallgroups'} = 1;

View File

@@ -104,7 +104,7 @@ use Bugzilla::Config qw(:DEFAULT :admin);
# this way we can look in the symbol table to see if they've been declared
# yet or not.
use vars qw( $db_name);
use vars qw( $db_name );
###########################################################################
# Check required module

View File

@@ -229,19 +229,19 @@ if ($action eq 'changeform') {
# a record making that group a child of this group
# and the existance of a record permitting that group to bless
# this one
SendSQL("SELECT groups.id, groups.name, groups.description,
ISNULL(group_group_map.child_id) = 0,
ISNULL(B.child_id) = 0
FROM groups
LEFT JOIN group_group_map
ON group_group_map.child_id = groups.id
AND group_group_map.parent_id = $group_id
AND group_group_map.isbless = 0
LEFT JOIN group_group_map as B
ON B.child_id = groups.id
AND B.parent_id = $group_id
AND B.isbless = 1
WHERE groups.id != $group_id ORDER by name");
SendSQL("SELECT groups.id, groups.name, groups.description," .
" group_group_map.child_id IS NOT NULL," .
" B.child_id IS NOT NULL" .
" FROM groups" .
" LEFT JOIN group_group_map" .
" ON group_group_map.child_id = groups.id" .
" AND group_group_map.parent_id = $group_id" .
" AND group_group_map.isbless = 0" .
" LEFT JOIN group_group_map as B" .
" ON B.child_id = groups.id" .
" AND B.parent_id = $group_id" .
" AND B.isbless" .
" WHERE groups.id != $group_id ORDER by name");
while (MoreSQLData()) {
my ($grpid, $grpnam, $grpdesc, $grpmember, $blessmember) = FetchSQLData();

View File

@@ -645,20 +645,20 @@ sub CanSeeBug {
# (specified in the MySQL documentation) and postgreSQL places NULLs
# ahead of number in descending sorts, this needs to change for Postgres
# the first row contain the NULL value if there is going to be one.
my $query = "SELECT bugs.bug_id, reporter, assigned_to, qa_contact,
reporter_accessible, cclist_accessible,
ISNULL(cc.who) = 0,
ISNULL(bug_group_map.group_id) = 0,
ISNULL(user_group_map.user_id) = 0
FROM bugs
LEFT JOIN cc ON bugs.bug_id = cc.bug_id
AND cc.who = $userid
LEFT JOIN bug_group_map ON bugs.bug_id = bug_group_map.bug_id
LEFT JOIN user_group_map ON
user_group_map.group_id = bug_group_map.group_id
AND user_group_map.isbless = 0
AND user_group_map.user_id = $userid
WHERE bugs.bug_id = $id ORDER BY user_group_map.user_id ";
my $query = "SELECT bugs.bug_id, reporter, assigned_to, qa_contact," .
" reporter_accessible, cclist_accessible," .
" cc.who IS NOT NULL," .
" bug_group_map.group_id IS NOT NULL," .
" user_group_map.user_id IS NOT NULL" .
" FROM bugs" .
" LEFT JOIN cc ON bugs.bug_id = cc.bug_id" .
" AND cc.who = $userid" .
" LEFT JOIN bug_group_map ON bugs.bug_id = bug_group_map.bug_id" .
" LEFT JOIN user_group_map ON" .
" user_group_map.group_id = bug_group_map.group_id" .
" AND user_group_map.isbless = 0" .
" AND user_group_map.user_id = $userid" .
" WHERE bugs.bug_id = $id ORDER BY user_group_map.user_id";
PushGlobalSQLState();
SendSQL($query);
my ($found_id, $reporter, $assigned_to, $qa_contact,
@@ -772,7 +772,7 @@ sub DeriveGroup {
my %groupidschecked = ();
my @groupidstocheck = ();
SendSQL("SELECT group_id FROM user_group_map WHERE user_id = $user
AND isbless = 0");
AND NOT isbless");
while (MoreSQLData()) {
my ($groupid) = FetchSQLData();
push(@groupidstocheck,$groupid);
@@ -783,8 +783,8 @@ sub DeriveGroup {
my $group = shift @groupidstocheck;
if (!defined($groupidschecked{"$group"})) {
$groupidschecked{"$group"} = 1;
SendSQL("SELECT parent_id FROM group_group_map WHERE
child_id = $group AND isbless = 0");
SendSQL("SELECT parent_id FROM group_group_map WHERE"
. " child_id = $group AND NOT isbless");
while (MoreSQLData()) {
my ($groupid) = FetchSQLData();
if (!defined($groupidschecked{"$groupid"})) {
@@ -793,9 +793,9 @@ sub DeriveGroup {
if (!$groupidsadded{$groupid}) {
$groupidsadded{$groupid} = 1;
PushGlobalSQLState();
SendSQL("INSERT INTO user_group_map
(user_id, group_id, isbless, isderived)
VALUES ($user, $groupid, 0, 1)");
SendSQL("INSERT INTO user_group_map"
. " (user_id, group_id, isbless, isderived)"
. " VALUES ($user, $groupid, 0, 1)");
PopGlobalSQLState();
}
}
@@ -1212,10 +1212,7 @@ sub UserInGroup {
AND groups.name = " . SqlQuote($groupname));
my $rslt = FetchOneColumn();
PopGlobalSQLState();
if ($rslt) {
return 1;
}
return 0;
return defined($rslt);
}
sub UserCanBlessGroup {