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

Modified Files:
	Format.pm Post.pm 
Log Message:
Bug 85: adding hulver's patch to let you restrict where and by whom specific
macros may be used.

-janra



Index: Format.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Comments/Format.pm,v
retrieving revision 1.57
retrieving revision 1.58
diff -C2 -d -r1.57 -r1.58
*** Format.pm	3 Feb 2005 15:48:30 -0000	1.57
--- Format.pm	11 Feb 2005 22:11:05 -0000	1.58
***************
*** 203,244 ****
  	$this_comment =~ s/%%new%%/$new/g;
  	$this_comment =~ s/%%member%%/$member/g;
! 
  	# 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) { 
  			#if sticky sig and in preview mode, then place sig below comment
! 			$this_comment =~ s/%%sig%%/$comment->{sig}/g
  
  		} else {
! 			#the user has a sig but doesn't want it shown, so get rid of %%sig%%'s
! 			$this_comment =~ s/%%sig%%//g;
  
  		}
  	} else {
! 		$this_comment =~ s/%%sig%%//g;
  	}
  
  	$this_comment =~ s/%%rating_format%%/$S->{UI}->{BLOCKS}->{rating_format}/g unless $rate eq 'hide';
  	$this_comment =~ s/%%rating_format%%//g; # If not already replaced in previous line, then remove the ey altogether
! 	$this_comment =~ s/%%comment%%/$comment->{comment}/g;
  	$this_comment =~ s/%%cid%%/$comment->{cid}/g;
  	$this_comment =~ s/%%actions%%/$action/g;
! 	$this_comment =~ s/%%user_info%%/$user_info/g;
!         $this_comment =~ s/%%commentip%%/$comment_ip/g;
  	$this_comment =~ s/%%sid%%/$comment->{sid}/g;
  	$this_comment =~ s/%%score%%/$comment->{points}/g unless $rate eq 'hide';
  	$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;
--- 203,252 ----
  	$this_comment =~ s/%%new%%/$new/g;
  	$this_comment =~ s/%%member%%/$member/g;
! 	
! 	my ($sig, $comment_text);
! 	$comment_text = $comment->{comment};
  	# check for sig behavior and act accordingly
  	if ($user->{prefs}->{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
! 			$sig = $user->{prefs}->{sig};
  
  		} elsif ($comment->{sig_behavior} eq 'sticky' || $comment->{sig_status} == 0) { 
  			#if sticky sig and in preview mode, then place sig below comment
! 			$sig = $comment->{sig};
  
  		} else {
! 			#the user has a sig but doesn't want it shown
! 			$sig = "";
  
  		}
  	} else {
! 		$sig = "";
! 	}
! 	if (exists($S->{UI}->{VARS}->{use_macros}) && $S->{UI}->{VARS}->{use_macros}) {
! 		$comment_text = $S->process_macros($comment_text,'comment');
! 		$sig = $S->process_macros($sig,'pref') if ($sig);
  	}
  
+ 	$this_comment =~ s/%%sig%%/$sig/g;
  	$this_comment =~ s/%%rating_format%%/$S->{UI}->{BLOCKS}->{rating_format}/g unless $rate eq 'hide';
  	$this_comment =~ s/%%rating_format%%//g; # If not already replaced in previous line, then remove the ey altogether
! 	$this_comment =~ s/%%comment%%/$comment_text/g;
  	$this_comment =~ s/%%cid%%/$comment->{cid}/g;
  	$this_comment =~ s/%%actions%%/$action/g;
! 	$this_comment =~ s/%%comment_ip%%/$comment_ip/g;
  	$this_comment =~ s/%%sid%%/$comment->{sid}/g;
  	$this_comment =~ s/%%score%%/$comment->{points}/g unless $rate eq 'hide';
  	$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;
***************
*** 249,253 ****
  		$item_start_subst =~ s/!cid!/$comment->{cid}/g;
  		$this_comment = $item_start_subst . $this_comment;
