Update of /cvs/scoop/scoop/lib/Scoop/Admin
In directory lithium.sabren.com:/tmp/cvs-serv22167/lib/Scoop/Admin
Modified Files:
AdminStories.pm
Log Message:
Fix for bug #173 from Janra and Captain_Tenille --hulver
Index: AdminStories.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Admin/AdminStories.pm,v
retrieving revision 1.146
retrieving revision 1.147
diff -C2 -d -r1.146 -r1.147
*** AdminStories.pm 11 Feb 2005 22:11:04 -0000 1.146
--- AdminStories.pm 26 May 2005 11:02:21 -0000 1.147
***************
*** 130,134 ****
if ($sid && !$tmpsid) {
! $keys->{error} = $error;
warn "SID: Getting $sid for display" if $DEBUG;
--- 130,134 ----
if ($sid && !$tmpsid) {
! $keys->{error} = $error;
warn "SID: Getting $sid for display" if $DEBUG;
***************
*** 1274,1279 ****
if ( $S->{CGI}->param('mode') eq 'spam' ) {
# mark the spam vote if it occurred
! $message = qq|
! <br><B>Your vote was recorded for consideration.|;
$S->_update_story_votes($sid, $vote);
$S->_spam_check_story($sid);
--- 1274,1278 ----
if ( $S->{CGI}->param('mode') eq 'spam' ) {
# mark the spam vote if it occurred
! $message = $S->{UI}->{BLOCKS}->{story_spam_vote_msg};
$S->_update_story_votes($sid, $vote);
$S->_spam_check_story($sid);
***************
*** 1281,1288 ****
# update the story record, eh?
my ($curr_votes, $curr_score) = $S->_update_story_votes($sid, $vote);
! $message = qq|
! <br><B>Your vote ($vote) was recorded.<BR>This story currently has a total score of $curr_score.|;
! $message .= $S->_post_story($sid);
}
return $message;
--- 1280,1288 ----
# update the story record, eh?
my ($curr_votes, $curr_score) = $S->_update_story_votes($sid, $vote);
! $message = $S->{UI}->{BLOCKS}->{story_vote_msg};
! $message =~ s/%%vote%%/$vote/g;
! $message =~ s/%%curr_score%%/$curr_score/g;
! $message .= $S->_post_story($sid);
}
return $message;
***************
*** 1482,1493 ****
sub _post_story {
! my $S = shift;
! my $sid = shift;
! my ($votes, $score) = $S->_get_total_votes($sid);
! my $threshold = $S->{UI}->{VARS}->{post_story_threshold};
! my $hide_threshold = $S->{UI}->{VARS}->{hide_story_threshold};
my $stop_threshold = $S->{UI}->{VARS}->{end_voting_threshold} || -1;
!
my $msg;
my $num;
--- 1482,1493 ----
sub _post_story {
! my $S = shift;
! my $sid = shift;
! my ($votes, $score) = $S->_get_total_votes($sid);
! my $threshold = $S->{UI}->{VARS}->{post_story_threshold};
! my $hide_threshold = $S->{UI}->{VARS}->{hide_story_threshold};
my $stop_threshold = $S->{UI}->{VARS}->{end_voting_threshold} || -1;
!
my $msg;
my $num;
***************
*** 1503,1517 ****
if ($mod_rec->{vote} == 1) {
$for_votes++;
! } elsif ($mod_rec->{vote} == -1) {
$against_votes--;
! }
}
! } else {
! $for_votes = $score;
$against_votes = $score;
! }
!
! $sth->finish;
if ($for_votes >= $threshold && $dstat < 0) {
# figure out if this story should post to the section or
--- 1503,1519 ----
if ($mod_rec->{vote} == 1) {
$for_votes++;
! } elsif ($mod_rec->{vote} == -1) {
$against_votes--;
! }
}
! } else {
! $for_votes = $score;
$against_votes = $score;
! }
+ $sth->finish;
+
+ warn "(_post_story) score is: $score ($for_votes/$against_votes); thresholds are $threshold and $hide_threshold" if $DEBUG;
+ warn "(_post_story) dstat: $dstat; wstat: $wstat" if $DEBUG;
if ($for_votes >= $threshold && $dstat < 0) {
# figure out if this story should post to the section or
***************
*** 1526,1530 ****
});
! my $sec_votes = {};
while (my ($sec, $num) = $sth1->fetchrow) {
$sec_votes->{$sec} = $num;
--- 1528,1532 ----
});
! my $sec_votes = {};
while (my ($sec, $num) = $sth1->fetchrow) {
$sec_votes->{$sec} = $num;
***************
*** 1540,1581 ****
$S->{UI}->{VARS}->{front_page_ratio} ||= 0.5;
! if( $ratio < $S->{UI}->{VARS}->{front_page_ratio}) {
$ws = -2;
$ds = 1;
$where = "Section";
! } else {
$ws = 0;
$ds = 0;
$where = "front";
! }
! # Post the story
! my $rv = $S->story_post_write($ds, $ws, $sid);
$S->run_hook('story_post', $sid, $where);
if ($rv) {
! $msg = qq|
! <P><B>You're the straw that broke the camel's back!</B><BR>Your vote put this story over the threshold, and it should now appear on the $where page. Enjoy!|;
}
# Send e-mail to the author
! $S->_send_story_mail($sid, 'posted')
! if ($S->{UI}->{VARS}->{notify_author} == 1);
! # END: if ($for_votes >= $threshold && $dstat < 0 && $wstat < 0) {
} elsif ($for_votes >= $threshold && $dstat >= 0 && $wstat >= 0) {
! $msg = qq|
! <P><B>This story has already been posted. It must have gone up while you were voting. Thanks for your vote anyway!</B>|;
! } elsif ($against_votes == $hide_threshold && $dstat < 0 && $wstat < 0) {
#Story is now hidden
my $rv = $S->story_post_write('-1', '-1', $sid);
$S->run_hook('story_hide', $sid);
! $S->_send_story_mail($sid, 'hidden') if($S->{UI}->{VARS}->{notify_author} == 1);
# This will activate the default (max_votes based) auto-clear
--- 1542,1583 ----
$S->{UI}->{VARS}->{front_page_ratio} ||= 0.5;
! if( $ratio < $S->{UI}->{VARS}->{front_page_ratio}) {
$ws = -2;
$ds = 1;
$where = "Section";
! } else {
$ws = 0;
$ds = 0;
$where = "front";
! }
! # Post the story
! my $rv = $S->story_post_write($ds, $ws, $sid);
$S->run_hook('story_post', $sid, $where);
if ($rv) {
! $msg = $S->{UI}->{BLOCKS}->{story_post_message};
! $msg =~ s/%%where%%/$where/;
}
# Send e-mail to the author
! $S->_send_story_mail($sid, 'posted') if ($S->{UI}->{VARS}->{notify_author} == 1);
! # END: if ($for_votes >= $threshold && $dstat < 0)
} elsif ($for_votes >= $threshold && $dstat >= 0 && $wstat >= 0) {
! $msg = $S->{UI}->{BLOCKS}->{story_already_post_msg};
! } elsif ($against_votes == $hide_threshold && $dstat < -1) {
#Story is now hidden
+ warn "(_post_story) hiding story $sid" if $DEBUG;
my $rv = $S->story_post_write('-1', '-1', $sid);
$S->run_hook('story_hide', $sid);
! $S->_send_story_mail($sid, 'hidden') if ($S->var('notify_author') == 1);
! $msg = $S->{UI}->{BLOCKS}->{story_dumped_message};
# This will activate the default (max_votes based) auto-clear
***************
*** 1651,1666 ****
$rv = $S->story_post_write($ds, $ws, $sid);
my $status = ($ds != -1) ? 'posted' : 'hidden';
! my $path = $S->{UI}->{VARS}->{rootdir};
! my $url = "http://$S->{SERVER_NAME}$path/?op=displaystory;sid=$sid";
if ($vote_score && $comment_score) {
$msg = "Vote score: $vote_score, Comment score: $comment_score, Avg: $avg";
}
# temp admin alert
! $S->admin_alert("Story auto-$status: story: $url, $msg") if ($S->{UI}->{VARS}->{auto_post_alert});
# Send e-mail to the author
if ($rv) {
! $S->_send_story_mail($sid, $status) if($S->{UI}->{VARS}->{notify_author} == 1);
! return "<P><B>You were the last vote. We've considered the votes and comments, and decided the story should be $status. Thank you!</B></P>";
}
return '';
--- 1653,1670 ----
$rv = $S->story_post_write($ds, $ws, $sid);
my $status = ($ds != -1) ? 'posted' : 'hidden';
! my $path = $S->var('rootdir');
! my $url = "http://$S->{SERVER_NAME}$path/story/$sid";
if ($vote_score && $comment_score) {
$msg = "Vote score: $vote_score, Comment score: $comment_score, Avg: $avg";
}
# temp admin alert
! $S->admin_alert("Story auto-$status: story: $url, $msg") if ($S->var('auto_post_alert'));
# Send e-mail to the author
if ($rv) {
! $S->_send_story_mail($sid, $status) if($S->var('notify_author') == 1);
! my $returnmsg = $S->{UI}->{BLOCKS}->{story_autopost_message};
! $returnmsg =~ s/%%status%%/$status/;
! return $returnmsg;
}
return '';