diff --git a/password_strength.admin.inc b/password_strength.admin.inc new file mode 100644 index 0000000..3cea9f3 --- /dev/null +++ b/password_strength.admin.inc @@ -0,0 +1,25 @@ + 'select', + '#title' => t('Password strength required minimum score'), + '#description' => t('The minimum score required to set a user account password.'), + '#default_value' => variable_get('password_strength_default_required_score', NULL), + '#options' => password_strength_score_list(), + ); + + return system_settings_form($form); +} diff --git a/password_strength.module b/password_strength.module index 27931d3..95cb295 100644 --- a/password_strength.module +++ b/password_strength.module @@ -23,6 +23,15 @@ function password_strength_menu() { 'access callback' => TRUE, 'type' => MENU_CALLBACK, ); + $items['admin/config/system/password-strength'] = array( + 'title' => 'Password Strength settings', + 'description' => 'Manage password strength settings.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('password_strength_settings'), + 'access arguments' => array('administer site configuration'), + 'file' => 'password_strength.admin.inc', + 'weight' => 20, + ); return $items; } @@ -352,25 +361,34 @@ function password_strength_strength_pattern($match) { } /** - * Returns a human readable version of the password score. + * Returns a human readable list of score levels. * - * @param int $score - * An integer coresponding to a password strength. - * - * @return string - * A human readable version of the score. + * @return array + * A list of human readable score levels. * */ -function password_strength_get_score($score) { - - $scores = array( +function password_strength_score_list() { + return array( t('very weak'), t('weak'), t('good'), t('strong'), t('very strong'), ); +} +/** + * Returns a human readable version of the password score. + * + * @param int $score + * An integer corresponding to a password strength. + * + * @return string + * A human readable version of the score. + * + */ +function password_strength_get_score($score) { + $scores = password_strength_score_list(); return isset($scores[$score]) ? $scores[$score] : t('unknown'); }