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

Modified Files:
	AdminStories.pm Groups.pm Polls.pm 
Log Message:
Move story posting form into blocks. Also moves the part of the poll form where it makes sense into blocks, since it's part of story 
posting. Adds an "edit_own_stories" perm that you can enable for users if you want them to be able to edit their own stuff after posting. 
And finally changes admin tools semantics to allow multiple perms per admin tool. The admin tools box right now only respects the first 
perm listed when it makes the tools list, to preserve the traditional behavior of that box. In the long run, this will need to be 
fixed. Also, it may be advantageous eventually to add an "edit" perm category to sections, to enable editing of some sections but not 
others.

--rusty



Index: Polls.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Admin/Polls.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** Polls.pm	2 Jul 2004 21:05:58 -0000	1.16
--- Polls.pm	3 Feb 2005 15:48:30 -0000	1.17
***************
*** 304,308 ****
  	# and fill in with correct values
  	my ($tmp_content, $qid_not_used) = $S->_make_edit_input("normal",$editqid);
! 	$content .= $tmp_content;
  
  	# Make the answer area, and fill in with correct values
--- 304,310 ----
  	# and fill in with correct values
  	my ($tmp_content, $qid_not_used) = $S->_make_edit_input("normal",$editqid);
! 	# FIXME: html in code here. I'm not fixing it because I already have enough 
! 	# changes in this particular patch. --R
! 	$content .= qq|<TR><TD>%%norm_fonr%%$tmp_content|;
  
  	# Make the answer area, and fill in with correct values
***************
*** 826,829 ****
--- 828,841 ----
  }
  
+ sub update_own_poll {
+ 	my $S = shift;
+ 	my $sid = shift;
+ 	
+ 	return 0 unless $sid;
+ 	
+ 	return 1 if (($S->have_perm('attach_poll') || $S->have_perm('edit_polls')) && $S->check_edit_story_perms($sid));
+ 
+ 	return 0;
+ }
  
  1;

Index: Groups.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Admin/Groups.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Groups.pm	21 Jan 2005 14:14:30 -0000	1.11
--- Groups.pm	3 Feb 2005 15:48:30 -0000	1.12
***************
*** 2,5 ****
--- 2,7 ----
  use strict;
  
