From 43ad961f703d8f6b93f105c991b894615ffab988 Mon Sep 17 00:00:00 2001 From: Jamie McCarthy Date: Sat, 7 Sep 2002 18:30:17 +0000 Subject: [PATCH] users.pl editComm reason modifiers were broken before, are fixed now. Debugging prints removed from a daily task. And the eligible mod list slightly randomized to help ensure fairness. --- Slash/DB/Static/MySQL/MySQL.pm | 8 +++++--- themes/slashcode/htdocs/users.pl | 30 +++++++++++++++++------------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Slash/DB/Static/MySQL/MySQL.pm b/Slash/DB/Static/MySQL/MySQL.pm index 5618d9721..da2ee87f6 100644 --- a/Slash/DB/Static/MySQL/MySQL.pm +++ b/Slash/DB/Static/MySQL/MySQL.pm @@ -436,7 +436,6 @@ sub updateLastaccess { { lastaccess => $day }, "uid IN ($uids_in)" ); -print STDERR "lastaccess set from lastclick to $day for $uids_in\n"; } } else { my @gmt = gmtime(time-86400); @@ -453,7 +452,6 @@ print STDERR "lastaccess set from lastclick to $day for $uids_in\n"; { lastaccess => $yesterday }, "uid IN ($uids_in) AND lastaccess < '$yesterday'" ); -print STDERR "lastaccess set from accesslog to $yesterday for $uids_in\n"; } } @@ -802,6 +800,10 @@ sub getAccessLogInfo { ######################################################## # For run_moderatord.pl +# New as of 2002/09/05: returns ordered first by hitcount, and +# second randomly, so when give_out_tokens() chops off the list +# halfway through the minimum number of clicks, the survivors +# are determined at random and not by (probably) uid order. sub fetchEligibleModerators { my($self) = @_; my $constants = getCurrentStatic(); @@ -825,7 +827,7 @@ sub fetchEligibleModerators { AND karma >= 0", "GROUP BY users_info.uid HAVING c >= $hitcount - ORDER BY c"); + ORDER BY c, RAND()"); return $returnable; } diff --git a/themes/slashcode/htdocs/users.pl b/themes/slashcode/htdocs/users.pl index b43b1bcbb..d99c7d71b 100755 --- a/themes/slashcode/htdocs/users.pl +++ b/themes/slashcode/htdocs/users.pl @@ -1399,20 +1399,22 @@ sub editComm { $fieldkey = 'uid'; } - my @reasons = (); - @reasons = @{$constants->{reasons}} - if $constants->{reasons} and ref($constants->{reasons}) eq 'ARRAY'; + my @reasons = ( ); + my $reasons = $slashdb->getReasons(); + for my $id (sort { $a <=> $b } keys %$reasons) { + push @reasons, $reasons->{$id}{name}; + } my %reason_select; my $hi = $constants->{comment_maxscore} - $constants->{comment_minscore}; my $lo = -$hi; - # And this was wrong, see we display +3 not 3. So the display was a bit off :) - my @range = map { $_ > 0 ? '+' . $_ : $_ } ($lo .. $hi); + my @range = map { $_ > 0 ? "+$_" : $_ } ($lo .. $hi); - for (@reasons) { - my $key = "reason_alter_$_"; - $reason_select{$_} = createSelect($key, \@range, + for my $reason_name (@reasons) { + my $key = "reason_alter_$reason_name"; + $reason_select{$reason_name} = createSelect( + $key, \@range, $user_edit->{$key} || 0, 1, 1 ); } @@ -1935,12 +1937,14 @@ sub saveComm { ? $form->{textarea_cols} : undef), }; - my @reasons = (); - @reasons = @{$constants->{reasons}} - if $constants->{reasons} and ref($constants->{reasons}) eq 'ARRAY'; + my @reasons = ( ); + my $reasons = $slashdb->getReasons(); + for my $id (sort { $a <=> $b } keys %$reasons) { + push @reasons, $reasons->{$id}{name}; + } - for (@reasons) { - my $key = "reason_alter_$_"; + for my $reason_name (@reasons) { + my $key = "reason_alter_$reason_name"; my $answer = $form->{$key}; $answer = 0 if $answer !~ /^[\-+]?\d+$/; $users_comments_table->{$key} = ($answer == 0) ? '' : $answer;