useredit_load_preferences($user); // Load custom profile fields data. profile_load_data($user); // Prepare the editor and create form. $editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'forcehttps' => false, 'context' => $personalcontext); $user = file_prepare_standard_editor($user, 'description', $editoroptions, $personalcontext, 'user', 'profile', 0); // Prepare filemanager draft area. $draftitemid = 0; $filemanagercontext = $editoroptions['context']; $filemanageroptions = array('maxbytes' => $CFG->maxbytes, 'subdirs' => 0, 'maxfiles' => 1, 'accepted_types' => 'web_image'); file_prepare_draft_area($draftitemid, $filemanagercontext->id, 'user', 'newicon', 0, $filemanageroptions); $user->imagefile = $draftitemid; // Create form. $userform = new user_edit_form(new moodle_url($PAGE->url, array('returnto' => $returnto)), array('editoroptions' => $editoroptions, 'filemanageroptions' => $filemanageroptions, 'user' => $user)); $emailchanged = false; if ($usernew = $userform->get_data()) { // Deciding where to send the user back in most cases. if ($returnto === 'profile') { if ($course->id != SITEID) { $returnurl = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id)); } else { $returnurl = new moodle_url('/user/profile.php', array('id' => $user->id)); } } else { // $returnurl = new moodle_url('/user/preferences.php', array('userid' => $user->id)); // Changed redirect to Dashboard // Austin Powell 11/16/16 $returnurl = new moodle_url('/my/'); } $emailchangedhtml = ''; if ($CFG->emailchangeconfirmation) {
require '../../config.php'; defined('MOODLE_INTERNAL') || die; require_once "{$CFG->libdir}/gdlib.php"; include 'user_form.php'; $course = $DB->get_record('course', array('id' => '' . SITEID)); require_login($course); $url = new moodle_url('/report/user/edit.php', array()); $PAGE->set_url($url); $PAGE->set_pagelayout('report'); require_capability('report/user:view', get_context_instance(CONTEXT_SYSTEM)); $PAGE->set_title(get_string('edit')); $PAGE->set_heading(get_string('edit')); echo $OUTPUT->header(); $mform = new user_edit_form(); if ($user = $mform->get_data()) { if ($user->pass1 != '') { $user->password = md5($user->pass1); } $DB->update_record('user', $user); foreach ((array) $user as $variable => $value) { $USER->{$variable} = $value; } $filename = $_FILES['picture']['name']; if ($filename != "") { $usercontext = get_context_instance(CONTEXT_USER, $USER->id); do { $itemid = rand(0, 9999999999); } while ($DB->record_exists('files', array('itemid' => $itemid))); $fs = get_file_storage(); $file_record = array('contextid' => $usercontext->id, 'component' => 'user', 'filearea' => 'draft', 'itemid' => $itemid, 'filepath' => '/', 'filename' => $filename, 'userid' => $USER->id);
if ($cancelemailchange) { cancel_email_update($user->id); } //load user preferences useredit_load_preferences($user); //Load custom profile fields data profile_load_data($user); //create form $userform = new user_edit_form(); if (empty($user->country)) { // MDL-16308 - we must unset the value here so $CFG->country can be used as default one unset($user->country); } $userform->set_data($user); $email_changed = false; if ($usernew = $userform->get_data()) { add_to_log($course->id, 'user', 'update', "view.php?id={$user->id}&course={$course->id}", ''); $email_changed_html = ''; if ($CFG->emailchangeconfirmation) { // Handle change of email carefully for non-trusted users if (isset($usernew->email) and $user->email != $usernew->email && !has_capability('moodle/user:update', $systemcontext)) { $a = new stdClass(); $a->newemail = $usernew->preference_newemail = $usernew->email; $usernew->preference_newemailkey = random_string(20); $usernew->preference_newemailattemptsleft = 3; $a->oldemail = $usernew->email = $user->email; $email_changed_html = print_box(get_string('auth_changingemailaddress', 'auth', $a), 'generalbox', 'notice', true); $email_changed_html .= print_continue("{$CFG->wwwroot}/user/view.php?id={$user->id}&course={$course->id}", true); $email_changed = true; } }
$blockpage->setup(); // Set the companyid $companyid = iomad::get_my_companyid($context); $companyform = new company_select_form($PAGE->url, $companyid, 'createuserforcompany'); $mform = new user_edit_form($PAGE->url, $companyid, $departmentid); if ($companyform->is_cancelled() || $mform->is_cancelled()) { // Code by sumit redirect(new moodle_url('/blocks/iomad_company_admin/editusers.php')); // end of code /* if ($returnurl) { redirect($returnurl); } else { redirect($dashboardurl); } */ } else { if ($data = $mform->get_data()) { $data->userid = $USER->id; if ($companyid > 0) { $data->companyid = $companyid; } if (!($userid = company_user::create($data))) { $this->verbose("Error inserting a new user in the database!"); if (!$this->get('ignore_errors')) { die; } } $user = new stdclass(); $user->id = $userid; // GWL : to save custom profile fields data. $usernew = new stdclass(); $usernew = $data;