+ my $DEBUG = 0;
+ 
  sub edit_groups {
  	my $S = shift;
***************
*** 27,31 ****
  	my $perm_group_id = $S->{CGI}->param('perm_group_id');
  	my $input_id = $S->{CGI}->param('group_id');
! 	warn "input id is $input_id";
  	my $group_description = $S->{CGI}->param('group_description');
  	my $default = $S->{CGI}->param('default_user_group') || 0;
--- 29,33 ----
  	my $perm_group_id = $S->{CGI}->param('perm_group_id');
  	my $input_id = $S->{CGI}->param('group_id');
! 	warn "input id is $input_id" if $DEBUG;
  	my $group_description = $S->{CGI}->param('group_description');
  	my $default = $S->{CGI}->param('default_user_group') || 0;
***************
*** 73,77 ****
  		}
  		$rv = $S->db_update({
! 			DEBUG => 1,
  			WHAT => "perm_groups",
  			SET => $set,
--- 75,79 ----
  		}
  		$rv = $S->db_update({
! 			DEBUG => $DEBUG,
  			WHAT => "perm_groups",
  			SET => $set,
***************
*** 120,124 ****
  	# then get the sect perms for each section for that group
  	my ($rv,$sth) = $S->db_select({
! 		DEBUG	=> 0,
  		FROM	=> 'section_perms',
  		WHAT	=> 'section,sect_perms,default_sect_perm',
--- 122,126 ----
  	# then get the sect perms for each section for that group
  	my ($rv,$sth) = $S->db_select({
! 		DEBUG	=> $DEBUG,
  		FROM	=> 'section_perms',
  		WHAT	=> 'section,sect_perms,default_sect_perm',
***************
*** 136,140 ****
  
  		my ($rv2,$sth2) = $S->db_insert({
! 			DEBUG	=> 0,
  			INTO	=> 'section_perms',
  			VALUES	=> qq| $f_newgroup, '$row->{section}', '$row->{sect_perms}', $row->{default_sect_perm} |,
--- 138,142 ----
  
  		my ($rv2,$sth2) = $S->db_insert({
! 			DEBUG	=> $DEBUG,
  			INTO	=> 'section_perms',
  			VALUES	=> qq| $f_newgroup, '$row->{section}', '$row->{sect_perms}', $row->{default_sect_perm} |,
***************
*** 227,231 ****
  		WHAT => 'perm_group_id',
  		FROM => 'perm_groups',
! 		DEBUG => 0});
  	
  	my $selector = qq|
--- 229,233 ----
  		WHAT => 'perm_group_id',
  		FROM => 'perm_groups',
! 		DEBUG => $DEBUG});
  	
  	my $selector = qq|
***************
*** 267,271 ****
  		FROM => 'perm_groups',
  		WHERE => qq|perm_group_id = $quoted_gid|,
! 		DEBUG => 0});
  	
  	my $group_data = $sth->fetchrow_hashref() || undef;
--- 269,273 ----
  		FROM => 'perm_groups',
  		WHERE => qq|perm_group_id = $quoted_gid|,
! 		DEBUG => $DEBUG});
  	
  	my $group_data = $sth->fetchrow_hashref() || undef;

Index: AdminStories.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Admin/AdminStories.pm,v
retrieving revision 1.144
retrieving revision 1.145
diff -C2 -d -r1.144 -r1.145
*** AdminStories.pm	23 Jan 2005 03:45:59 -0000	1.144
--- AdminStories.pm	3 Feb 2005 15:48:30 -0000	1.145
***************
*** 31,35 ****
  sub edit_story {
  	my $S = shift;
! 
  	# don't check for spellcheck perm here because fiddiling with params won't
  	# do any damage
--- 31,35 ----
  sub edit_story {
  	my $S = shift;
! 	warn "(edit_story) Starting..." if $DEBUG;
  	# don't check for spellcheck perm here because fiddiling with params won't
  	# do any damage
***************
*** 46,49 ****
--- 46,53 ----
  	my $params = $S->{CGI}->Vars_cloned;
  
+ 	# Check for extended perms here -- if users are allowed to edit their own entries,
+ 	# they will only have "edit_my_stories", not "story_admin"
+ 	return unless ($S->check_edit_story_perms($sid));
+ 
  	if ($S->{CGI}->param('spellcheck') && $S->spellcheck_enabled()) {
  		foreach my $e (qw(introtext bodytext)) {
***************
*** 56,76 ****
  	}
  
! 	my $content = qq|
! 	<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=2 WIDTH=100%>
! 	<TR>
! 		<TD BGCOLOR="%%title_bgcolor%%">%%title_font%%<B>Edit Story</B>%%title_font_end%%</TD>
! 	</TR>|;
  	
  	if ($archive) {
  
! 		if ($S->archive_story ($sid)) {
! 			$content .= qq|
! 			<TR><TD>%%norm_font%%<B>Story $sid archived.</B></TD></TR>
! 			</TABLE>|;
  			return $content;
  		} else {
! 			$content .= qq|
! 			<TR><TD>%%norm_font%%<B>Story $sid <em>not</em> archived.</B></TD></TR>
! 			</TABLE>|;
  			return $content;
  		}
--- 60,73 ----
  	}
  
! 	my $content;
! 	my $keys = {};
  	
  	if ($archive) {
  
! 		if ($S->archive_story($sid)) {
! 			$content = $S->{UI}->{BLOCKS}->{edit_story_archive_success};
  			return $content;
  		} else {
! 			$content = $S->{UI}->{BLOCKS}->{edit_story_archive_fail};
  			return $content;
  		}
***************
*** 78,86 ****
  	} elsif ($delete) {
  
! 		$S->delete_story ($sid);
  		
- 		$content .= qq|
- 			<TR><TD>%%norm_font%%<B>Story $sid deleted.</B></TD></TR>
- 			</TABLE>|;
  		return $content;
  	}
--- 75,80 ----
  	} elsif ($delete) {
  
! 		$content = $S->delete_story($sid);
  		
  		return $content;
  	}
***************
*** 99,102 ****
--- 93,97 ----
  
  	if ($save) {
+ 		warn "Saving $sid..." if $DEBUG;
  		($sid, $error) = $S->save_story();
  		if ($sid) {
***************
*** 110,131 ****
  		# to re-mark as "new"
  		$S->_clear_auto_votes($sid);
- #		if ( ($S->{UI}->{VARS}->{story_auto_vote_zero}) && $sid ) {
- #			my ($rv, $sth) = $S->db_delete({
- #				FROM => 'storymoderate',
- #				WHERE => "sid='$sid'"});
- #			$sth->finish();
- #			$S->save_vote ($sid, '0', 'N');
- #		}
  	}
  
- 	$content .= qq|
- 		<TR>
- 			<TD>|;
- 		
  	if ($preview) {
! 		
  		$tmpsid = 'preview';
  		
  		if ($preview eq 'Update') {
  			($sid, $error) = $S->save_story();
  			$tmpsid = $sid;
--- 105,116 ----
  		# to re-mark as "new"
  		$S->_clear_auto_votes($sid);
  	}
  
  	if ($preview) {
! 		warn "Previewing $sid..." if $DEBUG;
  		$tmpsid = 'preview';
  		
  		if ($preview eq 'Update') {
+ 			warn "This is an update" if $DEBUG;
  			($sid, $error) = $S->save_story();
  			$tmpsid = $sid;
***************
*** 134,148 ****
  
  		# Give a helpful message
! 		$content .=  qq| %%norm_font%%<FONT color="FF0000"><B>$error</B></FONT>%%norm_font_end%%
! 						|;
! 	
! 		$content .= $S->displaystory($tmpsid, $params);
  	
- 		$content .= qq|
- 			</TD>
- 		</TR>
- 		<TR>
- 			<TD align="center"><HR WIDTH=80% SIZE=1 NOSHADE></TD>
- 		</TR>|;
  	} 
  
--- 119,126 ----
  
  		# Give a helpful message
! 		$keys->{error} = $error;
! 		warn "Preview: Getting $tmpsid for display" if $DEBUG;
! 		$keys->{story} = $S->displaystory($tmpsid, $params);
  	
  	} 
  
***************
*** 152,177 ****
  	if ($sid && !$tmpsid) {
  
! 		$content .=  qq| %%norm_font%%<FONT color="FF0000"><B>$error</B></FONT>%%norm_font_end%%
!                         |;
  
! 		$content .= $S->displaystory($sid);
! 		$content .= qq|
! 			</TD>
! 		</TR>
! 		<TR>
! 			<TD align="center"><HR WIDTH=80% SIZE=1 NOSHADE></TD>
! 		</TR>|;
  	}
  	
  	if ($preview ne 'Saved') {
! 		$content .= $S->edit_story_form();
  	}
  	
! 	$content .= qq|
! 		</TABLE>|;
! 		
  	return $content;
  }
  
  sub _clear_auto_votes {
  	my $S = shift;
--- 130,165 ----
  	if ($sid && !$tmpsid) {
  
!                 $keys->{error} = $error;
  
! 		warn "SID: Getting $sid for display" if $DEBUG;
! 		$keys->{story} = $S->displaystory($sid);
  	}
  	
  	if ($preview ne 'Saved') {
! 		$keys->{edit_form} = $S->edit_story_form();
  	}
  	
! 	$content = $S->interpolate($S->{UI}->{BLOCKS}->{edit_story_admin_page}, $keys);	
  	return $content;
  }
  
+ sub check_edit_story_perms {
+ 	my $S = shift;
+ 	my $sid = shift;
+ 
+ 	# story_admin is the universal story edit perm
+ 	return 1 if ($S->have_perm('story_admin'));
+ 	
+ 	# if not, we have to be editing an existing story
+ 	return 0 unless ($sid);
+ 
+ 	my $r = $S->story_data([$sid]);
+ 	my $story = $r->[0];
+ 
+ 	return 1 if ($S->have_perm('edit_my_stories') && $story->{aid} == $S->{UID});
+ 	return 0;
+ }
+ 
+ 
  sub _clear_auto_votes {
  	my $S = shift;
***************
*** 202,205 ****
--- 190,208 ----
  	my $S = shift;
  	my $sid = $S->{CGI}->param('sid');
+  	my $quote_sid = $S->{DBH}->quote($sid);
+ 
+ 	# If not admin, just hide the story
+ 	if (!$S->have_perm('story_admin')) {
+ 		my ($rv, $sth) = $S->db_update({
+ 			WHAT => 'stories',
+ 			SET => 'displaystatus = -1',
+ 			WHERE => qq{sid = $quote_sid}
+ 		});
+ 		$sth->finish();
+ 		$S->run_hook('story_hide', $sid);
+ 	 	my $return = $S->{UI}->{BLOCKS}->{story_hide_message};
+ 		$return =~ s/%%sid%%/$sid/g;
+ 		return $return;
+ 	}	
  
  	my $archived = $S->_check_archivestatus($sid);
***************
*** 214,218 ****
  	$S->run_hook('story_delete', $sid);
  	
-  	my $quote_sid = $S->{DBH}->quote($sid);
  	
   	$S->_clean_up_db($sid, @clean_up_args);
--- 217,220 ----
***************
*** 225,231 ****
   		
   	
!  	my $return = qq|
!  		<TR><TD>%%norm_font%%<B>Story $sid deleted.</B></TD></TR>
!  		</TABLE>|;
   	return $return;
  }
--- 227,233 ----
   		
   	
!  	my $return = $S->{UI}->{BLOCKS}->{story_delete_message};
! 	$return =~ s/%%sid%%/$sid/g;
! 
   	return $return;
  }
***************
*** 552,556 ****
  		
  		unless ($S->have_perm('story_commentstatus_select')) {
! 			$params{commentstatus} = $S->{UI}->{VARS}->{default_commentstatus} || 0;
  		}
  
--- 554,559 ----
  		
  		unless ($S->have_perm('story_commentstatus_select')) {
! 			$params{comment_status} = $S->{UI}->{VARS}->{default_commentstatus};
! 			$params{comment_status} ||= $S->dbh->quote('0');
  		}
  
***************
*** 577,580 ****
--- 580,586 ----
  			$S->move_story_to_voting($sid);
  		}
+ 		unless ($S->have_perm('story_displaystatus_select')) {
+ 			$params{'displaystatus'} = $S->_check_story_mode($sid)
+ 		}
  	}
  	
***************
*** 608,611 ****
--- 614,618 ----
  	my $q_sid = $S->{DBH}->quote($sid);
  	my $edit_category = $params{edit_category} || 0;
+ 	my $commentstatus = $params{comment_status} || 0;
  	my $time = $params{time};
  	if ($params{timeupdate} eq 'now' || $time eq '') {
***************
*** 628,632 ****
  			 section=$section, 
  			 displaystatus=$params{displaystatus}, 
! 			 commentstatus=$params{commentstatus}|,
  			WHERE => qq|sid = $q_sid|});
  
--- 635,639 ----
  			 section=$section, 
  			 displaystatus=$params{displaystatus}, 
! 			 commentstatus=$commentstatus|,
  			WHERE => qq|sid = $q_sid|});
  
***************
*** 656,660 ****
  			INTO => 'stories',
  			COLS => 'sid, tid, aid, title, dept, time, introtext, bodytext, section, displaystatus, commentstatus, edit_category',
! 			VALUES => qq|$q_sid, $q_tid, $params{aid}, $title, $dept, '$time', $introtext, $bodytext, $section, $params{displaystatus}, $params{commentstatus}, $edit_category|});
  
  		$S->run_hook('story_new', $sid);
--- 663,667 ----
  			INTO => 'stories',
  			COLS => 'sid, tid, aid, title, dept, time, introtext, bodytext, section, displaystatus, commentstatus, edit_category',
! 			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);
***************
*** 666,670 ****
  	if( $S->{CGI}->param('qid') && $S->have_perm( 'attach_poll' ) ) {
  		# try to write the poll
! 		$S->write_attached_poll($sid, $S->cgi->param('edit_in_queue') );
  	}
  	
--- 673,678 ----
  	if( $S->{CGI}->param('qid') && $S->have_perm( 'attach_poll' ) ) {
  		# try to write the poll
! 		my $eiq = $S->cgi->param('edit_in_queue') || $S->update_own_poll($sid);
! 		$S->write_attached_poll($sid, $eiq );
  	}
  	
***************
*** 674,677 ****
--- 682,686 ----
  		my $r = $sid.'_mod';
  		$S->cache->stamp_cache($r, $time);
+ 		delete $S->{STORY_CACHE}->{$sid};
  		return ($sid, "Story $sid saved");
  	} else {
***************
*** 683,686 ****
--- 692,696 ----
  sub edit_story_form {
  	my $S = shift;
+ 	my $form_values;
  	my $mode = shift || 'full';
  	my $sid = 	$S->{CGI}->param('sid');
***************
*** 691,695 ****
  
  	if ( ($sid ne '') && ($story_mode ne 'edit') )  {
! 		unless ( $S->have_perm('story_admin') ) {return "<P><B>Story ($sid) cannot be edited because it is currently in $story_mode mode.</B></P>"; }
  	}
  	my $params = $S->{CGI}->Vars;
--- 701,706 ----
  
  	if ( ($sid ne '') && ($story_mode ne 'edit') )  {
! 		unless ( $S->have_perm('story_admin') || $S->have_perm('edit_my_stories')) {return "<P><B>Story ($sid) cannot be 
! edited because it is currently in $story_mode mode.</B></P>"; }
  	}
  	my $params = $S->{CGI}->Vars;
***************
*** 708,723 ****
  	}
  
! 	my $allowed_html_intro = $S->html_checker->allowed_html_as_string('intro')
  		if $mode ne 'full' && (!$S->{UI}->{VARS}->{hide_story_allowed_html});
! 	my $allowed_html_body = $S->html_checker->allowed_html_as_string('body')
  		if $mode ne 'full' && (!$S->{UI}->{VARS}->{hide_story_allowed_html});
  
  	
- 	my $notes;
  	if ($mode eq 'full') {
! 		$notes = qq|%%norm_font%%Special functions:<BR>
! 		Insert <B>[ED]</B> to create an "[editor's note]"<BR>
! 		Insert <B>[UPDATE]</B> to create an "[Update]"%%norm_font_end%%|;
! 	}#'
  	
  	if ($params->{delete}) {
--- 719,731 ----
  	}
  
! 	$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});
  
  	
  	if ($mode eq 'full') {
! 		$form_values->{notes} = $S->{UI}->{BLOCKS}->{story_edit_notes};
! 	}
  	
  	if ($params->{delete}) {
***************
*** 743,765 ****
  	}
  	
