Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-37704

Cannot lock Description field in users' profiles

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. Go in Home / ► Site administration / ► Plugins / ► Authentication / ► Manual accounts
      2. Set Description to "Locked"
      3. Log in with a student account
      4. Go to Settings/Edit my account
      5. Try to edit Description field and save
      6. Make sure it is locked and not editable.
      7. Now unlock it and make the description empty.
      8. How set the description field to "unlocked if empty"
      9. make sure it is unlocked in the profile edit screen.
      10. Add some data and save.
      11. Make sure it is locked now.
      Show
      Go in Home / ► Site administration / ► Plugins / ► Authentication / ► Manual accounts Set Description to "Locked" Log in with a student account Go to Settings/Edit my account Try to edit Description field and save Make sure it is locked and not editable. Now unlock it and make the description empty. How set the description field to "unlocked if empty" make sure it is unlocked in the profile edit screen. Add some data and save. Make sure it is locked now.
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_26_STABLE, MOODLE_27_STABLE
    • Fixed Branches:
      MOODLE_27_STABLE, MOODLE_28_STABLE
    • Pull Master Branch:
      MDL-37704-master

      Description

      In authentication plugins, even if Description is mark as Locked, it is still unlock and editable in the user profile.

      To reproduce :

      1. Go in Home
        / ► Site administration
        / ► Plugins
        / ► Authentication
        / ► Manual accounts
      2. Set Description to "Locked"
      3. Log in with a student account
      4. Go to Settings/Edit my account
      5. Try to edit Description field and save
      6. Modifications are indeed saved but they shouldn't

      I track this down to \user\edit_form.php, line #100 to #120 :

                  $fields = get_user_fieldnames();
                  $authplugin = get_auth_plugin($user->auth);
                  foreach ($fields as $field) {
                      if (!$mform->elementExists($field)) {
                          continue;
                      }
                      $configvariable = 'field_lock_' . $field;
                      if (isset($authplugin->config->{$configvariable})) {
                          if ($authplugin->config->{$configvariable} === 'locked') {
                              $mform->hardFreeze($field);
                              $mform->setConstant($field, $user->$field);
                          } else if ($authplugin->config->{$configvariable} === 'unlockedifempty' and $user->$field != '') {
                              $mform->hardFreeze($field);
                              $mform->setConstant($field, $user->$field);
                          }
                      }
                  }
      

      The problem is with

      $mform->elementExists($field)

      where $field == "description" but on the form, the Description field name is "description_editor[text]", so it just skipped it. .

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                8 Vote for this issue
                Watchers:
                10 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  12/Jan/15