This provides a way to compare the main user properties as well as the additional fields on user objects.

It adds a new entity settings local tab.

Example usage

Two users with a couple of fields (A name and file field).

$account_a = user_load(1);
$account_b = user_load(5);
module_load_include('pages.inc', 'diff');
$header = _diff_default_header(entity_label('user', $account_a), entity_label('user', $account_b));
$rows = diff_entity_body_rows('user', $account_a, $account_b);

$build['diff_table'] = array(
  '#theme' => 'table',
  '#header' => $header,
  '#rows' => $rows,
  '#attributes' => array('class' => array('diff')),
  '#colgroups' => _diff_default_cols(),
  '#sticky' => FALSE,
);

print drupal_render($build['diff_table']);

Which outputs:

admin test
Changes to Username
-
admin
+
test
Changes to E-mail address
-
developers@glodigital.com.au
+
test@example.com
Changes to Status
-
Active
+
Blocked
Changes to Time zone
-
Australia/Brisbane: Saturday, October 12, 2013 - 15:24 +1000
+
Atlantic/Stanley: Saturday, October 12, 2013 - 02:24 -0300
Changes to Password Hash
-
$S$DtNMVC8MT0gDA58mTJ9WbFV38XCnSvrosHTCw4p4xneRnbdrIXpz
+
$S$Dr7m6ex3JDzIPgNYfD8NQEbmSrQ8SiCgFe/RdtiDXychNKEfgscj
Changes to Roles
    +
test
Changes to Name
-
test name 2
+
test test2 test
Changes to test
    +
File: test.txt; File ID: 2; Displayed

Comments

alan d.’s picture

Status: Needs review » Fixed

Added in c4e7ac8

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Added separator between code and output