! 	my $tid = $S->{CGI}->param('tid') || $story_data->{tid};
! 	my $section = $S->{CGI}->param('section') || $story_data->{section};
! 	my $parent = $S->cgi->param('parent_section') || '';
! 	my $topic_select = $S->topic_select($tid);
! 	$topic_select = qq|<input type="hidden" name="tid" value="$tid">| unless ($topic_select);
! 	my $section_select = $S->section_select($parent, $section);
  	
! 	my ($edit_category_select, $writestatus_select, $displaystatus_select, $commentstatus_select, $postmode_select) = '';
! 	my ($del_button, $all_buttons, $archive_button);
  	
! 	$displaystatus_select = $S->displaystatus_select($story_data->{displaystatus}) 
! 		if ($S->have_perm('story_displaystatus_select') or ($mode eq 'full'));
  	
! 	$commentstatus_select = $S->commentstatus_select($story_data->{commentstatus})
! 		if ($S->have_perm('story_commentstatus_select') or ($mode eq 'full'));
  	
  	if ($mode eq 'full') {
  		if ($S->{UI}->{VARS}->{use_edit_categories} ) {
! 			$edit_category_select = $S->edit_category_select($story_data->{edit_category});}
  		#Not deleting this line quite yet in case someone needs it
  		#$writestatus_select = $S->writestatus_select($story_data->{writestatus});
--- 751,772 ----
  	}
  	
! 	$form_values->{tid} = $S->{CGI}->param('tid') || $story_data->{tid};
! 	$form_values->{section} = $S->{CGI}->param('section') || $story_data->{section};
! 	$form_values->{parent} = $S->cgi->param('parent_section') || '';
! 	$form_values->{topic_select} = $S->topic_select($form_values->{tid});
! 	$form_values->{topic_select} = qq|<input type="hidden" name="tid" value="$form_values->{tid}">| unless ($form_values->{topic_select});
! 	$form_values->{section_select} = $S->section_select($form_values->{parent}, $form_values->{section});
  	
! 	my ($del_button, $archive_button);
  	
! 	$form_values->{displaystatus_select} = $S->displaystatus_select($story_data->{displaystatus}) 
! 		if ($S->have_perm('story_displaystatus_select'));
  	
! 	$form_values->{commentstatus_select} = $S->commentstatus_select($story_data->{commentstatus})
! 		if ($S->have_perm('story_commentstatus_select'));
  	
  	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
  		#$writestatus_select = $S->writestatus_select($story_data->{writestatus});
