Warning: The author of this contribution does not provide support for it anymore.

Last Visit in Viewtopic

Incorrect last visit date - Last Visit in Viewtopic

Incorrect last visit date

by stokerpiller » Fri Aug 06, 2010 6:01 am

Hello Rich,

I love the idea of this mod, but the last visit date in view topic is incorrect. It doesnt display the same time as in the profile.

View topic = Last Visit: Today, 01:42
Profile = Last visited: less than a minute ago

It seems like it only works with users that isnt online.
I am done with phpBB
stokerpiller
Registered User
Posts: 1934
Joined: Wed Feb 28, 2007 8:06 pm

Re: Incorrect last visit date

by RMcGirr83 » Fri Aug 06, 2010 5:16 pm

For performance reasons, it uses the entry in the users table which is updated when a user leaves the forum/logs out. When viewing a users profile the newest is used as compared to either the sessions table or the entry in the users table for that user.

So it isn't necessarily incorrect it just doesn't take into account if a user is currently on the forum.
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored
User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Incorrect last visit date

by ALIENQuake » Fri Feb 18, 2011 1:32 am

How i can change this behavior ? I have a nice server with nice performance so i need to have this last visit date in viewtopic same as that one in profile.
ALIENQuake
Registered User
Posts: 85
Joined: Tue Dec 28, 2010 4:06 pm
Contact:

Re: Incorrect last visit date

by RMcGirr83 » Fri Feb 18, 2011 2:05 am

[snip] see below
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored
User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Incorrect last visit date

by ALIENQuake » Fri Feb 18, 2011 3:39 am

Och ... i know nothing about php :/ Is there are any instruction for this ? Or this functionality will require massive rewrite of you mod ??
ALIENQuake
Registered User
Posts: 85
Joined: Tue Dec 28, 2010 4:06 pm
Contact:

Re: Incorrect last visit date

by RMcGirr83 » Fri Feb 18, 2011 9:45 am

ALIENQuake wrote:Or this functionality will require massive rewrite of you mod ??


This
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored
User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Incorrect last visit date

by ALIENQuake » Fri Feb 18, 2011 5:39 pm

I have an idea how to fix this. How about "If user is online then show "Online" instead of last visit" ??
ALIENQuake
Registered User
Posts: 85
Joined: Tue Dec 28, 2010 4:06 pm
Contact:

Re: Incorrect last visit date

by RMcGirr83 » Fri Feb 18, 2011 7:42 pm

Try this for the edit to viewtopic.php

Code: Select all

//-- BEGIN Last Visit in Viewtopic ------
      'POSTER_LASTVISIT'    => $user_cache[$poster_id]['online'] ? $user->lang['ONLINE'] : (!empty($user_cache[$poster_id]['lastvisit']) ? $user->format_date($user_cache[$poster_id]['lastvisit']) : ''),
//-- END Last Visit In Viewtopic ------
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored
User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Incorrect last visit date

by ALIENQuake » Fri Feb 18, 2011 9:48 pm

It's work ! Thank you very much !! Pure genius !
I create additional instruction to match different languages:

language\en\common.php

Find:

Code: Select all

   'CURRENT_TIME'         =>

Add after:

Code: Select all

   'CURRENTLY_ONLINE'      => 'User is online',

Find:
viewtopic.php
Find:

Code: Select all

      //-- BEGIN Last Visit in Viewtopic ------
      'POSTER_LASTVISIT'   => ($poster_id != ANONYMOUS && $user_cache[$poster_id]['lastvisit']) ? $user->format_date($user_cache[$poster_id]['lastvisit']) : '',
      //-- END Last Visit In Viewtopic ------

Replace to:

Code: Select all

      //-- BEGIN Last Visit in Viewtopic ------
      'POSTER_LASTVISIT'    => $user_cache[$poster_id]['online'] ? $user->lang['CURRENTLY_ONLINE'] : (!empty($user_cache[$poster_id]['lastvisit']) ? $user->format_date($user_cache[$poster_id]['lastvisit']) : ''),
      //-- END Last Visit In Viewtopic ------


It will be nice to include such improvement in you mod. Anyway thank you again 8-)
ALIENQuake
Registered User
Posts: 85
Joined: Tue Dec 28, 2010 4:06 pm
Contact:

Re: Incorrect last visit date

