PunBB Resource

Your ultimate PunBB resource!

Keywords:

    (Extended)

You are not logged in.


Login to move these ads to the bottom of the page

#1 2005-01-29 13:59:56

Miles
Member
Registered: 2005-01-27
Posts: 31

Mark topics as read 1.1.1

Code:

##
##
##        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 (webmaster@twmagic.com)
##
##      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".
##
##            Notes:  An upgrade from 1.1.0 to 1.1.1 is available
##                    
##                    For more notes see the included notes.txt.
##
##       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.
##
##

Download here

Offline

 

#2 2005-01-29 14:04:37

Miles
Member
Registered: 2005-01-27
Posts: 31

Re: Mark topics as read 1.1.1

_________________________________________________________


PLEASE DO NOT RESPOND TO THIS TOPIC
Mark topics as read has been upgraded to v1.1.3.

_________________________________________________________



Sorry for the very frequent release schedule.  Fortunately there's an easy upgrade from 1.1.0 to 1.1.1:

Code:

#
#---------[ 1. OPEN ]---------------------------------------------------------
#

include/functions.php


#
#---------[ 2. FIND (NEAR END OF FILE) ]--------------------------------------
#

function mark_topic_read($topic_id, $forum_id, $last_post) {

    global $db, $pun_user;
    
    if (!empty($pun_user['read_topics']['f'][$forum_id])) {
        $cutoff = $pun_user['read_topics']['f'][$forum_id];
    } else {
        $cutoff = $pun_user['last_visit'];
    }
    
    if ($last_post >= $last_post) {
        $pun_user['read_topics']['t'][$topic_id] = $pun_user['logged'];
        $db->query('UPDATE '.$db->prefix.'users SET read_topics=\''.$db->escape(serialize($pun_user['read_topics'])).'\' WHERE id='.$pun_user['id']) or error('Unable to update read-topic data', __FILE__, __LINE__, $db->error());
    }
}


#
#---------[ 3. REPLACE WITH ]-------------------------------------------------
#

function mark_topic_read($topic_id, $forum_id, $last_post) {

    global $db, $pun_user;
    
    if (topic_is_new($topic_id, $forum_id, $last_post)) {
        $pun_user['read_topics']['t'][$topic_id] = time();
        $db->query('UPDATE '.$db->prefix.'users SET read_topics=\''.$db->escape(serialize($pun_user['read_topics'])).'\' WHERE id='.$pun_user['id']) or error('Unable to update read-topic data', __FILE__, __LINE__, $db->error());
    }
}

#
#---------[ 4. SAVE/UPLOAD ]--------------------------------------------------
#

smile

Last edited by Miles (2005-04-22 19:58:42)

Offline

 

#3 2005-01-29 14:12:40

Widell
Member
Registered: 2005-01-27
Posts: 20

Re: Mark topics as read 1.1.1

Whats the update for? Guess u could see it in the code but i cant :)

Offline

 

#4 2005-01-29 14:21:41

Miles
Member
Registered: 2005-01-27
Posts: 31

Re: Mark topics as read 1.1.1

Version 1.1.0 would do an UPDATE everytime a topic was viewed—much of the time, it isn't needed, and would bloat the database.

Version 1.1.1 only does an UPDATE to mark a topic as read if it would otherwise be unread.

It's not a major bug; it doesn't really affect usability at all, just the database and interaction with it.  I'm mostly pushing the releases out right away because for some reason I don't like the thought of people downloading and installing a buggy mod (especially as mods are so hard to install and upgrade), and I'd to get the mod to a complete state as soon as possible.  The only way I can do that is by feedback from others.  :)

Offline

 

#5 2005-01-29 16:22:14

Widell
Member
Registered: 2005-01-27
Posts: 20

Re: Mark topics as read 1.1.1

It didnt work for me, threads was showen as unread the whole time.. Switched back..

Offline

 

#6 2005-01-29 17:18:38

Miles
Member
Registered: 2005-01-27
Posts: 31

Re: Mark topics as read 1.1.1

That's very odd... my test forum correctly marks threads read after the 1.1.1 update.  If it wouldn't be a security risk, could you uncomment the

Code:

// define('PUN_SHOW_QUERIES', 1);

line in your include/common.php, and show me what UPDATE queries are performed, if any, on the users table when you view an unread topic?

Mmkay... I rewrote the 1.1.1 update to use less redundant code, but that probably wouldn't affect your problem.