***************
*** 772,798 ****
  		}
  	} else {
! 		$postmode_select = $S->_postmode_option_form();	
  	}
  	
  	if ($mode eq 'full') {
! 		$all_buttons = qq|
  			<INPUT TYPE="submit" NAME="preview" VALUE="Update">&nbsp;
- 			<INPUT TYPE="submit" NAME="save" VALUE="Save">&nbsp;
  			<INPUT TYPE="submit" NAME="preview" VALUE="Preview">&nbsp;
  			$del_button
  			$archive_button|;
  	} else {
! 		$all_buttons = qq|
  			<INPUT TYPE="submit" NAME="preview" VALUE="Preview">&nbsp;|;
  		if ($params->{preview} || $S->var('require_story_preview') == 0 ) {
! 			$all_buttons .= qq|	
! 				<INPUT TYPE="submit" NAME="save" VALUE="Submit">&nbsp;|;
  			if ( $S->have_perm('edit_own_story') ) {
! 				$all_buttons .= $del_button;
  			}
  		}
  	}
  			
! 	my $author = $story_data->{aid} || $S->{UID};
  	my $tool = '';
  	
--- 779,804 ----
  		}
  	} else {
! 		$form_values->{postmode_select} = $S->_postmode_option_form();	
  	}
  	
  	if ($mode eq 'full') {
! 		$form_values->{all_buttons} = qq|
  			<INPUT TYPE="submit" NAME="preview" VALUE="Update">&nbsp;
  			<INPUT TYPE="submit" NAME="preview" VALUE="Preview">&nbsp;
  			$del_button
  			$archive_button|;
  	} else {
! 		$form_values->{all_buttons} = qq|
  			<INPUT TYPE="submit" NAME="preview" VALUE="Preview">&nbsp;|;
  		if ($params->{preview} || $S->var('require_story_preview') == 0 ) {
! 			$form_values->{all_buttons} .= qq|	
! 			<INPUT TYPE="submit" NAME="save" VALUE="Submit">&nbsp;|;
  			if ( $S->have_perm('edit_own_story') ) {
! 				$form_values->{all_buttons} .= $del_button;
  			}
  		}
  	}
  			
! 	$form_values->{aid} = $story_data->{aid} || $S->{UID};
  	my $tool = '';
  	
***************
*** 805,834 ****
  	}
  	my $formkey = $S->get_formkey_element();
!  			
! 	my $upload_page = $S->display_upload_form(0, 'content');
! 	$upload_page = "<tr><td>$upload_page</td></tr>" unless $upload_page eq '';
! 	my $content = qq|
! 		<FORM NAME="editstory" ACTION="%%rootdir%%/" METHOD="POST" enctype="multipart/form-data">
  		%%submit_include_top%%
  		<INPUT TYPE="hidden" NAME="op" VALUE="$params->{op}">
  		$tool
  		<INPUT TYPE="hidden" NAME="sid" VALUE="$sid">
! 		<INPUT TYPE="hidden" NAME="aid" VALUE="$author">
  		$event
  		$formkey
! 		<INPUT TYPE="hidden" NAME="time" VALUE="$story_data->{time}">
! 		<TR>
! 			<TD>%%norm_font%%
! 			$all_buttons
! 			$topic_select
! 			$section_select
! 			$postmode_select
! 			%%norm_font_end%%</TD>
! 		</TR>|;
  
- 	my $checked = '';
- 	if ($params->{timeupdate} eq 'now') {
- 		$checked = ' CHECKED';
- 	}
  	
  #	$story_data->{title} =~ s/"/&quot;/g;
--- 811,829 ----
  	}
  	my $formkey = $S->get_formkey_element();
!  	
! 	$form_values->{upload_page} = $S->{UI}->{BLOCKS}->{story_edit_upload};
! 	my $upload_form = $S->display_upload_form(0, 'content');
! 	$form_values->{upload_page} =~ s/%%form%%/$upload_form/g;		
! 	
! 	$form_values->{hidden_form_data} = qq|
  		%%submit_include_top%%
  		<INPUT TYPE="hidden" NAME="op" VALUE="$params->{op}">
  		$tool
  		<INPUT TYPE="hidden" NAME="sid" VALUE="$sid">
! 		<INPUT TYPE="hidden" NAME="aid" VALUE="$form_values->{aid}">
  		$event
  		$formkey
! 		<INPUT TYPE="hidden" NAME="time" VALUE="$story_data->{time}">|;
  
  	
  #	$story_data->{title} =~ s/"/&quot;/g;
***************
*** 836,848 ****
  	$story_data->{title} =~ s/"/&quot;/g;
  
! 	$content .= qq|
! 		<TR>
! 			<TD>%%norm_font%%
! 			Title: <INPUT TYPE="text" NAME="title" VALUE="$story_data->{title}" SIZE=50>
! 			%%norm_font_end%%<BR>|;
! 	
  	if ($S->{UI}->{VARS}->{show_dept}) {
! 		$content .= qq|%%norm_font%%
! 			By: <INPUT TYPE="text" NAME="dept" VALUE="$story_data->{dept}" SIZE=40>%%norm_font_end%%<BR>|;
  	}
  
