Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

New posts since last visit

Quote Reply
New posts since last visit
What's the easiest way to get the number of new posts since a user's last visit?

Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] New posts since last visit In reply to
This isn't so easy, depending on your definition of "new". In GForum internal terms, "new posts" generally refers to any post you'll see as "new" when you view them, or a forum. If I haven't visited the XYZ forum for 2 weeks, then "new" posts are all the posts in the last two weeks, rather than all the new ones since (e.g.) yesterday. However, it sounds like what you're after is much easier - that is, the number of posts inserted since the last time the user was around. I'd use a query like:

$DB->table('Post')->count(GT::SQL::Condition->new(post_time => '>' => $last_seen));

The best place to get $last_seen is from $SESSION->{info}->{session_data}->{prior_last_seen}. Obviously, $SESSION is only defined for logged-in users.

Jason Rhinelander
Gossamer Threads