Skip to content

Commit

Permalink
MDL-20949 printing out password policy requirements on signup page.
Browse files Browse the repository at this point in the history
  • Loading branch information
rwijaya committed Dec 16, 2009
1 parent d8a3469 commit 0199077
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
6 changes: 6 additions & 0 deletions lang/en_utf8/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
?>
21 changes: 13 additions & 8 deletions lib/weblib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down
6 changes: 5 additions & 1 deletion login/change_password_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class login_change_password_form extends moodleform {

function definition() {
global $USER;
global $USER, $CFG;

$mform =& $this->_form;

Expand All @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion login/signup_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 4 additions & 1 deletion user/editadvanced_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 0199077

Please sign in to comment.