in classes/form/disconnect.php [39:96]
protected function definition() {
global $USER, $DB;
if (!empty($this->_customdata['userid'])) {
$userrec = $DB->get_record('user', ['id' => $this->_customdata['userid']]);
} else {
$userrec = $DB->get_record('user', ['id' => $USER->id]);
}
$authconfig = get_config('auth_oidc');
$opname = (!empty($authconfig->opname)) ? $authconfig->opname : get_string('pluginname', 'auth_oidc');
$mform =& $this->_form;
$mform->addElement('html', \html_writer::tag('h4', get_string('ucp_disconnect_title', 'auth_oidc', $opname)));
$mform->addElement('html', \html_writer::div(get_string('ucp_disconnect_details', 'auth_oidc', $opname)));
$mform->addElement('html', '<br />');
$mform->addElement('hidden', 'redirect', $this->_customdata['redirect']);
$mform->setType('redirect', PARAM_URL);
$mform->addElement('hidden', 'donotremovetokens', $this->_customdata['donotremovetokens']);
$mform->setType('donotremovetokens', PARAM_BOOL);
$mform->addElement('header', 'userdetails', get_string('userdetails'));
$newmethod = [];
$attributes = [];
$manualenabled = (is_enabled_auth('manual') === true) ? true : false;
if ($manualenabled === true) {
$newmethod[] =& $mform->createElement('radio', 'newmethod', '', 'manual', 'manual', $attributes);
}
if (!empty($this->_customdata['prevmethod'])) {
$prevmethod = $this->_customdata['prevmethod'];
$newmethod[] =& $mform->createElement('radio', 'newmethod', '', $prevmethod, $prevmethod, $attributes);
}
$mform->addGroup($newmethod, 'newmethodar', get_string('errorauthdisconnectnewmethod', 'auth_oidc'), [' '], false);
if (!empty($this->_customdata['prevmethod'])) {
$mform->setDefault('newmethod', $this->_customdata['prevmethod']);
} else if ($manualenabled === true) {
$mform->setDefault('newmethod', 'manual');
}
if ($manualenabled === true) {
$mform->addElement('html', \html_writer::div(get_string('errorauthdisconnectifmanual', 'auth_oidc')));
$mform->addElement('text', 'username', get_string('username'));
$mform->addElement('passwordunmask', 'password', get_string('password'));
$mform->setType('username', PARAM_USERNAME);
$mform->disabledIf('username', 'newmethod', 'neq', 'manual');
$mform->disabledIf('password', 'newmethod', 'neq', 'manual');
// If the user cannot choose a username, set it to their current username and freeze.
if (isset($this->_customdata['canchooseusername']) && $this->_customdata['canchooseusername'] == false) {
$mform->setDefault('username', $userrec->username);
$element = $mform->getElement('username');
$element->freeze();
}
}
$this->add_action_buttons();
}