function user_revision_form_user_profile_form_alter in User Revision 7.2
Same name and namespace in other branches
- 7 user_revision.module \user_revision_form_user_profile_form_alter()
] * Implements hook_form_alter().
File
- ./
user_revision.module, line 313 - Enables user revision.
Code
function user_revision_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
// Only alter the form if it's the actual account form (i.e. not a profile2 form).
if ($form['#user_category'] == 'account') {
$account = $form_state['user'];
$allowed = user_access('choose user revisions') || user_access('administer users');
$default = variable_get('user_revision_by_default', 1);
if ($allowed || $default) {
$form['revision_information'] = array(
'#type' => 'fieldset',
'#title' => t('Revision information'),
'#collapsible' => FALSE,
'#attributes' => array(
'class' => array(
'user-profile-form-revision-information',
),
),
'#weight' => 20,
);
$form['revision_information']['revision'] = array(
'#type' => $allowed ? 'checkbox' : 'value',
'#title' => t('Create new revision'),
'#default_value' => $default,
);
$form['revision_information']['log'] = array(
'#type' => 'textarea',
'#title' => t('Revision log message'),
'#rows' => 4,
'#description' => t('Provide an explanation of the changes you are making. This will help other authors understand your motivations.'),
'#states' => array(
'invisible' => array(
'input[name="revision"]' => array(
'checked' => FALSE,
),
),
),
);
}
else {
$form['revision'] = array(
'#type' => 'value',
'#value' => FALSE,
);
$form['log'] = array(
'#type' => 'value',
'#value' => '',
);
}
$form['#submit'][] = 'user_revision_user_profile_form_submit';
$form['vid'] = array(
'#type' => 'value',
'#value' => isset($account->vid) ? $account->vid : NULL,
);
$form['ip'] = array(
'#type' => 'value',
'#value' => ip_address(),
);
}
}