Update of /cvs/scoop/scoop/lib/Scoop/Comments
In directory sodium.sabren.com:/tmp/cvs-serv5844/lib/Scoop/Comments

Modified Files:
	Format.pm Post.pm 
Removed Files:
	Prefs.pm 
Log Message:

New flexible user preferences stuff.

-janra



--- Prefs.pm DELETED ---

Index: Post.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Comments/Post.pm,v
retrieving revision 1.72
retrieving revision 1.73
diff -C2 -d -r1.72 -r1.73
*** Post.pm	30 Jul 2004 08:12:57 -0000	1.72
--- Post.pm	4 Aug 2004 21:49:48 -0000	1.73
***************
*** 89,93 ****
  	if ($preview) {
  		my $user = $S->user_data( $S->{UID} );
! 		my $cur_sig = $user->{sig};
  
  		my $sig_states = { retroactive => 1, sticky => 0, none => -1 };
--- 89,93 ----
  	if ($preview) {
  		my $user = $S->user_data( $S->{UID} );
! 		my $cur_sig = $user->{prefs}->{sig};
  
  		my $sig_states = { retroactive => 1, sticky => 0, none => -1 };
***************
*** 155,160 ****
  	$subject = $S->comment_text($subject);
  
! 	$keys->{'textarea_cols'} = $S->{prefs}->{textarea_cols} || $S->{UI}->{VARS}->{default_textarea_cols};
! 	$keys->{'textarea_rows'} = $S->{prefs}->{textarea_rows} || $S->{UI}->{VARS}->{default_textarea_rows};
  	$keys->{'subject'} = $subject;
  	$keys->{'comment_body'} = $comment;
--- 155,160 ----
  	$subject = $S->comment_text($subject);
  
! 	$keys->{'textarea_cols'} = $S->pref('textarea_cols');
! 	$keys->{'textarea_rows'} = $S->pref('textarea_rows');
  	$keys->{'subject'} = $subject;
  	$keys->{'comment_body'} = $comment;
***************
*** 167,172 ****
  		# We only want to set the default spellcheck the first time they submit
  		# We don't want to override the setting.
! 		$spellcheck = $S->spellcheck_default() unless ($S->{CGI}->param('formkey'));
! 		my $checked = ($spellcheck) ? ' CHECKED' : '';
  		$keys->{'spellcheck_form'} = $S->{UI}->{BLOCKS}->{spellcheck_form_item};
  		$keys->{'spellcheck_form'} =~ s/%%checked%%/$checked/;
--- 167,172 ----
  		# We only want to set the default spellcheck the first time they submit
  		# We don't want to override the setting.
! 		$spellcheck = $S->pref('spellcheck_default') unless ($S->{CGI}->param('formkey'));
! 		my $checked = ($spellcheck eq 'on') ? ' CHECKED' : '';
  		$keys->{'spellcheck_form'} = $S->{UI}->{BLOCKS}->{spellcheck_form_item};
  		$keys->{'spellcheck_form'} =~ s/%%checked%%/$checked/;
***************
*** 185,189 ****
  	my $S = shift;
  	
! 	my $posttype = $S->{CGI}->param('posttype') || $S->{prefs}->{comment_posttype};
  	if ($posttype) {
  		$S->session('posttype', $posttype);
--- 185,189 ----
  	my $S = shift;
  	
! 	my $posttype = $S->{CGI}->param('posttype') || $S->pref('comment_posttype');
  	if ($posttype) {
  		$S->session('posttype', $posttype);
***************
*** 196,200 ****
  	my $S = shift;
  	
! 	my $sig_behavior = $S->{CGI}->param('sig_behavior') || $S->{prefs}->{comment_sig_behavior};
  	if ($sig_behavior) {
  		$S->session('sig_behavior',$sig_behavior);
--- 196,200 ----
  	my $S = shift;
  	
! 	my $sig_behavior = $S->{CGI}->param('sig_behavior') || $S->pref('comment_sig_behavior');
  	if ($sig_behavior) {
  		$S->session('sig_behavior',$sig_behavior);
***************
*** 215,219 ****
  
  		my ($sticky_sig, $reg_sig, $no_sig);
! 		my $sig_behavior = $S->session('sig_behavior') || $S->{UI}->{VARS}->{default_sig_behavior};
  		if ($sig_behavior eq 'sticky') {
  			$sticky_sig = ' SELECTED';
--- 215,219 ----
  
  		my ($sticky_sig, $reg_sig, $no_sig);
! 		my $sig_behavior = $S->session('sig_behavior') || $S->pref('sig_behavior');
  		if ($sig_behavior eq 'sticky') {
  			$sticky_sig = ' SELECTED';
***************
*** 224,228 ****
  		}
  
! 		if ($user->{sig}) {
  			$form .= qq|
  				<OPTION VALUE="retroactive"$reg_sig>Retroactive
--- 224,228 ----
  		}
  
! 		if ($user->{prefs}->{sig}) {
  			$form .= qq|
  				<OPTION VALUE="retroactive"$reg_sig>Retroactive
***************
*** 255,259 ****
  	my ($plainpost, $htmlpost, $autopost);
  
! 	my $posttype = $S->session('posttype') || $S->{UI}->{VARS}->{default_post_type};
  
  	if ($posttype eq 'text') {
--- 255,259 ----
  	my ($plainpost, $htmlpost, $autopost);
  
! 	my $posttype = $S->session('posttype') || $S->pref('posttype');
  
  	if ($posttype eq 'text') {
***************
*** 548,552 ****
  	my $user = $S->user_data($uid);
  
! 	my $sig = $user->{sig};
  
  	# taken out the part where appending to the comment, it should be attached
--- 548,552 ----
  	my $user = $S->user_data($uid);
  
! 	my $sig = $user->{prefs}->{sig};
  
  	# taken out the part where appending to the comment, it should be attached

Index: Format.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Comments/Format.pm,v
retrieving revision 1.52
retrieving revision 1.53
diff -C2 -d -r1.52 -r1.53
*** Format.pm	30 Jul 2004 08:12:56 -0000	1.52
--- Format.pm	4 Aug 2004 21:49:48 -0000	1.53
***************
*** 186,195 ****
  
  	# check for sig behavior and act accordingly
! 	if ($user->{sig}) {
! 		#$user->{sig} =~ s/<P>/<BR><BR>/gi;
!  		#$user->{sig} =~ s/<\/P>//gi;
  		if ($comment->{sig_behavior} eq 'retroactive' || $comment->{sig_status} == 1) {
  			#if normal sig, then proceed as usual
! 	 		$this_comment =~ s/%%sig%%/$user->{sig}/g;
  
  		} elsif ($comment->{sig_behavior} eq 'sticky' || $comment->{sig_status} == 0) { 
--- 186,193 ----
  
  	# check for sig behavior and act accordingly
! 	if ($user->{prefs}->{sig}) {
  		if ($comment->{sig_behavior} eq 'retroactive' || $comment->{sig_status} == 1) {
  			#if normal sig, then proceed as usual
! 	 		$this_comment =~ s/%%sig%%/$user->{prefs}->{sig}/g;
  
  		} elsif ($comment->{sig_behavior} eq 'sticky' || $comment->{sig_status} == 0) { 
***************
*** 216,226 ****
  	$this_comment =~ s/%%num_ratings%%/$comment->{numrate}/g unless $rate eq 'hide';
  	
! 	if ($user->{fakeemail}) {
! 		$this_comment =~ s/%%email%%/(<A CLASS="light" HREF="mailto:$user->{fakeemail}">$user->{fakeemail}<\/A>)/g;
  	} else {
  		$this_comment =~ s/%%email%%//g;
  	}
! 	if ($user->{homepage}) {
! 		$this_comment =~ s/%%url%%/<A CLASS="light" HREF="$user->{homepage}">$user->{homepage}<\/A>/g;
  	} else {
  		$this_comment =~ s/%%url%%//g;
--- 214,224 ----
  	$this_comment =~ s/%%num_ratings%%/$comment->{numrate}/g unless $rate eq 'hide';
  	
! 	if ($user->{prefs}->{fakeemail}) {
! 		$this_comment =~ s/%%email%%/(<A CLASS="light" HREF="mailto:$user->{prefs}->{fakeemail}">$user->{prefs}->{fakeemail}<\/A>)/g;
  	} else {
  		$this_comment =~ s/%%email%%//g;
  	}
! 	if ($user->{prefs}->{homepage}) {
! 		$this_comment =~ s/%%url%%/<A CLASS="light" HREF="$user->{prefs}->{homepage}">$user->{prefs}->{homepage}<\/A>/g;
  	} else {
  		$this_comment =~ s/%%url%%//g;
***************
*** 452,456 ****
  	} elsif ($mode eq 'flat_unthread') {
  		$selected_u = ' SELECTED';
! 	} elsif ($S->{UI}->{VARS}->{allow_dynamic_comment_mode}) {
  		if ($mode eq 'dthreaded') {
  			$selected_dt = ' SELECTED';
--- 450,454 ----
  	} elsif ($mode eq 'flat_unthread') {
  		$selected_u = ' SELECTED';
! 	} elsif ($S->{UI}->{VARS}->{allow_dynamic_comment_mode} && $S->pref('dynamic_interface') eq 'on') {
  		if ($mode eq 'dthreaded') {
  			$selected_dt = ' SELECTED';
***************
*** 466,470 ****
  		<OPTION VALUE="flat"$selected_f>Flat
  		<OPTION VALUE="flat_unthread"$selected_u>Flat Unthreaded|;
! 	if ($S->{UI}->{VARS}->{allow_dynamic_comment_mode}) {
  		$select .= qq|<OPTION VALUE="dthreaded"$selected_dt>Dynamic Threaded|;
  		$select .= qq|<OPTION VALUE="dminimal"$selected_dm>Dynamic Minimal|;
--- 464,468 ----
  		<OPTION VALUE="flat"$selected_f>Flat
  		<OPTION VALUE="flat_unthread"$selected_u>Flat Unthreaded|;
! 	if ($S->{UI}->{VARS}->{allow_dynamic_comment_mode} && $S->pref('dynamic_interface') eq 'on') {
  		$select .= qq|<OPTION VALUE="dthreaded"$selected_dt>Dynamic Threaded|;
  		$select .= qq|<OPTION VALUE="dminimal"$selected_dm>Dynamic Minimal|;
***************
*** 522,526 ****
  
  
- 
  sub _set_comment_mode {
  	my $S = shift;
--- 520,523 ----
***************
*** 540,578 ****
  	
  	return unless ($S->{SESSION_KEY});
! 	
! 	my @modeprefs = (
! 		'comment_flat_to',
! 		'comment_flat_unthread_to',
! 		'comment_minimal_to',
! 		'comment_threaded_to',
! 		'comment_nested_to',
! 		'comment_dthreaded_to',
! 		'comment_dminimal_to');
! 	
! 	my $curr_diff;
! 	my $curr_mode;
! 	my $spill;
! 	foreach my $mode_p (@modeprefs) {
! 		if ($S->{prefs}->{$mode_p} eq '+') {
! 			$spill = $mode_p;
! 			$spill =~ s/^comment_//;
! 			$spill =~ s/_to$//;
! 			next;
! 		}
! 		my $diff = $S->{prefs}->{$mode_p} - $count;
! 		next unless ($diff >= 0);
! 		if ($diff < $curr_diff || !defined($curr_diff)) {
! 			$curr_diff = $diff;
! 			$curr_mode = $mode_p;
! 			$curr_mode =~ s/^comment_//;
! 			$curr_mode =~ s/_to$//;
! 		}
  	}
  	
! 	my $mode = $curr_mode || $spill;
! 	#my $mode = $S->{CGI}->param('commentmode');
! 	#return unless $mode;
! 	
! 	$S->session('commentmode', $mode);
  	return;
  }
--- 537,553 ----
  	
  	return unless ($S->{SESSION_KEY});
! 
! 	my $mode = $S->pref('commentmode');
! 	my $overflow = $S->pref('commentmode_overflow');
! 	my $overflow_at = $S->pref('commentmode_overflow_at');
! 	my $return;
! 
! 	if ( $count > $overflow_at || $mode eq 'use_overflow' ) {
! 		$return = $overflow;
! 	} else {
! 		$return = $mode;
  	}
  	
! 	$S->session('commentmode', $return);
  	return;
  }