Forums / Developer / Setting the last_visit of a user?!

Setting the last_visit of a user?!

Author Message

Clemens T

Thursday 03 November 2005 1:04:39 pm

Hey all,
I'd like to set the last_visit variable of a user. But, do I need to setAttribute on the eZUser.. on the eZContentObject.. or is it a contentObjectAttribute?

Ofcourse I'd like to do this in PHP.

Thanks for helping out,
Clemens

Bruce Morrison

Thursday 03 November 2005 5:59:38 pm

Hi Clemens

From kernel/classes/datatypes/ezuser/ezuser.php

eZUser::updateLastVisit( $userID );

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Clemens T

Friday 04 November 2005 1:45:38 am

thx. I got to that function... but guess that's the only way.

Clemens T

Friday 04 November 2005 2:39:24 am

rewrote it, for my own purposes:

function updateLastVisit( $userID , $time)
{
    $userVisitArray = $db->arrayQuery( "SELECT 1 FROM ezuservisit WHERE user_id=$userID" );

    if ( count( $userVisitArray ) == 1 )
    {
        $db->query( "UPDATE ezuservisit SET last_visit_timestamp=current_visit_timestamp, current_visit_timestamp=$time WHERE user_id=$userID" );
    }
    else
    {
        $db->query( "INSERT INTO ezuservisit ( current_visit_timestamp, last_visit_timestamp, user_id ) VALUES ( $time, $time, $userID )" );
    }
 }

Bruce Morrison

Friday 04 November 2005 3:20:36 pm

Hi Clemens

How come you rewrote it? You code looks mostly identical to that in the eZUser::updateLastVisit function.

Cheers
Bruce

My Blog: http://www.stuffandcontent.com/
Follow me on twitter: http://twitter.com/brucemorrison
Consolidated eZ Publish Feed : http://friendfeed.com/rooms/ez-publish

Clemens T

Tuesday 08 November 2005 3:53:52 am

well, if you look closely. the updateLastVisit generates the current time. And to make my extension un-dependant of the ezpublish install. I rewrote the function in my extension :).

Thanks.

(ps: now I can set the time to any time i'd like. not just current time)