Commit a6ae1c6c authored by Dries's avatar Dries

- Patch #530652 by sun: _user_password_dynamic_validation() should be a...

- Patch #530652 by sun: _user_password_dynamic_validation() should be a #process of password_confirm().
parent 85161f23
......@@ -1377,8 +1377,6 @@ function install_configure_form($form, &$form_state, &$install_state) {
drupal_set_message(st('All necessary changes to %dir and %file have been made. They have been set to read-only for security.', array('%dir' => $settings_dir, '%file' => $settings_file)));
}
// Add JavaScript validation.
_user_password_dynamic_validation();
drupal_add_js(drupal_get_path('module', 'system') . '/system.js');
// Add JavaScript time zone detection.
drupal_add_js('misc/timezone.js');
......
......@@ -64,12 +64,12 @@ function _field_info_collate_types($reset = FALSE) {
if ($reset) {
$info = NULL;
cache_clear_all('field_info_types', 'cache_field');
cache_clear_all('field_info_types', 'cache_bootstrap');
return;
}
if (!isset($info)) {
if ($cached = cache_get('field_info_types', 'cache_field')) {
if ($cached = cache_get('field_info_types', 'cache_bootstrap')) {
$info = $cached->data;
}
else {
......@@ -137,7 +137,7 @@ function _field_info_collate_types($reset = FALSE) {
}
drupal_alter('field_storage_info', $info['storage types']);
cache_set('field_info_types', $info, 'cache_field');
cache_set('field_info_types', $info, 'cache_bootstrap');
}
}
......@@ -168,12 +168,12 @@ function _field_info_collate_fields($reset = FALSE) {
if ($reset) {
$info = NULL;
cache_clear_all('field_info_fields', 'cache_field');
cache_clear_all('field_info_fields', 'cache_field_bootstrap');
return;
}
if (!isset($info)) {
if ($cached = cache_get('field_info_fields', 'cache_field')) {
if ($cached = cache_get('field_info_fields', 'cache_bootstrap')) {
$definitions = $cached->data;
}
else {
......@@ -181,7 +181,7 @@ function _field_info_collate_fields($reset = FALSE) {
'field_ids' => field_read_fields(array(), array('include_deleted' => 1)),
'instances' => field_read_instances(),
);
cache_set('field_info_fields', $definitions, 'cache_field');
cache_set('field_info_fields', $definitions, 'cache_bootstrap');
}
// Populate 'field_ids' with all fields.
......
......@@ -368,7 +368,7 @@ function system_element_info() {
);
$types['password_confirm'] = array(
'#input' => TRUE,
'#process' => array('form_process_password_confirm'),
'#process' => array('form_process_password_confirm', 'user_form_process_password_confirm'),
'#theme_wrappers' => array('form_element'),
);
$types['textarea'] = array(
......
......@@ -866,7 +866,6 @@ function user_account_form(&$form, &$form_state) {
$account = $form['#user'];
$register = ($form['#user']->uid > 0 ? FALSE : TRUE);
_user_password_dynamic_validation();
$admin = user_access('administer users');
$form['#validate'][] = 'user_account_form_validate';
......@@ -2951,40 +2950,42 @@ function _user_mail_notify($op, $account, $language = NULL) {
}
/**
* Add javascript and string translations for dynamic password validation
* (strength and confirmation checking).
* Form element process handler for client-side password validation.
*
* This is an internal function that makes it easier to manage the translation
* strings that need to be passed to the javascript code.
* This #process handler is automatically invoked for 'password_confirm' form
* elements to add the JavaScript and string translations for dynamic password
* validation.
*
* @see system_element_info()
*/
function _user_password_dynamic_validation() {
static $complete = FALSE;
function user_form_process_password_confirm($element) {
global $user;
// Only need to do once per page.
if (!$complete) {
drupal_add_js(drupal_get_path('module', 'user') . '/user.js');
drupal_add_js(array(
'password' => array(
'strengthTitle' => t('Password strength:'),
'hasWeaknesses' => t('To make your password stronger:'),
'tooShort' => t('Make it at least 6 characters'),
'addLowerCase' => t('Add lowercase letters'),
'addUpperCase' => t('Add uppercase letters'),
'addNumbers' => t('Add numbers'),
'addPunctuation' => t('Add punctuation'),
'sameAsUsername' => t('Make it different from your username'),
'confirmSuccess' => t('yes'),
'confirmFailure' => t('no'),
'weak' => t('Weak'),
'fair' => t('Fair'),
'good' => t('Good'),
'strong' => t('Strong'),
'confirmTitle' => t('Passwords match:'),
'username' => (isset($user->name) ? $user->name : ''))),
'setting');
$complete = TRUE;
}
$js_settings = array(
'password' => array(
'strengthTitle' => t('Password strength:'),
'hasWeaknesses' => t('To make your password stronger:'),
'tooShort' => t('Make it at least 6 characters'),
'addLowerCase' => t('Add lowercase letters'),
'addUpperCase' => t('Add uppercase letters'),
'addNumbers' => t('Add numbers'),
'addPunctuation' => t('Add punctuation'),
'sameAsUsername' => t('Make it different from your username'),
'confirmSuccess' => t('yes'),
'confirmFailure' => t('no'),
'weak' => t('Weak'),
'fair' => t('Fair'),
'good' => t('Good'),
'strong' => t('Strong'),
'confirmTitle' => t('Passwords match:'),
'username' => (isset($user->name) ? $user->name : ''),
),
);
$element['#attached']['js'][] = drupal_get_path('module', 'user') . '/user.js';
$element['#attached']['js'][] = array('data' => $js_settings, 'type' => 'setting');
return $element;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment