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)

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 04:25:01
Script start
Timing: Jan 31 2025 04:25:01
Module start 'layout'
Timing: Jan 31 2025 04:25:01
Module start 'content'
Timing: Jan 31 2025 04:25:01
Module end 'content'
Timing: Jan 31 2025 04:25:01
Script end

Main resources:

Total runtime0.0224 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.1406151.2109
Module start 'layout' 0.00560.0030 739.351636.6484
Module start 'content' 0.00860.0123 776.000094.2813
Module end 'content' 0.02090.0015 870.281337.9922
Script end 0.0224  908.2734 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002912.9829140.0002
Check MTime0.00115.0810140.0001
Mysql Total
Database connection0.00073.057910.0007
Mysqli_queries0.002812.697130.0009
Looping result0.00000.071210.0000
Template Total0.00114.910.0011
Template load0.00083.730510.0008
Template processing0.00031.135810.0003
Override
Cache load0.00062.597910.0006
General
dbfile0.004620.642680.0006
String conversion0.00000.026640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs