Moodle
  1. Moodle
  2. MDL-8253

File upload seems to default to producing mnet user accounts

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.8
    • Fix Version/s: 1.8
    • Component/s: Administration, MNet
    • Labels:
      None
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE
    • Rank:
      29270

      Description

      When you upload users via Admin > Users > Upload Users with a file like:

      abigail, abigail, Abigail, Barzilai, abigailb@techunix.technion.ac.il

      then this user is an mnet account by default and you can't edit it.

        Issue Links

          Activity

          Hide
          Martin Dougiamas added a comment -

          I edited is_mnet_remote_user() to make it a bit more robust when mnethostid == 0

          This prevents the errors but upload should still set the correct mnethostid on new user accounts.

          Show
          Martin Dougiamas added a comment - I edited is_mnet_remote_user() to make it a bit more robust when mnethostid == 0 This prevents the errors but upload should still set the correct mnethostid on new user accounts.
          Hide
          Martín Langhoff added a comment -

          Thanks!

          Show
          Martín Langhoff added a comment - Thanks!
          Hide
          Martin Dougiamas added a comment -

          What is the correct way to find the local mnethostid to use as a default for new user accounts?

          Show
          Martin Dougiamas added a comment - What is the correct way to find the local mnethostid to use as a default for new user accounts?
          Hide
          Donal McMullan added a comment -

          This has been changed to give uploaded users the mnethostid of the admin user (as obtained by get_admin)

          Further - in the upload file, a field 'mnethostid' can be specified to override the default, to enable batch upload of remote user details.

          Re: What is the correct way to find the local mnethostid to use as a default for new user accounts?

          If you think it's possible that the localhost ID might not yet have been set yet, you can do:
          if (empty($CFG->mnet_localhost_id))

          { require_once $CFG->dirroot.'/mnet/lib.php'; }

          Thereafter, your local host ID is:
          $CFG->mnet_localhost_id

          When you include mnet/lib.php, the environment object is bootstrapped like so:
          $this->wwwroot = $CFG->wwwroot;
          $this->ip_address = $_SERVER['SERVER_ADDR'];
          $this->id = insert_record('mnet_host', $this, true);
          set_config('mnet_localhost_id', $this->id);

          You can see that this doesn't require any special knowledge or admin input. It may be the case that we need to do this earlier in the install or upgrade cycle, to prevent lots of
          if (empty($CFG->mnet_localhost_id)) {
          checking.

          Thanks

          Show
          Donal McMullan added a comment - This has been changed to give uploaded users the mnethostid of the admin user (as obtained by get_admin) Further - in the upload file, a field 'mnethostid' can be specified to override the default, to enable batch upload of remote user details. Re: What is the correct way to find the local mnethostid to use as a default for new user accounts? If you think it's possible that the localhost ID might not yet have been set yet, you can do: if (empty($CFG->mnet_localhost_id)) { require_once $CFG->dirroot.'/mnet/lib.php'; } Thereafter, your local host ID is: $CFG->mnet_localhost_id When you include mnet/lib.php, the environment object is bootstrapped like so: $this->wwwroot = $CFG->wwwroot; $this->ip_address = $_SERVER ['SERVER_ADDR'] ; $this->id = insert_record('mnet_host', $this, true); set_config('mnet_localhost_id', $this->id); You can see that this doesn't require any special knowledge or admin input. It may be the case that we need to do this earlier in the install or upgrade cycle, to prevent lots of if (empty($CFG->mnet_localhost_id)) { checking. Thanks
          Hide
          Martín Langhoff added a comment -

          I think we shouldn't need to have lots of if (empty($CFG->mnet_localhost_id)) – the value is guaranteed to be set except during the 1.7->1.8 upgrade.

          We did make sure that the upgrade works, so all the calls around login and access to the /admin area do test for empty(). However, general code shouldn't need to check... if the upgrade is botched, lots of other things will be broken

          BTW, I've added some notes in http://docs.moodle.org/en/Development:Moodle_Network

          Show
          Martín Langhoff added a comment - I think we shouldn't need to have lots of if (empty($CFG->mnet_localhost_id)) – the value is guaranteed to be set except during the 1.7->1.8 upgrade. We did make sure that the upgrade works, so all the calls around login and access to the /admin area do test for empty(). However, general code shouldn't need to check... if the upgrade is botched, lots of other things will be broken BTW, I've added some notes in http://docs.moodle.org/en/Development:Moodle_Network

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: