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

Post by Merlin Sythove »

asinshesq wrote: If statement I quoted in my last post above compares the post_id of the last elelment in $postrow[]['post_id'] to the last_post_id of the topic. If the post_id of the last element in $postrow[]['post_id'] (i.e. that post_id of the latest post in the topic as measured by post_time) is not the same as last+_post_id of the topic, viewtopic calls sync (which is where the trouble comes from).


Correct, and the problem arises because sync uses the post_id ordering, and not the time. That is (as far as I can tell) a left-over from an older version of phpBB that used the post_id for topic ordering, and it should be changed. On my board it is already changed, but I have no info anymore on whether I did that or if it was part of an update. I just noticed that 2.0.20 code of sync has the old ordering. The problem really is with sync, not with any mod that changes the post time, since the sync function is already "out of sync" compared to the standard viewtopic.php - they use different ways to sort posts in a topic.
Need custom work done? Pimp My Forum!
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

Merlin Sythove wrote:
asinshesq wrote:If statement I quoted in my last post above compares the post_id of the last elelment in $postrow[]['post_id'] to the last_post_id of the topic. If the post_id of the last element in $postrow[]['post_id'] (i.e. that post_id of the latest post in the topic as measured by post_time) is not the same as last+_post_id of the topic, viewtopic calls sync (which is where the trouble comes from).


Correct, and the problem arises because sync uses the post_id ordering, and not the time.

Symantecs. I would say the problem arises because viewtopic calls sync() when it perhaps should not (since viewtopic effectively compares post_id of post with the last_post_id to post_id of the post with the highest post_time). You could fix that by getting away from last_post_id altogether (it should really be last_post_time). But I would be very very cautious about changing this concept, because while it would be easy to fix phpbb for this point you would be risking breaking other mods that assume phpbb works the way unmodded phpbb works on this point.

(My original save posts as drafts mod saved a post as a draft simply by setting a flag and then when the user decided to submit the post live it got rid of the flag and updated the post_time; but in development a number of people suggested it would be a bad idea to allow time sequence to get out of sync with post_id sequence so I changed things to provide that when the draft gets submitted as a live post the mod inserts a brand new post with a new post_id and post_time and deletes the old one.)
zeber
Registered User
Posts: 55
Joined: Thu Apr 03, 2003 8:17 pm

Post by zeber »

Merlin Sythove wrote: Zeber, if you're up to it, would you mind running a test?

Sorry for being away for several days: some unexpected relatives arrived =)

As far as i have read, the discussion made some progress since your test request (considering the sync stuff), so should i run the code you asked or some more changes must be yet made? I'm ready to do all that tommorow (on clean install first).
Zeber
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Post by Merlin Sythove »

http://www.phpbb.com/phpBB/viewtopic.ph ... 16#2610416

This post and the next one propose some solutions. The first solution should be solid, the second one may need tweaking, both need testing to see if they solve your problem, before we continue.
Need custom work done? Pimp My Forum!
zeber
Registered User
Posts: 55
Joined: Thu Apr 03, 2003 8:17 pm

Post by zeber »

Merlin Sythove wrote: see if they solve your problem, before we continue.

No, they do not. I did not come up to testing simultaneous posts as far as simple refresh makes again the post forever READ.

Is all correct?

includes/functions.php

Code: Select all

	}
	$board_config['tracking_time'] = time();
	//MOD Keep_unread: solving refresh bypassing new posts 
	$sql = "SELECT MAX(post_time) AS maxtime 
	FROM "  . POSTS_TABLE; 
	if ( !($result = $db->sql_query($sql)) ) 
	{
		message_die(GENERAL_ERROR, 'Could not query latest post information', '', __LINE__, __FILE__, $sql); 
	}
	$row = $db->sql_fetchrow($result); 
	$board_config['tracking_time'] = $row['maxtime'];
	$board_config['tracking_unreads'] = $new_unreads;
	write_cookies($userdata); //save

	return $new_unreads;
}
posting.php

Code: Select all

		//START MOD Keep_unread_2
		if ( $mode == 'newtopic' || $mode == 'reply' || $mode == 'quote' || ($mode == 'editpost' && $post_data['last_post']) )
		{
			$sql = "SELECT post_id, post_time 
			FROM "  . POSTS_TABLE . " 
			WHERE post_time > " . $board_config['tracking_unreads'][$topic_id] . " 
			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) 
			{ 
				$board_config['tracking_unreads'][$topic_id] = $row['post_time']; 
			} 
			write_cookies($userdata);
		}
		//END MOD Keep_unread_2
Zeber
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Post by Merlin Sythove »

The first block of code is indeed correct.

If it does not solve the problem (you need TWO refreshes, correct?) then I'll have to rethink the situation.

Just out of interest, you could try this:
Remove the new block that we added, and change this line:

Code: Select all

   $board_config['tracking_time'] = time(); 
to

Code: Select all

   $board_config['tracking_time'] = time() - 5 * 60; 
so that we start working with a tracking time of 5 minutes ago. It may not work without altering more code elsewhere, and it will mess up your current unread list.

The main problem is that a refresh may fall in the middle of someone posting a long post, and that refresh sets the tracking time to now, when you have not yet collected the post being made but its time is already set. Please note that the tracking time was introduced to solve the spurious marking your own post as UNread, so this is not a definite solution, just a test to see if we might be going in the right direction.
Need custom work done? Pimp My Forum!
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Post by Merlin Sythove »

Just looking through the code, help me out, the refresh is in viewtopic?

Try this:

in viewtopic.php find

Code: Select all

$board_config['tracking_unreads'][$topic_id] = time();
and change it to

Code: Select all

$board_config['tracking_unreads'][$topic_id] = $postrow[$lastpost]['post_time'];
so the topic is not read up to "now" but only up to the last visible post, allowing a post currently being processed to remain unread. See if that solves it. Somehow the problem is in a mismatch and using time() when we should not use the current moment but the last post that is visible or in the topic etc.
Need custom work done? Pimp My Forum!
zeber
Registered User
Posts: 55
Joined: Thu Apr 03, 2003 8:17 pm

Post by zeber »

Merlin Sythove wrote: If it does not solve the problem (you need TWO refreshes, correct?)

Sure, everything is as usual.
Merlin Sythove wrote: Remove the new block that we added, and change this line:

Code: Select all

   $board_config['tracking_time'] = time(); 
to

Code: Select all

   $board_config['tracking_time'] = time() - 5 * 60; 

Here the post is UNread, but because of these 5 min. it remains UNread even after "mark all posts as read".
Merlin Sythove wrote: in viewtopic.php find

Code: Select all

$board_config['tracking_unreads'][$topic_id] = time();
and change it to

Code: Select all

$board_config['tracking_unreads'][$topic_id] = $postrow[$lastpost]['post_time'];

It is hard for me to make such a test on clean install - viewtopic is too slow to get refreshed, so that the first refresh completes after the post is submitted. All i can say is that both variants work..

Upd: I finally managed the last one. Got Read posts with the change and without it.
Zeber
angelp1ay
Registered User
Posts: 175
Joined: Tue Dec 23, 2003 1:32 pm
Location: Bristol, UK
Contact:

Post by angelp1ay »

Mod might want to include an update to the lang vars, this is the relevant section of mine:

Code: Select all

$lang['No_new_posts_last_visit'] = 'No unread posts';
$lang['No_new_posts'] = 'No unread posts';
$lang['New_posts'] = 'Unread posts';
$lang['New_post'] = 'Unread post';
$lang['No_new_posts_hot'] = 'No unread posts [ Popular ]';
$lang['New_posts_hot'] = 'Unread posts [ Popular ]';
$lang['No_new_posts_locked'] = 'No unread posts [ Locked ]';
$lang['New_posts_locked'] = 'Unread posts [ Locked ]';
$lang['Post_Poll'] = 'No unread posts [ Poll ]';
$lang['New_Post_Poll'] = 'Unread posts [ Poll ]';
$lang['Forum_is_locked'] = 'Forum is locked';
angelp1ay
Registered User
Posts: 175
Joined: Tue Dec 23, 2003 1:32 pm
Location: Bristol, UK
Contact:

Post by angelp1ay »

I have installed on my board View new topics since last visit v1_0_2 which still allows users to search for topics posted since last visit as well as those marked unread. Currently the index has the following:

Code: Select all

View topics since last visit (3 topics, 5 posts)
View all unread posts (2 topics)
View all unanswered posts
View all of your posts

View all posts in last:  - time period - 
I am using your little patch to dig out posts since last visit (in the code block "5 posts"). The view topics since last visit link successfully displays a search page with a list of all new topics. Is it possible to still get a search page with a list of all new posts? From what I understand of the mod it seems to overwrite the "view posts since last visit" code with "view all unread posts" - can you get both?

I was going to try to modify the view topics since last visit mod but since the link is search.php?search_id=newtopics I presume this is just another built in function like search.php?search_id=newposts which we've grabbed for unread posts already.

It would be nice to get to:

Code: Select all

View topics since last visit (3 topics)
View posts since last visit (5 posts)
View all unread posts (2 topics)
View all unanswered posts
View all of your posts

View all posts in last:  - time period - 
What do you think?
angelp1ay
Registered User
Posts: 175
Joined: Tue Dec 23, 2003 1:32 pm
Location: Bristol, UK
Contact:

Post by angelp1ay »

My bad, I just checked the mod file and it is added in not a built in function - sorry my understanding is a little limited. I found the link to the mod:

http://www.phpbb.com/phpBB/viewtopic.php?t=222168

I presume if I run through this again substituting "newtopics" for say "postssincevisit" (so as not to clash with the keep unread mod) and if I tweak the SQL to dig out posts instead of topics...

Anyway I guess this might help some other people - I'll post an update once I try going through this.
asinshesq
Registered User
Posts: 6266
Joined: Sun Feb 22, 2004 9:34 pm
Location: NYC
Name: Alan

Post by asinshesq »

angelp1ay wrote: Mod might want to include an update to the lang vars, this is the relevant section of mine:

Code: Select all

$lang['No_new_posts_last_visit'] = 'No unread posts';
$lang['No_new_posts'] = 'No unread posts';
$lang['New_posts'] = 'Unread posts';
$lang['New_post'] = 'Unread post';
$lang['No_new_posts_hot'] = 'No unread posts [ Popular ]';
$lang['New_posts_hot'] = 'Unread posts [ Popular ]';
$lang['No_new_posts_locked'] = 'No unread posts [ Locked ]';
$lang['New_posts_locked'] = 'Unread posts [ Locked ]';
$lang['Post_Poll'] = 'No unread posts [ Poll ]';
$lang['New_Post_Poll'] = 'Unread posts [ Poll ]';
$lang['Forum_is_locked'] = 'Forum is locked';


Sorry, I'm not following what you mean. The the following changes are the only changes this mod makes to the language files:

Code: Select all

#
#-----[ OPEN ]------------------------------------------------
#
language/lang_english/lang_main.php

#
#-----[ FIND ]------------------------------------------------
#
$lang['Search_new'] = 'View posts since last visit';

#
#-----[ REPLACE WITH ]------------------------------------------------
#
$lang['Search_new'] = 'View unread posts';

#
#-----[ FIND ]------------------------------------------------
#
?>

#
#-----[ BEFORE, ADD ]------------------------------------------------
#
//MOD Keep_unread
$lang['keep_post_unread_explain'] = 'Mark post as unread';
$lang['keep_unread_done'] = 'The post has been marked as unread.';
$lang['View_unread_posts'] = 'View unread posts';
$lang['No_unread_posts'] = 'You have no unread posts';
I'm not sure what mods have changed your langauge files the way you show but it wasn't this mod.
angelp1ay
Registered User
Posts: 175
Joined: Tue Dec 23, 2003 1:32 pm
Location: Bristol, UK
Contact:

Post by angelp1ay »

asinshesq wrote:
angelp1ay wrote:Mod might want to include an update to the lang vars, this is the relevant section of mine...

Sorry, I'm not following what you mean...

I was just pointing out that after this mod the forum and thread graphics no longer represent forums with new posts, rather they represent that the forum or thread contains unread posts. As such it makes sense that their descriptions are changed from "new posts" to "unread posts". I merely posted my version of the language vars in example.
Merlin Sythove
Registered User
Posts: 2339
Joined: Tue Mar 16, 2004 7:42 am

Post by Merlin Sythove »

angelp1ay wrote: ... As such it makes sense that their descriptions are changed from "new posts" to "unread posts".


Yep, possible, but since "new" is relative and COULD mean "new in the sense of posted after the last one that you read" it is a question of preference.
Need custom work done? Pimp My Forum!
angelp1ay
Registered User
Posts: 175
Joined: Tue Dec 23, 2003 1:32 pm
Location: Bristol, UK
Contact:

Post by angelp1ay »

Merlin Sythove wrote:
angelp1ay wrote:... As such it makes sense that their descriptions are changed from "new posts" to "unread posts".


Yep, possible, but since "new" is relative and COULD mean "new in the sense of posted after the last one that you read" it is a question of preference.

But the user isn't forced to read posts in chronological order so infact posts marked unread (or "new" with your lang vars) need not be the most recent.

It was just a suggestion, and a relatively simple one to implement at that.
Post Reply

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