keep unread flags

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
72
75%
Very Good
16
17%
Good
4
4%
Fair
0
No votes
Poor
4
4%
 
Total votes: 96

Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Re: keep unread flags

Post by Merlin Sythove »

I'll leave the support mostly to asinshesq since he is more familiar with the actual code at this time.

It LOOKS like your extra mod does the same as what was added to the Keep Unread mod a month or two ago: after posting a message you will be taken to your message, not to the last post in the topic (because other people may have posted in between), and certainly not to the first message in the topic. So ignore your extra mod for now, just install Keep Unread, I'm sure it works the way you expect already without your extra bits.
Need custom work done? Pimp My Forum!
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: keep unread flags

Post by asinshesq »

xceler8shun wrote:Hi,

I've just installed this mod and I think it is working, however, instant redirect is no longer working as it should. I will go straigt to the first post in a topic instead of the last post created by the poster.

This is the code in my posting.php file where I need to make the changes.

Code: Select all

		if ( $mode == 'newtopic' || $mode == 'reply' )
		{
			$tracking_topics = ( !empty($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_t']) : array();
			$tracking_forums = ( !empty($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) ) ? unserialize($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_f']) : array();

			if ( count($tracking_topics) + count($tracking_forums) == 100 && empty($tracking_topics[$topic_id]) )
			{
				asort($tracking_topics);
				unset($tracking_topics[key($tracking_topics)]);
			}

			$tracking_topics[$topic_id] = time();

			setcookie($board_config['cookie_name'] . '_t', serialize($tracking_topics), 0, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
			//-- mod : Instant Post Redirect ------------------------------------------------------------
			//-- add
			redirect(append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id", true) . '#' . $post_id);
			//-- fin mod : Instant Post Redirect --------------------------------------------------------
		}
Any help would be great.
That's odd...I answered this post yesterday when you made it but my answer did not take.

Anyway, the way to use your instant redirect with this mod is to add the redirect code after this in posting.php:

Code: Select all

			write_cookies($userdata);
But to be clear about what happens with or without your redirect code:

- if you do not put in your redirect code and the rest of your board looks normal, keep unread does not change the redirect code and so you will be brought to a screen that appears for 3 seconds and allows your users to select either to go to the message you just posted or to go to a list of topics in the forum you just posted to (and after 3 seconds it will automatically go to the message you just posted)

- if you do put in your redirect code and the rest of your board looks normal, you get immediately redirected to the message you just posted.

Neither one takes you to the first post in the topic you just posted to.
M<erlin wrote:It LOOKS like your extra mod does the same as what was added to the Keep Unread mod a month or two ago: after posting a message you will be taken to your message, not to the last post in the topic (because other people may have posted in between), and certainly not to the first message in the topic. So ignore your extra mod for now, just install Keep Unread, I'm sure it works the way you expect already without your extra bits.
The code recently added to keep unread does not change the post to which you get redirected. It only changes what posts are in fact marked as unread in the topic (there were instances where your own post was incorrectly marked as unread, especially when users clicked mark all posts read, and that's been fixed, I think).
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Re: keep unread flags

Post by Merlin Sythove »

Sorry, I was working from memory. I have a piece of code in my own forum that will re-set the topic unread time to what it was, instead of the post you have just made. This will make sure that if you reply to a 10-page topic on page 4, the topic remains unread from page 5 onward. I thought that was also dealt with in the mod as presented on this forum, if not, maybe we should add it :D
Need custom work done? Pimp My Forum!
nouveau
Registered User
Posts: 256
Joined: Tue Mar 27, 2007 1:51 pm

Re: keep unread flags

Post by nouveau »

asinshesq wrote: That's odd...I answered this post yesterday when you made it but my answer did not take.

Anyway, the way to use your instant redirect with this mod is to add the redirect code after this in posting.php:

Code: Select all

			write_cookies($userdata);
M<erlin wrote:It LOOKS like your extra mod does the same as what was added to the Keep Unread mod a month or two ago: after posting a message you will be taken to your message, not to the last post in the topic (because other people may have posted in between), and certainly not to the first message in the topic. So ignore your extra mod for now, just install Keep Unread, I'm sure it works the way you expect already without your extra bits.
The code recently added to keep unread does not change the post to which you get redirected. It only changes what posts are in fact marked as unread in the topic (there were instances where your own post was incorrectly marked as unread, especially when users clicked mark all posts read, and that's been fixed, I think).
Yup thats where I put in the code, as my posting.php now looks like this

Code: Select all

	if ( $error_msg == '' )
	{
		if ( $mode != 'editpost' )
		{
			$user_id = ( $mode == 'reply' || $mode == 'newtopic' ) ? $userdata['user_id'] : $post_data['poster_id'];
			update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);
		}
			$attachment_mod['posting']->insert_attachment($post_id);

		if ($error_msg == '' && $mode != 'poll_delete')
		{
			user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user);
		}

		//START MOD Keep_unread_2
		if ( $mode == 'newtopic' || $mode == 'reply' || $mode == 'quote' || ($mode == 'editpost' && $post_data['last_post']) )
		{
			//Get old tracking time and set set new default.
			$tracking_time = $board_config['tracking_unreads'][$topic_id];
			$board_config['tracking_unreads'][$topic_id] = time();
			//If the next post in this topic, beyond my "unread time", is not THIS post,
			//then mark the topic UNread at that post.
			//This covers situations where I reply to posts in the middle of a topic
			//and where people respond whilst I write a reply
			if ($tracking_time)
			{
				$sql = "SELECT post_id, post_time
				FROM "  . POSTS_TABLE . "
				WHERE post_time > $tracking_time
				AND topic_id = $topic_id
				ORDER BY post_time
				LIMIT 1";
				if ( !($result = $db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, 'Could not query latest post information', '', __LINE__, __FILE__, $sql);
				}
				$row = $db->sql_fetchrow($result);
				if ($row['post_id'] != $post_id && $row['post_time'] > 0)
				{
					$board_config['tracking_unreads'][$topic_id] = $row['post_time'] - 1; //-1 marks the found post as unread
				}
			}
			write_cookies($userdata);
			//-- mod : Instant Post Redirect ------------------------------------------------------------
			//-- add
			redirect(append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id", true) . '#' . $post_id);
			//-- fin mod : Instant Post Redirect --------------------------------------------------------
		}
		//END MOD Keep_unread_2
		//-- mod : Instant Post Redirect ------------------------------------------------------------
		//-- add
		elseif ( $mode == 'editpost' )
		{
		  redirect(append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id", true) . '#' . $post_id);
		}
		//-- fin mod : Instant Post Redirect --------------------------------------------------------

		$template->assign_vars(array(
			'META' => $return_meta)
		);
		message_die(GENERAL_MESSAGE, $return_message);
	}
I have "quick post es" mod added and when posting using quick reply it all works as it should and goes to the post I just typed, however if I use normal reply it goes to the first post. It is also the same if I edit a post, it will revert to the first post after being submitted.

Keep unread flags is working as it should though and the users are happy for it.
Formerly known as xceler8shun
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Re: keep unread flags

Post by Merlin Sythove »

Edit a post: Use echo statements to verify the post_id before saving the post and upon return, when $post_id is used in creating a redirect url. If you are directed to the first post instead of your own, I suspect the post_id is altered or reset to null or re-used at some point.
Need custom work done? Pimp My Forum!
nouveau
Registered User
Posts: 256
Joined: Tue Mar 27, 2007 1:51 pm

Re: keep unread flags

Post by nouveau »

If I remove the instant redirect, after the 3 seconds it will return to the post newly created or edited.

I cannot for the life of me find where it would be overwritten and why it works with quick post es
Formerly known as xceler8shun
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: keep unread flags

Post by asinshesq »

xceler8shun wrote:Yup thats where I put in the code, as my posting.php now looks like this

Code: Select all

	if ( $error_msg == '' )
	{
		if ( $mode != 'editpost' )
		{
			$user_id = ( $mode == 'reply' || $mode == 'newtopic' ) ? $userdata['user_id'] : $post_data['poster_id'];
			update_post_stats($mode, $post_data, $forum_id, $topic_id, $post_id, $user_id);
		}
			$attachment_mod['posting']->insert_attachment($post_id);

		if ($error_msg == '' && $mode != 'poll_delete')
		{
			user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $post_id, $notify_user);
		}

		//START MOD Keep_unread_2
		if ( $mode == 'newtopic' || $mode == 'reply' || $mode == 'quote' || ($mode == 'editpost' && $post_data['last_post']) )
		{
			//Get old tracking time and set set new default.
			$tracking_time = $board_config['tracking_unreads'][$topic_id];
			$board_config['tracking_unreads'][$topic_id] = time();
			//If the next post in this topic, beyond my "unread time", is not THIS post,
			//then mark the topic UNread at that post.
			//This covers situations where I reply to posts in the middle of a topic
			//and where people respond whilst I write a reply
			if ($tracking_time)
			{
				$sql = "SELECT post_id, post_time
				FROM "  . POSTS_TABLE . "
				WHERE post_time > $tracking_time
				AND topic_id = $topic_id
				ORDER BY post_time
				LIMIT 1";
				if ( !($result = $db->sql_query($sql)) )
				{
					message_die(GENERAL_ERROR, 'Could not query latest post information', '', __LINE__, __FILE__, $sql);
				}
				$row = $db->sql_fetchrow($result);
				if ($row['post_id'] != $post_id && $row['post_time'] > 0)
				{
					$board_config['tracking_unreads'][$topic_id] = $row['post_time'] - 1; //-1 marks the found post as unread
				}
			}
			write_cookies($userdata);
			//-- mod : Instant Post Redirect ------------------------------------------------------------
			//-- add
			redirect(append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id", true) . '#' . $post_id);
			//-- fin mod : Instant Post Redirect --------------------------------------------------------
		}
		//END MOD Keep_unread_2
		//-- mod : Instant Post Redirect ------------------------------------------------------------
		//-- add
		elseif ( $mode == 'editpost' )
		{
		  redirect(append_sid("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id", true) . '#' . $post_id);
		}
		//-- fin mod : Instant Post Redirect --------------------------------------------------------

		$template->assign_vars(array(
			'META' => $return_meta)
		);
		message_die(GENERAL_MESSAGE, $return_message);
	}
I have "quick post es" mod added and when posting using quick reply it all works as it should and goes to the post I just typed, however if I use normal reply it goes to the first post. It is also the same if I edit a post, it will revert to the first post after being submitted.

Keep unread flags is working as it should though and the users are happy for it.
Are you sure it's called quick post es? I can't find a quick post es on phpbb.com, but when I look at the quick post es that appears on phpbbhacks.com it does not alter the posting.php or includes/functions_post.php files at all. What's the link to the quick post es mod you are using?

As for where your code is messing up, it could happen in posting.php or it could happen in includes/functions_post.php. If you want to pm me those files (with code tags) I'll take a quick look.
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Re: keep unread flags

Post by Merlin Sythove »

Off topic: The instant post redirect code is duplicated in the IF and in the ELSE sections of code, but there is no difference. Having it once at the end, after the ELSE section, would be fine.
I don't see why it should not work other than that the $post_id is off.
Need custom work done? Pimp My Forum!
nouveau
Registered User
Posts: 256
Joined: Tue Mar 27, 2007 1:51 pm

Re: keep unread flags

Post by nouveau »

asinshesq, the mod details are below
## MOD Title: Quick Post ES (Expansion Set)
## MOD Author: reddog < N/A > (N/A) http://reddevboard.com/
## MOD Description: This Mod adds a quick reply form which is
## placed below every topic. Some options are
## available in this version, listed below in
## the Author Notes part.
## MOD Version: 1.1.3c
## MOD Compatibility: 2.0.21
I'll PM you both files now in

Code: Select all

 format
Formerly known as xceler8shun
nouveau
Registered User
Posts: 256
Joined: Tue Mar 27, 2007 1:51 pm

Re: keep unread flags

Post by nouveau »

i'll try and sort this out of the thread to not take away from the original purpose of the thread which is "keep unread flags"

thankyou asinshesq and Merlin Sythove for the help offered :)
Formerly known as xceler8shun
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: keep unread flags

Post by asinshesq »

xceler8shun wrote:i'll try and sort this out of the thread to not take away from the original purpose of the thread which is "keep unread flags"

thankyou asinshesq and Merlin Sythove for the help offered :)
Update: xceler8shun's problem turned out to be with the instant post redirect mod and not this one. He's got it all sorted out now.
cotp
Registered User
Posts: 445
Joined: Wed Sep 14, 2005 7:34 pm
Contact:

Re: keep unread flags

Post by cotp »

Wow 120 pages...

Does anyone know if there will be a way to migrate information to phpBB3 as for all my users unread posts ?

Cotp
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Re: keep unread flags

Post by asinshesq »

cotp wrote:Does anyone know if there will be a way to migrate information to phpBB3 as for all my users unread posts ?
I just answered this question in the phpbb3 view or mark unread posts thread here: http://www.phpbb.com/community/viewtopi ... 1#p3178841
tagalong
Registered User
Posts: 39
Joined: Mon Aug 27, 2007 1:54 am

Re: keep unread flags

Post by tagalong »

i just installed this, everything works great.

(i used the premodded files. thanks a bunch :D )

i haven't read thru this entire thread, so i apologize if this has been asked, but i'm wondering if there's a way to set it up so all posts show as unread for new users.
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Re: keep unread flags

Post by Merlin Sythove »

On my forum that would be 240.000 messages... :D

There is a limit of 300 entries (roughly), that is 300 topics that are unread from a given point onwards.
But there are no options to set that many recent topics to unread for newcomers.

You may try to experiment with the last visit date, artificially backdating it to a year ago, maybe that will do the trick to set last years topics all to unread, if no database unread information is found yet.
Need custom work done? Pimp My Forum!
Post Reply

Return to “[2.0.x] MOD Database Releases”