Commit 1a222139 authored by jake%acutex.net's avatar jake%acutex.net

Fix for bug 45164 - New users created by the admin were not subject to the…

Fix for bug 45164 - New users created by the admin were not subject to the userregexp for groupsets. Patch by Joe Robins <jmrobins@tgix.com> r= jake@acutex.net
parent 7eecb06d
...@@ -129,55 +129,63 @@ sub EmitFormElements ($$$$$$) ...@@ -129,55 +129,63 @@ sub EmitFormElements ($$$$$$)
} }
SendSQL("SELECT bit,name,description,bit & $groupset != 0, " . if($user ne "") {
" bit & $blessgroupset " . print "</TR><TR><TH VALIGN=TOP ALIGN=RIGHT>Group Access:</TH><TD><TABLE><TR>";
"FROM groups " . SendSQL("SELECT bit,name,description,bit & $groupset != 0, " .
"WHERE bit & $opblessgroupset != 0 AND isbuggroup " . " bit & $blessgroupset " .
"ORDER BY name"); "FROM groups " .
print "</TR><TR><TH VALIGN=TOP ALIGN=RIGHT>Group Access:</TH><TD><TABLE><TR>"; "WHERE bit & $opblessgroupset != 0 AND isbuggroup " .
if (MoreSQLData()) { "ORDER BY name");
if ($editall) { if (MoreSQLData()) {
print "<TD COLSPAN=3 ALIGN=LEFT><B>Can turn this bit on for other users</B></TD>\n"; if ($editall) {
print "</TR><TR>\n<TD ALIGN=CENTER><B>|</B></TD>\n"; print "<TD COLSPAN=3 ALIGN=LEFT><B>Can turn this bit on for other users</B></TD>\n";
print "</TR><TR>\n<TD ALIGN=CENTER><B>|</B></TD>\n";
}
print "<TD COLSPAN=2 ALIGN=LEFT><B>User is a member of these groups</B></TD>\n";
} }
print "<TD COLSPAN=2 ALIGN=LEFT><B>User is a member of these groups</B></TD>\n"; while (MoreSQLData()) {
} my ($bit,$name,$description,$checked,$blchecked) = FetchSQLData();
while (MoreSQLData()) { print "</TR><TR>\n";
my ($bit,$name,$description,$checked,$blchecked) = FetchSQLData(); if ($editall) {
print "</TR><TR>\n"; $blchecked = ($blchecked) ? "CHECKED" : "";
if ($editall) { print "<TD ALIGN=CENTER><INPUT TYPE=CHECKBOX NAME=\"blbit_$name\" $blchecked VALUE=\"$bit\"></TD>";
$blchecked = ($blchecked) ? "CHECKED" : ""; }
print "<TD ALIGN=CENTER><INPUT TYPE=CHECKBOX NAME=\"blbit_$name\" $blchecked VALUE=\"$bit\"></TD>"; $checked = ($checked) ? "CHECKED" : "";
print "<TD ALIGN=CENTER><INPUT TYPE=CHECKBOX NAME=\"bit_$name\" $checked VALUE=\"$bit\"></TD>";
print "<TD><B>" . ucfirst($name) . "</B>: $description</TD>\n";
} }
$checked = ($checked) ? "CHECKED" : ""; print "</TR></TABLE></TD>\n";
print "<TD ALIGN=CENTER><INPUT TYPE=CHECKBOX NAME=\"bit_$name\" $checked VALUE=\"$bit\"></TD>";
print "<TD><B>" . ucfirst($name) . "</B>: $description</TD>\n"; print "</TR><TR><TH VALIGN=TOP ALIGN=RIGHT>Privileges:</TH><TD><TABLE><TR>";
} SendSQL("SELECT bit,name,description,bit & $groupset != 0, " .
print "</TR></TABLE></TD>\n"; " bit & $blessgroupset " .
"FROM groups " .
SendSQL("SELECT bit,name,description,bit & $groupset != 0, " . "WHERE bit & $opblessgroupset != 0 AND !isbuggroup " .
" bit & $blessgroupset " . "ORDER BY name");
"FROM groups " . if (MoreSQLData()) {
"WHERE bit & $opblessgroupset != 0 AND !isbuggroup " . if ($editall) {
"ORDER BY name"); print "<TD COLSPAN=3 ALIGN=LEFT><B>Can turn this bit on for other users</B></TD>\n";
print "</TR><TR><TH VALIGN=TOP ALIGN=RIGHT>Privileges:</TH><TD><TABLE><TR>"; print "</TR><TR>\n<TD ALIGN=CENTER><B>|</B></TD>\n";
if (MoreSQLData()) { }
if ($editall) { print "<TD COLSPAN=2 ALIGN=LEFT><B>User has these priveleges</B></TD>\n";
print "<TD COLSPAN=3 ALIGN=LEFT><B>Can turn this bit on for other users</B></TD>\n";
print "</TR><TR>\n<TD ALIGN=CENTER><B>|</B></TD>\n";
} }
print "<TD COLSPAN=2 ALIGN=LEFT><B>User has these priveleges</B></TD>\n"; while (MoreSQLData()) {
} my ($bit,$name,$description,$checked,$blchecked) = FetchSQLData();
while (MoreSQLData()) { print "</TR><TR>\n";
my ($bit,$name,$description,$checked,$blchecked) = FetchSQLData(); if ($editall) {
print "</TR><TR>\n"; $blchecked = ($blchecked) ? "CHECKED" : "";
if ($editall) { print "<TD ALIGN=CENTER><INPUT TYPE=CHECKBOX NAME=\"blbit_$name\" $blchecked VALUE=\"$bit\"></TD>";
$blchecked = ($blchecked) ? "CHECKED" : ""; }
print "<TD ALIGN=CENTER><INPUT TYPE=CHECKBOX NAME=\"blbit_$name\" $blchecked VALUE=\"$bit\"></TD>"; $checked = ($checked) ? "CHECKED" : "";
print "<TD ALIGN=CENTER><INPUT TYPE=CHECKBOX NAME=\"bit_$name\" $checked VALUE=\"$bit\"></TD>";
print "<TD><B>" . ucfirst($name) . "</B>: $description</TD>\n";
} }
$checked = ($checked) ? "CHECKED" : ""; } else {
print "<TD ALIGN=CENTER><INPUT TYPE=CHECKBOX NAME=\"bit_$name\" $checked VALUE=\"$bit\"></TD>"; print "</TR><TR><TH ALIGN=RIGHT>Groups and<br>Priveleges:</TH><TD><TABLE><TR>";
print "<TD><B>" . ucfirst($name) . "</B>: $description</TD>\n"; print "<TD COLSPAN=3>The new user will be inserted into groups " .
"based on their userregexps.<BR>To change the group " .
"permissions for this user, you must edit the account after ".
"creating it.</TD>\n";
} }
print "</TR></TABLE></TD>\n"; print "</TR></TABLE></TD>\n";
...@@ -445,13 +453,23 @@ if ($action eq 'new') { ...@@ -445,13 +453,23 @@ if ($action eq 'new') {
exit; exit;
} }
# For new users, we use the regexps from the groups table to determine
# their initial group membership.
# We also keep a list of groups the user was added to for display on the
# confirmation page.
my $bits = "0"; my $bits = "0";
foreach (keys %::FORM) { my @grouplist = ();
next unless /^bit_/; SendSQL("select bit, name, userregexp from groups where userregexp != ''");
#print "$_=$::FORM{$_}<br>\n"; while (MoreSQLData()) {
$bits .= "+ $::FORM{$_}"; my @row = FetchSQLData();
if ($user =~ m/$row[2]/i) {
$bits .= "+ $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.
push(@grouplist, $row[1]);
}
} }
# Add the new user # Add the new user
SendSQL("INSERT INTO profiles ( " . SendSQL("INSERT INTO profiles ( " .
...@@ -467,7 +485,19 @@ if ($action eq 'new') { ...@@ -467,7 +485,19 @@ if ($action eq 'new') {
#+++ send e-mail away #+++ send e-mail away
print "OK, done.<p>\n"; print "OK, done.<br>\n";
if($#grouplist > -1) {
print "New user added to these groups based on group regexps:\n";
print "<ul>\n";
foreach (@grouplist) {
print "<li>$_</li>\n";
}
print "</ul>\n";
} else {
print "New user not added to any groups.<br><br>\n";
}
print "To change ${user}'s permissions, go back and <a href=\"editusers.cgi?action=edit&user=" . url_quote($user)."\">edit this user</A>";
print "<p>\n";
PutTrailer($localtrailer, PutTrailer($localtrailer,
"<a href=\"editusers.cgi?action=add\">add</a> another user."); "<a href=\"editusers.cgi?action=add\">add</a> another user.");
exit; exit;
...@@ -518,18 +548,16 @@ if ($action eq 'del') { ...@@ -518,18 +548,16 @@ if ($action eq 'del') {
print "</TR><TR>\n"; print "</TR><TR>\n";
print " <TD VALIGN=\"top\">Group set:</TD>\n"; print " <TD VALIGN=\"top\">Group set:</TD>\n";
print " <TD VALIGN=\"top\">"; print " <TD VALIGN=\"top\">";
SendSQL("SELECT bit, name SendSQL("SELECT name
FROM groups FROM groups
ORDER BY name"); WHERE bit & $groupset = bit
ORDER BY isbuggroup, name");
my $found = 0; my $found = 0;
while ( MoreSQLData() ) { while ( MoreSQLData() ) {
my ($bit,$name) = FetchSQLData(); my ($name) = FetchSQLData();
my $cmpr = $bit & $groupset; print "<br>\n" if $found;
if ($cmpr) { print ucfirst $name;
print "<br>\n" if $found; $found = 1;
print ucfirst $name;
$found = 1;
}
} }
print "none" unless $found; print "none" unless $found;
print "</TD>\n</TR>"; print "</TD>\n</TR>";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment