1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Provide diff functions for the user module.
|
6
|
*
|
7
|
* Note as users do not have revisions enabled, most use cases for comparisons
|
8
|
* will be between two different users.
|
9
|
*/
|
10
|
|
11
|
/**
|
12
|
* Private callback function to render the name field.
|
13
|
*/
|
14
|
function _user_entity_diff_additional_options_name($old_user, $new_user, $context) {
|
15
|
$row = array(
|
16
|
'#name' => t('Username'),
|
17
|
'#states' => array(),
|
18
|
'#weight' => -5,
|
19
|
'#settings' => array(
|
20
|
'show_header' => variable_get('diff_show_header_user', 1),
|
21
|
),
|
22
|
);
|
23
|
foreach ($context['states'] as $state) {
|
24
|
switch ($state) {
|
25
|
case 'rendered':
|
26
|
$row['#states'][$state] = array(
|
27
|
'#old' => theme('username', array('account' => $old_user)),
|
28
|
'#new' => theme('username', array('account' => $old_user)),
|
29
|
);
|
30
|
break;
|
31
|
|
32
|
// We specify a default so that the name is always compared.
|
33
|
case 'raw':
|
34
|
default:
|
35
|
$row['#states'][$state] = array(
|
36
|
'#old' => array($old_user->name),
|
37
|
'#new' => array($new_user->name),
|
38
|
);
|
39
|
break;
|
40
|
}
|
41
|
}
|
42
|
return $row;
|
43
|
}
|
44
|
|
45
|
/**
|
46
|
* Private callback function to render the mail field.
|
47
|
*/
|
48
|
function _user_entity_diff_additional_options_mail($old_user, $new_user, $context) {
|
49
|
$row = array(
|
50
|
'#name' => t('E-mail address'),
|
51
|
'#states' => array(),
|
52
|
'#weight' => -4,
|
53
|
'#settings' => array(),
|
54
|
);
|
55
|
|
56
|
foreach ($context['states'] as $state) {
|
57
|
$row['#states'][$state] = array(
|
58
|
'#old' => array($old_user->mail),
|
59
|
'#new' => array($new_user->mail),
|
60
|
);
|
61
|
}
|
62
|
return $row;
|
63
|
}
|
64
|
|
65
|
/**
|
66
|
* Private callback function to render the status field.
|
67
|
*/
|
68
|
function _user_entity_diff_additional_options_status($old_user, $new_user, $context) {
|
69
|
$row = array(
|
70
|
'#name' => t('Status'),
|
71
|
'#states' => array(),
|
72
|
'#weight' => -3,
|
73
|
'#settings' => array(),
|
74
|
);
|
75
|
|
76
|
foreach ($context['states'] as $state) {
|
77
|
$row['#states'][$state] = array(
|
78
|
'#old' => array($old_user->status ? t('Active') : t('Blocked')),
|
79
|
'#new' => array($new_user->status ? t('Active') : t('Blocked')),
|
80
|
);
|
81
|
}
|
82
|
return $row;
|
83
|
}
|
84
|
|
85
|
/**
|
86
|
* Private callback function to render the timezone field.
|
87
|
*/
|
88
|
function _user_entity_diff_additional_options_timezone($old_user, $new_user, $context) {
|
89
|
$row = array(
|
90
|
'#name' => t('Time zone'),
|
91
|
'#states' => array(),
|
92
|
'#weight' => -1,
|
93
|
'#settings' => array(),
|
94
|
);
|
95
|
$system_time_zones = system_time_zones(TRUE);
|
96
|
$old_zone = isset($old_user->timezone) ? $old_user->timezone : '';
|
97
|
$new_zone = isset($new_user->timezone) ? $new_user->timezone : '';
|
98
|
|
99
|
foreach ($context['states'] as $state) {
|
100
|
$row['#states'][$state] = array(
|
101
|
'#old' => array(isset($system_time_zones[$old_zone]) ? $system_time_zones[$old_zone] : t('- None selected -')),
|
102
|
'#new' => array(isset($system_time_zones[$new_zone]) ? $system_time_zones[$new_zone] : t('- None selected -')),
|
103
|
);
|
104
|
}
|
105
|
return $row;
|
106
|
}
|
107
|
|
108
|
/**
|
109
|
* Private callback function to render the password field.
|
110
|
*/
|
111
|
function _user_entity_diff_additional_options_password($old_user, $new_user, $context) {
|
112
|
$row = array(
|
113
|
'#name' => t('Password Hash'),
|
114
|
'#states' => array(),
|
115
|
'#weight' => -1,
|
116
|
'#settings' => array(),
|
117
|
);
|
118
|
|
119
|
foreach ($context['states'] as $state) {
|
120
|
$row['#states'][$state] = array(
|
121
|
'#old' => array($old_user->pass),
|
122
|
'#new' => array($new_user->pass),
|
123
|
);
|
124
|
}
|
125
|
return $row;
|
126
|
}
|
127
|
|
128
|
/**
|
129
|
* Private callback function to render the roles field.
|
130
|
*/
|
131
|
function _user_entity_diff_additional_options_roles($old_user, $new_user, $context) {
|
132
|
$row = array(
|
133
|
'#name' => t('Roles'),
|
134
|
'#states' => array(),
|
135
|
'#weight' => -1,
|
136
|
'#settings' => array(),
|
137
|
);
|
138
|
|
139
|
$roles = user_roles(TRUE);
|
140
|
unset($roles[DRUPAL_AUTHENTICATED_RID]);
|
141
|
foreach ($context['states'] as $state) {
|
142
|
$row['#states'][$state] = array(
|
143
|
'#old' => array(implode("\n", array_intersect_key($roles, $old_user->roles))),
|
144
|
'#new' => array(implode("\n", array_intersect_key($roles, $new_user->roles))),
|
145
|
);
|
146
|
}
|
147
|
return $row;
|
148
|
}
|