} break; case 'assign': $user = $DB->get_record('user', array('id' => required_param('user', PARAM_INT)), '*', MUST_EXIST); $roleid = required_param('roleid', PARAM_INT); if (!array_key_exists($roleid, $manager->get_assignable_roles())) { throw new enrol_ajax_exception('invalidrole'); } if (!has_capability('moodle/role:assign', $manager->get_context()) || !$manager->assign_role_to_user($roleid, $user->id)) { throw new enrol_ajax_exception('assignnotpermitted'); } $outcome->response->roleid = $roleid; break; case 'getassignable': $otheruserroles = optional_param('otherusers', false, PARAM_BOOL); $outcome->response = $manager->get_assignable_roles_for_json($otheruserroles); break; case 'searchotherusers': $search = optional_param('search', '', PARAM_RAW); $page = optional_param('page', 0, PARAM_INT); $outcome->response = $manager->search_other_users($search, $searchanywhere, $page); $extrafields = get_extra_user_fields($context); $useroptions = array(); // User is not enrolled, either link to site profile or do not link at all. if (has_capability('moodle/user:viewdetails', context_system::instance())) { $useroptions['courseid'] = SITEID; } else { $useroptions['link'] = false; } foreach ($outcome->response['users'] as &$user) { $user->userId = $user->id;