Update of /cvs/scoop/scoop/lib/Scoop/Admin
In directory lithium.sabren.com:/tmp/cvs-serv7737/lib/Scoop/Admin

Modified Files:
	AdminStories.pm 
Log Message:
Checking in hillct's misc. error fix patch. -ct


Index: AdminStories.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Admin/AdminStories.pm,v
retrieving revision 1.150
retrieving revision 1.151
diff -C2 -d -r1.150 -r1.151
*** AdminStories.pm	13 Jan 2006 21:14:10 -0000	1.150
--- AdminStories.pm	8 Feb 2006 03:42:02 -0000	1.151
***************
*** 604,610 ****
  	my $bodytext = $params{bodytext};
  
! 	if (exists($S->{UI}->{VARS}->{use_macros}) && $S->{UI}->{VARS}->{use_macros}
! 		&& defined($S->{UI}->{VARS}->{macro_render_on_save})
! 		&& $S->{UI}->{VARS}->{macro_render_on_save}) {
  		$introtext = $S->process_macros($introtext,'intro');
  		$bodytext = $S->process_macros($bodytext,'body');
--- 604,608 ----
  	my $bodytext = $params{bodytext};
  
! 	if ( $S->var('use_macros') && $S->var('macro_render_on_save') ) {
  		$introtext = $S->process_macros($introtext,'intro');
  		$bodytext = $S->process_macros($bodytext,'body');
***************
*** 643,651 ****
  			WHERE => qq|sid = $q_sid|});
  
  		$S->run_hook('story_update', $sid);
  	} else {
  		$sid = $S->make_new_sid();
  	
! 		if( $params{op} eq 'submitstory' && $params{section} ne 'Diary' && $S->{UI}->{VARS}->{post_story_threshold} == 0 ) {
  			$params{displaystatus} = "0";
  			$params{writestatus} = "0";
--- 641,651 ----
  			WHERE => qq|sid = $q_sid|});
  
+ 		# Save story tags, if we're using them
+ 		$S->save_tags($sid, $params{'tags'}) if $S->var('use_tags');
  		$S->run_hook('story_update', $sid);
  	} else {
  		$sid = $S->make_new_sid();
  	
! 		if( $params{op} eq 'submitstory' && $params{section} ne 'Diary' && !$S->var('post_story_threshold') ) {
  			$params{displaystatus} = "0";
  			$params{writestatus} = "0";
***************
*** 670,683 ****
  			VALUES => qq|$q_sid, $q_tid, $params{aid}, $title, $dept, '$time', $introtext, $bodytext, $section, $params{displaystatus}, $commentstatus, $edit_category|});
  
  		$S->run_hook('story_new', $sid);
  	}
  	$sth->finish;
  
- 
- 	# Save story tags, if we're using them
- 	if ($S->var('use_tags')) {
- 		$S->save_tags($sid, $params{'tags'});
- 	}
- 
  	# don't try to write a poll if they aren't allowed to 
  	# they must have attach_poll perms
--- 670,679 ----
  			VALUES => qq|$q_sid, $q_tid, $params{aid}, $title, $dept, '$time', $introtext, $bodytext, $section, $params{displaystatus}, $commentstatus, $edit_category|});
  
+ 		# Save story tags, if we're using them
+ 		$S->save_tags($sid, $params{'tags'}) if $S->var('use_tags');
  		$S->run_hook('story_new', $sid);
  	}
  	$sth->finish;
  
  	# don't try to write a poll if they aren't allowed to 
  	# they must have attach_poll perms
***************
*** 731,737 ****
  
  	$form_values->{allowed_html_intro} = $S->html_checker->allowed_html_as_string('intro')
! 		if $mode ne 'full' && (!$S->{UI}->{VARS}->{hide_story_allowed_html});
  	$form_values->{allowed_html_body} = $S->html_checker->allowed_html_as_string('body')
! 		if $mode ne 'full' && (!$S->{UI}->{VARS}->{hide_story_allowed_html});
  
  	
--- 727,733 ----
  
  	$form_values->{allowed_html_intro} = $S->html_checker->allowed_html_as_string('intro')
! 		if $mode ne 'full' && !$S->var('hide_story_allowed_html');
  	$form_values->{allowed_html_body} = $S->html_checker->allowed_html_as_string('body')
