From 5bc886259b2fe5a24264c274cfb3a96098ffb56c Mon Sep 17 00:00:00 2001 From: Ankit Agarwal Date: Tue, 2 Dec 2014 09:34:27 +0530 Subject: [PATCH] MDL-37704 user_profile: Make sure description field can be locked Thanks JD for the initial patch. --- user/edit_form.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/user/edit_form.php b/user/edit_form.php index 4c46d6bb0a9..5456c38a280 100644 --- a/user/edit_form.php +++ b/user/edit_form.php @@ -133,17 +133,23 @@ class user_edit_form extends moodleform { $fields = get_user_fieldnames(); $authplugin = get_auth_plugin($user->auth); foreach ($fields as $field) { - if (!$mform->elementExists($field)) { + if ($field === 'description') { + // Hard coded hack for description field. See MDL-37704 for details. + $formfield = 'description_editor'; + } else { + $formfield = $field; + } + if (!$mform->elementExists($formfield)) { continue; } $configvariable = 'field_lock_' . $field; if (isset($authplugin->config->{$configvariable})) { if ($authplugin->config->{$configvariable} === 'locked') { - $mform->hardFreeze($field); - $mform->setConstant($field, $user->$field); + $mform->hardFreeze($formfield); + $mform->setConstant($formfield, $user->$field); } else if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->$field != '') { - $mform->hardFreeze($field); - $mform->setConstant($field, $user->$field); + $mform->hardFreeze($formfield); + $mform->setConstant($formfield, $user->$field); } } } -- 2.11.4.GIT