--- 831,839 ----
  	$story_data->{title} =~ s/"/&quot;/g;
  
! 	$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;
  	}
  
***************
*** 854,903 ****
  		$params->{spellcheck} = $S->pref('spellcheck_default') unless ($S->{CGI}->param('formkey'));
  		my $check = ($params->{spellcheck} eq 'on') ? ' CHECKED' : '';
! 		$content .= qq|
! 			<INPUT TYPE="checkbox" NAME="spellcheck" VALUE="on"$check>
! 			%%norm_font%%&nbsp;Spellcheck text (will force "Preview")%%norm_font_end%%<BR>|;
! 	}
! 	
! 	my $location_box;
! 	if ($S->{UI}->{VARS}->{use_locations}) {
! 		$location_box = qq|%%BOX,location_box%%|;
  	}
- 
- 	$content .= $location_box;
  	
  	# show edit in queue checkbox only if the var is set and the mode is normal (non-admin)
   	if ( ($S->have_perm('edit_own_story')) && ($mode ne 'full') && ($params->{section} ne 'Diary')){
-  		
   		my $check =  $params->{'preview'} ? 
  		             ($params->{edit_in_queue} ? ' CHECKED' : '') 
  					 : ' CHECKED';
! 
!  		$content .= qq|
!  			<INPUT TYPE="checkbox" NAME="edit_in_queue" VALUE="1"$check>
!  			%%norm_font%%&nbsp;Request editorial feedback before voting%%norm_font_end%%<BR>|;
   	}
  	
! 	if ($mode eq 'full') {
! 		$content .= qq|
! 			<INPUT TYPE="checkbox" VALUE="now" NAME="timeupdate"$checked>
! 			%%norm_font%%&nbsp;Set timestamp to now%%norm_font_end%%|;
  	}
  	
- 	$content .= qq|				
- 			</TD>
- 		</TR>|;
- 	
- 	$content .= qq|
- 		<TR>
- 			<TD>%%norm_font%%
- 			$edit_category_select
- 			$displaystatus_select
- 			$commentstatus_select
- 			%%norm_font_end%%</TD>
- 		</TR>|;
- 	
- 	my $update_txt = '';
  	if ($mode eq 'full') {	
! 		$update_txt = qq|<FONT SIZE=-1>(use [UPDATE] to create an update stamp in the introtext)</FONT>|;
  	}
  
--- 845,870 ----
  		$params->{spellcheck} = $S->pref('spellcheck_default') unless ($S->{CGI}->param('formkey'));
  		my $check = ($params->{spellcheck} eq 'on') ? ' CHECKED' : '';
! 		$form_values->{spellcheck} = $S->{UI}->{BLOCKS}->{story_edit_spellcheck};
! 		$form_values->{spellcheck} =~ s/%%check%%/$check/g;
  	}
  	
  	# show edit in queue checkbox only if the var is set and the mode is normal (non-admin)
   	if ( ($S->have_perm('edit_own_story')) && ($mode ne 'full') && ($params->{section} ne 'Diary')){
   		my $check =  $params->{'preview'} ? 
  		             ($params->{edit_in_queue} ? ' CHECKED' : '') 
  					 : ' CHECKED';
! 		$form_values->{edit_queue} = $S->{UI}->{BLOCKS}->{story_edit_editqueue};
! 		$form_values->{edit_queue} =~ s/%%check%%/$check/g;
   	}
  	
! 	if ($S->have_perm('story_time_update')) {
! 		my $check = ' CHECKED' if ($params->{timeupdate} eq 'now');
! 		$form_values->{time_update} = $S->{UI}->{BLOCKS}->{story_edit_timeupdate};
! 		$form_values->{time_update} =~ s/%%check%%/$check/g;
  	}
  	
  	if ($mode eq 'full') {	
! 		$form_values->{update_txt} = $S->{UI}->{BLOCKS}->{story_edit_updatetxt};
! 		$form_values->{edit_txt}   = $S->{UI}->{BLOCKS}->{story_edit_edittxt};
  	}
  
***************
*** 906,970 ****
  	}
  
! 	my $textarea_cols = $S->pref('textarea_cols'); 
! 	my $textarea_rows = $S->pref('textarea_rows'); 
  
