PHP Drupal 6 - 自定义“Who's Online”阻止私人消息链接。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Drupal 6 - 自定义“Who's Online”阻止私人消息链接。相关的知识,希望对你有一定的参考价值。
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;
}
以上是关于PHP Drupal 6 - 自定义“Who's Online”阻止私人消息链接。的主要内容,如果未能解决你的问题,请参考以下文章
Drupal 6-自定义“谁在线”阻止私人消息链接。
PHP Drupal 6自定义登录块
PHP 在Drupal 6中自定义块搜索表单
Drupal,在自定义 php 页面上嵌入视图块/结果
带有自定义 php 代码的 drupal 条件操作
自定义字段的drupal主题化视图:PHP代码