mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 17:36:38 +02:00
Merge branch 'MDL-55062_master' of git://github.com/markn86/moodle
This commit is contained in:
commit
428e18ed2b
3 changed files with 38 additions and 28 deletions
|
@ -358,38 +358,40 @@ if ($formdata = $mform2->is_cancelled()) {
|
||||||
|
|
||||||
// add default values for remaining fields
|
// add default values for remaining fields
|
||||||
$formdefaults = array();
|
$formdefaults = array();
|
||||||
foreach ($STD_FIELDS as $field) {
|
if ($updatetype != UU_UPDATE_FILEOVERRIDE && $updatetype != UU_UPDATE_NOCHANGES) {
|
||||||
if (isset($user->$field)) {
|
foreach ($STD_FIELDS as $field) {
|
||||||
continue;
|
if (isset($user->$field)) {
|
||||||
}
|
continue;
|
||||||
// all validation moved to form2
|
}
|
||||||
if (isset($formdata->$field)) {
|
// all validation moved to form2
|
||||||
// process templates
|
if (isset($formdata->$field)) {
|
||||||
$user->$field = uu_process_template($formdata->$field, $user);
|
// process templates
|
||||||
$formdefaults[$field] = true;
|
$user->$field = uu_process_template($formdata->$field, $user);
|
||||||
if (in_array($field, $upt->columns)) {
|
$formdefaults[$field] = true;
|
||||||
$upt->track($field, s($user->$field), 'normal');
|
if (in_array($field, $upt->columns)) {
|
||||||
|
$upt->track($field, s($user->$field), 'normal');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
foreach ($PRF_FIELDS as $field) {
|
||||||
foreach ($PRF_FIELDS as $field) {
|
if (isset($user->$field)) {
|
||||||
if (isset($user->$field)) {
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (isset($formdata->$field)) {
|
|
||||||
// process templates
|
|
||||||
$user->$field = uu_process_template($formdata->$field, $user);
|
|
||||||
|
|
||||||
// Form contains key and later code expects value.
|
|
||||||
// Convert key to value for required profile fields.
|
|
||||||
require_once($CFG->dirroot.'/user/profile/field/'.$proffields[$field]->datatype.'/field.class.php');
|
|
||||||
$profilefieldclass = 'profile_field_'.$proffields[$field]->datatype;
|
|
||||||
$profilefield = new $profilefieldclass($proffields[$field]->id);
|
|
||||||
if (method_exists($profilefield, 'convert_external_data')) {
|
|
||||||
$user->$field = $profilefield->edit_save_data_preprocess($user->$field, null);
|
|
||||||
}
|
}
|
||||||
|
if (isset($formdata->$field)) {
|
||||||
|
// process templates
|
||||||
|
$user->$field = uu_process_template($formdata->$field, $user);
|
||||||
|
|
||||||
$formdefaults[$field] = true;
|
// Form contains key and later code expects value.
|
||||||
|
// Convert key to value for required profile fields.
|
||||||
|
require_once($CFG->dirroot.'/user/profile/field/'.$proffields[$field]->datatype.'/field.class.php');
|
||||||
|
$profilefieldclass = 'profile_field_'.$proffields[$field]->datatype;
|
||||||
|
$profilefield = new $profilefieldclass($proffields[$field]->id);
|
||||||
|
if (method_exists($profilefield, 'convert_external_data')) {
|
||||||
|
$user->$field = $profilefield->edit_save_data_preprocess($user->$field, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
$formdefaults[$field] = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ $string['deleteerrors'] = 'Delete errors';
|
||||||
$string['encoding'] = 'Encoding';
|
$string['encoding'] = 'Encoding';
|
||||||
$string['errormnetadd'] = 'Can not add remote users';
|
$string['errormnetadd'] = 'Can not add remote users';
|
||||||
$string['errors'] = 'Errors';
|
$string['errors'] = 'Errors';
|
||||||
|
$string['invalidupdatetype'] = 'You can not select this option with the chosen \'Upload type\'';
|
||||||
$string['invaliduserdata'] = 'Invalid data detected for user {$a} and it has been automatically cleaned.';
|
$string['invaliduserdata'] = 'Invalid data detected for user {$a} and it has been automatically cleaned.';
|
||||||
$string['nochanges'] = 'No changes';
|
$string['nochanges'] = 'No changes';
|
||||||
$string['pluginname'] = 'User upload';
|
$string['pluginname'] = 'User upload';
|
||||||
|
|
|
@ -350,6 +350,7 @@ class admin_uploaduser_form2 extends moodleform {
|
||||||
$errors = parent::validation($data, $files);
|
$errors = parent::validation($data, $files);
|
||||||
$columns = $this->_customdata['columns'];
|
$columns = $this->_customdata['columns'];
|
||||||
$optype = $data['uutype'];
|
$optype = $data['uutype'];
|
||||||
|
$updatetype = $data['uuupdatetype'];
|
||||||
|
|
||||||
// detect if password column needed in file
|
// detect if password column needed in file
|
||||||
if (!in_array('password', $columns)) {
|
if (!in_array('password', $columns)) {
|
||||||
|
@ -382,6 +383,12 @@ class admin_uploaduser_form2 extends moodleform {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the 'Existing user details' value is set we need to ensure that the
|
||||||
|
// 'Upload type' is not set to something invalid.
|
||||||
|
if (!empty($updatetype) && ($optype == UU_USER_ADDNEW || $optype == UU_USER_ADDINC)) {
|
||||||
|
$errors['uuupdatetype'] = get_string('invalidupdatetype', 'tool_uploaduser');
|
||||||
|
}
|
||||||
|
|
||||||
// look for other required data
|
// look for other required data
|
||||||
if ($optype != UU_USER_UPDATE) {
|
if ($optype != UU_USER_UPDATE) {
|
||||||
$requiredusernames = useredit_get_required_name_fields();
|
$requiredusernames = useredit_get_required_name_fields();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue