Revision: 31237
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at September 1, 2010 18:58 by daipratt
Initial Code
function online_block() { $localIP=$_SERVER['SERVER_ADDR']; //Count users with activity in the past defined period. $time_period = variable_get('user_block_seconds_online', 150); //Perform database queries to gather online user lists. $guests = sess_count(time() - $time_period); $total_guests = db_result(db_query('SELECT COUNT(hostname) FROM {sessions} WHERE timestamp >= %d AND uid = 0', time() - $time_period)); $users = db_query('SELECT DISTINCT u.uid, u.name, s.timestamp FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', time() - $time_period); $total_users = db_result(db_query('SELECT DISTINCT COUNT(u.uid) FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', time() - $time_period)); //Display a list of currently online users. $max_users = variable_get('user_block_max_list_count', 10); if ($total_users && $max_users) { $items = array(); while ($max_users-- && $account = db_fetch_object($users)) { $items[] = $account; } $output.="<div class=\"item-list\"><h4>Members online</h4><p>Within the last 150 seconds</p><ul>"; for($i=0; $i<count($items); $i++) { //Add the account type. $account=user_load(array('uid'=>$items[$i]->uid)); $acc = ""; if (in_array("gold member", $account->roles)) { $acc = "Gold"; }elseif(in_array("silver member", $account->roles)){ $acc = "Silver"; }elseif(in_array("site manager", $account->roles)){ $acc = "Tim"; }elseif(in_array("performer", $account->roles)){ $acc = "Performer"; }elseif(in_array("admin", $account->roles)){ $acc = "Admin"; } $output .= '<li><a href="/messages/new/'.$items[$i]->uid.'">'.$items[$i]->name.'</a> - ' . $acc . '</li>'; } $output.="</ul><p>Lurkers online: ".$guests."</p></div>"; } return $output; }
Initial URL
http://zoocha.com
Initial Description
Customises the \"who\'s online\" block to show what role type the user has + the links now point to private message instead of profiles.
Initial Title
Drupal 6 - Custom \"Who\'s Online\" block with private message links.
Initial Tags
drupal, Online
Initial Language
PHP