Description:
erases all of a user's comments, ratings, stories, etc, and anonymizes the account. Intended for spammers. Put this box on the user info page.
Box Code:
return unless $S->have_perm('edit_user');
my $uid = $S->cgi->param('uid');
my $nick = $S->cgi->param('nick');
unless ($uid) {
$uid = $S->get_uid_from_nick($nick);
}
my $erase = $S->cgi->param('erase');
my $confirm = $S->cgi->param('confirm');
#warn "Nick is: $nick, uid is $uid\n";
return unless ($uid);
my $return;
if ($erase && $confirm && $uid) {
$return = "Erasing $nick...<br>";
# First, wipe user ratings
$S->undo_user_ratings($uid);
$return .= 'Wiped ratings...<br>';
# Make anonymous
my ($rv, $sth) = $S->db_update({
WHAT => "users",
SET => qq{perm_group = "Anonymous"},
WHERE => "uid = $uid"});
$sth->finish();
$return .= 'Anonymized account...<br>';
# Remove all comments
($rv, $sth) = $S->db_select({
WHAT => 'sid, cid, pid',
FROM => 'comments',
WHERE => "uid = $uid"});
my $i = 0;
my ($sid, $cid, $pid) = $sth->fetchrow();
while ($cid) {
$i++;
$S->_delete_comment($sid, $cid, $pid);
($sid, $cid, $pid) = $sth->fetchrow();
}
$sth->finish();
$return .= "Erased $i comments...<br>";
# Hide stories
($rv, $sth) = $S->db_update({
WHAT => 'stories',
SET => "displaystatus = '-1'",
WHERE => "aid = $uid"
});
$return .= "Hid all stories...<br>";
$return .= "Done.";
} else {
#my $urlnick = $S->urlify($nick);
$return = qq{
<form name="eraseuser" method="GET" action="|rootdir|/erase">|norm_font|
<input type="hidden" name="nick" value="$nick">
<input type="submit" name="erase" value="Erase $nick">
<input type="checkbox" name="confirm"> Are you sure?
|norm_font_end|</form>};
}
return $return;
|