Skip to content

Commit

Permalink
Updated to allow for concurrent admin m1 and m2s to be handled more
Browse files Browse the repository at this point in the history
correctly

Added check for postanon use
  • Loading branch information
tvroom committed May 11, 2004
1 parent 4402079 commit 9fbb637
Showing 1 changed file with 70 additions and 54 deletions.
124 changes: 70 additions & 54 deletions themes/slashcode/htdocs/comments.pl
Expand Up @@ -943,6 +943,11 @@ sub validateComment {
$$error_message = getError('anonymous disallowed');
return;
}

if (!$user->{is_anon} && $form->{postanon} && $user->{karma} < 0) {
$$error_message = getError('postanon_option_disabled');
return
}

my $post_restrictions = $slashdb->getNetIDPostingRestrictions("subnetid", $user->{subnetid});
if (($user->{is_anon} || $form->{postanon}) && $constants->{allow_anonymous} && $post_restrictions->{no_anon}) {
Expand Down Expand Up @@ -1480,34 +1485,28 @@ sub moderate {
my $was_touched = 0;

my $meta_mods_performed = 0;
if ($user->{is_admin}) {
$meta_mods_performed = metaModerate();
}

if ($form->{meta_mod_only}) {
titlebar("100%", getData('metamoderating'));
print getData("metamoderate_message");
print getData("metamods_performed", { num => $meta_mods_performed }) if $meta_mods_performed;
return;
}
my $skip_moderation = $form->{meta_mod_only} || 0;

my $message = "";

if (!dbAvailable("write_comments")) {
print getError("comment_db_down");
return;
}

if (! $constants->{allow_moderation}) {
print getData('no_moderation');
return;
}



if ($discussion->{type} eq 'archived'
&& !$constants->{comments_moddable_archived}) {
print getData("metamods_performed", { num => $meta_mods_performed }) if $meta_mods_performed;
print getData('archive_error');
return;
$message .= getData('archive_error');
}

if (! $constants->{allow_moderation}) {
print getData("metamods_performed", { num => $meta_mods_performed }) if $meta_mods_performed;
print getData('no_moderation');
return;
}

my $total_deleted = 0;
my $hasPosted;
Expand All @@ -1519,51 +1518,68 @@ sub moderate {
&& $user->{seclev} >= $constants->{authors_unlimited})
|| $user->{acl}{modpoints_always};

slashDisplay('mod_header');
print getData("metamods_performed", { num => $meta_mods_performed }) if $meta_mods_performed;

# Handle Deletions, Points & Reparenting
# It would be nice to sort these by current score of the comments
# ascending, maybe also by val ascending, or some way to try to
# get the single-point-spends first and then to only do the
# multiple-point-spends if the user still has points.
my $can_del = ($constants->{authors_unlimited} && $user->{seclev} >= $constants->{authors_unlimited})
|| $user->{acl}{candelcomments_always};
for my $key (sort keys %{$form}) {
if ($can_del && $key =~ /^del_(\d+)$/) {
$total_deleted += deleteThread($sid, $1);
} elsif (!$hasPosted && $key =~ /^reason_(\d+)$/) {
my $cid = $1;
my $ret_val = $slashdb->moderateComment($sid, $cid, $form->{$key});
# If an error was returned, tell the user what
# went wrong.
if ($ret_val < 0) {
if ($ret_val == -1) {
print getError('no points');
} elsif ($ret_val == -2){
print getError('not enough points');
if($skip_moderation){
print $message;
if ($user->{is_admin}) {
$meta_mods_performed = metaModerate();
}
print getData("metamods_performed", { num => $meta_mods_performed }) if $meta_mods_performed;
return;
} else {
slashDisplay('mod_header');


# Handle Deletions, Points & Reparenting
# It would be nice to sort these by current score of the comments
# ascending, maybe also by val ascending, or some way to try to
# get the single-point-spends first and then to only do the
# multiple-point-spends if the user still has points.
my $can_del = ($constants->{authors_unlimited} && $user->{seclev} >= $constants->{authors_unlimited})
|| $user->{acl}{candelcomments_always};
for my $key (sort keys %{$form}) {
if ($can_del && $key =~ /^del_(\d+)$/) {
$total_deleted += deleteThread($sid, $1);
} elsif (!$hasPosted && $key =~ /^reason_(\d+)$/) {
my $cid = $1;
my $ret_val = $slashdb->moderateComment($sid, $cid, $form->{$key});
# If an error was returned, tell the user what
# went wrong.
if ($ret_val < 0) {
if ($ret_val == -1) {
print getError('no points');
} elsif ($ret_val == -2){
print getError('not enough points');
}
} else {
$was_touched += $ret_val;
}
} else {
$was_touched += $ret_val;
}
}
}
$slashdb->setDiscussionDelCount($sid, $total_deleted);
$was_touched = 1 if $total_deleted;
$slashdb->setDiscussionDelCount($sid, $total_deleted);
$was_touched = 1 if $total_deleted;

if ($user->{is_admin}) {
$meta_mods_performed = metaModerate();
}
print getData("metamods_performed", { num => $meta_mods_performed }) if $meta_mods_performed;

slashDisplay('mod_footer', {
metamod_elig => scalar $slashdb->metamodEligible($user),
});
slashDisplay('mod_footer', {
metamod_elig => scalar $slashdb->metamodEligible($user),
});

if ($hasPosted && !$total_deleted) {
print getError('already posted');
if ($hasPosted && !$total_deleted) {
print getError('already posted');

} elsif ($user->{seclev} && $total_deleted) {
slashDisplay('del_message', {
total_deleted => $total_deleted,
comment_count => $slashdb->countCommentsBySid($sid),
});
}

} elsif ($user->{seclev} && $total_deleted) {
slashDisplay('del_message', {
total_deleted => $total_deleted,
comment_count => $slashdb->countCommentsBySid($sid),
});
}

printComments($discussion, $form->{pid}, $form->{cid},
{ force_read_from_master => 1 } );

Expand Down

0 comments on commit 9fbb637

Please sign in to comment.