capability class management\n"; $ret .= "
"; $ret .= "Modify capabilities for user: "; $ret .= "
"; return $ret; } if ($mode eq "save") { return "Error: requires post" unless (LJ::did_post()); return"Error: You don't have access to change a user's capability class." unless (LJ::check_priv($remote, "admin", "*")); unless ($u) { $ret .= "Unknown user.\n"; return $ret; } my @cap_add = (); my @cap_del = (); my $newcaps = $u->{caps}; foreach my $n (sort { $a <=> $b } keys %LJ::CAP) { if ($FORM{"class_$n"}) { push @cap_add, $n; $newcaps |= (1 << $n); } else { push @cap_del, $n; $newcaps &= ~(1 << $n); } } # note which caps were changed and log $logmsg to statushistory my $add_txt = join(",", @cap_add); my $del_txt = join(",", @cap_del); LJ::statushistory_add($u->{'userid'}, $remote->{'userid'}, "capedit", "add: $add_txt, del: $del_txt\n"); LJ::modify_caps($u, \@cap_add, \@cap_del) or return"Error: Unable to modify caps."; # $u->{caps} is now updated in memory for later in this request $u->{caps} = $newcaps; $ret .= "Saved."; $mode = "viewuser"; } if ($mode eq "viewuser") { $ret .= "

<< edit user '$user'

\n"; unless ($u) { $ret .= "Unknown user.\n"; return $ret; } $ret .= "
"; $ret .= "\n"; $ret .= "\n"; foreach my $n (sort { $a <=> $b } keys %LJ::CAP) { my $on = ($u->{'caps'}+0) & (1 << $n); my $checked = $on ? " checked='1'" : ""; $ret .= "

"; my $name = $LJ::CAP{$n}->{'_name'} || "Unnamed capability class \#$n"; if ($on) { $ret .= ""; } $ret .= ""; if ($on) { $ret .= ""; } } $ret .= "

\n"; $ret .= "

"; return $ret; } return "Unknown mode."; _code?> lib: cgi-bin/ljlib.pl form: htdocs/admin/capedit.bml post: htdocs/admin/capedit.bml