[BETA] Simple Ignore 1.4.0

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment! No new topics are allowed in this forum.
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

IMPORTANT: MOD Development Forum rules

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.
Ravenhearte
Registered User
Posts: 96
Joined: Fri Oct 10, 2003 3:45 pm
Location: Just this side of sane.
Contact:

Post by Ravenhearte » Fri Dec 12, 2003 2:57 pm

Release 1.3.0!

Now hopefully it'll finally get in the mod database. The unmarking of unread topics, which was accidentally left out of the last release, was intentionally left out of this release, due to the fact that I still cannot get index to properly detect these things, and it is more annoying than helpful in it's current form. Work continues on this and will hopefully be in the next release in perfect form. However, it's current WIP form is below.

Code: Select all

# 
#-----[ OPEN ]------------------------------------------ 
# 
viewforum.php
# 
#-----[ FIND ]------------------------------------------ 
# 
//
// Grab all the basic data (all topics except announcements)
// for this forum
//
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
//Get user ignore settings 
$sql = "SELECT ignored_id FROM " . IGNORE_TABLE . " WHERE user_id = " . $userdata[user_id]; 
if ( !($result = $db->sql_query($sql)) ) 
{ 
   message_die(GENERAL_ERROR, 'Error retrieving ignore user data', '', __LINE__, __FILE__, $sql); 
} 
$ignored_ids = array(); 
while( $row = $db->sql_fetchrow($result) ) 
{ 
   $ignored_ids[$row['ignored_id']] = true; 
}
# 
#-----[ FIND ]------------------------------------------ 
# 
	$topic_rowset[] = $row;
	$total_topics++;
}
# 
#-----[ AFTER, ADD ]------------------------------------------ 
#

//Check last post for ignored_ids
for($i=0; $i<$total_topics; $i++)
{
	if ( isset($ignored_ids[$topic_rowset[$i]['id2']]) && $ignored_ids[$topic_rowset[$i]['id2']] )
	{
		$sql = "SELECT p.post_id, p.poster_id, u.username, p.post_time FROM " . POSTS_TABLE . " p, "
		. USERS_TABLE . " u " . " WHERE p.topic_id = " . $topic_rowset[$i]['topic_id']
		. " AND u.user_id = p.poster_id ORDER BY post_id DESC";
		if ( !($result = $db->sql_query($sql)) )
		{
		   message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
		}
		while($row = $db->sql_fetchrow($result))
		{
			if( !(isset($ignored_ids[$row['poster_id']])) )
			{
				$topic_rowset[$i]['id2'] = $row['poster_id'];
				$topic_rowset[$i]['user2'] = $row['username'];
				$topic_rowset[$i]['post_time'] = $row['post_time'];
				$topic_rowset[$i]['post_username2'] = $row['post_username'];
				break;
			}
		}
	}
}

vHiker
Registered User
Posts: 333
Joined: Thu Feb 14, 2002 9:59 pm

Post by vHiker » Sun Dec 14, 2003 2:59 am

A few comments:

- There's a variable $ignore floating around that no longer is used. You may want to consider removing it.

- I would recommend changes to the ignoreusers table. The fields should be mediumint 8 to be consistent with other phpbb tables. Also, I would recommend indexing both fields.

- When you are ignoring a user, the "you are ignoring {username}" in the post and the unignore icon at the bottom are a bit much IMO - after all the idea is to make the posts of these users less visible. :wink: What I did in my forums was blank out the message, remove the unignore icon, and put an "unignore" link where the rank usually goes, i.e.

Code: Select all

$message = "";
$ignore_img = "";
$temp_url = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start&mode=unignore&ignoree_id=" . $postrow[$i]['user_id'] . "&sid=" . $userdata['session_id'];
$poster_rank = '<a href="' . $temp_url . '">' . $lang['Unignore_user'] . '</a>';
- When you "ignore" or "unignore" a user on a multi-page post it takes you to the first page which is kind of annoying. To fix this I suggest appending $start to the link. I would also add $sid to the link (like it always does when you watch/unwatch a topic) to accomodate coding of a session check to prevent malicious users from posting a link that would cause those who click on the link to unintentionally ignore (or unignore) a user:

$temp_url = "viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&start=$start&mode=ignore&ignoree_id=" . $postrow[$i]['user_id'] . "&sid=" . $userdata['session_id'];

- The WIP code posted above for viewforum.php still has a few bugs. When an ignored user is the last post in forum view it adjusts the name of the "last poster" (great) but when you click on the icon to go to the the "last post" it takes you to the ignored post. It is also not getting post_username from the query. Also, the post tracking is not ignoring topics with only ignored users. I fixed these issues and re-wrote the code to be a little cleaner...

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
viewforum.php
#
#-----[ FIND ]------------------------------------------
#
//
// Grab all the basic data (all topics except announcements)
// for this forum
//
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// Get user ignore settings
$ignored_ids = '';
if ($userdata['session_logged_in'])
{
	$sql = "SELECT ignored_id FROM " . IGNORE_TABLE . " WHERE user_id = " . $userdata[user_id];
	if ( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Error retrieving ignore user data', '', __LINE__, __FILE__, $sql);
	}
	while( $row = $db->sql_fetchrow($result) )
	{
		$ignored_ids .= ' , ' . $row['ignored_id'];
	}
	if ($ignored_ids) $ignored_ids = 'AND u.user_id NOT IN (' . substr($ignored_ids, 2) . ' )';
}

#
#-----[ FIND ]------------------------------------------
#
//
// Total topics ...
#
#-----[ BEFORE, ADD ]------------------------------------------
#
// Check last post for ignored_ids
for($i=0; $i<$total_topics; $i++)
{
	if (strpos($ignored_ids, ' ' . $topic_rowset[$i]['id2'] . ' '))
	{
		$sql = "SELECT p.post_id, p.poster_id, p.post_username, u.username, p.post_time FROM " . POSTS_TABLE . " p, "
		. USERS_TABLE . " u " . " WHERE p.topic_id = " . $topic_rowset[$i]['topic_id']
		. " AND u.user_id = p.poster_id $ignored_ids
			ORDER BY post_id DESC
			LIMIT 1";
		if ( !($result = $db->sql_query($sql)) )
		{
			message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
		}
		$topic_rowset[$i]['post_time'] = -$topic_rowset[$i]['post_time']; // necessary to mark topic as read in case all posters in topic are ignored
		if ($row = $db->sql_fetchrow($result))
		{
			$topic_rowset[$i]['id2'] = $row['poster_id'];
			$topic_rowset[$i]['user2'] = $row['username'];
			$topic_rowset[$i]['post_time'] = $row['post_time'];
			$topic_rowset[$i]['post_username2'] = $row['post_username'];
			$topic_rowset[$i]['topic_last_post_id'] = $row['post_id'];
		}
	}
}
#
#-----[ FIND ]------------------------------------------
#
		$last_post_time = create_date($board_config['default_dateformat'], $topic_rowset[$i]['post_time'], $board_config['board_timezone']);
#
#-----[ REPLACE WITH ]------------------------------------------
#
		$last_post_time = create_date($board_config['default_dateformat'], abs($topic_rowset[$i]['post_time']), $board_config['board_timezone']);
- I think I might have something for index.php, and search.php as well...
Last edited by vHiker on Sun Dec 14, 2003 9:39 pm, edited 3 times in total.

vHiker
Registered User
Posts: 333
Joined: Thu Feb 14, 2002 9:59 pm

Post by vHiker » Sun Dec 14, 2003 9:15 am

As promised, here is the silver bullet for index.php. :wink:

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
index.php
#
#-----[ FIND ]------------------------------------------
#
	if ( $userdata['session_logged_in'] )
	{
#
#-----[ AFTER, ADD ]------------------------------------------
#
		// Get user ignore settings
		$ignored_ids = '';
		if ($userdata['session_logged_in'])
		{
			$sql = "SELECT ignored_id FROM " . IGNORE_TABLE . " WHERE user_id = " . $userdata[user_id];
			if ( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'Error retrieving ignore user data', '', __LINE__, __FILE__, $sql);
			}
			while( $row = $db->sql_fetchrow($result) )
			{
				$ignored_ids .= ' , ' . $row['ignored_id'];
			}
			if ($ignored_ids) $ignored_ids = 'AND u.user_id NOT IN (' . substr($ignored_ids, 2) . ' )';
		}
#
#-----[ FIND ]------------------------------------------
#
		$sql = "SELECT t.forum_id, t.topic_id, p.post_time 
#
#-----[ AFTER, ADD]------------------------------------------
#
			, p.poster_id
#
#-----[ FIND ]------------------------------------------
#
			$new_topic_data[$topic_data['forum_id']][$topic_data['topic_id']] = $topic_data['post_time'];
#
#-----[ BEFORE, ADD ]------------------------------------------
#
			if (strpos($ignored_ids, ' ' . $topic_data['poster_id'] . ' '))
			{
				if (!$already_recalc_post_time)
				{
					$sql = "SELECT topic_id, max(post_time) as post_time
						FROM " . POSTS_TABLE . "
						WHERE post_time > " . $userdata['user_lastvisit'] . "
						" . str_replace('u.user_id', 'poster_id', $ignored_ids) . "
						GROUP BY post_id";

					if ( !($result = $db->sql_query($sql)) )
					{
						message_die(GENERAL_ERROR, 'Could not query last unignored post information', '', __LINE__, __FILE__, $sql);
					}

					while ( $row = $db->sql_fetchrow($result) )
					{
						$recalc_post_time[$row['topic_id']] = $row['post_time'];
					}

					$already_recalc_post_time = true;
				}
				$topic_data['post_time'] = $recalc_post_time[$topic_data['topic_id']];
			}

#
#-----[ FIND ]------------------------------------------
#
							if ( $forum_data[$j]['forum_last_post_id'] )
#
#-----[ BEFORE, ADD ]------------------------------------------
#

							if (strpos($ignored_ids, ' ' . $forum_data[$j]['user_id'] . ' '))
							{
								$sql = "SELECT t.topic_title, p.post_id, p.post_time, p.post_username, u.username
									FROM " . TOPICS_TABLE . " t, " . POSTS_TABLE . " p, " . USERS_TABLE . " u
									WHERE p.topic_id = t.topic_id AND u.user_id = p.poster_id AND t.forum_id = $forum_id
										$ignored_ids
										AND t.topic_moved_id = 0
									ORDER BY post_id DESC
									LIMIT 1";

								if ( !($result = $db->sql_query($sql)) )
								{
									message_die(GENERAL_ERROR, 'Could not query forum last post information', '', __LINE__, __FILE__, $sql);
								}

								if ( $row = $db->sql_fetchrow($result) )
								{
									$forum_data[$j]['topic_title'] = $row['topic_title'];
									$forum_data[$j]['forum_last_post_id'] = $row['post_id'];
									$forum_data[$j]['post_time'] = $row['post_time'];
									$forum_data[$j]['post_username'] = $row['post_username'];
									$forum_data[$j]['username'] = $row['username'];
									$forum_data[$j]['user_id'] = $row['user_id'];
								}
							}

vHiker
Registered User
Posts: 333
Joined: Thu Feb 14, 2002 9:59 pm

Post by vHiker » Sun Dec 14, 2003 7:21 pm

Similarly, this mod to search.php is needed for post tracking to work properly with the "view posts since last visit" feature and similar active topic searches:

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
search.php
#
#-----[ FIND ]------------------------------------------
#
		for($i = 0; $i < count($searchset); $i++)
#
#-----[ BEFORE, ADD ]------------------------------------------
#
		// Get user ignore settings
		$ignored_ids = '';
		if ($userdata['session_logged_in'] && $show_results != 'posts')
		{
			$sql = "SELECT ignored_id FROM " . IGNORE_TABLE . " WHERE user_id = " . $userdata[user_id];
			if ( !($result = $db->sql_query($sql)) )
			{
				message_die(GENERAL_ERROR, 'Error retrieving ignore user data', '', __LINE__, __FILE__, $sql);
			}
			while( $row = $db->sql_fetchrow($result) )
			{
				$ignored_ids .= ' , ' . $row['ignored_id'];
			}
			if ($ignored_ids) $ignored_ids = 'AND u.user_id NOT IN (' . substr($ignored_ids, 2) . ' )';
		}
#
#-----[ FIND ]------------------------------------------
#
						if ( $searchset[$i]['post_time'] > $userdata['user_lastvisit'] ) 
#
#-----[ BEFORE, ADD]------------------------------------------
#
						// Check last post for ignored_ids
						if (strpos($ignored_ids, ' ' . $searchset[$i]['id2'] . ' '))
						{
							$sql = "SELECT p.post_id, p.poster_id, p.post_username, u.username, p.post_time FROM " . POSTS_TABLE . " p, "
							. USERS_TABLE . " u " . " WHERE p.topic_id = " . $searchset[$i]['topic_id']
							. " AND u.user_id = p.poster_id $ignored_ids
								ORDER BY post_id DESC
								LIMIT 1";
							if ( !($result = $db->sql_query($sql)) )
							{
								message_die(GENERAL_ERROR, 'Could not obtain topic information', '', __LINE__, __FILE__, $sql);
							}
							$searchset[$i]['post_time'] = -$searchset[$i]['post_time']; // necessary to mark topic as read in case all posters in topic are ignored
							if ($row = $db->sql_fetchrow($result))
							{
								$searchset[$i]['id2'] = $row['poster_id'];
								$searchset[$i]['user2'] = $row['username'];
								$searchset[$i]['post_time'] = $row['post_time'];
								$searchset[$i]['post_username2'] = $row['post_username'];
								$searchset[$i]['topic_last_post_id'] = $row['post_id'];
							}
						}
#
#-----[ FIND ]------------------------------------------
#
				$last_post_time = create_date($board_config['default_dateformat'], $searchset[$i]['post_time'], $board_config['board_timezone']);
#
#-----[ REPLACE WITH ]------------------------------------------
#
				$last_post_time = create_date($board_config['default_dateformat'], abs($searchset[$i]['post_time']), $board_config['board_timezone']);

