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

      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.

        Gliffy Diagrams

          Issue Links

            Activity

            Martin Dougiamas created issue -
            Martin Dougiamas made changes -
            Field Original Value New Value
            Priority Minor [ 4 ] Blocker [ 1 ]
            Martin Dougiamas made changes -
            Link This issue blocks MDL-8068 [ MDL-8068 ]
            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.
            Martin Dougiamas made changes -
            Priority Blocker [ 1 ] Major [ 3 ]
            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
            Donal McMullan made changes -
            Status Open [ 1 ] Resolved [ 5 ]
            Resolution Fixed [ 1 ]
            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
            Martin Dougiamas made changes -
            Status Resolved [ 5 ] Closed [ 6 ]
            QA Assignee martinlanghoff nobody
            Martin Dougiamas made changes -
            Workflow jira [ 19164 ] MDL Workflow [ 54782 ]
            Martin Dougiamas made changes -
            Workflow MDL Workflow [ 54782 ] MDL Full Workflow [ 83902 ]

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: