Drupal 6-自定义“谁在线”阻止私人消息链接。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Drupal 6-自定义“谁在线”阻止私人消息链接。相关的知识,希望对你有一定的参考价值。

Customises the "who's online" block to show what role type the user has + the links now point to private message instead of profiles.
  1. function online_block() {
  2. $localIP=$_SERVER['SERVER_ADDR'];
  3.  
  4. //Count users with activity in the past defined period.
  5. $time_period = variable_get('user_block_seconds_online', 150);
  6.  
  7. //Perform database queries to gather online user lists.
  8. $guests = sess_count(time() - $time_period);
  9.  
  10. $total_guests = db_result(db_query('SELECT COUNT(hostname) FROM {sessions} WHERE timestamp >= %d AND uid = 0', time() - $time_period));
  11. $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);
  12. $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));
  13.  
  14. //Display a list of currently online users.
  15. $max_users = variable_get('user_block_max_list_count', 10);
  16.  
  17. if ($total_users && $max_users) {
  18. $items = array();
  19. while ($max_users-- && $account = db_fetch_object($users)) {
  20. $items[] = $account;
  21. }
  22. $output.="<div class="item-list"><h4>Members online</h4><p>Within the last 150 seconds</p><ul>";
  23. for($i=0; $i<count($items); $i++) {
  24. //Add the account type.
  25. $account=user_load(array('uid'=>$items[$i]->uid));
  26. $acc = "";
  27. if (in_array("gold member", $account->roles)) {
  28. $acc = "Gold";
  29. }elseif(in_array("silver member", $account->roles)){
  30. $acc = "Silver";
  31. }elseif(in_array("site manager", $account->roles)){
  32. $acc = "Tim";
  33. }elseif(in_array("performer", $account->roles)){
  34. $acc = "Performer";
  35. }elseif(in_array("admin", $account->roles)){
  36. $acc = "Admin";
  37. }
  38. $output .= '<li><a href="/messages/new/'.$items[$i]->uid.'">'.$items[$i]->name.'</a> - ' . $acc . '</li>';
  39. }
  40. $output.="</ul><p>Lurkers online: ".$guests."</p></div>";
  41. }
  42.  
  43. return $output;
  44. }

以上是关于Drupal 6-自定义“谁在线”阻止私人消息链接。的主要内容,如果未能解决你的问题,请参考以下文章

如何阻止 JavaScript 函数影响子元素?

PHP Drupal:编辑此阻止链接

Drupal 6 中的自定义搜索表单:视图/面板还是自定义 sql?

Drupal 视图中自定义表记录项的编辑链接

Drupal查看自定义下载文件链接

PHP Drupal RelatedContent模块:阻止相关内容的链接