Last edited by Miles (2005-01-29 17:34:15)

Offline

 

#7 2005-01-30 01:56:55

cheesypeanut
New member
Registered: 2005-01-22
Posts: 5

Re: Mark topics as read 1.1.1

So far, so good with the update for me. Thanks.

Offline

 

#8 2005-02-01 07:26:34

Shindler
Guest

Re: Mark topics as read 1.1.1

I have the sane problem my punBB doesn't marks topic as read :-(... what to do!? help me some one please

 

#9 2005-02-01 07:33:27

Shindler
Guest

Re: Mark topics as read 1.1.1

One more thing I'm a php devolper and I've noticed something interesting:

if ($last_post >= $last_post) {
        $pun_user['read_topics']['t'][$topic_id] = $pun_user['logged'];
        $db->query('UPDATE '.$db->prefix.'users SET read_topics=\''.$db->escape(serialize($pun_user['read_topics'])).'\' WHERE id='.$pun_user['id']) or error('Unable to update read-topic data', __FILE__, __LINE__, $db->error());
    }

why in the IF clause you compare two same varibles?? Isn't this a mistake?

 

#10 2005-02-01 12:59:20

Miles
Member
Registered: 2005-01-27
Posts: 31

Re: Mark topics as read 1.1.1

That was a very stupid IF clause on my part (I was tired ;)), but that was in v1.1.0; I fixed it in the 1.1.1 upgrade.  Check the second post in this thread.  Hopefully that will make this mod work for you. :)

Last edited by Miles (2005-02-01 12:59:51)

Offline

 

#11 2005-02-01 13:44:30

Shindler
Guest

Re: Mark topics as read 1.1.1

I have for you sad news... I've already instaled PunJS Topics. And it's working fine. When I've instaled your mod version 1.1.1 it wasn't working at all. If tried to use the code from 1.0 - then I discoverd this IF :) - and it wasn't still working.

 

#12 2005-02-01 17:26:50

Miles
Member
Registered: 2005-01-27
Posts: 31

Re: Mark topics as read 1.1.1

I've already instaled PunJS Topics.

Sorry to hear that. ;) But in all seriousness, if it works for you, and you like it, that's fine by me.

What I don't like is that my mod doesn't work for you or Widell.  I just installed the mod on a fresh copy of punBB 1.2 according to the directions in readme.txt, and it worked just like I'd expect: topics aren't marked as new anymore after I click them.  You say that it has no effect, that topics are still marked new even after you read them.  If either of you still have it installed somewhere, can you do some testing?  Just log in, go through and read a bunch of new topics, and then check out the contents of the users.read_topics cell for your user?  :)  It might help me figure out what's not working for you guys, and fix it.

Thanks Shindler, cheesypeanut, and Widell for the feedback.  If anyone else has installed this mod, how well is it working (or not working) for you?

Offline

 

#13 2005-02-01 17:45:18

Shindler
Guest

Re: Mark topics as read 1.1.1

I think that I can install this mod again and help you I by that I devoplment :D... but todat it's too late... my clock points 2:44 AM and I must study tommorow (today) for exam... so goodnight at the moment. I post a message here when I install your mod again. :lol:

 

#14 2005-02-02 00:38:12

Widell
Member
Registered: 2005-01-27
Posts: 20

Re: Mark topics as read 1.1.1

I haven't it installed now.. I use the 1.1.0.. I shall install punbb 1.2.1 later then i can try 1.1.1 again. Do you have any im-service? Easier to talk that way if i have problems again..

Offline

 

#15 2005-02-02 03:47:53

Miles
Member
Registered: 2005-01-27
Posts: 31

Re: Mark topics as read 1.1.1

My AIM screen name is tctlids.  I'm on it very rarely, though.  I've subscribed to this thread, and I usually leave my mail client open, so if you respond and I'm sitting at my computer, I'll usually know within 5 minutes and can try logging on to AIM then.  So responding to this topic usually is a pretty fast way to get in touch with me. ;)

Offline

 

#16 2005-02-02 05:01:56

Shindler
Member
From: Tychy, Poland
Registered: 2005-02-01
Posts: 10
Website

Re: Mark topics as read 1.1.1

Will MTaR will work under punBB 1.2.1??


Skodovka-Club Member
SAOL Devolper
iNetArt IM Devolper
AQQ: 28102, GG: 122232, WPK: shindler; Tlen: shindler;

Offline

 

#17 2005-02-02 15:20:03

