Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changes to make moderatorlog aware that a moderation has actually been

performed since there are cases when we do wish to log moderation but
NOT have it made active. (as is the case with moderating a comment when
it is already at the maximum or minimum score - we still want those
moderations subject to M2).

All scripts dealing with moderatorlog EXCEPT for metamod.pl are now aware
of this change. Metamod.pl shouldn't need to be changed for this issue.

Future changes to metamod.pl are expected, however.
  • Loading branch information...
commit fb0ab7de1c89d67444160d493ad8ff31a56e3c87 1 parent 2adae37
@Xliff Xliff authored
View
3  Slash.pm
@@ -2026,7 +2026,8 @@ sub moderatorCommentLog {
moderatorlog.val as val,
moderatorlog.reason as reason",
"moderatorlog, users, comments",
- "moderatorlog.sid='$sid'
+ "moderatorlog.active=1
+ AND moderatorlog.sid='$sid'
AND moderatorlog.cid=$cid
AND moderatorlog.uid=users.uid
AND comments.sid=moderatorlog.sid
View
5 public_html/article.pl
@@ -111,7 +111,8 @@ sub moderatorLog {
subject, moderatorlog.uid as uid,
users.nickname as nickname,
moderatorlog.val as val,
- moderatorlog.reason as reason",
+ moderatorlog.reason as reason,
+ moderatorlog.active as active",
"moderatorlog, users, comments",
"moderatorlog.sid='$S->{sid}'
AND moderatorlog.uid=users.uid
@@ -127,6 +128,7 @@ sub moderatorLog {
<TH><FONT COLOR="$I{fg}[3]"> reason </FONT></TH>
<TH><FONT COLOR="$I{fg}[3]"> moderator </FONT></TH>
<TH><FONT COLOR="$I{fg}[3]"> comment </FONT></TH>
+ <TH><FONT COLOR="$I{fg}[3]"> active </FONT></TH>
</TR>
EOT
@@ -138,6 +140,7 @@ sub moderatorLog {
<TD> $I{reasons}[$C->{reason}] </TD>
<TD> $C->{nickname} ($C->{uid}) </TD>
<TD><A HREF="$I{rootdir}/comments.pl?sid=$S->{sid}&cid=$C->{cid}">$C->{subject}</A></TD>
+ <TD> $C->{active} </TD>
</TR>
EOT
View
20 public_html/comments.pl
@@ -833,14 +833,16 @@ sub moderateCid {
# If the resulting score is out of comment score range, no further actions
# need be performed.
if ($scorecheck < $I{comment_minscore} || $scorecheck > $I{comment_maxscore}) {
- # We should still log the attempt.
+ # We should still log the attempt for M2, but marked as inactive so
+ # we don't mistakenly undo it.
sqlInsert("moderatorlog", {
uid => $I{U}{uid},
val => $val,
sid => $sid,
cid => $cid,
reason => $modreason,
- -ts => 'now()'
+ -ts => 'now()',
+ active => 0
});
print "<LI>$subj ($sid-$cid, <B>Comment already at limit</B>)</LI>";
@@ -941,16 +943,22 @@ sub hasPosted {
sub undoModeration {
my($sid) = @_;
return if $I{U}{uid} == -1 || ($I{U}{aseclev} > 99 && $I{authors_unlimited});
- my $c=sqlSelectMany("cid,val", "moderatorlog",
+ my $c=sqlSelectMany("cid,val,active", "moderatorlog",
"uid=$I{U}{uid} and sid=" . $I{dbh}->quote($sid)
);
- while (my($cid, $val) = $c->fetchrow) {
+ while (my($cid, $val, $active) = $c->fetchrow) {
+ # We undo moderation even for inactive records (but silently for
+ # inactive records)
$I{dbh}->do("delete from moderatorlog where
cid=$cid and uid=$I{U}{uid} and sid=" .
$I{dbh}->quote($sid)
);
+ # If moderation wasn't actually performed, we should not change
+ # the score.
+ next if ! $active;
+
# Insure scores still fall within the proper boundaries
my $scorelogic = $val < 0 ? "points < $I{comment_maxscore}" :
"points > $I{comment_minscore}";
@@ -976,7 +984,7 @@ sub isTroll {
# Anonymous only checks HOST
($badIP) = sqlSelect("sum(val)","comments,moderatorlog",
"comments.sid=moderatorlog.sid AND comments.cid=moderatorlog.cid
- AND host_name='$ENV{REMOTE_ADDR}'
+ AND host_name='$ENV{REMOTE_ADDR}' AND moderatorlog.active=1
AND (to_days(now()) - to_days(ts) < 3) GROUP BY host_name"
);
@@ -985,7 +993,7 @@ sub isTroll {
if ($I{U}{uid} > 0) {
($badUID) = sqlSelect("sum(val)","comments,moderatorlog",
"comments.sid=moderatorlog.sid AND comments.cid=moderatorlog.cid
- AND comments.uid=$I{U}{uid}
+ AND comments.uid=$I{U}{uid} AND moderatorlog.active=1
AND (to_days(now()) - to_days(ts) < 3) GROUP BY comments.uid"
);
}
View
1  sql/updates/1.0.6/db_update.sql
@@ -0,0 +1 @@
+ALTER TABLE moderatorlog ADD column active int(1) DEFAULT 1;
View
5 themes/slashcode/htdocs/article.pl
@@ -111,7 +111,8 @@ sub moderatorLog {
subject, moderatorlog.uid as uid,
users.nickname as nickname,
moderatorlog.val as val,
- moderatorlog.reason as reason",
+ moderatorlog.reason as reason,
+ moderatorlog.active as active",
"moderatorlog, users, comments",
"moderatorlog.sid='$S->{sid}'
AND moderatorlog.uid=users.uid
@@ -127,6 +128,7 @@ sub moderatorLog {
<TH><FONT COLOR="$I{fg}[3]"> reason </FONT></TH>
<TH><FONT COLOR="$I{fg}[3]"> moderator </FONT></TH>
<TH><FONT COLOR="$I{fg}[3]"> comment </FONT></TH>
+ <TH><FONT COLOR="$I{fg}[3]"> active </FONT></TH>
</TR>
EOT
@@ -138,6 +140,7 @@ sub moderatorLog {
<TD> $I{reasons}[$C->{reason}] </TD>
<TD> $C->{nickname} ($C->{uid}) </TD>
<TD><A HREF="$I{rootdir}/comments.pl?sid=$S->{sid}&cid=$C->{cid}">$C->{subject}</A></TD>
+ <TD> $C->{active} </TD>
</TR>
EOT
View
20 themes/slashcode/htdocs/comments.pl
@@ -833,14 +833,16 @@ sub moderateCid {
# If the resulting score is out of comment score range, no further actions
# need be performed.
if ($scorecheck < $I{comment_minscore} || $scorecheck > $I{comment_maxscore}) {
- # We should still log the attempt.
+ # We should still log the attempt for M2, but marked as inactive so
+ # we don't mistakenly undo it.
sqlInsert("moderatorlog", {
uid => $I{U}{uid},
val => $val,
sid => $sid,
cid => $cid,
reason => $modreason,
- -ts => 'now()'
+ -ts => 'now()',
+ active => 0
});
print "<LI>$subj ($sid-$cid, <B>Comment already at limit</B>)</LI>";
@@ -941,16 +943,22 @@ sub hasPosted {
sub undoModeration {
my($sid) = @_;
return if $I{U}{uid} == -1 || ($I{U}{aseclev} > 99 && $I{authors_unlimited});
- my $c=sqlSelectMany("cid,val", "moderatorlog",
+ my $c=sqlSelectMany("cid,val,active", "moderatorlog",
"uid=$I{U}{uid} and sid=" . $I{dbh}->quote($sid)
);
- while (my($cid, $val) = $c->fetchrow) {
+ while (my($cid, $val, $active) = $c->fetchrow) {
+ # We undo moderation even for inactive records (but silently for
+ # inactive records)
$I{dbh}->do("delete from moderatorlog where
cid=$cid and uid=$I{U}{uid} and sid=" .
$I{dbh}->quote($sid)
);
+ # If moderation wasn't actually performed, we should not change
+ # the score.
+ next if ! $active;
+
# Insure scores still fall within the proper boundaries
my $scorelogic = $val < 0 ? "points < $I{comment_maxscore}" :
"points > $I{comment_minscore}";
@@ -976,7 +984,7 @@ sub isTroll {
# Anonymous only checks HOST
($badIP) = sqlSelect("sum(val)","comments,moderatorlog",
"comments.sid=moderatorlog.sid AND comments.cid=moderatorlog.cid
- AND host_name='$ENV{REMOTE_ADDR}'
+ AND host_name='$ENV{REMOTE_ADDR}' AND moderatorlog.active=1
AND (to_days(now()) - to_days(ts) < 3) GROUP BY host_name"
);
@@ -985,7 +993,7 @@ sub isTroll {
if ($I{U}{uid} > 0) {
($badUID) = sqlSelect("sum(val)","comments,moderatorlog",
"comments.sid=moderatorlog.sid AND comments.cid=moderatorlog.cid
- AND comments.uid=$I{U}{uid}
+ AND comments.uid=$I{U}{uid} AND moderatorlog.active=1
AND (to_days(now()) - to_days(ts) < 3) GROUP BY comments.uid"
);
}
Please sign in to comment.
Something went wrong with that request. Please try again.