Skip to content

Commit

Permalink
Authplugin locked fields now use freeze() method rather than rely on js
Browse files Browse the repository at this point in the history
based disabledIf().
Thanks to Jamie P and Petr S.
  • Loading branch information
ikawhero committed Jan 12, 2007
1 parent 4cd1267 commit bd749a7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions user/edit_form.php
Expand Up @@ -241,7 +241,6 @@ function definition () {
} }




//$this->add_action_buttons(false, get_string('updatemyprofile'));
$mform->addElement('submit', 'submitbutton1', get_string('updatemyprofile')); $mform->addElement('submit', 'submitbutton1', get_string('updatemyprofile'));
$mform->closeHeaderBefore('submitbutton1'); $mform->closeHeaderBefore('submitbutton1');


Expand Down Expand Up @@ -299,15 +298,20 @@ function definition () {
/// disable fields that are locked by auth plugins /// disable fields that are locked by auth plugins
if ($userupdate) { if ($userupdate) {
$fields = get_user_fieldnames(); $fields = get_user_fieldnames();
$freezefields = array();


foreach ($fields as $field) { foreach ($fields as $field) {
$configvariable = 'field_lock_' . $field; $configvariable = 'field_lock_' . $field;
if (isset($authplugin->config->{$configvariable})) { if (isset($authplugin->config->{$configvariable}) and
$mform->disabledIf($field, ( $authplugin->config->{$configvariable} === 'locked' or ($authplugin->config->{$configvariable} === 'unlockedifempty' and !empty($user->$field))), true); ( $authplugin->config->{$configvariable} === 'locked' or
( $authplugin->config->{$configvariable} === 'unlockedifempty' and !empty($user->$field)) ) ) {
$freezefields[] = $field;
} }
} }
if (!empty($freezefields)) {
$mform->freeze($freezefields);
}
} }



/// Next the customisable categories /// Next the customisable categories
if ($categories = get_records_select('user_info_category', '1', 'sortorder ASC')) { if ($categories = get_records_select('user_info_category', '1', 'sortorder ASC')) {
Expand All @@ -328,7 +332,6 @@ function definition () {
} /// End of $categories foreach } /// End of $categories foreach
} /// End of $categories if } /// End of $categories if


//$this->add_action_buttons(false, get_string('updatemyprofile'));
$mform->addElement('submit', 'submitbutton2', get_string('updatemyprofile')); $mform->addElement('submit', 'submitbutton2', get_string('updatemyprofile'));
$mform->closeHeaderBefore('submitbutton2'); $mform->closeHeaderBefore('submitbutton2');


Expand Down

0 comments on commit bd749a7

Please sign in to comment.