Hiding foe quotes

Looking for a MOD? Have a MOD request? Post here for help. (Note: This forum is community supported; phpBB does not have official MOD authors)
Get Involved
Tenzel.Kim
Registered User
Posts: 14
Joined: Sun Aug 02, 2009 1:21 pm

Hiding foe quotes

Post by Tenzel.Kim » Tue Jul 10, 2012 9:20 am

I've tried looking for a MOD that could hide quotes made by people on your foe list but having been able to find one. Would this be possible.

Basically what I'd be interested in would be for a quote made by someone on your foe list show up with a comment much like the posts by foes do.

So if someone quoted a person on your foe list his quote would be hidden and youd get a text that you could click to see if you wanted to see the quote that said:

"This quote was made by XX who is currently on your ignore list. Display this quote."

I have some posters on my boards that others find a nuisance and they'd rather not see these posters' posts so they have added them to their foe list. When somebody else quotes them they end up seeing it anyway.

From what I've been able to gather the foes are defined by user_id, which is not used in quotes, so I guess a MOD would have to look up the name in the quote and compare it to the foe user_id list or something for this to be a possibility.

I know that if someone changes the name in the quote or leaves out the name it would still show up, but since that doesn't happen all that often I'd still say it would be an improvement.

RubiconCSL
Registered User
Posts: 26
Joined: Thu May 11, 2006 9:12 am
Location: Somerset UK

Re: Hiding foe quotes

Post by RubiconCSL » Wed Sep 11, 2013 10:23 am

I'd also like to see this. Is there any further news on this, or is it a no go?

corleoner
Registered User
Posts: 189
Joined: Wed Jan 29, 2014 9:57 pm

Re: Hiding foe quotes

Post by corleoner » Tue Mar 11, 2014 11:23 pm

bump, I'd love to see this one.

Airless
Registered User
Posts: 1
Joined: Sun Apr 06, 2014 5:42 am

Re: Hiding foe quotes

Post by Airless » Sun Apr 06, 2014 5:43 am

Please find a way to implement this!

FoulFoot
Registered User
Posts: 261
Joined: Mon Jun 23, 2003 1:04 am
Location: Honolulu, HI
Contact:

Re: Hiding foe quotes

Post by FoulFoot » Thu Apr 10, 2014 1:53 am

I think I can puzzle out how this can be done -- if I have some time in the next few days, I'll take a crack at it.

The biggest problem is that the current foes system uses a template trigger (S_IGNORE_POST) to replace an entire post with the "you're ignoring this person" message. Replacing only part of a post (the quoted part) is a different animal entirely, and requires editing the post before it gets to the template. Which isn't hard, but at the moment I can't see a way to have a clickable "view this post" link on the blocked quotes. It would just be something like "this quote blocked because author is on your foes list". Even that would be an improvement, though.

Foul

User avatar
Oyabun1
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill

Re: Hiding foe quotes

Post by Oyabun1 » Thu Apr 10, 2014 4:40 am

FoulFoot wrote:The biggest problem is ...
Another problem is standard phpBB doesn't track quotes or who's posts were quoted. The username in the quote is just plain text and not a link to the username, user_id nor the original post, making identifying the subject quotes more difficult.
FoulFoot wrote:It would just be something like "this quote blocked because author is on your foes list". Even that would be an improvement, though.
The trouble with just hiding the quoted text of foes is that it can remove the context of other posts, as a example:
Normal user wrote:
User on foe list wrote:This quote blocked because author is on your foes list
That is a good point. On this occasion I totally agree with what you are saying.
If you can't see the quoted text of the foe you don't know what the normal user is talking about or agreeing with.
                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests

FoulFoot
Registered User
Posts: 261
Joined: Mon Jun 23, 2003 1:04 am
Location: Honolulu, HI
Contact:

Re: Hiding foe quotes

Post by FoulFoot » Thu Apr 10, 2014 11:27 am

All true!
Oyabun1 wrote:Another problem is standard phpBB doesn't track quotes or who's posts were quoted. The username in the quote is just plain text and not a link to the username, user_id nor the original post, making identifying the subject quotes more difficult.
I'd just take whatever name is between the brackets -- valid or not - and see if it's in the Foes table. If it's been altered, it'll slip through.
Oyabun1 wrote:The trouble with just hiding the quoted text of foes is that it can remove the context of other posts
I think I figured out a way to display a clickable link that will display the blocked post, which would alleviate this concern.

All conjecture at the moment, as I haven't really gotten into the weeds with it yet, but I'm cautiously optimistic. :)

Foul

corleoner
Registered User
Posts: 189
Joined: Wed Jan 29, 2014 9:57 pm

Re: Hiding foe quotes

Post by corleoner » Sat Apr 12, 2014 7:47 pm

This would be great foulfoot!!

FoulFoot
Registered User
Posts: 261
Joined: Mon Jun 23, 2003 1:04 am
Location: Honolulu, HI
Contact:

Re: Hiding foe quotes

Post by FoulFoot » Sun Apr 13, 2014 3:47 am