by JustinCasey » Wed Mar 02, 2011 4:14 am

Here's a better fix that makes it the same as the last visit time in the member profile page (in addition to the original modification).

viewtopic.php

Find:

Code: Select all

'SELECT'   => 'u.*, z.friend, z.foe, p.*',

Replace with:

Code: Select all

'SELECT'   => 'u.*, z.friend, z.foe, p.*, (SELECT MAX(session_time) from ' . SESSIONS_TABLE . ' WHERE session_user_id = u.user_id) session_time',

Find:

Code: Select all

'lastvisit'      => $row['user_lastvisit'],

Replace with:

Code: Select all

'lastvisit'      => (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit'],
JustinCasey
Registered User
Posts: 1
Joined: Wed Mar 02, 2011 4:06 am
Contact:

Re: Incorrect last visit date

by nuke_q7 » Sun Apr 10, 2011 4:11 pm

JustinCasey wrote:Here's a better fix that makes it the same as the last visit time in the member profile page (in addition to the original modification).

viewtopic.php

Find:

Code: Select all

'SELECT'   => 'u.*, z.friend, z.foe, p.*',

Replace with:

Code: Select all

'SELECT'   => 'u.*, z.friend, z.foe, p.*, (SELECT MAX(session_time) from ' . SESSIONS_TABLE . ' WHERE session_user_id = u.user_id) session_time',

Find:

Code: Select all

'lastvisit'      => $row['user_lastvisit'],

Replace with:

Code: Select all

'lastvisit'      => (!empty($row['session_time'])) ? $row['session_time'] : $row['user_lastvisit'],

with this fix it shows users last visit time even if the user was hidden :(
can we add something to the above code to Not show the hidden users time?
thanks

edit:
for hidden users:
in viewtopic it shows
Last Visit: less than a minute ago
and in memberlist it shows
Last visited: -

how can i adjust the viewtopic to look like memberlist?
User avatar
nuke_q7
Registered User
Posts: 21
Joined: Wed Mar 10, 2010 1:36 am

Re: Incorrect last visit date

by elsa23 » Mon Jun 13, 2011 11:25 pm

ALIENQuake wrote:It's work ! Thank you very much !! Pure genius !
I create additional instruction to match different languages:

language\en\common.php

Find:

Code: Select all

   'CURRENT_TIME'         =>

Add after:

Code: Select all

   'CURRENTLY_ONLINE'      => 'User is online',

Find:
viewtopic.php
Find:

Code: Select all

      //-- BEGIN Last Visit in Viewtopic ------
      'POSTER_LASTVISIT'   => ($poster_id != ANONYMOUS && $user_cache[$poster_id]['lastvisit']) ? $user->format_date($user_cache[$poster_id]['lastvisit']) : '',
      //-- END Last Visit In Viewtopic ------

Replace to:

Code: Select all

      //-- BEGIN Last Visit in Viewtopic ------
      'POSTER_LASTVISIT'    => $user_cache[$poster_id]['online'] ? $user->lang['CURRENTLY_ONLINE'] : (!empty($user_cache[$poster_id]['lastvisit']) ? $user->format_date($user_cache[$poster_id]['lastvisit']) : ''),
      //-- END Last Visit In Viewtopic ------


It will be nice to include such improvement in you mod. Anyway thank you again 8-)



i had made this change, so i had put a little green circle for user online :

language\en\common.php

Code: Select all

'CURRENTLY_ONLINE'   => '<img src="../test-on-2011/images/icon_user_online.png" title="User is online"/></a>',   


i want to add also, a little red circle for user offline (icon_user_offline.png)
and add in a second line, the time of last visit

can you help me to add the image to the format date

thanks a lot :)
sorry for my bad english
elsa23
Registered User
Posts: 180
Joined: Sun Jul 25, 2010 3:36 am
Contact:

Re: Incorrect last visit date

by elsa23 » Thu Jun 16, 2011 4:13 am

Please, i only need the code to put in viewtopic.php
sorry for my bad english
elsa23
Registered User
Posts: 180
Joined: Sun Jul 25, 2010 3:36 am
Contact:

Re: Incorrect last visit date

by elsa23 » Thu Jun 23, 2011 5:44 pm

anyone to help me add image to date format ? :(
sorry for my bad english
elsa23
Registered User
Posts: 180
Joined: Sun Jul 25, 2010 3:36 am
Contact: