Skip to content

Commit

Permalink
Merge branch 'wip-MDL-51834-master' of https://github.com/kwiliarty/m…
Browse files Browse the repository at this point in the history
  • Loading branch information
danpoltawski committed Oct 26, 2015
2 parents 3ec49c6 + b718906 commit d3cd5f1
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions user/edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public function definition_after_data() {
// Disable fields that are locked by auth plugins.
$fields = get_user_fieldnames();
$authplugin = get_auth_plugin($user->auth);
$customfields = $authplugin->get_custom_user_profile_fields();
$fields = array_merge($fields, $customfields);
foreach ($fields as $field) {
if ($field === 'description') {
// Hard coded hack for description field. See MDL-37704 for details.
Expand All @@ -135,14 +137,15 @@ public function definition_after_data() {
if (!$mform->elementExists($formfield)) {
continue;
}
$value = $mform->getElementValue($formfield);
$configvariable = 'field_lock_' . $field;
if (isset($authplugin->config->{$configvariable})) {
if ($authplugin->config->{$configvariable} === 'locked') {
$mform->hardFreeze($formfield);
$mform->setConstant($formfield, $user->$field);
} else if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->$field != '') {
$mform->setConstant($formfield, $value);
} else if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $value != '') {
$mform->hardFreeze($formfield);
$mform->setConstant($formfield, $user->$field);
$mform->setConstant($formfield, $value);
}
}
}
Expand Down

0 comments on commit d3cd5f1

Please sign in to comment.