Your ultimate PunBB resource!
You are not logged in.
## ## ## 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. ## ##
Offline
_________________________________________________________
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:
#
#---------[ 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 ]--------------------------------------------------
#![]()
Last edited by Miles (2005-04-22 19:58:42)
Offline
Whats the update for? Guess u could see it in the code but i cant :)
Offline
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
It didnt work for me, threads was showen as unread the whole time.. Switched back..
Offline
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
// 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
So far, so good with the update for me. Thanks.
Offline
I have the sane problem my punBB doesn't marks topic as read :-(... what to do!? help me some one please
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?
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
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.
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
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:
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
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
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
Widell: Open header.php. Find this line:
else if (basename($_SERVER['PHP_SELF']) == 'viewforum.php')
Immediately after it, you see
$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
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
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
Thanks Miles! Now it works fine :)
Offline
Ok I'm studing now... but can someone tell me what are this diff files and how can I use them under W2k??
Offline
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
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.
Offline