Here we go:

OPEN viewtopic.php

FIND

Code: Select all

$template->assign_vars(array(
	'S_NUM_POSTS' => sizeof($post_list))
);
AFTER, ADD

Code: Select all

// BEGIN Hide Quotes by Foes

// take each post on the page
foreach ( $rowset as $key1 => $message )
{
	// skip the post if there's no quote
	if ( strpos($message['post_text'],'[quote=') !== false ) 
	{
		// count opening quote tags to tell us how many quotes we have
		$grinder = $message['post_text'];
		$reps = substr_count($grinder,'[quote=');
				
		for ($x=0; $x<$reps; $x++)
		{
			// pull out nested quote or first quote (unnested)
			if ( preg_match('#\[quote="(.*?)":[\w]{8}]((?>(?:[^[]++|\[(?!/?quote[:=][^]]*?]))+|(?R))*)\[/quote:[\w]{8}]#s', $grinder, $quote) )
			{
			// single quote?
			if ( substr_count($quote[0],'[quote=') == 1 )
			{
				// peel off and store this quote
				$quotearray[] = array(
					"qtextrep" => $quote[0],
					"quser" => $quote[1],
					"qtext" => $quote[2],
					);
				$safe = '#' . preg_quote($quote[0], '#') . '#s';
				$grinder = preg_replace($safe, "", $grinder, 1);
			}
			// nested quote; peel off and store superior quote
			else
			{		
				if ( preg_match('#(^\[quote="(.*?)":[\w]{8}])(.*?)(\[quote=".*?":[\w]{8}].*\[/quote:[\w]{8}])(.*?)(\[/quote:[\w]{8}]$)#s', $quote[0], $quoteb) )
				{		
				$quotearray[] = array(
					"qtextrep" => $quoteb[0],
					"quser" => $quoteb[2],								
					"qtext" => $quoteb[3].$quoteb[4].$quoteb[5],
					); 
							
				$front = '#^' . preg_quote($quoteb[1], '#') .  preg_quote($quoteb[3], '#') . '#s';
				$back = '#' . preg_quote($quoteb[5], '#') .  preg_quote($quoteb[6], '#') . '$#s';
				$grinder = preg_replace($front, "", $grinder, 1);
				$grinder = preg_replace($back, "", $grinder, 1);
				}
			}
			}
		}
	}
}
unset($key1);

// skip the rest of this if there's no quotes on the page
if ( isset($quotearray) )
{
	// flatten the quote authors into a simple array
	foreach($quotearray as $idx => $temp) 
	{ 
		$qusers[] = $quotearray[$idx]['quser'];
	}  
	unset($idx);
	
	$qusers = array_unique($qusers);

	// see if any of these quote authors are on your foes list
	$sql_array = array(
		'SELECT'    => 'u.username, u.user_id',
		'FROM'      => array(
			USERS_TABLE     => 'u',
			ZEBRA_TABLE     => 'z',
		),
		'WHERE'     => 'z.user_id = ' . $user->data['user_id'] . '
			AND z.foe = 1
			AND u.user_id = z.zebra_id
			AND ' . $db->sql_in_set('u.username', $qusers),
	);
	$sql = $db->sql_build_query('SELECT', $sql_array);
	$result = $db->sql_query($sql);

	// for each foe author, replace their quote text with a "blocked" message	
	while( $cRow = $db-> sql_fetchrow($result) )
	{
		$qindex = $cRow['username'];
		$id = $cRow['user_id'];
		
		foreach ($quotearray as $key => $c)
		{	
			if ( $c['quser'] == $qindex )
			{
				$quote_rep = $c['qtextrep'];
				$quote_text = $c['qtext'];
				foreach ( $rowset as $key1 => $message )
				{	
					$quote_replace = '<blockquote><i><b><small>This quote is from <a href="'. $phpbb_root_path . 'memberlist.' . $phpEx . '?mode=viewprofile&u=' . $id .'">' . $qindex . '</a> who is currently on your ignore list.&nbsp;&nbsp;Remove this user from your Foes to view.</small></b></i></blockquote>';
		
					$rowset[$key1]['post_text'] = str_replace($quote_rep, $quote_replace, $rowset[$key1]['post_text']);		
				}
				unset ($key1);
			}
		}		
	}
	$db-> sql_freeresult($result);
	unset ($key);
}

// END Hide Quotes by Foes
The code above does *not* give the user the option to display the hidden quote. If you want that functionality, you must first install Primehalo's excellent Prime BBCode Spoiler: viewtopic.php?t=691145 . Once you have that mod (and this one) installed, make the following changes:

OPEN viewtopic.php

FIND

Code: Select all

$quote_replace = '<blockquote><i><b><small>This quote is from <a href="'. $phpbb_root_path . 'memberlist.' . $phpEx . '?mode=viewprofile&u=' . $id .'">' . $qindex . '</a> who is currently on your ignore list.&nbsp;&nbsp;Remove this user from your Foes to view.</small></b></i></blockquote>';
REPLACE WITH

Code: Select all

$quote_replace = '<div class="spoiler"><div class="spoiler-top"><a href="#toggle_spoiler" class="spoiler-link postlink-local" onclick="return(spoilerToggle(this));"><small>Display this quote.</small></a>&nbsp;&nbsp;<span class="spoiler-title"><small>This quote is from <a href="'. $phpbb_root_path . 'memberlist.' . $phpEx . '?mode=viewprofile&u=' . $id .'">' . $qindex . '</a> who is currently on your ignore list.</small></span></div><div class="spoiler-box" onclick="spoilerToggle(this);"><div class="spoiler-hidden">'.$quote_text.'</div></div></div>';
And optionally, to make things a little nicer:

OPEN language/en/mods/prime_bbcode_spoiler.php

FIND

Code: Select all

	'PRIME_BBCODE_SPOILER_HIDE'	=> '[Obscure]',
	'PRIME_BBCODE_SPOILER_SHOW'	=> '[Reveal]',
REPLACE WITH

Code: Select all

	'PRIME_BBCODE_SPOILER_HIDE'	=> '<small>Hide this quote.</small>',
	'PRIME_BBCODE_SPOILER_SHOW'	=> '<small>Display this quote.</small>',
For speed freaks, this mod adds a single SQL query and several preg_matches (along with str_replaces of foe quotes). It shouldn't effect speed noticeably even on large forums, but I figured I'd mention it.

Enjoy, and please let me know of any problems!

Foul
Last edited by FoulFoot on Thu Dec 11, 2014 3:38 am, edited 7 times in total.

FoulFoot
Registered User
Posts: 261
Joined: Mon Jun 23, 2003 1:04 am
Location: Honolulu, HI
Contact:

Re: Hiding foe quotes

Post by FoulFoot » Sun Apr 13, 2014 3:02 pm

Screenies:

BEFORE
Image


AFTER
Image
Last edited by FoulFoot on Wed May 21, 2014 12:28 am, edited 5 times in total.

corleoner
Registered User
Posts: 189
Joined: Wed Jan 29, 2014 9:57 pm

Re: Hiding foe quotes

Post by corleoner » Sun Apr 13, 2014 10:30 pm

Foulfoot - you are the man! (or woman if that is your gender :oops: ), but regardless you are awesome, thank you very much.

The first part of your code works perfectly.

Now, I did try to add the second part. I installed the prime bbcode spoiler mod, and then made the edits as you put them.

Here is what I get:

Display this quote. This quote is from Jave who is currently on your ignore list.
I don't see how anyone can watch this kid play and not be horrified. Lets see:
*He makes horrible decisions
*Throws into traffic
*Has horrible mechanics
*Throws off his backfoot
*Palms the ball while he runs keeping it away from his body
*Throws into 2 and 3 defenders consistently
*Relies on his speed to get himself out of trouble (Which won't work in the NFL) and
*Isn't patient in the pocket



That is the quote from the user who should be hidden. The text appears as normal text in the post, and there is not a clickable link to display the quote (even though it is already shown). It does not display inside a box like your screen shot shows.

Any clue what I may have done wrong? I'm pretty sure I did all the edits exactly as you showed, I cut and pasted them.

FoulFoot
Registered User
Posts: 261
Joined: Mon Jun 23, 2003 1:04 am
Location: Honolulu, HI
Contact:

Re: Hiding foe quotes

Post by FoulFoot » Sun Apr 13, 2014 11:40 pm

That's a problem with the Prime BBCode Spoiler mod -- looks like Javascript isn't enabled on your system? Does your browser / security settings have Javascript blocked?

After confirming that, I'd go back through the BBCode spoiler mod and double-check that you did everything correctly.

Foul

FoulFoot
Registered User
Posts: 261
Joined: Mon Jun 23, 2003 1:04 am
Location: Honolulu, HI
Contact:

Re: Hiding foe quotes

Post by FoulFoot » Sun Apr 13, 2014 11:49 pm

Make sure that you copied the four files from the "root" folder into their correct places. You don't need to make the edits under "DIY Instructions" unless you want the actual Spoiler BBCode functionality.

Foul

corleoner
Registered User
Posts: 189
Joined: Wed Jan 29, 2014 9:57 pm

Re: Hiding foe quotes

Post by corleoner » Mon Apr 14, 2014 12:22 am

Worked like a charm! Long story short, I have two prosilver styles and it needed to add to the other one for it to work on my other styles which inherit from prosilver.

Thanks again foulfoot, your work is greatly appreciated and a wonderful addition that every forum should add! I especially like the option of being able to show the quote because curiosity often gets the better of most of us. Great work!

FoulFoot
Registered User
Posts: 261
Joined: Mon Jun 23, 2003 1:04 am
Location: Honolulu, HI
Contact:

Re: Hiding foe quotes

Post by FoulFoot » Mon Apr 14, 2014 11:33 am

Awesome! Glad it's working for you now.

Foul

Locked

Return to “[3.0.x] MOD Requests”