From 1a2221391b29920332d504dc3e80803a23e430d7 Mon Sep 17 00:00:00 2001 From: "jake%acutex.net" <> Date: Wed, 30 May 2001 22:47:30 +0000 Subject: Fix for bug 45164 - New users created by the admin were not subject to the userregexp for groupsets. Patch by Joe Robins r= jake@acutex.net --- editusers.cgi | 148 ++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 88 insertions(+), 60 deletions(-) (limited to 'editusers.cgi') diff --git a/editusers.cgi b/editusers.cgi index a38f86b3c..41240473e 100755 --- a/editusers.cgi +++ b/editusers.cgi @@ -129,55 +129,63 @@ sub EmitFormElements ($$$$$$) } - SendSQL("SELECT bit,name,description,bit & $groupset != 0, " . - " bit & $blessgroupset " . - "FROM groups " . - "WHERE bit & $opblessgroupset != 0 AND isbuggroup " . - "ORDER BY name"); - print "Group Access:"; - if (MoreSQLData()) { - if ($editall) { - print "\n"; - print "\n\n"; + if($user ne "") { + print "\n"; - - SendSQL("SELECT bit,name,description,bit & $groupset != 0, " . - " bit & $blessgroupset " . - "FROM groups " . - "WHERE bit & $opblessgroupset != 0 AND !isbuggroup " . - "ORDER BY name"); - print "\n"; + + print "
Can turn this bit on for other users
|
Group Access:"; + SendSQL("SELECT bit,name,description,bit & $groupset != 0, " . + " bit & $blessgroupset " . + "FROM groups " . + "WHERE bit & $opblessgroupset != 0 AND isbuggroup " . + "ORDER BY name"); + if (MoreSQLData()) { + if ($editall) { + print "\n"; + print "\n\n"; + } + print "\n"; } - print "\n"; - } - while (MoreSQLData()) { - my ($bit,$name,$description,$checked,$blchecked) = FetchSQLData(); - print "\n"; - if ($editall) { - $blchecked = ($blchecked) ? "CHECKED" : ""; - print ""; + while (MoreSQLData()) { + my ($bit,$name,$description,$checked,$blchecked) = FetchSQLData(); + print "\n"; + if ($editall) { + $blchecked = ($blchecked) ? "CHECKED" : ""; + print ""; + } + $checked = ($checked) ? "CHECKED" : ""; + print ""; + print "\n"; } - $checked = ($checked) ? "CHECKED" : ""; - print ""; - print "\n"; - } - print "
Can turn this bit on for other users
|User is a member of these groupsUser is a member of these groups
" . ucfirst($name) . ": $description" . ucfirst($name) . ": $description
Privileges:"; - if (MoreSQLData()) { - if ($editall) { - print "\n"; - print "\n\n"; + print "
Can turn this bit on for other users
|
Privileges:"; + SendSQL("SELECT bit,name,description,bit & $groupset != 0, " . + " bit & $blessgroupset " . + "FROM groups " . + "WHERE bit & $opblessgroupset != 0 AND !isbuggroup " . + "ORDER BY name"); + if (MoreSQLData()) { + if ($editall) { + print "\n"; + print "\n\n"; + } + print "\n"; } - print "\n"; - } - while (MoreSQLData()) { - my ($bit,$name,$description,$checked,$blchecked) = FetchSQLData(); - print "\n"; - if ($editall) { - $blchecked = ($blchecked) ? "CHECKED" : ""; - print ""; + while (MoreSQLData()) { + my ($bit,$name,$description,$checked,$blchecked) = FetchSQLData(); + print "\n"; + if ($editall) { + $blchecked = ($blchecked) ? "CHECKED" : ""; + print ""; + } + $checked = ($checked) ? "CHECKED" : ""; + print ""; + print "\n"; } - $checked = ($checked) ? "CHECKED" : ""; - print ""; - print "\n"; + } else { + print "\n"; @@ -445,13 +453,23 @@ if ($action eq 'new') { 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"; - foreach (keys %::FORM) { - next unless /^bit_/; - #print "$_=$::FORM{$_}
\n"; - $bits .= "+ $::FORM{$_}"; + my @grouplist = (); + SendSQL("select bit, name, userregexp from groups where userregexp != ''"); + while (MoreSQLData()) { + 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 SendSQL("INSERT INTO profiles ( " . @@ -467,7 +485,19 @@ if ($action eq 'new') { #+++ send e-mail away - print "OK, done.

\n"; + print "OK, done.
\n"; + if($#grouplist > -1) { + print "New user added to these groups based on group regexps:\n"; + print "

    \n"; + foreach (@grouplist) { + print "
  • $_
  • \n"; + } + print "
\n"; + } else { + print "New user not added to any groups.

\n"; + } + print "To change ${user}'s permissions, go back and edit this user"; + print "

\n"; PutTrailer($localtrailer, "add another user."); exit; @@ -518,18 +548,16 @@ if ($action eq 'del') { print "

\n"; print " \n"; print " \n"; -- cgit v1.2.1
Can turn this bit on for other users
|User has these privelegesUser has these priveleges
" . ucfirst($name) . ": $description" . ucfirst($name) . ": $description
Groups and
Priveleges:
"; + print "\n"; } print "
The new user will be inserted into groups " . + "based on their userregexps.
To change the group " . + "permissions for this user, you must edit the account after ". + "creating it.
Group set:"; - SendSQL("SELECT bit, name + SendSQL("SELECT name FROM groups - ORDER BY name"); + WHERE bit & $groupset = bit + ORDER BY isbuggroup, name"); my $found = 0; while ( MoreSQLData() ) { - my ($bit,$name) = FetchSQLData(); - my $cmpr = $bit & $groupset; - if ($cmpr) { - print "
\n" if $found; - print ucfirst $name; - $found = 1; - } + my ($name) = FetchSQLData(); + print "
\n" if $found; + print ucfirst $name; + $found = 1; } print "none" unless $found; print "