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

tagalong
Registered User
Posts: 39
Joined: Mon Aug 27, 2007 1:54 am

Re: keep unread flags

Post by tagalong » Fri Sep 07, 2007 2:05 am

Merlin Sythove wrote:On my forum that would be 240.000 messages... :D

ACK!!! no i don't think that would be necessary, hadn't thought that far ahead, LOL

i created a test account after installing the mod and the test account didn't show any posts unread, though.

if it's supposed to show unreads (up to 300) for a new user account, then it is likely something in my computer, as i had problems with the "new post" icon as well when alternating between admin account and test accounts, and i will try from a different computer.

thanks.

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

Re: keep unread flags

Post by Merlin Sythove » Fri Sep 07, 2007 6:55 am

Try this:

In includes/sessions.php find

Code: Select all

$last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time;
and change it to this:

Code: Select all

$last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time;
//Testing to get brand new users to see the previous 6 months of messages as unread:
if ($userdata['username'] == "TestName")
{
  $last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : time() - 6 * 30 * 24 * 3600;
}
Next, make a new account for yourself with the name TestName and log in and see what happens. Let me know. $last_visit is saved in $userdata['user_lastvisit'] and this again is used later on to determine which messages are "new", written after the user visited last. That is the theory... :D

(Using a hard-coded name ensures that other users won't be troubled if YOUR experiment goes wrong. For example, user_session_time must be checked to see that it can never become zero, causing the last 6 months of messages to become unread again. If this trick works, it pays to perform that check)
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 » Fri Sep 07, 2007 1:15 pm

tagalong wrote:if it's supposed to show unreads (up to 300) for a new user account, then it is likely something in my computer, as i had problems with the "new post" icon as well when alternating between admin account and test accounts, and i will try from a different computer.
No, by design it is NOT supposed to show any unread posts to a new user. The only posts it is supposed to show as unread are posts made since the user joined that he hasn't already read.

I gather merlin is giving you some code to alter that normal behavior, but what you are describing is the normal and intended behavior.

tagalong
Registered User
Posts: 39
Joined: Mon Aug 27, 2007 1:54 am

Re: keep unread flags

Post by tagalong » Fri Sep 07, 2007 2:51 pm

Merlin Sythove wrote: (Using a hard-coded name ensures that other users won't be troubled if YOUR experiment goes wrong. For example, user_session_time must be checked to see that it can never become zero, causing the last 6 months of messages to become unread again. If this trick works, it pays to perform that check)
the test worked like a charm. exactly what i want it to do.

i'm not sure though exactly what you mean here about user_session_time must be checked.

mind you it's a new forum and at the moment all my users are people i know, so testing it without a hard-coded name wouldn't be a problem.

thank you very much! :mrgreen:

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

Re: keep unread flags

Post by Merlin Sythove » Fri Sep 07, 2007 4:58 pm

tagalong wrote:the test worked like a charm. exactly what i want it to do.
Brilliant. I'm sure asinshesq can add it as a micro-mod to the bundle :-)
i'm not sure though exactly what you mean here about user_session_time must be checked.
Because of what I did in the code, if user_session_time ever got set to zero, then that user would lose their current unread list and revert to having all posts from the last 6 months unread again. So careful checking of that variable was necessary. I HAVE checked it and that variable is never set to zero (in standard phpBB), but only ever set to the current time. So you are safe with the modification. Just make sure you document it in some way.
Need custom work done? Pimp My Forum!

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

Re: keep unread flags

Post by Merlin Sythove » Fri Sep 07, 2007 5:04 pm

This is the final micro-mod, that will set all posts from the last 6 months to unread for new, first time users of your forum. Adjust the number (6 months = 6 * 30 * 24 * 3600) as you like.

In includes/sessions.php find

Code: Select all

$last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time;
and change it to this:

Code: Select all

//MOD Keep_unread: Set posts from the last 6 months to unread for new first-time users 
//$last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : $current_time;
  $last_visit = ( $userdata['user_session_time'] > 0 ) ? $userdata['user_session_time'] : time() - 6 * 30 * 24 * 3600;
Need custom work done? Pimp My Forum!

tagalong
Registered User
Posts: 39
Joined: Mon Aug 27, 2007 1:54 am

Re: keep unread flags

Post by tagalong » Fri Sep 07, 2007 7:24 pm

Merlin Sythove wrote:Just make sure you document it in some way.
absolutely. your efforts are very much appreciated.

it is wonderful to see you and asinshesq still actively and quickly responding here two years later :D

thank you.

momoftwo
Registered User
Posts: 188
Joined: Mon Mar 05, 2007 4:07 pm

Re: keep unread flags

Post by momoftwo » Mon Oct 01, 2007 4:34 pm

I want to install a mod for unread topics, now am is this mod enough to accomplish this or do i need to upload and install another mod and then use this one to make upgrades?? I was a bit confused cause when i opned the zip file, all it had was upgrades and changed files.

also, which should i install first??

i am using ezmod so i hope this is ok

thanks

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

Re: keep unread flags

Post by asinshesq » Tue Oct 02, 2007 10:32 am

momoftwo wrote:I want to install a mod for unread topics, now am is this mod enough to accomplish this or do i need to upload and install another mod and then use this one to make upgrades?? I was a bit confused cause when i opned the zip file, all it had was upgrades and changed files.
You either have the wrong zip file are are not looking in the right place. The zip file has a file called keep unread 2-0-7.txt right there in the root. That's the one and only one mod file you need with ezmod. The upgrades are for upgrading, so if you don't have a prior version of this mod already installed you would not touch them.

momoftwo
Registered User
Posts: 188
Joined: Mon Mar 05, 2007 4:07 pm

Re: keep unread flags

Post by momoftwo » Wed Oct 03, 2007 2:43 am

thanks! you are correct...great mod!

and thank goodness for easy mod! :D

ace2ace
Registered User
Posts: 364
Joined: Sat Aug 14, 2004 3:48 pm

Re: keep unread flags

Post by ace2ace » Wed Oct 03, 2007 4:10 am

my Keep-unread MOD stopped working.
When I click on the orange little icon to go to viewtopic, I guet disconnected. :(
Where do I start for the fix.. ?
Maybe someone ran into this problem before...

All used to work fine.. Not sure what MOD killed it.

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

Re: keep unread flags

Post by Merlin Sythove » Wed Oct 03, 2007 6:45 am

I'm sure we would like some more information. Such as what "disconnected" means.

The little orange icon, is that the one where, if you hover with the mouse over it, the status bar says "viewtopic.php?t=nnnn&view=newest"?
If the link is NOT lke this, the problem is in the current page (maybe search.php or viewforum.php).
If the link is as given, the problem is probably in viewtopic.php.
Need custom work done? Pimp My Forum!

ace2ace
Registered User
Posts: 364
Joined: Sat Aug 14, 2004 3:48 pm

Re: keep unread flags

Post by ace2ace » Thu Oct 04, 2007 12:51 am

yes when the links contains view=newest, I get logged out and become a guest.

Code: Select all

http://www.mysite.com/forum/viewtopic.php?t=1232&view=newest
The only links I see in viewtopic are:

Code: Select all

$view_prev_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=previous");
$view_next_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=next");
I see one in search.php for this MOD that looks allright.

Code: Select all

$newest_post_img = '<a href="' . append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&view=newest")

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

Re: keep unread flags

Post by Merlin Sythove » Thu Oct 04, 2007 6:37 am

In viewtopic.php, look for the word 'newest'. There should be code to translate newest to an actual post id, and then a redirect statement to actually go to that post.
Compare your files with the original phpbb 2.0.22, using a utility such as CompareIT (free) to see the differences.
Need custom work done? Pimp My Forum!

scottflory
Registered User
Posts: 5
Joined: Wed Nov 15, 2006 9:59 pm

Performance issues?

Post by scottflory » Thu Oct 04, 2007 6:03 pm

We have this MOD installed and I'm noticing a very significant performance hit when the query to get the unread topics is executed. It takes 15 seconds and sometimes longer.
We are using MS SQL Server 2005 with an ODBC connection.
We have PHP running on a windows machine with IIS.
When I perform the query both directly in the database and from MS Access using ODBC across our network, the response is immediate.

What is wrong?? Is it the ODBC connection?

Here is the query:
SELECT t.forum_id, t.topic_id, p.post_time FROM phpbb_topics t, phpbb_posts p WHERE p.post_id = t.topic_last_post_id AND t.topic_id IN (3219,3146,3975,......MANY OTHER NUMBERS, ABOUT 300 OF THEM......4221,4222,4224) AND (p.post_time <= 1191520768) AND t.topic_moved_id = 0

Granted, it is a long query, but it runs very fast EXCEPT for from the php page being executed.

Again, we are using MS SQL Server 2005 through an ODBC connection... I am getting my timing from directly before and after the command:
$result = $db->sql_query($sql)

So... any tips?

Post Reply

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