function block_revisions_overview in Block Revisions 6
Same name and namespace in other branches
- 7 block_revisions.admin.inc \block_revisions_overview()
Menu callback for the revisions overview page.
This page lists all the revisions for a specific custom block.
1 string reference to 'block_revisions_overview'
- block_revisions_menu in ./
block_revisions.module - Implementation of hook_menu().
File
- ./
block_revisions.admin.inc, line 69 - Admin functions and page callbacks for the Block Revisions module.
Code
function block_revisions_overview($delta) {
$output = '';
// Fetch information about the block and the current revision from the database.
$block = db_fetch_object(db_query('SELECT b.info, b.timestamp, b.uid FROM {boxes} b WHERE b.bid = %d', $delta));
// Set the title for the page.
drupal_set_title(t("Revisions for '%title' block", array(
'%title' => $block->info,
)));
// Fetch a list of revisions for this custom block from the database.
$revisions = block_revision_list($delta);
$latest_revision = reset($revisions);
// By comparing the timestamp of the block with the timestamp of the
// most recent revision, we can determine if the block was altered
// after that revision was created. If it is, warn the user that
// the most recent revision differs from the actual block content.
if ($block->timestamp !== $latest_revision->timestamp) {
$account = user_load($block->uid);
$output .= t('Warning: the block has been altered since the most recent revision. The latest, non-versioned, edit was made by !username on %timestamp.', array(
'!username' => theme_username($account),
'%timestamp' => format_date($block->timestamp),
));
}
$header = array(
t('Revision'),
array(
'data' => t('Operations'),
'colspan' => 2,
),
);
$rows = array();
foreach ($revisions as $revision) {
$row = array();
$operations = array();
$row[] = array(
'data' => t('!date by !username', array(
'!date' => format_date($revision->timestamp, 'small'),
'!username' => theme('username', $revision),
)) . ($revision->log != '' ? '<p class="revision-log">' . check_plain($revision->log) . '</p>' : ''),
);
if ($revision->vid == 0) {
$operations[] = array(
'data' => theme('placeholder', t('current revision')),
'class' => 'revision-current',
'colspan' => 2,
);
$row[0]['class'] = 'revision-current';
}
else {
$operations[] = l(t('revert'), "admin/build/block/revisions/revert/{$delta}/{$revision->vid}");
$operations[] = l(t('delete'), "admin/build/block/revisions/delete/{$delta}/{$revision->vid}");
}
$rows[] = array_merge($row, $operations);
}
$output .= theme('table', $header, $rows);
return $output;
}