Hi,
I'm writing a relatively simple forum system (I know it's generally better to go with phpBB or vB or another GPL forum, but this is a [rare] exception...).
I've got to the point where I'm trying to write the code for working out whether a post's been read.
Assumptions I don't want to make:
Assumptions I'm happy to make
That the user has read all topics older than say, 14 days (perhaps user-configurable, but that shouldn't be hard).
That the user has read all topics for which they are the last poster (even if there was a post written between them hitting reply and them posting the reply
I'm thinking of something along the following lines (pseudo-code and pseudo dbase structure follows...):
table bb_readtopics
ID (primary key, auto_increment, int(11))
userid (int(11))
topicid (int(11))
tstamp (int(11))
table bb_readforums
ID (primary key, auto_increment, int(11))
userid (int(11))
forumid (int(11))
tstamp (int(11))
To check whether a topic is read, go through the following:
- See if older than 30 days. If yes, then read, else go to 2.
- See if older than the last time the entire forum was read, if yes, then mark read, else go to 3.
- See if older than last time that topic was read, if yes, then mark read, else go to 4.
- Mark as unread.
bb_readforums is for marking an entire forum as read, bb_readtopics is for marking a topic as read.
How does that sound- can it be made more efficient? Is there a better way (without using cookies)?
Many thanks,
ucbones