|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
how to know if a user is onlineHi all. I'm creating a user-profile page and I need to write if the user
X is online or not. How can I do it ? M. -- Michel 'ZioBudda' Morelli michel@... Sviluppo applicazioni CMS DRUPAL e web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ziodrupal.net MSN: michel@... JABBER: michel@... -- [ Drupal support list | http://lists.drupal.org/ ] |
|
|
Re: how to know if a user is onlineOn Tue, 27 Oct 2009 17:55:07 +0100
Michel Morelli <michel@...> wrote: > Hi all. I'm creating a user-profile page and I need to write if > the user X is online or not. > How can I do it ? I'd go for counting the sessions (whth/without uid). If you want to do it the drupal way you could give a look on how it is done in the Who's online block. -- Ivan Sergio Borgonovo http://www.webthatworks.it -- [ Drupal support list | http://lists.drupal.org/ ] |
|
|
Re: how to know if a user is onlineIvan Sergio Borgonovo ha scritto:
> I'd go for counting the sessions (whth/without uid). > If you want to do it the drupal way you could give a look on how it > is done in the Who's online block. > Ok. Thanks for the help. M. -- Michel 'ZioBudda' Morelli michel@... Sviluppo applicazioni CMS DRUPAL e web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ziodrupal.net MSN: michel@... JABBER: michel@... -- [ Drupal support list | http://lists.drupal.org/ ] |
|
|
Re: how to know if a user is onlineMichel Morelli ha scritto:
> Hi all. I'm creating a user-profile page and I need to write if the > user X is online or not. > How can I do it ? > > M. > Here my code. "theme286" is my theme. //Here for an another element of the $account's fields in the user's account page. theme286_preprocess_user_profile(&$vars) { $vars['account']->online = _user_online($vars['account']); } //This is the real function. I have c&p code from "who's online" block. Thanks Ivan for the tips. function _user_online($account) { $interval = time() - variable_get('user_block_seconds_online', 900); // Perform database queries to gather online user lists. We use s.timestamp // rather than u.access because it is much faster. $online = db_result(db_query('SELECT u.uid FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid = %d LIMIT 1', $interval,$account->uid)); if ($online === false) return false; else return true; } M. -- Michel 'ZioBudda' Morelli michel@... Sviluppo applicazioni CMS DRUPAL e web dinamiche (LAMP+Ajax) Telefono: 0200619074 Telefono Cell: +39-3939890025 -- Fax: +39-0291390660 http://www.ziobudda.net ICQ: 58351764 http://www.ziobuddalabs.it Skype: zio_budda http://www.ziodrupal.net MSN: michel@... JABBER: michel@... -- [ Drupal support list | http://lists.drupal.org/ ] |
| Free embeddable forum powered by Nabble | Forum Help |