diff options
Diffstat (limited to 'modules/statistics.module')
-rw-r--r-- | modules/statistics.module | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/modules/statistics.module b/modules/statistics.module index 01a61dd72..71b4dfbfe 100644 --- a/modules/statistics.module +++ b/modules/statistics.module @@ -46,10 +46,10 @@ function statistics_help($section) { <li><em>administer statistics module</em> - enable for user roles that get to configure the statistics module.</li><li><em>administer statistics</em> - enable for user roles that get to view the referrer statistics.</li> </ul> <p>If '<em>administer statistics</em>' and '<em>access statistics</em>' are both enabled, the user will see a link from each node to that node's referrer statistics (if enabled).</p>", - array('%modules' => url('admin/system/modules'), '%permissions' => url('admin/user/permission'), '%referer' => url('admin/logs/referrer'), '%access' => url('admin/logs/access'), '%configuration' => url('admin/system/modules/statistics'), '%block' => url('admin/system/block'))); - case 'admin/system/modules#description': + array('%modules' => url('admin/modules'), '%permissions' => url('admin/user/permission'), '%referer' => url('admin/logs/referrer'), '%access' => url('admin/logs/access'), '%configuration' => url('admin/settings/statistics'), '%block' => url('admin/block'))); + case 'admin/modules#description': return t('Logs access statistics for your site.'); - case 'admin/system/modules/statistics': + case 'admin/settings/statistics': return t('Settings for the statistical information that Drupal will keep about the site. See <a href="%statistics">site statistics</a> for the actual information.', array('%statistics' => url('admin/logs/topnodes'))); case 'admin/logs/topnodes': return t('This page gives you an at-a-glance look at your most popular content.'); @@ -140,21 +140,36 @@ function statistics_link($type, $node = 0, $main = 0) { } } - if ($type == 'system') { - menu('statistics', t('most popular content'), user_access('access content') ? 'statistics_page' : MENU_DENIED, 0, MENU_HIDE); - - $access = user_access('administer statistics module') || user_access('administer statistics'); - - menu('admin/logs/topnodes', t('top nodes'), $access ? 'statistics_admin_topnodes' : MENU_DENIED, 1); - menu('admin/logs/referrer', t('referrer'), $access ? 'statistics_top_refer' : MENU_DENIED, 2); - menu('admin/logs/referrer/internal', t('internal referrers only'), MENU_FALLTHROUGH); - menu('admin/logs/referrer/external', t('external referrers only'), MENU_FALLTHROUGH); - menu('admin/logs/access', t('access'), $access ? 'statistics_admin_displaylog' : MENU_DENIED, 3); - } - return $links; } +/** + * Implementation of hook_menu(). + */ +function statistics_menu() { + $items = array(); + $items[] = array('path' => 'statistics', 'title' => t('most popular content'), + 'callback' => 'statistics_page', + 'access' => user_access('access content'), + 'type' => MENU_SUGGESTED_ITEM); + + $access = user_access('administer statistics module') || user_access('administer statistics'); + $items[] = array('path' => 'admin/logs/topnodes', 'title' => t('top nodes'), + 'callback' => 'statistics_admin_topnodes', 'access' => $access, + 'weight' => 1); + $items[] = array('path' => 'admin/logs/referrer', 'title' => t('referrer'), + 'callback' => 'statistics_top_refer', 'access' => $access, + 'weight' => 2); + $items[] = array('path' => 'admin/logs/referrer/internal', 'title' => t('internal referrers only'), + 'access' => $access); + $items[] = array('path' => 'admin/logs/referrer/external', 'title' => t('external referrers only'), + 'access' => $access); + $items[] = array('path' => 'admin/logs/access', 'title' => t('access'), + 'callback' => 'statistics_admin_displaylog', 'access' => $access, + 'weight' => 3); + return $items; +} + function statistics_admin_topnodes_table() { $header = array( @@ -169,7 +184,7 @@ function statistics_admin_topnodes_table() { $result = pager_query($sql, 20); // WHERE s.%s <> '0' while ($nid = db_fetch_array($result)) { - $rows[] = array(l($nid['title'], 'node/view/'. $nid['nid'], array('title' => t('View this posting.'))), $nid['daycount'], $nid['totalcount'], format_date($nid['timestamp'], 'small'), l('track node', "admin/logs/access/node/$nid[nid]")); + $rows[] = array(l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))), $nid['daycount'], $nid['totalcount'], format_date($nid['timestamp'], 'small'), l('track node', "admin/logs/access/node/$nid[nid]")); } if ($pager = theme('pager', NULL, 20, 0, tablesort_pager())) { $rows[] = array(array('data' => $pager, 'colspan' => 5)); @@ -226,7 +241,7 @@ function statistics_admin_accesslog_table($type, $id) { $url = message_na(); } - $rows[] = array(array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), ($log->nid ? l($log->title, "node/view/$log->nid") : message_na()), format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($log->nid ? l(t('track node'), "admin/logs/access/node/$log->nid") : ''), ($user->uid ? l(t('track user'), "admin/logs/access/user/$user->uid") : ''), ($log->hostname ? l(t('track host'), "admin/logs/access/host/$log->hostname") : '')); + $rows[] = array(array('data' => format_date($log->timestamp, 'small'), 'nowrap' => 'nowrap'), ($log->nid ? l($log->title, "node/$log->nid") : message_na()), format_name($user), $log->hostname ? $log->hostname : message_na(), $url, ($log->nid ? l(t('track node'), "admin/logs/access/node/$log->nid") : ''), ($user->uid ? l(t('track user'), "admin/logs/access/user/$user->uid") : ''), ($log->hostname ? l(t('track host'), "admin/logs/access/host/$log->hostname") : '')); } if ($pager = theme('pager', NULL, 50, 0, tablesort_pager())) { @@ -513,7 +528,7 @@ function statistics_summary($dbfield, $dbrows) { $content = node_load(array('nid' => $nid['nid'])); $links = link_node($content, 1); - $output .= '<tr><td><strong>'. l($nid['title'], 'node/view/'. $nid['nid'], array('title' => t('View this posting.'))) .'</strong></td><td style="text-align: right;"><small>'. t('Submitted by %a on %b', array('%a' => format_name($content), '%b' => format_date($content->created, 'large'))) .'</small></td></tr>'; + $output .= '<tr><td><strong>'. l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))) .'</strong></td><td style="text-align: right;"><small>'. t('Submitted by %a on %b', array('%a' => format_name($content), '%b' => format_date($content->created, 'large'))) .'</small></td></tr>'; $output .= '<tr><td colspan="2"><div style="margin-left: 20px;">'. check_output($content->teaser) .'</div></td></tr>'; $output .= '<tr><td style="text-align: right;" colspan="2">[ '. theme('links', $links) .' ]<br /><br /></td></tr>'; } |