Widell
Member
Registered: 2005-01-27
Posts: 20

Re: Mark topics as read 1.1.1

Now ive installed 1.1.1 under punbb 1.2.1 and it works great.

I have just one problem. I dont know if it appeard when i installed the mod or before (kind of tired). Anyway, do you have any sollution or know witch file the problem is in: www.jrc.nu/fel.gif

It looks wierd in viewforum.php only.. Maybe its only a missing tag or somethin..

It looks fine every where else like www.jrc.nu/ratt.gif

Last edited by Widell (2005-02-02 15:24:24)

Offline

 

#18 2005-02-02 17:02:07

Shindler
Member
From: Tychy, Poland
Registered: 2005-02-01
Posts: 10
Website

Re: Mark topics as read 1.1.1

OK so I'm gona try it tommorow (friday)


Skodovka-Club Member
SAOL Devolper
iNetArt IM Devolper
AQQ: 28102, GG: 122232, WPK: shindler; Tlen: shindler;

Offline

 

#19 2005-02-02 17:59:01

Miles
Member
Registered: 2005-01-27
Posts: 31

Re: Mark topics as read 1.1.1

Widell: Open header.php.  Find this line:

Code:

    else if (basename($_SERVER['PHP_SELF']) == 'viewforum.php')

Immediately after it, you see

Code:

    $tpl_temp .= '</p>'."\n\t\t\t"...

Change that </p> to </ul> and it should work.  I've reuploaded the v1.1.1 mod with that instruction for PunBB 1.2.1 users.

Shindler: Thanks :)

Last edited by Miles (2005-02-02 18:00:54)

Offline

 

#20 2005-02-02 19:24:00

redshift
New member
Registered: 2005-02-02
Posts: 3

Re: Mark topics as read 1.1.1

Thanks a lot for this mod, it should be standard if you ask me.

One request - your directions are easy and clear, but could you please provide a unified diff?  There's no sense in manually updating every file when a simple patch will save us both some trouble :)

Offline

 

#21 2005-02-02 20:38:56

Miles
Member
Registered: 2005-01-27
Posts: 31

Re: Mark topics as read 1.1.1

redshift wrote:

Thanks a lot for this mod, it should be standard if you ask me.

Glad you like it. :)

redshift wrote:

One request - your directions are easy and clear, but could you please provide a unified diff?  There's no sense in manually updating every file when a simple patch will save us both some trouble :)

Done.  I've reuploaded v1.1.1 of this mod with the unified diff files.  This is the first time I've done this, though, so tell me if they work for you.

Offline

 

#22 2005-02-03 01:19:45

Widell
Member
Registered: 2005-01-27
Posts: 20

Re: Mark topics as read 1.1.1

Thanks Miles! Now it works fine :)

Offline

 

#23 2005-02-03 07:19:27

Shindler
Member
From: Tychy, Poland
Registered: 2005-02-01
Posts: 10
Website

Re: Mark topics as read 1.1.1

Ok I'm studing now... but can someone tell me what are this diff files and how can I use them under W2k??


Skodovka-Club Member
SAOL Devolper
iNetArt IM Devolper
AQQ: 28102, GG: 122232, WPK: shindler; Tlen: shindler;

Offline

 

#24 2005-02-03 13:21:03

redshift
New member
Registered: 2005-02-02
Posts: 3

Re: Mark topics as read 1.1.1

I'm not familiar with diffs on windows, as they're more oriented for real developers (snicker).  Diffs are just files that thoroughly list the differences between one set of files and another, so that you can easily patch the files and have identical copies.  It's a lot easier to apply than manual changes (like previous versions of this plugin) and it's easier to keep track of exactly what's changed.

Thanks Miles!  (I actually went ahead last night and manually changed everything, I was excited :p)

Offline

 

#25 2005-02-03 13:48:25

Shindler
Member
From: Tychy, Poland
Registered: 2005-02-01
Posts: 10
Website

Re: Mark topics as read 1.1.1

Redshift: Ok say my one more thing with wich program can I easy use these files.

Miles: I've installed your mod and it's working fine now :D.


Skodovka-Club Member
SAOL Devolper
iNetArt IM Devolper
AQQ: 28102, GG: 122232, WPK: shindler; Tlen: shindler;

Offline

 

Board footer

Based on PunBB
© Copyright 2002–2005 Rickard Andersson

© Copyright 2004–2006 Kristoffer Jansson

User contributed files are property of their respective owners.