Share » Forums » Setup & design » List of last loggedin user

List of last loggedin user

List of last loggedin user

Wednesday 06 May 2009 3:21:12 pm - 12 replies

Author Message

Łukasz Serwatka

Thursday 07 May 2009 12:07:34 am

Hi,

Information about user visit is stored in the ezuservisit table. ezuservisit. current_visit_timestamp and ezuservisit.last_visit_timestamp

Information about user last visit you can get from eZUser object as attribute $user.last_visit
which is actually a value from ezuservisit.last_visit_timestamp. Having this information you can build extended attribute filter.

You may also look on the logged_in_users[1] template fetch function and sort by activity.

[1] http://ez.no/doc/ez_publish/technical_manual/4_0/reference/modules/user/fetch_functions/logged_in_users

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Łukasz Serwatka

Thursday 07 May 2009 12:26:38 am

Aside note. I have added attribute current_visit to the eZUser object.
http://issues.ez.no/14870

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Michael Fürst

Thursday 07 May 2009 12:02:23 pm

Hi Lukasz,

I tried to fetch the users by they parent node. The reason is, that i only want to display users of group "registered users". Reason is, that i don't want to show the logins of users of group "Admin" or "Editors" and so on.

So i built the following fetch:

{def $registeredUserNodeId = 12} // ID of Node "Registered Users"
{def $latestLogins=fetch(content, list, hash( parent_node_id, $registeredUserNodeId,
                                                               sort_by, array('last_visit',true())
                                                             ) 
)}

But, as you can think, sorting like this doesn't work. Do you have an idea what to do to get the sorting?

Beside I've a caching problem - user list isn't update without clearing cache. But i think i can fix it with the viewcache.ini...

Thanks & regards,
Michael

Michael Fürst

Thursday 07 May 2009 12:37:43 pm

So, now I've tried to do it the other way round...

{def $latestLogins=fetch( 'user', 'logged_in_users',
                   hash( 'sort_by', array( array( 'activity', true() ) ) ) )}

{$latestLogins|attribute(show,1)}

But I've no idea, how to order the users by attribute "last_login"... seems there is no attribute filter on user-fetches!?

Michael Fürst

Tuesday 12 May 2009 1:43:42 pm

Ok, now I've tried many different solutions like this one the last days:

{def $latestLogins=fetch( 'user', 'logged_in_users',
                   hash( 'sort_by', array( 'last_visit', true() ) ) )}

But none of my solutions work as expected.
Has anyone another hint for me, how to get the ten last loggedin users?
In meantime I've upgraded to version 4.1.1...

Thanks in advance,
ciao,
Mike

André R.

Tuesday 12 May 2009 2:19:29 pm

Could use custom sql using a simple template operator, you'll find the data you need in ezsession / ezuservisit tables. Alternatively there are some functions in eZUser class, for instance 'fetchLoggedInList', it uses ezsession.expiration_time if you set sort by parameter to array('activity', true ). But it is probably best to use ezuservisit.current_visit_timestamp, witch is updated on login.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Michael Fürst

Thursday 14 May 2009 2:57:49 am

Hi Andre,
Do you know a tutorial for developing own template operators!? I think this would be the best way...

Cheers,
Mike

André R.

Thursday 14 May 2009 6:08:12 am

A simple example would be:
http://pubsvn.ez.no/community/trunk/extension/is_ssl/

A more full example with named parameters could be(just the operator, look at above example for the other files you need):
http://svn.ez.no/svn/extensions/ezwebin/trunk/packages/ezwebin_extension/ezextension/ezwebin/autoloads/eztagcloud.php

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Michael Fürst

Thursday 14 May 2009 7:20:26 am

Hi Andre,

Thanks for this information.
Just another question: Shall the new operator be a function in "ezwebin/autoloads" (as ezTagCloud is which i've already extended some months ago) or shall the function for fetching the last loggedin users be an own extension (like "ezfind", "ezoe") in the extension directory?

Wich is the correct way?

Bye,
Mike

André R.

Thursday 14 May 2009 8:17:03 am

Either a custom extension of its own, or part of some extension you already use(but not in others extensions like ezwebin, just creates problems for your self when you want to update them..).
It basically depends on how reusable you think the operator is, in this case I would say an extension of its own and upload it to projects.ez.no ;)

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Michael Fürst

Thursday 14 May 2009 8:32:19 am

HI,

Ok, thanks :) That's a very important information for reuse of extensions and understanding of the system. Maybe you can give me a hint with my eZOE problem... I really have no more idea what to do to embed the images...

Thanks a lot Andre,
Cheers,
Michael

Nicolas Jessel

Wednesday 17 November 2010 8:06:48 am

Hello,

In my case, I fetch logged in users with:

fetch( "user", "logged_in_list",
hash( "sort_by", "activity" ) )

But, I've a SQL ERROR:

Error: eZMySQLiDB Nov 17 2010 16:58:02
Query error (1054): Unknown column 'ezuservisit.expiration_time' in 'where clause'. Query: SELECT ezuser.contentobject_id as user_id, ezcontentobject.name
FROM ezuservisit, ezuser, ezcontentobject
WHERE ezuservisit.user_id != '10' AND
      ezuservisit.expiration_time > '1290009422' AND
      ezuser.contentobject_id = ezuservisit.user_id AND
      ezcontentobject.id = ezuser.contentobject_id

I remplace, in eZUser::fetchLoggedInList(), ezuservisit.expiration_time by ezuservisit.last_visit_timestamp and it's working.

I hope it's exact ....

Bye

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu