Subject: | Multiple groups in group field in the DB |
Would it be possible to allow multiple groups in the user's entry in the
database?
I think/hope it is as simple as adding an if to the existing code.
if ($sth->fetchrow_array[0] =~ m/\b$group\b/) {
Original code (around line 943):
# Now loop through all the groups to see if we're a member of any:
my $sth = $dbh->prepare_cached( <<"EOS" );
SELECT $c{'DBI_GroupUserField'}
FROM $c{'DBI_GroupsTable'}
WHERE $c{'DBI_GroupField'} = ?
AND $c{'DBI_GroupUserField'} = ?
EOS
foreach my $group (@groups) {
$sth->execute( $group, $user );
if ( $sth->fetchrow_array ) {
$sth->finish();
# add the group to an ENV var that CGI programs can access:
$r->subprocess_env( 'AUTH_COOKIE_DBI_GROUP' => $group );
return Apache2::Const::OK;
}
}
$sth->finish();
#########################
New code (untested):
# Now loop through all the groups to see if we're a member of any:
my $sth = $dbh->prepare_cached( <<"EOS" );
SELECT $c{'DBI_GroupUserField'}
FROM $c{'DBI_GroupsTable'}
WHERE $c{'DBI_GroupField'} = ?
AND $c{'DBI_GroupUserField'} = ?
EOS
foreach my $group (@groups) {
$sth->execute( $group, $user );
if ( $sth->fetchrow_array ) {
$sth->finish();
###### New if statement ######
if ($sth->fetchrow_array[0] =~ m/\b$group\b/) {
# add the group to an ENV var that CGI programs can access:
$r->subprocess_env( 'AUTH_COOKIE_DBI_GROUP' => $group );
return Apache2::Const::OK;
}
}
}
$sth->finish();