[Pugged] Tracking Read Topics/Messages, and the "unread"
flag.
Angie Tollerson
ciapug@ciapug.org
Fri, 06 Sep 2002 13:41:59 -0500
This is a MIME message. If you are reading this text, you may want to
consider changing to a mail reader or gateway that understands how to
properly handle MIME multipart messages.
--=_DA869200.3E5F3C1A
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
How is it that Tim can say the same thing as me but he sounds so much
better? You have to teach me how you do that Tim.... hehehe
Angie Tollerson
Alliance Technologies
Web Programmer
(515)245-7628
tollerson@alliancetechnologies.net
>>> tim@perdue.net 09/06/02 01:38PM >>>
Hi Chris - it's been eons since I've heard anything from you.
> I have been working on a project for a while to write my own forum
and I have had a bit of a hang up on one area. I was hoping I could get
some direction on this.
>
> When the user visits the forum the first time I write a time/date
stamp into his profile for the last visit. Upon their return I grab that
time/date stamp create a variable to hold it then update the profile
with the current time/date. While that page is cycling through the
forums to display I check each forum's last post time/date and compare
that to the last visit. If there has been traffic more recent than the
last visit, it gets marked "New" to indicate new posts... I do the same
with the page which displays each of the topic in a forum.
>
> However I am getting stuck here; If you are the user and this is a
return visit, you are looking at the topic list for a specific forum,
and there are 5 new or updated topics since your last visit they are
marked with a "New" before them in the display. You select the first of
the 5 topics, view the messages/posts, and then return to the topic
listing, all 5 are now marked read. Rather, I would like only the topic
you just read to be marked read, and the 4 remaining to still be
indicating "New".
I did it this exact same way, and it does have its weak points, but
it's
certainly the easiest way to go.
> What I hoping for in asking is either some pseudo code or a good
description of how a forum usually handles this. Ask any questions I
will do my best to give you a answer. I will be happy to show the code
if needed, let me know.
The other way I've seen this done is to create an associative array of
each
message you've read and store it in a permanent cookie.
like:
$read_messages[$msg_id]=true;
setcookie( foo, blah, serialize($read_messages), bar );
The problem with that is you wind up with an increasingly bloated
cookie
getting passed back and forth. I saw this done with the "Phorum"
software that
I used to use on PHPBuilder a while back and the cookie got so big it
would
max out your modem transferring it back and forth.
You could solve that by having an algorithm that goes through and
whittles
down the array over time. Modern PHP sessions would probably also solve
it,
although the session data is lost pretty easily. Not very good for
multiple
visits.
You could also create a separate table in the database like:
read_messages table:
--------------------
| user_id | msg_id |
| 5 | 67 |
| 5 | 68 |
| 5 | 61 |
| 5 | 90 |
--------------------
As each message is read, you insert a row into that table for the
user.
On reading, you left-join your forum SELECT query against that table,
pulling out
the matching rows for the corresponding user_id.
Probably the easiest and best-performing way is how you have already
done it.
Tim
--
Founder - PHPBuilder.com / Geocrawler.com / SourceForge
GPG Public Key: http://www.perdue.net/personal/pgp.php
Perdue, Inc. / Immortal LLC
515-554-9520
_______________________________________________
Ciapug mailing list
Ciapug@ciapug.org
http://cialug.org/mailman/listinfo/ciapug
--=_DA869200.3E5F3C1A
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2719.2200" name=GENERATOR></HEAD>
<BODY style="MARGIN-TOP: 2px; FONT: 8pt Tahoma; MARGIN-LEFT: 2px">
<DIV><FONT size=2>How is it that Tim can say the same thing as me but he sounds
so much better? You have to teach me how you do that Tim.... hehehe</FONT></DIV>
<DIV> </DIV>
<DIV><FONT size=2>Angie Tollerson<BR>Alliance Technologies<BR>Web
Programmer<BR>(515)245-7628<BR><A
href="mailto:tollerson@alliancetechnologies.net">tollerson@alliancetechnologies.net</A></FONT><BR><BR>>>>
tim@perdue.net 09/06/02 01:38PM >>><BR>Hi Chris - it's been eons since
I've heard anything from you.<BR><BR>> I have been working on a project for a
while to write my own forum and I have had a bit of a hang up on one area. I was
hoping I could get some direction on this.<BR>> <BR>> When the user
visits the forum the first time I write a time/date stamp into his profile for
the last visit. Upon their return I grab that time/date stamp create a variable
to hold it then update the profile with the current time/date. While that page
is cycling through the forums to display I check each forum's last post
time/date and compare that to the last visit. If there has been traffic more
recent than the last visit, it gets marked "New" to indicate new posts... I do
the same with the page which displays each of the topic in a
forum.<BR>> <BR>> However I am getting stuck here; If you are the
user and this is a return visit, you are looking at the topic list for a
specific forum, and there are 5 new or updated topics since your last visit they
are marked with a "New" before them in the display. You select the first of the
5 topics, view the messages/posts, and then return to the topic listing, all 5
are now marked read. Rather, I would like only the topic you just read to be
marked read, and the 4 remaining to still be indicating "New".<BR><BR>I did it
this exact same way, and it does have its weak points, but it's<BR>certainly the
easiest way to go.<BR> <BR>> What I hoping for in asking is either some
pseudo code or a good description of how a forum usually handles this. Ask any
questions I will do my best to give you a answer. I will be happy to show the
code if needed, let me know.<BR><BR>The other way I've seen this done is to
create an associative array of each<BR>message you've read and store it in a
permanent
cookie.<BR><BR>like:<BR><BR>$read_messages[$msg_id]=true;<BR>setcookie( foo,
blah, serialize($read_messages), bar );<BR><BR>The problem with that is you wind
up with an increasingly bloated cookie<BR>getting passed back and forth. I saw
this done with the "Phorum" software that<BR>I used to use on PHPBuilder a while
back and the cookie got so big it would<BR>max out your modem transferring it
back and forth.<BR><BR>You could solve that by having an algorithm that goes
through and whittles<BR>down the array over time. Modern PHP sessions would
probably also solve it,<BR>although the session data is lost pretty easily. Not
very good for multiple<BR>visits.<BR><BR>You could also create a separate table
in the database like:<BR><BR>read_messages table:<BR>--------------------<BR>|
user_id | msg_id |<BR>| 5 |
67 |<BR>| 5 |
68 |<BR>| 5 |
61 |<BR>| 5 |
90 |<BR>--------------------<BR><BR>As each message is read, you
insert a row into that table for the user.<BR>On reading, you left-join your
forum SELECT query against that table, pulling out<BR>the matching rows for the
corresponding user_id.<BR><BR>Probably the easiest and best-performing way is
how you have already done it.<BR><BR>Tim<BR><BR>-- <BR>Founder - PHPBuilder.com
/ Geocrawler.com / SourceForge<BR>GPG Public Key: <A
href="http://www.perdue.net/personal/pgp.php">http://www.perdue.net/personal/pgp.php</A><BR>Perdue,
Inc. / Immortal
LLC<BR>515-554-9520<BR>_______________________________________________<BR>Ciapug
mailing list<BR>Ciapug@ciapug.org<BR><A
href="http://cialug.org/mailman/listinfo/ciapug">http://cialug.org/mailman/listinfo/ciapug</A><BR></DIV></BODY></HTML>
--=_DA869200.3E5F3C1A--