| 1 |
<?php
|
| 2 |
// $Id: profilevisitors.module,v 1.1 2006/09/25 06:54:46 frjo Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Author: Fredrik Jonsson <fredrik at combonet dot se>
|
| 7 |
* Module that display a list of the last members that have visited
|
| 8 |
* a users profile page.
|
| 9 |
*/
|
| 10 |
|
| 11 |
/**
|
| 12 |
* Implementation of hook_help().
|
| 13 |
*/
|
| 14 |
function profilevisitors_help($section = 'admin/help#profilevisitors') {
|
| 15 |
switch ($section) {
|
| 16 |
case 'admin/modules#description':
|
| 17 |
return t('Displays a list of the last members that have visited a users profile page.');
|
| 18 |
break;
|
| 19 |
}
|
| 20 |
}
|
| 21 |
|
| 22 |
/**
|
| 23 |
* Implementation of hook_user().
|
| 24 |
*/
|
| 25 |
function profilevisitors_user($type, &$edit, &$account, $category = NULL) {
|
| 26 |
if ($type == 'view') {
|
| 27 |
$nlimit = 5;
|
| 28 |
$visitors = array();
|
| 29 |
$result = db_query_range("SELECT DISTINCT al.uid
|
| 30 |
FROM {accesslog} al
|
| 31 |
WHERE al.path = '%s' AND al.uid != %s AND al.uid != 0
|
| 32 |
ORDER BY al.timestamp DESC", 'user/'. $account->uid, $account->uid, 0, $nlimit);
|
| 33 |
while ($row = db_fetch_object($result)) {
|
| 34 |
$visitors[] = theme('username', user_load($row));
|
| 35 |
}
|
| 36 |
if ($visitors) {
|
| 37 |
$items[] = array(
|
| 38 |
'title' => t('Recent visitors'),
|
| 39 |
'value' => theme('item_list', $visitors),
|
| 40 |
'class' => 'profilevisitors',
|
| 41 |
);
|
| 42 |
|
| 43 |
return array(t('History') => $items);
|
| 44 |
}
|
| 45 |
}
|
| 46 |
}
|
| 47 |
|
| 48 |
?>
|