function definition() { global $USER, $CFG; $mform =& $this->_form; $mform->addElement('header', '', get_string('createuserandpass'), ''); $mform->addElement('text', 'username', get_string('username'), 'maxlength="100" size="12"'); $mform->setType('username', PARAM_NOTAGS); $mform->addRule('username', get_string('missingusername'), 'required', null, 'server'); $mform->addElement('passwordunmask', 'password', get_string('password'), 'maxlength="32" size="12"'); $mform->setType('password', PARAM_RAW); $mform->addRule('password', get_string('missingpassword'), 'required', null, 'server'); $mform->addElement('header', '', get_string('supplyinfo'), ''); $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="25"'); $mform->setType('email', PARAM_NOTAGS); $mform->addRule('email', get_string('missingemail'), 'required', null, 'server'); $mform->addElement('text', 'email2', get_string('emailagain'), 'maxlength="100" size="25"'); $mform->setType('email2', PARAM_NOTAGS); $mform->addRule('email2', get_string('missingemail'), 'required', null, 'server'); $nameordercheck = new object(); $nameordercheck->firstname = 'a'; $nameordercheck->lastname = 'b'; if (fullname($nameordercheck) == 'b a') { // See MDL-4325 $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"'); $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"'); } else { $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"'); $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"'); } $mform->setType('firstname', PARAM_TEXT); $mform->addRule('firstname', get_string('missingfirstname'), 'required', null, 'server'); $mform->setType('lastname', PARAM_TEXT); $mform->addRule('lastname', get_string('missinglastname'), 'required', null, 'server'); $mform->addElement('text', 'city', get_string('city'), 'maxlength="20" size="20"'); $mform->setType('city', PARAM_TEXT); $mform->addRule('city', get_string('missingcity'), 'required', null, 'server'); $country = get_list_of_countries(); $default_country[''] = get_string('selectacountry'); $country = array_merge($default_country, $country); $mform->addElement('select', 'country', get_string('country'), $country); $mform->addRule('country', get_string('missingcountry'), 'required', null, 'server'); if (!empty($CFG->country)) { $mform->setDefault('country', $CFG->country); } else { $mform->setDefault('country', ''); } if (signup_captcha_enabled()) { $mform->addElement('recaptcha', 'recaptcha_element', get_string('recaptcha', 'auth'), array('https' => $CFG->loginhttps)); $mform->setHelpButton('recaptcha_element', array('recaptcha', get_string('recaptcha', 'auth'))); } profile_signup_fields($mform); if (!empty($CFG->sitepolicy)) { $mform->addElement('header', '', get_string('policyagreement'), ''); $mform->addElement('static', 'policylink', '', '<a href="' . $CFG->sitepolicy . '" onclick="this.target=\'_blank\'">' . get_String('policyagreementclick') . '</a>'); $mform->addElement('checkbox', 'policyagreed', get_string('policyaccept')); $mform->addRule('policyagreed', get_string('policyagree'), 'required', null, 'server'); } // buttons $this->add_action_buttons(true, get_string('createaccount')); }
function definition() { global $USER, $CFG; $mform = $this->_form; $mform->addElement('header', 'createuserandpass', get_string('createuserandpass'), ''); $mform->addElement('text', 'username', get_string('username'), 'maxlength="100" size="12"'); $mform->setType('username', PARAM_NOTAGS); $mform->addRule('username', get_string('missingusername'), 'required', null, 'server'); if (!empty($CFG->passwordpolicy)) { $mform->addElement('static', 'passwordpolicyinfo', '', print_password_policy()); } $mform->addElement('passwordunmask', 'password', get_string('password'), 'maxlength="32" size="12"'); $mform->setType('password', PARAM_RAW); $mform->addRule('password', get_string('missingpassword'), 'required', null, 'server'); $mform->addElement('header', 'supplyinfo', get_string('supplyinfo'), ''); $mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="25"'); $mform->setType('email', PARAM_RAW_TRIMMED); $mform->addRule('email', get_string('missingemail'), 'required', null, 'server'); $mform->addElement('text', 'email2', get_string('emailagain'), 'maxlength="100" size="25"'); $mform->setType('email2', PARAM_RAW_TRIMMED); $mform->addRule('email2', get_string('missingemail'), 'required', null, 'server'); $namefields = useredit_get_required_name_fields(); foreach ($namefields as $field) { $mform->addElement('text', $field, get_string($field), 'maxlength="100" size="30"'); $mform->setType($field, PARAM_TEXT); $stringid = 'missing' . $field; if (!get_string_manager()->string_exists($stringid, 'moodle')) { $stringid = 'required'; } $mform->addRule($field, get_string($stringid), 'required', null, 'server'); } $mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="20"'); $mform->setType('city', PARAM_TEXT); if (!empty($CFG->defaultcity)) { $mform->setDefault('city', $CFG->defaultcity); } $country = get_string_manager()->get_list_of_countries(); $default_country[''] = get_string('selectacountry'); $country = array_merge($default_country, $country); $mform->addElement('select', 'country', get_string('country'), $country); if (!empty($CFG->country)) { $mform->setDefault('country', $CFG->country); } else { $mform->setDefault('country', ''); } if ($this->signup_captcha_enabled()) { $mform->addElement('recaptcha', 'recaptcha_element', get_string('security_question', 'auth'), array('https' => $CFG->loginhttps)); $mform->addHelpButton('recaptcha_element', 'recaptcha', 'auth'); } profile_signup_fields($mform); if (!empty($CFG->sitepolicy)) { $mform->addElement('header', 'policyagreement', get_string('policyagreement'), ''); $mform->setExpanded('policyagreement'); $mform->addElement('static', 'policylink', '', '<a href="' . $CFG->sitepolicy . '" onclick="this.target=\'_blank\'">' . get_String('policyagreementclick') . '</a>'); $mform->addElement('checkbox', 'policyagreed', get_string('policyaccept')); $mform->addRule('policyagreed', get_string('policyagree'), 'required', null, 'server'); } // buttons $this->add_action_buttons(true, get_string('createaccount')); }
function definition() { global $USER, $CFG; $invite = false; $sitecontext = get_context_instance(CONTEXT_SYSTEM); if (isloggedin() && has_capability('moodle/local:invitenewuser', $sitecontext)) { $invite = true; } $mform =& $this->_form; $mform->addElement('header', '', get_string('createuserandpass'), ''); $mform->addElement('text', 'username', get_string('username'), 'maxlength="100" size="12"'); $mform->setType('username', PARAM_NOTAGS); $mform->addRule('username', get_string('missingusername'), 'required', null, 'server'); $mform->addElement('passwordunmask', 'password1', get_string('password'), 'maxlength="32" size="12"'); $mform->setType('password1', PARAM_RAW); $mform->addRule('password1', get_string('missingpassword'), 'required', null, 'server'); $mform->addElement('passwordunmask', 'password2', get_string('password') . ' (' . get_String('again') . ')', 'maxlength="32" size="12"'); $mform->setType('password2', PARAM_RAW); $mform->addRule('password2', get_string('missingpassword'), 'required', null, 'server'); $mform->addElement('header', '', get_string('supplyinfo'), ''); $nameordercheck = new object(); $nameordercheck->firstname = 'a'; $nameordercheck->lastname = 'b'; if (fullname($nameordercheck) == 'b a') { // See MDL-4325 $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"'); $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"'); } else { $mform->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"'); $mform->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"'); } $mform->setType('firstname', PARAM_TEXT); $mform->addRule('firstname', get_string('missingfirstname'), 'required', null, 'server'); $mform->setType('lastname', PARAM_TEXT); $mform->addRule('lastname', get_string('missinglastname'), 'required', null, 'server'); $mform->addElement('text', 'city', get_string('city'), 'maxlength="20" size="20"'); $mform->setType('city', PARAM_TEXT); $mform->addRule('city', get_string('missingcity'), 'required', null, 'server'); $country = get_list_of_countries(); $default_country[''] = get_string('selectacountry'); $country = array_merge($default_country, $country); $mform->addElement('select', 'country', get_string('country'), $country); $mform->addRule('country', get_string('missingcountry'), 'required', null, 'server'); if (!empty($CFG->country)) { $mform->setDefault('country', $CFG->country); } else { $mform->setDefault('country', ''); } $mform->addElement('text', 'idnumber', get_string('idnumber'), 'maxlength="20" size="20"'); $mform->setType('idnumber', PARAM_NOTAGS); $mform->addRule('idnumber', get_string('missingidnumber', 'local'), 'required', null, 'server'); profile_signup_fields($mform); if (!empty($CFG->sitepolicy)) { $mform->addElement('header', '', get_string('policyagreement'), ''); $mform->addElement('static', 'policylink', '', '<a href="' . $CFG->sitepolicy . '" onclick="this.target=\'_blank\'">' . get_String('policyagreementclick') . '</a>'); $mform->addElement('checkbox', 'policyagreed', get_string('policyaccept')); $mform->addRule('policyagreed', get_string('policyagree'), 'required', null, 'server'); } $mform->addElement('hidden', 'data'); // buttons $this->add_action_buttons(true, get_string('createaccount')); }
/** * Build form content */ function buildForm() { $this->_formBuilt = true; // rectangle around elements $this->addElement('header', 'top_header', get_string('newuser.contactform', 'samouk')); $this->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"'); $this->setType('email', PARAM_NOTAGS); $this->addRule('email', get_string('missingemail'), 'required', null, 'server'); $nameordercheck = new object(); $nameordercheck->firstname = 'a'; $nameordercheck->lastname = 'b'; if (fullname($nameordercheck) == 'b a') { // See MDL-4325 $this->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"'); $this->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"'); } else { $this->addElement('text', 'firstname', get_string('firstname'), 'maxlength="100" size="30"'); $this->addElement('text', 'lastname', get_string('lastname'), 'maxlength="100" size="30"'); } $this->setType('firstname', PARAM_TEXT); $this->addRule('firstname', get_string('missingfirstname'), 'required', null, 'server'); $this->setType('lastname', PARAM_TEXT); $this->addRule('lastname', get_string('missinglastname'), 'required', null, 'server'); // add an address textbox $this->addElement('text', 'address', get_string('address'), 'maxlength="70" size="30"'); $this->setType('address', PARAM_TEXT); // add a city textbox $this->addElement('text', 'city', get_string('city'), 'maxlength="20" size="30"'); $this->setType('city', PARAM_TEXT); $this->addRule('city', get_string('missingcity'), 'required', null, 'server'); $country = get_list_of_countries(); $default_country[''] = get_string('selectacountry'); $country = array_merge($default_country, $country); $this->addElement('select', 'country', get_string('country'), $country, 'width="130"'); $this->addRule('country', get_string('missingcountry'), 'required', null, 'server'); $this->setDefault('country', 'CZ'); // show phone number input box $this->addElement('text', 'phone1', get_string('phone'), 'maxlength="20" size="30"'); $this->setType('phone1', PARAM_TEXT); // add custom profile elements profile_signup_fields($this); if (!empty($CFG->sitepolicy)) { $this->addElement('header', 'top_header', get_string('policyagreement')); $this->addElement('static', 'policylink', '', '<a href="' . $CFG->sitepolicy . '" onclick="this.target=\'_blank\'">' . get_String('policyagreementclick') . '</a>'); $this->addElement('checkbox', 'policyagreed', get_string('policyaccept')); $this->addRule('policyagreed', get_string('policyagree'), 'required', null, 'server'); } ShowStepPrediction($this, 2, 4); // add command buttons $buttons[0] =& HTML_QuickForm::createElement('submit', $this->getButtonName('back'), get_string('button.prev', 'samouk')); $buttons[1] =& HTML_QuickForm::createElement('button', 'cancel', get_string('cancel'), array('onclick' => "javascript:location.href='index.php';")); $buttons[2] =& HTML_QuickForm::createElement('submit', $this->getButtonName('next'), get_string('button.next', 'samouk')); $this->addGroup($buttons, 'buttons', '', ' ', false); $this->setDefaultAction('next'); }