! 		if ($comment->{mode} eq 'alone') {
  			$this_comment .= $item_end;
  		} else {
--- 257,261 ----
  		$item_start_subst =~ s/!cid!/$comment->{cid}/g;
  		$this_comment = $item_start_subst . $this_comment;
! 		if ($comment->{mode} eq 'alone' && $comment->{mode} ne 'Preview') {
  			$this_comment .= $item_end;
  		} else {
***************
*** 256,265 ****
  	}
  
! 	if ($comment->{mode} ne 'alone') {
  		$this_comment =~ s/%%replies%%/$replies/g;
- 	}
- 
- 	if (exists($S->{UI}->{VARS}->{use_macros}) && $S->{UI}->{VARS}->{use_macros}) {
- 		$this_comment = $S->process_macros($this_comment);
  	}
  
--- 264,269 ----
  	}
  
! 	if ($comment->{mode} ne 'alone' && $comment->{mode} ne 'Preview') {
  		$this_comment =~ s/%%replies%%/$replies/g;
  	}
  

Index: Post.pm
===================================================================
RCS file: /cvs/scoop/scoop/lib/Scoop/Comments/Post.pm,v
retrieving revision 1.74
retrieving revision 1.75
diff -C2 -d -r1.74 -r1.75
*** Post.pm	17 Aug 2004 19:03:41 -0000	1.74
--- Post.pm	11 Feb 2005 22:11:05 -0000	1.75
***************
*** 568,590 ****
  	}
  
!     $comment = $S->filter_comment($comment, 'comment', $posttype, 1);
  	return if $S->html_checker->errors_as_string;
  
  	# if using macros, and 'render on save' is on, then render the macro(s) before saving.
  
! 	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}) {
! 		$comment = $S->process_macros($comment);
  	}
  
!     $comment = $S->{DBH}->quote($comment);
! 	$sig = $S->filter_comment($sig, 'prefs', 'html', 1);
  	$sig = $S->{DBH}->quote($sig);
!     $subject = $S->filter_subject($subject);
  	# check the length of the filtered subject to make sure it won't be cut
  	# off by the db
  	return 0 if length($subject) > 50;
!     $subject = $S->{DBH}->quote($subject);
  	$commentip = $S->{DBH}->quote($commentip);
  
--- 568,589 ----
  	}
  
! 	$comment = $S->filter_comment($comment, 'comment', $posttype, 1);
  	return if $S->html_checker->errors_as_string;
+ 	$sig = $S->filter_comment($sig, 'prefs', 'html', 1);
  
  	# if using macros, and 'render on save' is on, then render the macro(s) before saving.
  
! 	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}) {
! 		$comment = $S->process_macros($comment,'comment');
! 		$sig = $S->process_macros($sig,'pref');
  	}
  
! 	$comment = $S->{DBH}->quote($comment);
  	$sig = $S->{DBH}->quote($sig);
! 	$subject = $S->filter_subject($subject);
  	# check the length of the filtered subject to make sure it won't be cut
  	# off by the db
  	return 0 if length($subject) > 50;
! 	$subject = $S->{DBH}->quote($subject);
  	$commentip = $S->{DBH}->quote($commentip);
  
***************
*** 592,597 ****
  	my $set_rating = 0;
  	my $cols = 'sid, pid, date, subject, comment, uid, pending, sig_status, sig, commentip';
! 	my $vals = qq|$f_sid, $pid, NOW(), $subject, $comment, $uid, $pending, $sig_status, $sig, $commentip|;
! 	
  	if ($S->{UI}->{VARS}->{use_initial_rating}) {
  		$points = ($uid == -1) ? $S->{UI}->{VARS}->{anonymous_default_points} : $S->{UI}->{VARS}->{user_default_points};
--- 591,595 ----
  	my $set_rating = 0;
  	my $cols = 'sid, pid, date, subject, comment, uid, pending, sig_status, sig, commentip';
! 	my $vals = qq|"$sid", $pid, NOW(), $subject, $comment, $uid, $pending, $sig_status, $sig, $commentip|;
  	if ($S->{UI}->{VARS}->{use_initial_rating}) {
  		$points = ($uid == -1) ? $S->{UI}->{VARS}->{anonymous_default_points} : $S->{UI}->{VARS}->{user_default_points};