! 		if $mode ne 'full' && !$S->var('hide_story_allowed_html');
  
  	
***************
*** 778,782 ****
  	
  	if ($mode eq 'full') {
! 		if ($S->{UI}->{VARS}->{use_edit_categories} ) {
  			$form_values->{edit_category_select} = $S->edit_category_select($story_data->{edit_category});}
  		#Not deleting this line quite yet in case someone needs it
--- 774,778 ----
  	
  	if ($mode eq 'full') {
! 		if ($S->var('use_edit_categories') ) {
  			$form_values->{edit_category_select} = $S->edit_category_select($story_data->{edit_category});}
  		#Not deleting this line quite yet in case someone needs it
***************
*** 844,848 ****
  	$form_values->{title} = $story_data->{title};
  
! 	if ($S->{UI}->{VARS}->{show_dept}) {
  		$form_values->{dept} = $S->{UI}->{BLOCKS}->{story_edit_dept};
  		$form_values->{dept} =~ s/%%dept%%/$story_data->{dept}/g;
--- 840,844 ----
  	$form_values->{title} = $story_data->{title};
  
! 	if ($S->var('show_dept')) {
  		$form_values->{dept} = $S->{UI}->{BLOCKS}->{story_edit_dept};
  		$form_values->{dept} =~ s/%%dept%%/$story_data->{dept}/g;
***************
*** 920,929 ****
  	my $selected= '';
  	
! 	return '' unless $S->{UI}->{VARS}->{use_topics};
  	
  	# Check for diary
! 	my $section = $S->{CGI}->param('section');
! 	my $sid = $S->{CGI}->param('sid');
! 	if (!$S->{UI}->{VARS}->{diary_topics}) {
  		if ($S->have_perm('story_admin') && $sid) {
  			warn "SID is $sid\n" if $DEBUG;
--- 916,925 ----
  	my $selected= '';
  	
! 	return '' unless $S->var('use_topics');
  	
  	# Check for diary
! 	my $section = $S->cgi->param('section');
! 	my $sid = $S->cgi->param('sid');
! 	if (!$S->var('diary_topics')) {
  		if ($S->have_perm('story_admin') && $sid) {
  			warn "SID is $sid\n" if $DEBUG;
***************
*** 949,953 ****
  	if ($rv ne '0E0') {
  		while (my $topic = $sth->fetchrow_hashref) {
! 			next if (($topic->{tid} eq 'diary') && (!$S->{UI}->{VARS}->{diary_topics}));
  
  			if (($topic->{tid} eq $tid) || (($tid eq '') && ($topic->{tid} eq 'diary') && ($section eq 'Diary'))) {
--- 945,949 ----
  	if ($rv ne '0E0') {
  		while (my $topic = $sth->fetchrow_hashref) {
! 			next if (($topic->{tid} eq 'diary') && !$S->var('diary_topics'));
  
  			if (($topic->{tid} eq $tid) || (($tid eq '') && ($topic->{tid} eq 'diary') && ($section eq 'Diary'))) {
***************
*** 1031,1035 ****
  	my $S = shift;
  	my $tmpstat = shift; # || $S->{UI}->{VARS}->{default_displaystatus};
! 	my $stat = (defined($tmpstat))? $tmpstat : $S->{UI}->{VARS}->{default_displaystatus};
  	# have to test if $tmpstat is defined; if it's zero (front page) it used the var
  	my $selected= '';
--- 1027,1031 ----
  	my $S = shift;
  	my $tmpstat = shift; # || $S->{UI}->{VARS}->{default_displaystatus};
! 	my $stat = (defined($tmpstat))? $tmpstat : $S->var('default_displaystatus');
  	# have to test if $tmpstat is defined; if it's zero (front page) it used the var
  	my $selected= '';
***************
*** 1075,1079 ****
  		while (my $status = $sth->fetchrow_hashref) {
  			my $selected = '';
! 			my $default = $S->{UI}->{VARS}->{default_commentstatus};
  			if (defined($stat) && ($status->{code} == $stat)) {
  				$selected = ' SELECTED';
--- 1071,1075 ----
  		while (my $status = $sth->fetchrow_hashref) {
  			my $selected = '';
! 			my $default = $S->var('default_commentstatus');
  			if (defined($stat) && ($status->{code} == $stat)) {
  				$selected = ' SELECTED';
***************
*** 1125,1129 ****
  	my $section_siblings = {};
  	
! 	if ($S->{UI}->{VARS}->{restrict_story_submit_to_subsect}) {
  		if ($op eq 'admin') {
  
--- 1121,1125 ----
  	my $section_siblings = {};
  	
! 	if ($S->var('restrict_story_submit_to_subsect')) {
  		if ($op eq 'admin') {
  
***************
*** 1165,1169 ****
  	
  	# Put the parent section up front, as a choice
! 	if ($S->{UI}->{VARS}->{restrict_story_submit_to_subsect} && $op eq 'submitstory' && !$no_perm_hash->{ $parent }) {
  		my $selected = (!$sec || $parent eq $sec) ? ' SELECTED' : '';
  		$section_select .= qq|
--- 1161,1165 ----
  	
  	# Put the parent section up front, as a choice
! 	if ($S->var('restrict_story_submit_to_subsect') && $op eq 'submitstory' && !$no_perm_hash->{ $parent }) {
  		my $selected = (!$sec || $parent eq $sec) ? ' SELECTED' : '';
  		$section_select .= qq|
***************
*** 1176,1181 ****
  		next if ($key eq 'Diary');
  		next if ( $no_perm_hash->{ $key } );
! 		next if ($S->{UI}->{VARS}->{restrict_story_submit_to_subsect} && $op eq 'admin' && !$section_siblings->{$key});
! 		next if ($S->{UI}->{VARS}->{restrict_story_submit_to_subsect} && $op eq 'submitstory' && !$S->{SECTION_DATA}->{$parent}->{children}->{$key});
  		 
  		my $section = $S->{SECTION_DATA}->{$key};
--- 1172,1177 ----
  		next if ($key eq 'Diary');
  		next if ( $no_perm_hash->{ $key } );
! 		next if ($S->var('restrict_story_submit_to_subsect') && $op eq 'admin' && !$section_siblings->{$key});
! 		next if ($S->var('restrict_story_submit_to_subsect') && $op eq 'submitstory' && !$S->{SECTION_DATA}->{$parent}->{children}->{$key});
  		 
  		my $section = $S->{SECTION_DATA}->{$key};
***************
*** 1448,1452 ****
  	my $sid = shift;
  
! 	return unless $S->{UI}->{VARS}->{use_anti_spam};
  
  	# Double check story's current status
--- 1444,1448 ----
  	my $sid = shift;
  
! 	return unless $S->var('use_anti_spam');
  
  	# Double check story's current status
***************
*** 1455,1460 ****
  	return unless ($dstat == -3);
  
! 	my $votes_threshold = $S->{UI}->{VARS}->{spam_votes_threshold};
! 	my $spam_percent 	= $S->{UI}->{VARS}->{spam_votes_percentage};
  	
  	my ($spam_votes, $dummy)= $S->_get_total_votes($sid);
--- 1451,1456 ----
  	return unless ($dstat == -3);
  
! 	my $votes_threshold	= $S->var('spam_votes_threshold');
! 	my $spam_percent	= $S->var('spam_votes_percentage');
  	
  	my ($spam_votes, $dummy)= $S->_get_total_votes($sid);
***************
*** 1500,1506 ****
  	
  	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;
--- 1496,1502 ----
  	
  	my ($votes, $score) = $S->_get_total_votes($sid);
! 	my $threshold		= $S->var('post_story_threshold');
! 	my $hide_threshold	= $S->var('hide_story_threshold');
! 	my $stop_threshold	= $S->var('end_voting_threshold') || -1;
  
  	my $msg;
***************
*** 1513,1517 ****
  	# Aha!  Wizardry.  If they want the 'old' scoring then we use $score
  
! 	if ( $S->{UI}->{VARS}->{use_alternate_scoring} ) {
  		while (my $mod_rec = $sth->fetchrow_hashref) {
  			if ($mod_rec->{vote} == 1) {
--- 1509,1513 ----
  	# Aha!  Wizardry.  If they want the 'old' scoring then we use $score
  
! 	if ( $S->var('use_alternate_scoring') ) {
  		while (my $mod_rec = $sth->fetchrow_hashref) {
  			if ($mod_rec->{vote} == 1) {