! 	$content .= qq|
! 		<TR>
! 			<TD>
! 			$notes<P>
! 			%%norm_font%%Intro Copy:%%norm_font_end%%<BR>
! 			$allowed_html_intro
! 			</TD>
! 		</TR>
! 		<TR>
! 			<TD>%%norm_font%%
! 			<TEXTAREA NAME="introtext" COLS=$textarea_cols ROWS=$textarea_rows WRAP="soft">$story_data->{introtext}</TEXTAREA>
! 			%%norm_font_end%%
! 			</TD>
! 		</TR>
! 		<TR>
! 			<TD>%%norm_font%%
! 				$all_buttons
! 			%%norm_font_end%%</TD>
! 		</TR>|;
! 	
! 	$content .= qq|
! 		<TR>
! 			<TD>
! 			%%norm_font%%Extended Copy:<BR>
! 			$allowed_html_body%%norm_font_end%%
! 			</TD>
! 		</TR>
! 		<TR>
! 			<TD>%%norm_font%%
! 			<TEXTAREA NAME="bodytext" COLS=$textarea_cols ROWS=$textarea_rows WRAP="soft">$story_data->{bodytext}</TEXTAREA>
! 			%%norm_font_end%%
! 			</TD>
! 		</TR>|;
! 	$content .= qq|
! 		$upload_page
! 		<TR>
! 			<TD>%%norm_font%%
! 			$all_buttons
! 			%%norm_font_end%%</TD>
! 		</TR>|;
  
  	# if they can attach polls generate the form
  	if( $S->have_perm( 'attach_poll' ) ) {
! 		$content .= qq|
! 		<TR>
! 			<TD>%%norm_font%%$S->{UI}->{BLOCKS}->{attach_poll_message}%%norm_font_end%%</TD>
! 		</TR>|;
  	
  		# if they are previewing pass the args to the function.  else give them the real story $sid
  		if($params->{preview} && !$params->{retrieve_poll}) {
! 			$content .= $S->make_attached_poll_form('preview', $params);
  		} else {
! 			$content .= $S->make_attached_poll_form('normal', $sid);
  		}
  	}
  	
! 	$content .= qq|
! 		</FORM>|;
  		
  	return $content;
--- 873,899 ----
  	}
  
! 	$form_values->{textarea_cols} = $S->pref('textarea_cols'); 
! 	$form_values->{textarea_rows} = $S->pref('textarea_rows'); 
  
! 	$form_values->{introtext} = $story_data->{introtext};
! 	$form_values->{bodytext} = $story_data->{bodytext};
  
  	# if they can attach polls generate the form
  	if( $S->have_perm( 'attach_poll' ) ) {
! 		$form_values->{poll_message} = $S->{UI}->{BLOCKS}->{attach_poll_message};
  	
  		# if they are previewing pass the args to the function.  else give them the real story $sid
  		if($params->{preview} && !$params->{retrieve_poll}) {
! 			$form_values->{poll_form} = $S->make_attached_poll_form('preview', $params);
  		} else {
! 			$form_values->{poll_form} .= $S->make_attached_poll_form('normal', $sid);
  		}
  	}
  	
! 	if ($mode ne 'full') {
! 		$form_values->{guidelines} = $S->{UI}->{BLOCKS}->{submission_guidelines};
! 	}
! 	
! 	my $content = $S->interpolate($S->{UI}->{BLOCKS}->{edit_story_form}, $form_values);
  		
  	return $content;
***************
*** 1122,1126 ****
  	
  	my $status_select = qq|
! 		<SELECT NAME="commentstatus" SIZE=1>
  	|;
  	my ($rv, $sth) = $S->db_select({
--- 1051,1055 ----
  	
  	my $status_select = qq|
! 		<SELECT NAME="comment_status" SIZE=1>
  	|;
  	my ($rv, $sth) = $S->db_select({
***************
*** 1213,1217 ****
  	$section_select .= qq|
  		<SELECT NAME="section" SIZE=1>
- 		<OPTION VALUE="all">Please Choose a Section
  		$parent_selections
  		$child_selections
--- 1142,1145 ----
***************
*** 1357,1360 ****
--- 1285,1291 ----
  	$message .= $S->_post_story($sid);
  	}
+ 	return $message;
+ }
+ 
  sub save_vote {
  	my $S = shift;
***************
*** 1378,1384 ****
  }
  		
- 	return $message;
- }
- 
  
  sub _check_vote {
--- 1309,1312 ----