} // Load user preferences. 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)); } $emailchangedhtml = ''; if ($CFG->emailchangeconfirmation) { // Users with 'moodle/user:update' can change their email address immediately.
} // Load user preferences. 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/'); }
if ($user->deleted) { print_header(); print_heading(get_string('userdeleted')); print_footer($course); die; } // Process email change cancellation 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);
//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); $userform = new user_edit_form(null, array('editoroptions'=>$editoroptions)); 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) {
<?php 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();
$user->userregion = $userregionlocation->parent; $user->userlocation = $userregionlocation->id; } else { // user is assigned at region level don't need to identify location. $user->userregion = $userregionlocation->id; $user->userlocation = ''; } // Get user role in region or location // Code by sumit $userrole = $DB->get_record('company_users', array('userid' => $user->id), 'managertype'); $user->managertype = $userrole->managertype ? $userrole->managertype : 0; if ($userdepartmenttitle = get_user_department_title($user->id, $companyid)) { $user->userdepartment = $userdepartmenttitle->department; $user->usertitle = $userdepartmenttitle->title; } $userform = new user_edit_form(null, $companyid, $user->id, $user->userregion, $user->userlocation); //End of code $userform->set_data($user); if ($userform->is_cancelled()) { redirect("{$CFG->wwwroot}/blocks/iomad_company_admin/editusers.php"); } else { if ($usernew = $userform->get_data()) { if ($usernew->id == -1) { $event = \core\event\user_updated::create(array('context' => $systemcontext, 'userid' => $usernew->id, 'relateduserid' => $USER->id)); $event->trigger(); } if (empty($usernew->auth)) { // User editing self. $authplugin = get_auth_plugin($user->auth); unset($usernew->auth); // Can not change/remove.
// Build the nav bar. //company_admin_fix_breadcrumb($PAGE, $linktext, $linkurl); // code by sumit /*GWL : Add condition to provide access for Site admin*/ if (!has_capability('block/iomad_company_admin:manageallcompany', context_system::instance())) { admin_externalpage_setup('managecompanyusersetting'); } /*GWL : Add condition to provide access for Site admin*/ $PAGE->navbar->add($linktext, $linkurl); // end of code $blockpage = new blockpage($PAGE, $OUTPUT, 'iomad_company_admin', 'block', 'user_create_title'); $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; }