1 (edited by Miles 2006-03-21 22:41)

Topic: Mark topics as read v1.1

##
##
##        Mod title:  Mark topics as read
##
##      Mod version:  1.1.1
##   Works on PunBB:  1.2, 1.2.1
##     Release date:  2005-01-29
##           Author:  Miles Kaufmann
##
##      Description:  This mod makes it so that topics are no longer marked as
##                    "new" in the forum view after they have been read, if
##                    they have not been posted in since being read.  This 
##                    mod also works on the list of forums in index.php.
##
##   Affected files:  header.php
##                    include/functions.php
##                    index.php
##                    lang/English/common.php
##                    lang/English/misc.php
##                    moderate.php
##                    misc.php
##                    search.php
##                    viewforum.php
##                    viewtopic.php
##
##       Affects DB:  Yes; adds column "read_topics" to table "users".
##
##       DISCLAIMER:  Please note that "mods" are not officially supported by
##                    PunBB. Installation of this modification is done at your
##                    own risk. Backup your forum database and any and all
##                    applicable files before proceeding.
##
##

PunRes project download
PunRes discussion thread


"Mark topics as read" is a PunBB mod which makes topics which have been viewed no longer appear as "new" in the forum view. It adds a single column to the "users" table, and uses no cookies. Installing this mod adds about 6KB of code to punBB.

I realize that the functionality of this mod overlaps with that of the PunJS New Posts mod by Shawn Brown; my main intention was to take the load off of the client and put it onto the server.  Unfortunately, the JavaScript solution doesn't work for me at all; in Safari, it adds about a five-second delay when viewing a forum page, and completely blanks the topic list, and Firefox/Mac has a similar problem with blank columns. hmm

I'm not trying to bash the competition, though.  wink  This is the second release of the mod, which fixed a bug that crept by me in testing, and has portions of the code substantially rewritten.  If you install it on your forums, I'd love to hear feedback.  Bug reports are equally welcome. smile

Thanks,
Miles

Re: Mark topics as read v1.1

Only problem I had was something with install_mod.php that you couldn't POSSIBLY have done tongue

Line 57: require $pun_root.'include/common.php';

When it should be

require PUN_ROOT.'include/common.php';

Re: Mark topics as read v1.1

this is great.. thanks man

4

Re: Mark topics as read v1.1

Smartys wrote:

Only problem I had was something with install_mod.php that you couldn't POSSIBLY have done tongue

require PUN_ROOT.'include/common.php';

That is odd, but that's the the way the MDK came.  For some reason I don't recall any error or notice when I ran install_mod.php... should I update the install_mod.php to fix that?

Re: Mark topics as read v1.1

I had no problem with the install_mod.php

6 (edited by Smartys 2005-01-29 16:04)

Re: Mark topics as read v1.1

Odd, I had the notice.
But yes, it probably should be changed: however, Rickard needs to change that line in the MDK as well wink

Oh, and if a topic is already read before the current visit, why does the mod need to do an UPDATE on the user setting? Doesn't it only need to record topics that are newer then the last visit but have been read?

Re: Mark topics as read v1.1

I've updated the MOD SDK with the above fix. Sorry smile

"Programming is like sex: one mistake and you have to support it for the rest of your life."

8

Re: Mark topics as read v1.1

I just switched from Shawns javascript-based mod to yours, works perfectly, very nice work!

9

Re: Mark topics as read v1.1

Smartys wrote:

Oh, and if a topic is already read before the current visit, why does the mod need to do an UPDATE on the user setting? Doesn't it only need to record topics that are newer then the last visit but have been read?

After I submitted this mod in the wee hours of the morning, I realized that a topic didn't need to be mark read if it was older than the cut-off date (for the forum, or globally for last_visit).  Version 1.0.0 had just always marked a topic as read, which would have caused a lot of unnecessary UPDATEs when browsing through old topics, and greatly increased the size of the database, and, at first 1.1.0 had behaved the same way.  When I realized that, I quickly pulled the update, added that check, and reposted it.

I didn't, however, think about users viewing topics that had already been marked read by the mod.  You're right about that.  At first, I didn't think that it really mattered that much?it doesn't increase the size of the database at all, and users aren't very likely to reread threads they've just read if nobody has posted in them since?but I guess that this would apply to users reading multipage threads, and on a busy website, it's important to eliminate  every unnecessary UPDATE query.

Looking over that code now, I guess I did too much of a rush job (I test to see if $last_post >= $last_post hmm), so I'll fix that section and roll your suggestion in.

10

Re: Mark topics as read v1.1

All right, Smartys, I made the fix, building on what you pointed out.  It's quick and easy to install. smile

Re: Mark topics as read v1.1

Perfect smile

12

Re: Mark topics as read v1.1

This doesn't work at all for me, I wonder what went wrong?
When I read a new post it works the first time, but if i refresh the windows it gets the "unread"-icon back....
And I also get a error when I try to sign out.

Re: Mark topics as read v1.1

Did you run mod_install.php

14 (edited by bubach 2005-02-06 14:14)

Re: Mark topics as read v1.1

Yes, and it said that everything was ok.
The error at sign out said something about unable to ... user data?

Re: Mark topics as read v1.1

Enable debug mode and paste the exact error?

16

Re: Mark topics as read v1.1

Ok, and i also have to double check, and make sure i have the new code on the right places... :-)

17

Re: Mark topics as read v1.1

I'm not sure what your problem could be; I would recommend trying a new install on a fresh copy of PunBB.  If that works, I would have to assume that the problem is either a mistake during installation, or a conflict with another mod you have installed.  In any case, I would be interested in seeing the debugging output.

You did help me realize that I fail to clear the topic_read cell for a user when they log out.  This shouldn't be causing any problems though; at worst, it'll make the database a bit larger if there are users that always log out without ever letting their visit timeout.  I'll fix it, but it shouldn't be causing any errors.

Re: Mark topics as read v1.1

You are my hero.

19

Re: Mark topics as read v1.1

Hmm, sorry but i uninstalled it and forgot about debug mode...
But before i uninstalled it, I checked and everything seemed to be ok (db and code).
I installed it on my fresh 1.2.1 board, without any other mod's.
PS: when i installed it the first time i also had a problem with position of the "mark forum as read"-link, which used "wrong" html(?)

/ Christoffer

20 (edited by Miles 2005-02-07 20:32)

Re: Mark topics as read v1.1

The markup for that line of code differs between the versions for PunBB 1.2.1 and 1.2.  MTaR v1.1.1 comes with two versions of the mod, so if you make sure you install the one for PunBB 1.2.1, it should output proper HTML.

Jérémie: glad this mod is useful to you. smile

21

Re: Mark topics as read v1.1

Ok, thanks..
Maybe they also differ some in the php-code? Otherwise I problably made some stupid misstake when I installed it.

Re: Mark topics as read v1.1

Ok...It's mostly working awesomely.

Except for this page:
http://www.zanthria.com/bb/search.php?action=show_new

It's still uses the original code. So, stuff shows up as unread like it used to.

23

Re: Mark topics as read v1.1

Does this work with 1.2.2?

Can i just change the install_mod.php to include 1.2.2 as well?

I'd love to add this to my board.

24

Re: Mark topics as read v1.1

To be honest, I don't know.  You're welcome to try it on a test board and give me an official answer wink but I'll get around to making a bugfix and adding PunBB 1.2.2 support to this mod this weekend, I promise tongue

Re: Mark topics as read v1.1

It seems to work fine on mine (although I'm not really checking and testing) tongue
But nothing seems to break with it on...