// 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. } else { $authplugin = get_auth_plugin($usernew->auth); }
//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; } if (!($userid = company_user::create($data))) {