MDL-11090
Passwords are now held in clear text so you can see what the password is on the config screen. Still backward compatible with old md5 passwords (which are still not displayed of course)
This commit is contained in:
+1
-3
@@ -508,9 +508,7 @@ function lesson_process_pre_save(&$lesson) {
|
||||
unset($lesson->completed);
|
||||
unset($lesson->gradebetterthan);
|
||||
|
||||
if (!empty($lesson->password)) {
|
||||
$lesson->password = md5($lesson->password);
|
||||
} else {
|
||||
if (empty($lesson->password)) {
|
||||
unset($lesson->password);
|
||||
}
|
||||
|
||||
|
||||
@@ -182,10 +182,9 @@ class mod_lesson_mod_form extends moodleform_mod {
|
||||
$mform->setHelpButton('usepassword', array('usepassword', get_string('usepassword', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('usepassword', 0);
|
||||
|
||||
$mform->addElement('text', 'password', get_string('password', 'lesson'));
|
||||
$mform->addElement('passwordunmask', 'password', get_string('password', 'lesson'));
|
||||
$mform->setHelpButton('password', array('password', get_string('password', 'lesson'), 'lesson'));
|
||||
$mform->setDefault('password', '');
|
||||
//never displayed converted to md5
|
||||
$mform->setType('password', PARAM_RAW);
|
||||
|
||||
$mform->addElement('date_time_selector', 'available', get_string('available', 'lesson'), array('optional'=>true));
|
||||
@@ -299,13 +298,15 @@ class mod_lesson_mod_form extends moodleform_mod {
|
||||
* @return void
|
||||
**/
|
||||
function data_preprocessing(&$default_values) {
|
||||
global $module;
|
||||
if (isset($default_values['conditions'])) {
|
||||
$conditions = unserialize($default_values['conditions']);
|
||||
$default_values['timespent'] = $conditions->timespent;
|
||||
$default_values['completed'] = $conditions->completed;
|
||||
$default_values['gradebetterthan'] = $conditions->gradebetterthan;
|
||||
}
|
||||
if (isset($default_values['password'])) {
|
||||
// after this passwords are clear text, MDL-11090
|
||||
if (isset($default_values['password']) and ($module->version<2008112600)) {
|
||||
unset($default_values['password']);
|
||||
}
|
||||
if (isset($default_values['add']) and $defaults = get_record('lesson_default', 'course', $default_values['course'])) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* @package lesson
|
||||
**/
|
||||
|
||||
$module->version = 2007101509; // The current module version (Date: YYYYMMDDXX)
|
||||
$module->version = 2008112600; // The current module version (Date: YYYYMMDDXX)
|
||||
$module->requires = 2007101509; // Requires this Moodle version
|
||||
$module->cron = 0; // Period for cron to check this module (secs)
|
||||
|
||||
|
||||
+4
-2
@@ -16,6 +16,7 @@
|
||||
$id = required_param('id', PARAM_INT); // Course Module ID
|
||||
$pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID
|
||||
$edit = optional_param('edit', -1, PARAM_BOOL);
|
||||
$userpassword = optional_param('userpassword','',PARAM_CLEAN);
|
||||
|
||||
list($cm, $course, $lesson) = lesson_get_basics($id);
|
||||
|
||||
@@ -50,8 +51,9 @@
|
||||
|
||||
} else if ($lesson->usepassword and empty($USER->lessonloggedin[$lesson->id])) { // Password protected lesson code
|
||||
$correctpass = false;
|
||||
if ($password = optional_param('userpassword', '', PARAM_CLEAN)) {
|
||||
if ($lesson->password == md5(trim($password))) {
|
||||
if (!empty($userpassword)) {
|
||||
// with or without md5 for backward compatibility (MDL-11090)
|
||||
if (($lesson->password == md5(trim($userpassword))) or ($lesson->password == $userpassword)) {
|
||||
$USER->lessonloggedin[$lesson->id] = true;
|
||||
$correctpass = true;
|
||||
if ($lesson->highscores) {
|
||||
|
||||
Reference in New Issue
Block a user