2007-08-23 16:34:44 +00:00
< ? php
// $Id$
/**
* @ file
* User page callbacks for the statistics module .
*/
function statistics_node_tracker () {
if ( $node = node_load ( arg ( 1 ))) {
$header = array (
array ( 'data' => t ( 'Time' ), 'field' => 'a.timestamp' , 'sort' => 'desc' ),
array ( 'data' => t ( 'Referrer' ), 'field' => 'a.url' ),
array ( 'data' => t ( 'User' ), 'field' => 'u.name' ),
array ( 'data' => t ( 'Operations' )));
2008-04-14 17:48:46 +00:00
$result = pager_query ( 'SELECT a.aid, a.timestamp, a.url, a.uid, u.name FROM {accesslog} a LEFT JOIN {users} u ON a.uid = u.uid WHERE a.path LIKE \'node/%d%%\'' . tablesort_sql ( $header ), 30 , 0 , NULL , $node -> nid );
2007-08-23 16:34:44 +00:00
$rows = array ();
while ( $log = db_fetch_object ( $result )) {
$rows [] = array (
array ( 'data' => format_date ( $log -> timestamp , 'small' ), 'class' => 'nowrap' ),
_statistics_link ( $log -> url ),
theme ( 'username' , $log ),
2007-10-20 21:57:50 +00:00
l ( t ( 'details' ), " admin/reports/access/ $log->aid " ));
2007-08-23 16:34:44 +00:00
}
if ( empty ( $rows )) {
$rows [] = array ( array ( 'data' => t ( 'No statistics available.' ), 'colspan' => 4 ));
}
2008-10-12 06:27:06 +00:00
drupal_set_title ( check_plain ( $node -> title ));
2007-08-23 16:34:44 +00:00
$output = theme ( 'table' , $header , $rows );
$output .= theme ( 'pager' , NULL , 30 , 0 );
return $output ;
}
else {
drupal_not_found ();
}
}
function statistics_user_tracker () {
if ( $account = user_load ( array ( 'uid' => arg ( 1 )))) {
$header = array (
array ( 'data' => t ( 'Timestamp' ), 'field' => 'timestamp' , 'sort' => 'desc' ),
array ( 'data' => t ( 'Page' ), 'field' => 'path' ),
array ( 'data' => t ( 'Operations' )));
2008-04-14 17:48:46 +00:00
$result = pager_query ( 'SELECT aid, timestamp, path, title FROM {accesslog} WHERE uid = %d' . tablesort_sql ( $header ), 30 , 0 , NULL , $account -> uid );
2007-08-23 16:34:44 +00:00
$rows = array ();
while ( $log = db_fetch_object ( $result )) {
$rows [] = array (
array ( 'data' => format_date ( $log -> timestamp , 'small' ), 'class' => 'nowrap' ),
_statistics_format_item ( $log -> title , $log -> path ),
2007-10-20 21:57:50 +00:00
l ( t ( 'details' ), " admin/reports/access/ $log->aid " ));
2007-08-23 16:34:44 +00:00
}
if ( empty ( $rows )) {
$rows [] = array ( array ( 'data' => t ( 'No statistics available.' ), 'colspan' => 3 ));
}
2008-10-12 06:27:06 +00:00
drupal_set_title ( check_plain ( $account -> name ));
2007-08-23 16:34:44 +00:00
$output = theme ( 'table' , $header , $rows );
$output .= theme ( 'pager' , NULL , 30 , 0 );
return $output ;
}
else {
drupal_not_found ();
}
}