Browse files

MDL-20949 printing out password policy requirements on signup page.

  • Loading branch information...
1 parent d8a3469 commit 019907767adcaac2847c6b2042f9bc6fef6393ea Rossiani Wijaya committed Dec 16, 2009
Showing with 33 additions and 11 deletions.
  1. +6 −0 lang/en_utf8/auth.php
  2. +13 −8 lib/weblib.php
  3. +5 −1 login/change_password_form.php
  4. +5 −1 login/signup_form.php
  5. +4 −1 user/editadvanced_form.php
View
6 lang/en_utf8/auth.php
@@ -417,4 +417,10 @@
$string['getanaudiocaptcha'] = 'Get an audio CAPTCHA';
$string['getanimagecaptcha'] = 'Get an image CAPTCHA';
$string['recaptcha'] = 'reCAPTCHA';
+$string['informminpasswordlength'] = 'at least $a characters';
+$string['informminpassworddigits'] = 'at least $a digit(s)';
+$string['informminpasswordlower'] = 'at least $a lower case letter(s)';
+$string['informminpasswordnonalphanum'] = 'at least $a non-alphanumeric character(s)';
+$string['informminpasswordupper'] = 'at least $a upper case letter(s)';
+$string['informpasswordpolicy'] = 'Your password must have $a';
?>
View
21 lib/weblib.php
@@ -3497,7 +3497,8 @@ function user_login_string($course=NULL, $user=NULL) {
} else if (!empty($user->access['rsw'][$context->path])) {
$rolename = '';
if ($role = get_record('role', 'id', $user->access['rsw'][$context->path])) {
- $rolename = ': '.format_string($role->name);
+ $rolename = join("", role_fix_names(array($role->id=>$role->name), $context));
+ $rolename = ': '.format_string($rolename);
}
$loggedinas = get_string('loggedinas', 'moodle', $username).$rolename.
" (<a $CFG->frametarget
@@ -6442,16 +6443,20 @@ function print_side_block($heading='', $content='', $list=NULL, $icons=NULL, $fo
if ($list) {
$row = 0;
//Accessibility: replaced unnecessary table with list, see themes/standard/styles_layout.css
- echo "\n<ul class='list'>\n";
- foreach ($list as $key => $string) {
+ echo "\n<ul class='list'>\n";
+ foreach ($list as $key => $string) {
echo '<li class="r'. $row .'">';
- if ($icons) {
- $newstring = str_replace('">', '">'.$icons[$key].'&nbsp;', $string);
- $newstring = str_replace('" >', '">'.$icons[$key].'&nbsp;', $newstring);
+ if ($icons) { // Hacky way to insert the icon into the link. See MDL-6820
+ $splitstring = explode ('</a>', $string);
+ $splitstring[0] = str_replace('">', '">'.$icons[$key].'&nbsp;', $splitstring[0]);
+ $splitstring[0] = str_replace('" >', '">'.$icons[$key].'&nbsp;', $splitstring[0]);
+ $newstring = implode ('</a>', $splitstring);
+
+ // Make block icon clickable if configured and there is html in the block text
if ($newstring == $string) { // No link found, so insert before the string
- $newstring = $icons[$key].'&nbsp;'.$string;
+ $newstring = $icons[$key].'&nbsp;'.$string;
}
- $string = $newstring;
+ $string = $newstring;
}
echo '<div class="column c1">' . $string . '</div>';
echo "</li>\n";
View
6 login/change_password_form.php
@@ -5,7 +5,7 @@
class login_change_password_form extends moodleform {
function definition() {
- global $USER;
+ global $USER, $CFG;
$mform =& $this->_form;
@@ -14,6 +14,10 @@ function definition() {
// visible elements
$mform->addElement('static', 'username', get_string('username'), $USER->username);
+ if(!empty($CFG->passwordpolicy)){
+ $passwordpolicy = print_password_policy();
+ $mform->addElement('html', $passwordpolicy);
+ }
$mform->addElement('password', 'password', get_string('oldpassword'));
$mform->addRule('password', get_string('required'), 'required', null, 'client');
$mform->setType('password', PARAM_RAW);
View
6 login/signup_form.php
@@ -14,8 +14,12 @@ function definition() {
$mform->addElement('text', 'username', get_string('username'), 'maxlength="100" size="12"');
$mform->setType('username', PARAM_NOTAGS);
- $mform->addRule('username', get_string('missingusername'), 'required', null, 'server');
+ $mform->addRule('username', get_string('missingusername'), 'required', null, 'server');
+ if(!empty($CFG->passwordpolicy)){
+ $passwordpolicy = print_password_policy();
+ $mform->addElement('html', $passwordpolicy);
+ }
$mform->addElement('passwordunmask', 'password', get_string('password'), 'maxlength="32" size="12"');
$mform->setType('password', PARAM_RAW);
$mform->addRule('password', get_string('missingpassword'), 'required', null, 'server');
View
5 user/editadvanced_form.php
@@ -36,6 +36,10 @@ function definition() {
$mform->setHelpButton('auth', array('authchange', get_string('chooseauthmethod','auth')));
$mform->setAdvanced('auth');
+ if(!empty($CFG->passwordpolicy)){
+ $passwordpolicy = print_password_policy();
+ $mform->addElement('html', '<div class="fitem">'.$passwordpolicy . '</div>');
+ }
$mform->addElement('passwordunmask', 'newpassword', get_string('newpassword'), 'size="20"');
$mform->setHelpButton('newpassword',array('newpassword', get_string('leavetokeep')));
$mform->setType('newpassword', PARAM_RAW);
@@ -139,7 +143,6 @@ function validation($usernew, $files) {
}
//check allowed characters
if ($usernew->username !== moodle_strtolower($usernew->username)) {
- echo 'grrrr';
$err['username'] = get_string('usernamelowercase');
} else {
if (empty($CFG->extendedusernamechars)) {

0 comments on commit 0199077

Please sign in to comment.