vHiker
Registered User
Posts: 333
Joined: Thu Feb 14, 2002 9:59 pm

Post by vHiker » Mon Dec 15, 2003 2:56 am

Found a bug in release 1.30. Basically guest posts are displaying the $ignore_img of the member before it. To fix this, change the code in viewtopic.php to initialize the $ignore variables, i.e.

Code: Select all

# 
#-----[ FIND ]------------------------------------------ 
#
	if ( $poster_id != ANONYMOUS )
	{
# 
#-----[ BEFORE, ADD ]------------------------------------------ 
#
	$ignore_img = "";
	$ignore = "";
# 
#-----[ FIND ]------------------------------------------ 
#
	if ( $poster_id != ANONYMOUS )
	{
# 
#-----[ AFTER, ADD ]------------------------------------------ 
#
		if ($userdata['session_logged_in'])
		{
			$temp_url = ...
			$ignore_img = ...
			$ignore = ...
		}

Ravenhearte
Registered User
Posts: 96
Joined: Fri Oct 10, 2003 3:45 pm
Location: Just this side of sane.
Contact:

Post by Ravenhearte » Mon Dec 15, 2003 2:55 pm

Thanks, I'll try to implement these changes as soon as possible. Probably when I retrieve my computer from the house I was kicked out of. Right now I'm posting from work, maybe I can work on it during my luch break and get out a new release in the next couple days.

stujoe
Registered User
Posts: 55
Joined: Sun May 18, 2003 9:39 pm

Post by stujoe » Wed Dec 17, 2003 1:19 am

Is there a way to get the ignored users not to show up in ANY searches?
Stujoe

stujoe
Registered User
Posts: 55
Joined: Sun May 18, 2003 9:39 pm

Post by stujoe » Wed Dec 17, 2003 1:34 am

Also, so far, I have not been able to get the index or viewforum parts to work right. It might be conflicting with another mod for me. Not sure. or it just might be because they are not done yet?
Stujoe

vHiker
Registered User
Posts: 333
Joined: Thu Feb 14, 2002 9:59 pm

Post by vHiker » Wed Dec 17, 2003 2:30 am

What doesn't work right?

stujoe
Registered User
Posts: 55
Joined: Sun May 18, 2003 9:39 pm

Post by stujoe » Wed Dec 17, 2003 2:50 am

I am thinking that for the index and viewforum, the ignore user should not show up in the 'Last Post by:..." part? If so, when I did it, the ignored user would still show up. I may have mesed up the edits but I did it twice.

If that is the way it is supposed to work, I will try it again and try to give more info. I think I may have had a problem because of an existing mod (the categories hiearch mod) in view forum but am not sure what teh problem was n the Index.php part.
Stujoe

vHiker
Registered User
Posts: 333
Joined: Thu Feb 14, 2002 9:59 pm

Post by vHiker » Wed Dec 17, 2003 4:43 am

The index.php mod does two things.

1) if the last post in a forum is by an ignored user, it will display the last post by an unignored user.

2) if all unignored posts in a forum have been read, it will mark the forum as read.

So far I haven't had an problems on my site. If you have installed it properly and it's still not working, perhaps it's due to the other mod(s) you have installed.

stujoe
Registered User
Posts: 55
Joined: Sun May 18, 2003 9:39 pm

Post by stujoe » Wed Dec 17, 2003 4:59 am

That is my guess too. Probably the Categories Hierarchy (1.1.0). It changes up the last post info. I will poke around with it and see if I can figure it out.

Not a huge issue. I would realy like to see all the ignored users post eliminated from searches but not sure if that is possible.
Stujoe

Ravenhearte
Registered User
Posts: 96
Joined: Fri Oct 10, 2003 3:45 pm
Location: Just this side of sane.
Contact:

Post by Ravenhearte » Wed Dec 17, 2003 2:31 pm

I really wish I could give better support for this and look into finding out why it conflicts with CH, but at the moment my hands are sorta tied.

stujoe
Registered User
Posts: 55
Joined: Sun May 18, 2003 9:39 pm

Post by stujoe » Thu Dec 18, 2003 1:56 am

That's ok. I have been thinking of trying the Control panel Mod again but it has some things that are troubling for my site and I do not believe it eliminates users from searches either. Anyway, your mod does eliminate the user's posts from Viewtopic on my site and is easy to install so i am going to keep with it for a while.
Stujoe

Dagon
Registered User
Posts: 422
Joined: Tue Jun 03, 2003 8:59 pm

Post by Dagon » Fri Dec 26, 2003 6:09 am

If your mod is 1.3.0, it should probably say 1.3.0 in the mod version on the install text instead of 1.2.0. :)

Post Reply

Return to “[2.0.x] MODs in Development”