diff --git a/admin/settings/plugins.php b/admin/settings/plugins.php index f311696f5db..94147442d13 100644 --- a/admin/settings/plugins.php +++ b/admin/settings/plugins.php @@ -80,6 +80,9 @@ if ($hassiteconfig) { $temp->add(new admin_setting_heading('manageauthscommonheading', new lang_string('commonsettings', 'admin'), '')); $temp->add(new admin_setting_special_registerauth()); $temp->add(new admin_setting_configcheckbox('authloginviaemail', new lang_string('authloginviaemail', 'core_auth'), new lang_string('authloginviaemail_desc', 'core_auth'), 0)); + $temp->add(new admin_setting_configcheckbox('allowuserstoshareemailaddresses', + new lang_string('allowuserstoshareemailaddresses', 'core_auth'), + new lang_string('allowuserstoshareemailaddresses_desc', 'core_auth'), 0)); $temp->add(new admin_setting_configcheckbox('authpreventaccountcreation', new lang_string('authpreventaccountcreation', 'admin'), new lang_string('authpreventaccountcreation_help', 'admin'), 0)); $temp->add(new admin_setting_configcheckbox('loginpageautofocus', new lang_string('loginpageautofocus', 'admin'), new lang_string('loginpageautofocus_help', 'admin'), 0)); $temp->add(new admin_setting_configselect('guestloginbutton', new lang_string('guestloginbutton', 'auth'), diff --git a/admin/tool/uploaduser/index.php b/admin/tool/uploaduser/index.php index 8d898fd05c7..70ca155699c 100644 --- a/admin/tool/uploaduser/index.php +++ b/admin/tool/uploaduser/index.php @@ -168,7 +168,7 @@ if ($formdata = $mform2->is_cancelled()) { $allowdeletes = (!empty($formdata->uuallowdeletes) and $optype != UU_USER_ADDNEW and $optype != UU_USER_ADDINC); $allowsuspends = (!empty($formdata->uuallowsuspends)); $bulk = $formdata->uubulk; - $noemailduplicates = $formdata->uunoemailduplicates; + $noemailduplicates = empty($CFG->allowuserstoshareemailaddresses) ? 1 : $formdata->uunoemailduplicates; $standardusernames = $formdata->uustandardusernames; $resetpasswords = isset($formdata->uuforcepasswordchange) ? $formdata->uuforcepasswordchange : UU_PWRESET_NONE; diff --git a/admin/tool/uploaduser/user_form.php b/admin/tool/uploaduser/user_form.php index 2e919fd7361..9a2a33b4dee 100644 --- a/admin/tool/uploaduser/user_form.php +++ b/admin/tool/uploaduser/user_form.php @@ -138,8 +138,13 @@ class admin_uploaduser_form2 extends moodleform { $mform->disabledIf('uuallowsuspends', 'uutype', 'eq', UU_USER_ADDNEW); $mform->disabledIf('uuallowsuspends', 'uutype', 'eq', UU_USER_ADDINC); - $mform->addElement('selectyesno', 'uunoemailduplicates', get_string('uunoemailduplicates', 'tool_uploaduser')); - $mform->setDefault('uunoemailduplicates', 1); + if (!empty($CFG->allowuserstoshareemailaddresses)) { + $mform->addElement('selectyesno', 'uunoemailduplicates', get_string('uunoemailduplicates', 'tool_uploaduser')); + $mform->setDefault('uunoemailduplicates', 1); + } else { + $mform->addElement('hidden', 'uunoemailduplicates', 1); + } + $mform->setType('uunoemailduplicates', PARAM_BOOL); $mform->addElement('selectyesno', 'uustandardusernames', get_string('uustandardusernames', 'tool_uploaduser')); $mform->setDefault('uustandardusernames', 1); diff --git a/lang/en/auth.php b/lang/en/auth.php index 68799d5138f..fb499d95317 100644 --- a/lang/en/auth.php +++ b/lang/en/auth.php @@ -113,6 +113,8 @@ $string['limitconcurrentlogins_desc'] = 'If enabled the number of concurrent bro $string['locked'] = 'Locked'; $string['authloginviaemail'] = 'Allow log in via email'; $string['authloginviaemail_desc'] = 'Allow users to use both username and email address (if unique) for site login.'; +$string['allowuserstoshareemailaddresses'] = 'Allow users to share email addresses'; +$string['allowuserstoshareemailaddresses_desc'] = 'Allow different user accounts to share the same email address. It is important to ensure that this will not cause any unexpected security issues in your setup before enabling it. For example, password change confirmations will be sent to the shared email address.'; $string['md5'] = 'MD5 hash'; $string['nopasswordchange'] = 'Password can not be changed'; $string['nopasswordchangeforced'] = 'You cannot proceed without changing your password, however there is no available page for changing it. Please contact your Moodle Administrator.'; diff --git a/user/edit_form.php b/user/edit_form.php index 65e86076d89..fd997883153 100644 --- a/user/edit_form.php +++ b/user/edit_form.php @@ -174,7 +174,9 @@ class user_edit_form extends moodleform { // Mail not confirmed yet. } else if (!validate_email($usernew->email)) { $errors['email'] = get_string('invalidemail'); - } else if (($usernew->email !== $user->email) and $DB->record_exists('user', array('email' => $usernew->email, 'mnethostid' => $CFG->mnet_localhost_id))) { + } else if (($usernew->email !== $user->email) + and empty($CFG->allowuserstoshareemailaddresses) + and $DB->record_exists('user', array('email' => $usernew->email, 'mnethostid' => $CFG->mnet_localhost_id))) { $errors['email'] = get_string('emailexists'); } diff --git a/user/editadvanced_form.php b/user/editadvanced_form.php index ea95370ae08..b58b90747e5 100644 --- a/user/editadvanced_form.php +++ b/user/editadvanced_form.php @@ -262,7 +262,8 @@ class user_editadvanced_form extends moodleform { if (!$user or $user->email !== $usernew->email) { if (!validate_email($usernew->email)) { $err['email'] = get_string('invalidemail'); - } else if ($DB->record_exists('user', array('email' => $usernew->email, 'mnethostid' => $CFG->mnet_localhost_id))) { + } else if (empty($CFG->allowuserstoshareemailaddresses) + and $DB->record_exists('user', array('email' => $usernew->email, 'mnethostid' => $CFG->mnet_localhost_id))) { $err['email'] = get_string('emailexists'); } }