You are here

function node_revision_overview in Drupal 6

Same name and namespace in other branches
  1. 4 modules/node.module \node_revision_overview()
  2. 5 modules/node/node.module \node_revision_overview()
  3. 7 modules/node/node.pages.inc \node_revision_overview()

Generate an overview table of older revisions of a node.

1 string reference to 'node_revision_overview'
node_menu in modules/node/node.module
Implementation of hook_menu().

File

modules/node/node.pages.inc, line 529
Page callbacks for adding, editing, deleting, and revisions management for content.

Code

function node_revision_overview($node) {
  drupal_set_title(t('Revisions for %title', array(
    '%title' => $node->title,
  )));
  $header = array(
    t('Revision'),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  $revisions = node_revision_list($node);
  $rows = array();
  $revert_permission = FALSE;
  if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) {
    $revert_permission = TRUE;
  }
  $delete_permission = FALSE;
  if ((user_access('delete revisions') || user_access('administer nodes')) && node_access('delete', $node)) {
    $delete_permission = TRUE;
  }
  foreach ($revisions as $revision) {
    $row = array();
    $operations = array();
    if ($revision->current_vid > 0) {
      $row[] = array(
        'data' => t('!date by !username', array(
          '!date' => l(format_date($revision->timestamp, 'small'), "node/{$node->nid}"),
          '!username' => theme('username', $revision),
        )) . ($revision->log != '' ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : ''),
        'class' => 'revision-current',
      );
      $operations[] = array(
        'data' => theme('placeholder', t('current revision')),
        'class' => 'revision-current',
        'colspan' => 2,
      );
    }
    else {
      $row[] = t('!date by !username', array(
        '!date' => l(format_date($revision->timestamp, 'small'), "node/{$node->nid}/revisions/{$revision->vid}/view"),
        '!username' => theme('username', $revision),
      )) . ($revision->log != '' ? '<p class="revision-log">' . filter_xss($revision->log) . '</p>' : '');
      if ($revert_permission) {
        $operations[] = l(t('revert'), "node/{$node->nid}/revisions/{$revision->vid}/revert");
      }
      if ($delete_permission) {
        $operations[] = l(t('delete'), "node/{$node->nid}/revisions/{$revision->vid}/delete");
      }
    }
    $rows[] = array_merge($row, $operations);
  }
  return theme('table', $header, $rows);
}