You are here

function user_rev_diff_user_revisions in User Revision 7.2

Input form to select two revisions.

Parameters

$viewed_user: User whose revisions are displayed for selection.

1 string reference to 'user_rev_diff_user_revisions'
user_rev_diff_diffs_overview in diff/user_rev_diff.pages.inc
Generate an overview table of older revisions of a node and provide an input form to select two revisions for a comparison.

File

diff/user_rev_diff.pages.inc, line 33
Menu callbacks for hook_menu().

Code

function user_rev_diff_user_revisions($form, $form_state, $viewed_user) {
  $data = user_revision_list_build($viewed_user);

  // Each element of $data is an array containing:
  // 'row': an array keyed by the revision-id, containing an array keyed 'data' containing markup.
  // 'operations: an array containing revert and delete links.
  foreach ($data as $item) {
    $row = $item['row'];
    $vid = key($row);
    $revision_ids[$vid] = '';
    $form['info'][$vid] = array(
      '#markup' => $row[$vid]['data'],
      '#revision' => $row[$vid]['revision'],
    );
    $operations = array();
    foreach ($item['operations'] as $operation) {
      if (!is_array($operation)) {
        $operations[] = array(
          '#markup' => $operation,
        );
      }
    }
    $form['operations'][$vid] = $operations;
  }
  $new_vid = key($revision_ids);
  next($revision_ids);
  $old_vid = key($revision_ids);
  $form['diff']['old'] = array(
    '#type' => 'radios',
    '#options' => $revision_ids,
    '#default_value' => $old_vid,
  );
  $form['diff']['new'] = array(
    '#type' => 'radios',
    '#options' => $revision_ids,
    '#default_value' => $new_vid,
  );
  $form['uid'] = array(
    '#type' => 'hidden',
    '#value' => $viewed_user->uid,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Compare'),
  );

  // use the diff module's theme function.
  $form['#attached'] = diff_build_attachments(TRUE);
  $form['#theme'] = 'diff_node_revisions';
  return $form;
}