function block_tracker_report in Util 7
Same name and namespace in other branches
- 6.3 contribs/block_tracker/block_tracker.module \block_tracker_report()
Menu callback. Report on block usage.
1 string reference to 'block_tracker_report'
- block_tracker_menu in contribs/
block_tracker/ block_tracker.module - Implements hook_menu().
File
- contribs/
block_tracker/ block_tracker.module, line 64 - Track block usage.
Code
function block_tracker_report() {
$output = '<div id="block-tracker-report">';
$table = array(
'header' => array(
t('Bid'),
t('Module'),
t('Delta'),
t('Theme'),
t('Status'),
t('Name'),
),
'attributes' => array(
'style' => 'width: auto;',
),
'rows' => array(),
);
$query = "SELECT bid, module, delta, theme, status FROM {block} WHERE lastused = 0 ORDER BY module, delta";
$result = db_query($query);
foreach ($result as $row) {
$table['rows'][] = theme('block_tracker_item', array(
'item' => $row,
));
}
$output .= '<h3>' . t('Unused blocks') . '</h3>';
$output .= theme('table', $table);
$output .= '<p>' . t('Note: this report only lists those that have been unused since this tracker was installed.
Site usage usually varies, so sufficient time should be allowed before actng on this report.') . '</p>';
// Unused in a week.
$table['rows'] = array();
$query = "SELECT bid, module, delta, theme, status, lastused FROM {block} WHERE lastused > 0 AND lastused < :when ORDER BY module, delta";
$result = db_query($query, array(
':when' => time() - 604800,
));
foreach ($result as $row) {
$table['rows'][] = theme('block_tracker_item', array(
'item' => $row,
));
}
if ($table['rows']) {
$output .= '<h3>' . t('Blocks not used in the last week') . '</h3>';
$output .= theme('table', $table);
}
return $output . '</div>';
}